Difference between revisions of "MediaWiki:Common.js"

From Game Detectives Wiki
Jump to: navigation, search
Line 1: Line 1:
document.head.innerHTML += '<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css">';
+
var my_awesome_script = document.createElement('script');
document.head.innerHTML += '<script src="//code.jquery.com/jquery-1.12.4.js"></script>';
+
my_awesome_script.setAttribute('src','//code.jquery.com/jquery-1.12.4.js');
document.head.innerHTML += '<script src="//code.jquery.com/ui/1.12.1/jquery-ui.js"></script>';
+
document.head.appendChild(my_awesome_script);
 +
 
 +
var my_awesome_script2 = document.createElement('script');
 +
my_awesome_script2.setAttribute('src','//code.jquery.com/ui/1.12.1/jquery-ui.js');
 +
document.head.appendChild(my_awesome_script2);
  
 
$(function () {
 
$(function () {

Revision as of 00:30, 15 August 2018

var my_awesome_script = document.createElement('script');
my_awesome_script.setAttribute('src','//code.jquery.com/jquery-1.12.4.js');
document.head.appendChild(my_awesome_script);

var my_awesome_script2 = document.createElement('script');
my_awesome_script2.setAttribute('src','//code.jquery.com/ui/1.12.1/jquery-ui.js');
document.head.appendChild(my_awesome_script2);

$(function () {

  var cnt = 0;

  for(var n = 1; n < 100; n++) {
    if(document.getElementById('tableRow' + n)) {
      var row = document.getElementById('tableRow' + n);
      row.addEventListener('click', function(){
        console.log('working');
        var dialog = 'dialog' + n;
        $( function() {
          $( '#' + dialog ).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>';

      cnt = 0;
    }
    else {
      cnt++;
    }
    if(cnt > 1) {
      break;
    }
  }
}());