ਮੀਡੀਆਵਿਕੀ:Sandbox.js
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.
/* This is a sandbox to experiment with Javascript. Load it by appending &withJS=MediaWiki:Sandbox.js to the URL */
mw.loader.using([
'mediawiki.util',
'mediawiki.user'
]).done(function () {
/* This is to check that the code is loaded */
mw.util.addCSS( "#p-logo {background: pink;}");
function addFooter( name ) {
var footer = document.getElementById('footer');
var box = document.createElement("div");
box.id = "footer-custom";
$.ajax({
url: mw.util.wikiScript('api'),
data: {
format: 'json',
action: 'parse',
prop: 'text',
page: name
}
}).done(function (data) {
box.appendChild( document.createTextNode( data.parse && data.parse.text['*'] ) );
footer.insertBefore( box, footer.firstChild );
});
}
if (mw.config.get('wgNamespaceNumber') == 0) {
$(function(){
var cats = mw.config.get( 'wgCategories' );
if (!cats)
return;
for (var i = 0; i < cats.length; i++) {
if (cats[i] == 'Living people' || cats[i].title == 'Possibly living people') {
addFooter('Template:BLP');
break;
}
}
});
}
});