MediaWiki:Common.js: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
Pianoforte (talk | contribs) No edit summary |
||
Line 1: | Line 1: | ||
/* Any JavaScript here will be loaded for all users on every page load. */ | /* Any JavaScript here will be loaded for all users on every page load. */ | ||
/* skilldata.js object code to gf-table conversion */ | |||
$(document).ready(function() { | |||
calculator_element = document.getElementById("convertDiv"); | |||
data = calculator_element.innerHTML; | |||
output = "{| class=gf-table<br>"; | |||
$.each(data.split("\n"), function(index, value) { | |||
if (value.charAt(0) !== "") { | |||
key = value.substring(0,value.lastIndexOf(":")).trim(); | |||
output = output + "! " + key + "<br>"; | |||
if (key == "text") { | |||
output = output + "| colspan=10 | " + value.substring(value.indexOf("\"")+1, value.lastIndexOf("\"")) + "<br>|-<br>"; | |||
console.log(output); | |||
} else if (key == "initial") { | |||
output = output + "| colspan=10 | " + value.substring(value.indexOf(":")+1, value.lastIndexOf(",")) + "<br>|-<br>"; | |||
} else { | |||
output = output + "| " + value.substring(value.indexOf("[")+1, value.lastIndexOf("]")).split(",").join(" ||") + "<br>|-<br>"; | |||
} | |||
} | |||
}); | |||
output = output.substring(0, output.length - 6) + "|}"; | |||
output = output.split("\'").join(""); | |||
document.getElementById("convertedDiv").innerHTML = output; | |||
}); |
Revision as of 11:48, 10 April 2017
/* Any JavaScript here will be loaded for all users on every page load. */
/* skilldata.js object code to gf-table conversion */
$(document).ready(function() {
calculator_element = document.getElementById("convertDiv");
data = calculator_element.innerHTML;
output = "{| class=gf-table<br>";
$.each(data.split("\n"), function(index, value) {
if (value.charAt(0) !== "") {
key = value.substring(0,value.lastIndexOf(":")).trim();
output = output + "! " + key + "<br>";
if (key == "text") {
output = output + "| colspan=10 | " + value.substring(value.indexOf("\"")+1, value.lastIndexOf("\"")) + "<br>|-<br>";
console.log(output);
} else if (key == "initial") {
output = output + "| colspan=10 | " + value.substring(value.indexOf(":")+1, value.lastIndexOf(",")) + "<br>|-<br>";
} else {
output = output + "| " + value.substring(value.indexOf("[")+1, value.lastIndexOf("]")).split(",").join(" ||") + "<br>|-<br>";
}
}
});
output = output.substring(0, output.length - 6) + "|}";
output = output.split("\'").join("");
document.getElementById("convertedDiv").innerHTML = output;
});