MediaWiki:Common.js — различия между версиями
Alastar (обсуждение | вклад) |
Alastar (обсуждение | вклад) |
||
Строка 25: | Строка 25: | ||
element.removeChild(element.firstChild); | element.removeChild(element.firstChild); | ||
} | } | ||
+ | } | ||
+ | |||
+ | function importScript(path){ | ||
+ | mw.loader.load( '/w/index.php?title=MediaWiki:'+path+'&action=raw&ctype=text/javascript' ); | ||
} | } | ||
Версия 12:19, 25 августа 2019
/* Any JavaScript here will be loaded for all users on every page load. */
/**
* Determines if a particular element possesses a class.
*/
var hasClass = (function () {
var reCache = {};
return function (element, className) {
return (reCache[className] ? reCache[className] : (reCache[className] = new RegExp('(?:\\s|^)' + className + '(?:\\s|$)'))).test(element.className);
};
})();
/**
* Determines if a given value is a number.
*/
function isNumeric(value) {
return new RegExp(/(^\d+$)|(^\d+\.\d+$)/).test(value);
}
/**
* Removes all children from an element.
*/
function removeChildren(element) {
while (element.hasChildNodes()) {
element.removeChild(element.firstChild);
}
}
function importScript(path){
mw.loader.load( '/w/index.php?title=MediaWiki:'+path+'&action=raw&ctype=text/javascript' );
}
/**
* Import more specific scripts.
*/
importScript('MediaWiki:Calculator.js');