Cookies help us deliver our services. By using our services, you agree to our use of cookies. More information

Difference between revisions of "MediaWiki:Common.js"

From NoSQLZoo
Jump to: navigation, search
 
(65 intermediate revisions by 3 users not shown)
Line 1: Line 1:
$(function(){
+
function linkScript() {
  alert("test");
+
    /* poor man's autoloader */
  var nosqlzoo = document.createElement('script');
+
    "use strict";
  nosqlzoo.src = 'nosqlzoo.js';
+
    Array.prototype.slice.call(arguments, 0).forEach(function (a) {
  document.head.appendChild(nosqlzoo);
+
        var x = document.createElement("script");
 +
        x.async = false;
 +
        x.src = "/mw/scripts/" + a + ".js";
 +
        document.head.appendChild(x);
 +
    });
 +
}
  
  //Allow all the tables to be collapsible
+
$(function () {
  //items move into the "More" actions
+
    "use strict";
  //Change the following to change the word "More"
+
    //CodeMirror.
  //http://sqlzoo.net/dev/MediaWiki:Vector-more-actions
+
    var cmVersion = "codemirror-5.49.2/";
  $('#left-navigation,#right-navigation').hide();
+
     linkScript(
  $('#ca-view,#ca-viewsource,#ca-edit').addClass('collapsible');
+
         "jshint-2.10.2-min",
+
        cmVersion + "lib/codemirror",
  $('#mw-head').append(
+
         cmVersion + "mode/javascript/javascript",
     $('<div/>',{id:'cog-cont'}).append(
+
         cmVersion + "mode/cypher/cypher",
      $('<div/>',{
+
         cmVersion + "addon/display/fullscreen",
         css:{'background-image':'url(//sqlzoo.net/design/Cog_font_awesome.svg)',
+
        cmVersion + "addon/display/rulers",
            'z-index':1003,
+
        cmVersion + "addon/edit/closebrackets",
            width:32,height:32,position:'absolute',right:0,top:0},
+
        cmVersion + "addon/edit/matchbrackets",
         title:'Wiki Controls',
+
        cmVersion + "addon/fold/foldcode",
         id:'cog',
+
        cmVersion + "addon/fold/foldgutter",
         click:function(){
+
        cmVersion + "addon/fold/brace-fold",
          $('#coglist').slideToggle();
+
         cmVersion + "addon/hint/show-hint",
          if ($('#overlay').length==0){
+
        cmVersion + "addon/lint/lint",
            $('<div/>',{id:'overlay',
+
        cmVersion + "addon/lint/javascript-lint",
              click:function(){
+
        cmVersion + "addon/lint/json-lint",
                $('#coglist').slideUp();
+
        cmVersion + "addon/edit/trailingspace"
                $('#overlay').remove();
+
    );
              },
+
 
              css:{
+
    //Question-related scripts.
                position:'absolute',
+
    linkScript("nosqlzoo", "beautify", "validator");
                top:0,left:0,background:'#aaaaaa',
+
 
                width:'100%',height:'100%',
+
    //Google Analytics
                opacity:0.3,
+
    var tag_manager = document.createElement("script");
                'z-index':1002
+
    tag_manager.async = true;
            }})
+
    tag_manager.src = "https://www.googletagmanager.com/gtag/js?id=UA-120387375-1";
              .appendTo('body');
+
    document.head.appendChild(tag_manager);
          }else{
+
 
            $('#overlay').remove();
+
    var google = document.createElement("script");
          }
+
    google.src = "/mw/scripts/google.js";
         }
+
    document.head.appendChild(google);
      }))
 
  );
 
  $('#cog-cont').append(
 
    $('<ul/>',{id:'coglist',css:{display:'none','z-index':1003}})
 
      .append($('<li/>').append($('#p-search')))
 
      .append($('#pick-engine'))
 
      .append($('#pt-createaccount'))
 
      .append($('#pt-userpage'))
 
      .append($('#pt-mytalk'))
 
      .append($('#pt-preferences'))
 
      .append($('#pt-watchlist'))
 
      .append($('#pt-mycontris'))
 
//     .append($('#pt-login'))
 
//     .append($('#pt-logout'))
 
      .append($('#ca-view'))
 
      .append($('#ca-viewsource'))
 
      .append($('#ca-edit'))
 
      .append($('#ca-history'))
 
      .append($('#ca-nstab-main'))
 
      .append($('#ca-talk'))
 
      .append($('#ca-watch'))
 
      .append($('#ca-unwatch'))
 
      .append($('#ca-move'))
 
      .append($('#ca-delete'))
 
      .append($('#ca-protect'))
 
  );
 
  $('#pt-login,#pt-logout').before($('#pick-engine'));
 
  $('#mw-head').prepend($('<a/>',{
 
    id:'napier-ad',
 
    href:'//www.napier.ac.uk/faculties/engineering-computing-creative/computing/Pages/Postgraduate.aspx?sz',
 
    title:'NoSQLZoo: developed and maintained at Edinburgh Napier University'
 
  }));
 
});
 
 
/*
 
Tweek the Log in scheme
 
* */
 
$(function(){
 
  $('#mw-user-domain-section').hide();
 
  $('#wpRemember').attr('checked',true);
 
 
});
 
});

Latest revision as of 15:23, 25 October 2020

function linkScript() {
    /* poor man's autoloader */
    "use strict";
    Array.prototype.slice.call(arguments, 0).forEach(function (a) {
        var x = document.createElement("script");
        x.async = false;
        x.src = "/mw/scripts/" + a + ".js";
        document.head.appendChild(x);
    });
}

$(function () {
    "use strict";
    //CodeMirror.
    var cmVersion = "codemirror-5.49.2/";
    linkScript(
        "jshint-2.10.2-min",
        cmVersion + "lib/codemirror",
        cmVersion + "mode/javascript/javascript",
        cmVersion + "mode/cypher/cypher",
        cmVersion + "addon/display/fullscreen",
        cmVersion + "addon/display/rulers",
        cmVersion + "addon/edit/closebrackets",
        cmVersion + "addon/edit/matchbrackets",
        cmVersion + "addon/fold/foldcode",
        cmVersion + "addon/fold/foldgutter",
        cmVersion + "addon/fold/brace-fold",
        cmVersion + "addon/hint/show-hint",
        cmVersion + "addon/lint/lint",
        cmVersion + "addon/lint/javascript-lint",
        cmVersion + "addon/lint/json-lint",
        cmVersion + "addon/edit/trailingspace"
    );

    //Question-related scripts.
    linkScript("nosqlzoo", "beautify", "validator");

    //Google Analytics
    var tag_manager = document.createElement("script");
    tag_manager.async = true;
    tag_manager.src = "https://www.googletagmanager.com/gtag/js?id=UA-120387375-1";
    document.head.appendChild(tag_manager);

    var google = document.createElement("script");
    google.src = "/mw/scripts/google.js";
    document.head.appendChild(google);
});