Difference between revisions of "MediaWiki:Common.js"
From Game Detectives Wiki
Line 1: | Line 1: | ||
− | (function() { | + | (function () { |
// Load the script | // Load the script | ||
var cnt = 0; | var cnt = 0; | ||
− | var | + | var jQuery = document.createElement('script'); |
− | + | jQuery.setAttribute('src','//code.jquery.com/jquery-1.12.4.js'); | |
− | var | + | var jQueryUI = document.createElement('script'); |
− | + | jQueryUI.setAttribute('src','//code.jquery.com/ui/1.12.1/jquery-ui.js'); | |
− | var | + | var jQueryCSS = document.createElement('link'); |
− | + | jQueryCSS.setAttribute('rel','stylesheet' ); | |
− | + | jQueryCSS.setAttribute('href','//code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css'); | |
− | + | jQuery.onload = function () { | |
− | + | jQueryUI.onload = function () { | |
var $ = window.jQuery; | var $ = window.jQuery; | ||
for (var n = 1; n < 100; n++) { | for (var n = 1; n < 100; n++) { | ||
Line 21: | Line 21: | ||
var dialog = 'dialog' + n; | var dialog = 'dialog' + n; | ||
row.addEventListener('click', function (dialog) { | row.addEventListener('click', function (dialog) { | ||
− | |||
− | |||
$(function () { | $(function () { | ||
$('#' + dialog).dialog(); | $('#' + dialog).dialog(); | ||
− | |||
}); | }); | ||
}.bind(null, dialog)); | }.bind(null, dialog)); | ||
Line 32: | Line 29: | ||
row.innerHTML += '<div style="display:none" id="dialog' + n + '"' + ' title="' + nameCol + '"' + n + '">' + '\n' + | row.innerHTML += '<div style="display:none" id="dialog' + n + '"' + ' title="' + nameCol + '"' + n + '">' + '\n' + | ||
− | + | '<p>Table Row ' + n + '</p>\n' + | |
− | + | '</div>'; | |
} | } | ||
Line 45: | Line 42: | ||
}; | }; | ||
}; | }; | ||
− | document.getElementsByTagName('head')[0].appendChild( | + | document.getElementsByTagName('head')[0].appendChild(jQuery); |
− | document.getElementsByTagName('head')[0].appendChild( | + | document.getElementsByTagName('head')[0].appendChild(jQueryUI); |
− | document.getElementsByTagName('head')[0].appendChild( | + | document.getElementsByTagName('head')[0].appendChild(jQueryCSS); |
})(); | })(); |
Revision as of 13:38, 15 August 2018
(function () { // Load the script var cnt = 0; var jQuery = document.createElement('script'); jQuery.setAttribute('src','//code.jquery.com/jquery-1.12.4.js'); var jQueryUI = document.createElement('script'); jQueryUI.setAttribute('src','//code.jquery.com/ui/1.12.1/jquery-ui.js'); var jQueryCSS = document.createElement('link'); jQueryCSS.setAttribute('rel','stylesheet' ); jQueryCSS.setAttribute('href','//code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css'); jQuery.onload = function () { jQueryUI.onload = function () { var $ = window.jQuery; for (var n = 1; n < 100; n++) { if (document.getElementById('tableRow' + n)) { var row = document.getElementById('tableRow' + n); var dialog = 'dialog' + n; row.addEventListener('click', function (dialog) { $(function () { $('#' + dialog).dialog(); }); }.bind(null, dialog)); var nameCol = document.getElementById('tableCol1-' + n).innerText; row.innerHTML += '<div style="display:none" id="dialog' + n + '"' + ' title="' + nameCol + '"' + n + '">' + '\n' + '<p>Table Row ' + n + '</p>\n' + '</div>'; } else { cnt++; } if (cnt > 0) { break; } } }; }; document.getElementsByTagName('head')[0].appendChild(jQuery); document.getElementsByTagName('head')[0].appendChild(jQueryUI); document.getElementsByTagName('head')[0].appendChild(jQueryCSS); })();