MediaWiki:Common.js

From Zelda Dungeon Wiki
Revision as of 10:38, October 24, 2011 by Emma (talk | contribs)
Jump to navigation Jump to search
Want an adless experience? Log in or Create an account.

Note: After saving, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: hold Shift while clicking Reload, or press either Ctrl+F5 or Ctrl+R (Command+R on a Mac)
  • Google Chrome: press Ctrl+Shift+R (Command+Shift+R on a Mac)
  • Internet Explorer: hold Ctrl while clicking Refresh, or press Ctrl+F5
  • Konqueror: click Reload or press F5
  • Opera: clear the cache in Tools → Preferences
/* Any JavaScript here will be loaded for all users on every page load. */

// --------------------------------------------------------
// Rank Coloring
// (adapted from http://en.wikipedia.org/wiki/User:Ais523/adminrights.js)
// This script changes the color of links to admins' and patrollers' userpages in the bodyContent of Special, History pages, diff pages,
// and old page revisions.
// ("bodyContent" being everything but the tabs,personal links at the top of the screen and sidebar).
// --------------------------------------------------------

var patrollerrights=new Array();
 
importScript('MediaWiki:Patrollerlist.js');
 
//Highlighting script. Based on [[User:ais523/highlightmyname.js]].
 
function highlightpatrollers(n,p) //node, parent node
{
  while(n!=null)
  {
    if(n.nodeType==1&&n.tagName.toLowerCase()=="a") //anchor
    {
      if(n.href.indexOf("/User:")!=-1)
      {
        var u=n.href.split("/User:")[1];
        if(patrollerrights[u.split("_").join("%20")]==1)
        {
          n.style.color="#E99216";
        }
      }
      else if(n.href.indexOf("/index.php?title=User:")!=-1)
      {
        var u=n.href.split("/index.php?title=User:")[1];
        if(patrollerrights[u.split("_").join("%20")]==1)
        {
          n.style.color="#E99216";
        }
      }
      else
      {
        if(n.firstChild!=null) highlightpatrollers(n.firstChild,n);
      }
    }
    else
    {
      if(n.firstChild!=null) highlightpatrollers(n.firstChild,n);
    }
    n=n.nextSibling;
  }
}


if (wgCanonicalNamespace == 'Special' || wgAction == 'history' || document.URL.indexOf('diff=') > 0 || document.URL.indexOf('oldid=') > 0)
{
$(function() {
    highlightpatrollers(document.getElementById('bodyContent').firstChild,
                    document.getElementById('bodyContent'));
});
}

var adminrights=new Array();
 
importScript('MediaWiki:Adminlist.js');
 
//Highlighting script. Based on [[User:ais523/highlightmyname.js]].
 
function highlightadmins(n,p) //node, parent node
{
  while(n!=null)
  {
    if(n.nodeType==1&&n.tagName.toLowerCase()=="a") //anchor
    {
      if(n.href.indexOf("/User:")!=-1)
      {
        var u=n.href.split("/User:")[1];
        if(adminrights[u.split("_").join("%20")]==1)
        {
          n.style.color="#2BA206";
        }
      }
      else if(n.href.indexOf("/index.php?title=User:")!=-1)
      {
        var u=n.href.split("/index.php?title=User:")[1];
        if(adminrights[u.split("_").join("%20")]==1)
        {
          n.style.color="#2BA206";
        }
      }
      else
      {
        if(n.firstChild!=null) highlightadmins(n.firstChild,n);
      }
    }
    else
    {
      if(n.firstChild!=null) highlightadmins(n.firstChild,n);
    }
    n=n.nextSibling;
  }
}


if (wgCanonicalNamespace == 'Special' || wgAction == 'history' || document.URL.indexOf('diff=') > 0 || document.URL.indexOf('oldid=') > 0)
{
$(function() {
    highlightadmins(document.getElementById('bodyContent').firstChild,
                    document.getElementById('bodyContent'));
});
}
//