Difference between revisions of "MediaWiki:Common.js"

From Game Detectives Wiki
Jump to: navigation, search
Line 1: Line 1:
var my_awesome_script = document.createElement('script');
+
(function() {
my_awesome_script.setAttribute('src','//code.jquery.com/jquery-1.12.4.js');
+
  // Load the script
document.head.appendChild(my_awesome_script);
+
  let cnt = 0;
  
var my_awesome_script2 = document.createElement('script');
+
  let my_awesome_script = document.createElement('script');
my_awesome_script2.setAttribute('src','//code.jquery.com/ui/1.12.1/jquery-ui.js');
+
  my_awesome_script.setAttribute('src','//code.jquery.com/jquery-1.12.4.js');
document.head.appendChild(my_awesome_script2);
 
  
var my_awesome_script3 = document.createElement('link');
+
  let my_awesome_script2 = document.createElement('script');
my_awesome_script3.setAttribute('rel','stylesheet');
+
  my_awesome_script2.setAttribute('src','//code.jquery.com/ui/1.12.1/jquery-ui.js');
my_awesome_script3.setAttribute('href','//code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css');
 
document.head.appendChild(my_awesome_script3);
 
  
$(function () {
+
  let 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');
  
   var cnt = 0;
+
   my_awesome_script.onload = function() {
 +
    my_awesome_script2.onload = function () {
 +
      let $ = window.jQuery;
 +
      for (let n = 1; n < 100; n++) {
 +
        if (document.getElementById('tableRow' + n)) {
 +
          let row = document.getElementById('tableRow' + n);
 +
          row.addEventListener('click', function () {
 +
            console.log('working');
 +
            let dialog = 'dialog' + n;
 +
            $(function () {
 +
              $('#' + dialog).dialog();
 +
            });
 +
          });
  
  for(var n = 1; n < 100; n++) {
+
          let nameCol = document.getElementById('tableCol1-' + n).innerText;
    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>';
  
      row.innerHTML += '<div style="display:none" id="dialog' + n + '"' + ' title="' + nameCol + '"' + n + '">' + '\n' +
+
         }
         '<p>Table Row {{argbox}} ' + n + '</p>\n' +
+
         else {
         '</div>';
+
          cnt++;
 
+
        }
    }
+
        if (cnt > 0) {
    else {
+
          break;
      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);
 +
})();

Revision as of 01:46, 15 August 2018

(function() {
  // Load the script
  let cnt = 0;

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

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

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

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