MediaWiki:Common.js: Unterschied zwischen den Versionen
Comkra (Diskussion | Beiträge) (DSVGO) |
|||
(6 dazwischenliegende Versionen von 3 Benutzern werden nicht angezeigt) | |||
Zeile 1: | Zeile 1: | ||
− | + | /** Test if an element has a certain class ************************************** | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | /** Test if an element has a certain class ************************************** | ||
* | * | ||
* Description: Uses regular expressions and caching for better performance. | * Description: Uses regular expressions and caching for better performance. | ||
Zeile 98: | Zeile 11: | ||
}; | }; | ||
})(); | })(); | ||
− | |||
− | |||
− | |||
− | |||
(function () { | (function () { | ||
+ | var loadScripts = document.querySelectorAll('div[data-load-javascript]'); | ||
+ | if (loadScripts.length) { | ||
+ | var scriptNames = {Tabber: true}; | ||
+ | loadScripts.forEach(function(el) { | ||
+ | var script = el.dataset['loadJavascript']; | ||
+ | if (scriptNames[script]) { | ||
+ | mw.loader.load("/index.php?title=MediaWiki:Script/" + script + ".js&action=raw&ctype=text/javascript"); | ||
+ | delete scriptNames[script]; | ||
+ | } | ||
+ | }); | ||
+ | } | ||
+ | |||
var req = new XMLHttpRequest(); | var req = new XMLHttpRequest(); | ||
req.addEventListener('load', function (ev) { | req.addEventListener('load', function (ev) { |
Aktuelle Version vom 21. Januar 2023, 14:27 Uhr
/** 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 () {
var loadScripts = document.querySelectorAll('div[data-load-javascript]');
if (loadScripts.length) {
var scriptNames = {Tabber: true};
loadScripts.forEach(function(el) {
var script = el.dataset['loadJavascript'];
if (scriptNames[script]) {
mw.loader.load("/index.php?title=MediaWiki:Script/" + script + ".js&action=raw&ctype=text/javascript");
delete scriptNames[script];
}
});
}
var req = new XMLHttpRequest();
req.addEventListener('load', function (ev) {
if (this.status >= 200 && this.status < 300) {
var data = JSON.parse(this.responseText);
if (data.hasOwnProperty('version')) {
var gdpr = document.createElement("script");
gdpr.src = "https://s3-static.geo.gfsrv.net/cookiebanner/" + data.version + "/cookie.min.js";
document.head.appendChild(gdpr);
}
}
});
req.open('GET', "https://s3-static.geo.gfsrv.net/cookiebanner/version.json");
req.send();
})();