Difference between revisions of "MediaWiki:Common.js"
From Game Detectives Wiki
Line 19: | Line 19: | ||
if (document.getElementById('tableRow' + n)) { | if (document.getElementById('tableRow' + n)) { | ||
var row = document.getElementById('tableRow' + n); | var row = document.getElementById('tableRow' + n); | ||
− | row.addEventListener('click', function () { | + | var dialog = 'dialog' + n; |
− | console.log('working'); | + | row.addEventListener('click', function (dialog) { |
− | + | console.log('working' + n); | |
+ | console.log(dialog); | ||
$(function () { | $(function () { | ||
$('#' + dialog).dialog(); | $('#' + dialog).dialog(); | ||
+ | console.log($('#' + dialog).dialog); | ||
}); | }); | ||
− | }); | + | }.bind(null, dialog)); |
var nameCol = document.getElementById('tableCol1-' + n).innerText; | var nameCol = document.getElementById('tableCol1-' + n).innerText; |
Revision as of 02:11, 15 August 2018
(function() { // Load the script var cnt = 0; var my_awesome_script = document.createElement('script'); my_awesome_script.setAttribute('src','//code.jquery.com/jquery-1.12.4.js'); var my_awesome_script2 = document.createElement('script'); my_awesome_script2.setAttribute('src','//code.jquery.com/ui/1.12.1/jquery-ui.js'); var my_awesome_script3 = document.createElement('link'); my_awesome_script3.setAttribute('rel','stylesheet'); my_awesome_script3.setAttribute('href','//code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css'); my_awesome_script.onload = function() { my_awesome_script2.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) { console.log('working' + n); console.log(dialog); $(function () { $('#' + dialog).dialog(); console.log($('#' + 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 {{argbox}} ' + n + '</p>\n' + '</div>'; } else { cnt++; } if (cnt > 0) { break; } } }; }; document.getElementsByTagName('head')[0].appendChild(my_awesome_script); document.getElementsByTagName('head')[0].appendChild(my_awesome_script2); document.getElementsByTagName('head')[0].appendChild(my_awesome_script3); })();