MediaWiki

Gadget-pagecount.js

From Dogcraft Wiki

No edit summary
Tag: Manual revert
m (rewrite)
Line 1: Line 1:
$( function () {
$( function () {
var pagecount,  
var pagecount = document.createElement('div'),
pages,  
link = document.createElement('a'),
output,  
pages = document.createElement('span'),
api = new mw.Api();
text = document.createElement('span'),
actions = document.getElementById('wikiActions'),
api = new mw.Api(),
num = api.get( {
action:"query",
meta:"siteinfo",
siprop:"statistics",
formatversion:"2"
} );
pagecount = $('<div id="pagecount"><a href="/wiki/Special:AllPages?namespace=0&hideredirects=1"><span></span><span>pages</span></a></div>');
pagecount.id = 'pagecount';
link.href = "/wiki/Special:AllPages?namespace=0&hideredirects=1";
text.textContent = 'pages';
$('#wikiActions').before(pagecount);
$.when( num ).then( function ( data ) {
pages.textContent = data.query.statistics.articles;
link.append(pages, text);
pagecount.append(link);
api.get({action:"query",meta:"siteinfo",siprop:"statistics",formatversion:"2"}).done( function ( data ) {
actions.parentNode.insertBefore(pagecount, actions);
pages = data.query.statistics.articles;
var temp = $("#pagecount a span:nth-child(1)");
temp[0].innerText = pages;
});
});
});
});

Revision as of 23:12, 3 June 2022

$( 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);
	});
});
This page was last modified on 3 June 2022, at 23:12. (15 months ago)