Common.js

Revision as of 10:00, 20 February 2017 by Registered User (Created page with "→‎Any JavaScript here will be loaded for all users on every page load.: →‎Any JavaScript here will be loaded for all users on every page load.: /** Collasible tables & fra...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Note: After publishing, 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 (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
/* Any JavaScript here will be loaded for all users on every page load. */
/* Any JavaScript here will be loaded for all users on every page load. */

/** Collasible tables & frames *************************************
 *  Please have a look to css in MediaWiki:Common.css 
 */
//importScript("MediaWiki:Collapsible-tables.js"); // With [show] / [hide]
//importScript("MediaWiki:Collapsible-frames.js"); // With [show] / [hide]
importScript("MediaWiki:Collapsible-tables-pm.js"); // With [+] / [-]
importScript("MediaWiki:Collapsible-frames-pm.js"); // With [+] / [-]


importScript("MediaWiki:Imagemap-Highlight.js");

importScript("MediaWiki:AddLinkToTop.js");

importScript("MediaWiki:RotateTable.js");

importScript("MediaWiki:Copy2Clipboard.js");


/* ******************** HELPERS ****************** */

/** Test if an element has a certain class
 *
 * Description: Uses regular expressions and caching for better performance.
 * Maintainers: [[User:Mike Dillon]], [[User:R. Koot]], [[User:SG]]
 */
var hasClass = ( function() {
        var reCache = {};
        return function( element, className ) {
                return ( reCache[className] ? reCache[className] : ( reCache[className] = new RegExp( "(?:\\s|^)" + className + "(?:\\s|$)" ) ) ).test( element.className );
        };
})();


function replaceText(oldText, newText, node){ 
  node = node || document.body; // base node 

  var childs = node.childNodes, i = 0;

  while(node = childs[i]){ 
//console.log("coucou" + node.nodeName);
    if (node.nodeType == 3){ // text node found, do the replacement

      if (node.textContent) {
        node.textContent = node.textContent.replace(oldText, newText);

      } else { // support to IE
        node.nodeValue = node.nodeValue.replace(oldText, newText);
      }
    } else { // not a text mode, look forward
      replaceText(oldText, newText, node); 
    } 
    i++; 
  } 
}

//$(document).ready(replaceText('PCO ', 'PCO ') );

/* Show few items dedicated to writers only when logged */
function hide_edition() {
  if (wgUserName) {
    $('#n-Help-\\.26-Syntax, #n-Glossary, #n-Contributors').css('display', 'block');
  }
}
$(document).ready(hide_edition());
No categories assignedEdit