Jump to content

User:Verdy p/common.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
/* Deprecation of Javascript functions in Mediawiki:
  importScript
  importScriptURI
  importStylesheet
  importStylesheetURI
  See: https://www.mediawiki.org/wiki/ResourceLoader/JavaScript_Deprecations
       https://www.mediawiki.org/wiki/ResourceLoader/Default_modules#mw.loader.load
*/
function importScriptWP(lang, page) {
  mediaWiki.loader.load('//' + lang + '.wikipedia.org/w/index.php?action=raw&ctype=text/javascript&title=' + encodeURI(page), 'text/javascript');
  // was: mw.loader.load('https//' + lang + '.wikipedia.org/w/index.php?action=raw&ctype=text/javascript&title=' + encodeURI(page));
}
function importStylesheetWP(lang, page) {
  mediaWiki.loader.load('//' + lang + '.wikipedia.org/w/index.php?action=raw&ctype=text/css&title=' + encodeURI(page), 'text/css');
  // was: importStylesheetURI('https://'+lang+'.wikipedia.org/w/index.php?action=raw&ctype=text/css&title=' + encodeURI(page));
}

/* supporte le maximum d’écritures */
importStylesheetWP('fr','Utilisateur:Verdy_p/polices.css');
 
/* Keymanweb */
if (0) { // disabled (script not secured with HTTPS)
  importStylesheetWP('en','User:Keymanweb/keymanweb.css');
  addOnloadHook(function() {
        mw.loader.load('http://r.keymanweb.com/code/?id=243&domain='+location.hostname+'&page='+encodeURIComponent(location.pathname));
        var b=document.getElementById('bodyContent');b.innerHTML= '<div id="KeymanWebControl" />'+b.innerHTML;
     });
}

/* tri correct des tableaux */
importScriptWP('en', 'User:Verdy_p/tablesort.js');

/* correcting current bug in Common.js */
function createCollapseButtons() {
    var tableIndex = 0;
    var NavigationBoxes = new Object();
    var Tables = document.getElementsByTagName("table");
    for (var i = 0; i < Tables.length; i++) {
        if (hasClass(Tables[i], "collapsible")) {
            /* only add button and increment count if there is a header row to work with */
            var HeaderRow = Tables[i].getElementsByTagName("tr")[0];
            if (!HeaderRow) continue;
            var Header = HeaderRow.getElementsByTagName("th")[0];
            if (!Header) continue;
            NavigationBoxes[tableIndex] = Tables[i];
            Tables[i].setAttribute("id", "collapsibleTable" + tableIndex);
            var Button     = document.createElement("span");
            var ButtonLink = document.createElement("a");
            var ButtonText = document.createTextNode(collapseCaption);
            Button.className = "collapseButton"; //Styles are declared in Common.css
            ButtonLink.style.color = Header.style.color;
            ButtonLink.setAttribute("id", "collapseButton" + tableIndex);
            ButtonLink.setAttribute("href", "#");
            ButtonLink.setAttribute("onclick", function(evt) {
                    collapseTable(tableIndex);
                    return killEvt(evt);
                });
            ButtonLink.appendChild(ButtonText);
            Button.appendChild(document.createTextNode("["));
            Button.appendChild(ButtonLink);
            Button.appendChild(document.createTextNode("]"));
            Header.insertBefore(Button, Header.childNodes[0]);
            tableIndex++;
        }
    }
}