MediaWiki
Gadget-pagecount.js
From Dogcraft Wiki
No edit summary |
(Moved code to common.js) |
||
Line 1: | Line 1: | ||
/* This code has been moved to Common.js */ | |||
$( function () { | $( function () { | ||
var pagecount = document.createElement('div'), | var pagecount = document.createElement('div'), |
Latest revision as of 21:51, 1 February 2023
/* This code has been moved to Common.js */
$( function () {
var pagecount = document.createElement('div'),
link = document.createElement('a'),
pages = document.createElement('span'),
text = document.createElement('span'),
actions = document.getElementById('wikiActions'),
api = new mw.Api(),
num = api.get( {
action:"query",
meta:"siteinfo",
siprop:"statistics",
formatversion:"2"
} );
pagecount.id = 'pagecount';
link.href = "/wiki/Special:AllPages?namespace=0&hideredirects=1";
text.textContent = 'pages';
$.when( num ).then( function ( data ) {
pages.textContent = data.query.statistics.articles;
link.append(pages, text);
pagecount.append(link);
actions.parentNode.insertBefore(pagecount, actions);
});
mw.hook( 'userjs.pagecount.done' ).fire();
mw.hook( 'userjs.pagecount.done' ).add( function() {
if (mw.config.get('wgNamespaceNumber') === 3004) {
$("#pagecount").append($(".mw-indicators.mw-body-content"));
}
});
});