User:Nederlandse Leeuw/common.js

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search
Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
// <nowiki> Service to prevent categorization of this page
importScript('User:Rillke/bigChunkedUpload.js');
$( document ).ready(function() {
if (mw.config.get('wgNamespaceNumber') == 14 && mw.config.get('wgAction') == 'edit'){ // 14 = category
	$($( "a:contains('People')" )[0]).removeAttr('href');
	$($( "a:contains('People')" )[0]).on('click', function (){
		parts = mw.config.get('wgPageName').replace('Category:', '').replace(/\(.+?\)/g,"").replace(/_/g, " ").trim().split(' ');
		sort = '{{DEFAULTSORT:'+  parts[parts.length - 1];
		delete parts[parts.length - 1];
		sort += ', '+parts.join(" ").trim()+'}}';
		document.getElementById("wpTextbox1").value = document.getElementById("wpTextbox1").value 
		+'\n' +sort + '\n[[Category:People by name]]\n';
	});
}
});
// </nowiki>