MediaWiki:Common.js

Revision as of 19:03, 10 April 2017 by Pianoforte (talk | contribs)

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
/* 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");
if (calculator_element !== null) {
	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;
}
});