User:Verdy p/common.js
Appearance
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)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/* 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: importScriptURI('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() {
importScriptURI('http://r.keymanweb.com/code/?id=243&domain='+location.hostname+'&page='+encodeURIComponent(location.pathname));
var b=document.getElementById('bodyContent');b.innerHTML= '<div id="KeymanWebControl"></div>'+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++;
}
}
}