Added more infoLinks and updated newOperation script to include prompt for them.

This commit is contained in:
n1474335 2018-08-21 19:07:13 +01:00
commit e81c81351d
206 changed files with 249 additions and 12 deletions

View file

@ -26,6 +26,7 @@ class HTMLOperation {
this.name = name;
this.description = config.description;
this.infoURL = config.infoURL;
this.manualBake = config.manualBake || false;
this.config = config;
this.ingList = [];
@ -46,8 +47,10 @@ class HTMLOperation {
let html = "<li class='operation'";
if (this.description) {
const infoLink = this.infoURL ? `<hr>${titleFromWikiLink(this.infoURL)}` : "";
html += ` data-container='body' data-toggle='popover' data-placement='right'
data-content="${this.description}" data-html='true' data-trigger='hover'
data-content="${this.description}${infoLink}" data-html='true' data-trigger='hover'
data-boundary='viewport'`;
}
@ -119,4 +122,23 @@ class HTMLOperation {
}
/**
* Given a URL for a Wikipedia (or other wiki) page, this function returns a link to that page.
*
* @param {string} url
* @returns {string}
*/
function titleFromWikiLink(url) {
const splitURL = url.split("/");
if (splitURL.indexOf("wiki") < 0) {
// Not a wiki link, return full URL
return `<a href='${url}' target='_blank'>More Information<i class='material-icons inline-icon'>open_in_new</i></a>`;
}
const pageTitle = decodeURIComponent(splitURL[splitURL.length - 1])
.replace(/_/g, " ");
return `<a href='${url}' target='_blank'>${pageTitle}<i class='material-icons inline-icon'>open_in_new</i></a> on Wikipedia`;
}
export default HTMLOperation;