MediaWiki

Gadget-pagecount.js

From Dogcraft Wiki

m (rewrite)
No edit summary
Tag: Reverted
Line 24: Line 24:
actions.parentNode.insertBefore(pagecount, actions);
actions.parentNode.insertBefore(pagecount, actions);
});
});
});
//temp: move news-info indicator into pagecount's place
mw.hook( 'userjs.breadcrumbs.done' ).add( function() {
if (mw.config.get('wgNamespace') === 30040) {
$("#pagecount").append($(".mw-indicators.mw-body-content"));
}
});
});

Revision as of 21:26, 1 February 2023

$( 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);
	});
});

//temp: move news-info indicator into pagecount's place
mw.hook( 'userjs.breadcrumbs.done' ).add( function() {
	if (mw.config.get('wgNamespace') === 30040) {
		$("#pagecount").append($(".mw-indicators.mw-body-content")); 
	}
});
This page was last modified on 1 February 2023, at 21:26. (13 months ago)
Background Takeshi by Edo