MediaWiki:Common.js: Difference between revisions

From canbudget Wiki
Jump to navigation Jump to search
(Created page with "onload=function(){ if (document.getElementsByClassName == undefined) { document.getElementsByClassName = function(className) { var hasClassName = new RegExp("(?:^|\\s...")
 
No edit summary
Line 1: Line 1:
onload=function(){
onload=function(){
  $('.noprint').display('none');
   if (document.getElementsByClassName == undefined) {
   if (document.getElementsByClassName == undefined) {
     document.getElementsByClassName = function(className) {
     document.getElementsByClassName = function(className) {

Revision as of 14:13, 14 April 2011

onload=function(){
  $('.noprint').display('none');

  if (document.getElementsByClassName == undefined) {
    document.getElementsByClassName = function(className) {
      var hasClassName = new RegExp("(?:^|\\s)" + className + "(?:$|\\s)");
        var allElements = document.getElementsByTagName("*");
        var results = [];

        var element;
        for (var i = 0; (element = allElements[i]) != null; i++) {
          var elementClass = element.className;
          if (elementClass && elementClass.indexOf(className) != -1 && hasClassName.test(elementClass))
            results.push(element);
          }
        return results;
      }
    }
    makeExt('external');
    function makeExt(lclass) {
      links = document.getElementsByClassName(lclass);
      // add onClick handler to links
      for (var i = 0; (element = links[i]) != null; i++) {
        element.href = "/frame/?l="+escape(element.href);
      }
    }
}