MediaWiki:Common.js

From Game Detectives Wiki
Revision as of 00:17, 15 August 2018 by Mattyb (talk | contribs)
Jump to: navigation, search
$(function () {

  var cnt = 0;

  document.head.innerHTML += '<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css">\n' + '<script src="//code.jquery.com/jquery-1.12.4.js"></script>\n' + '<script src="//code.jquery.com/ui/1.12.1/jquery-ui.js"></script>';

  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;
    }
  }
}());