User:Frietjes/sortcat.js

/// Sort cat jQuery(document).ready(function($) { // //

if(mw.config.get('wgNamespaceNumber') != -1 ) { mw.loader.using(['mediawiki.util']).done( function { var portletlink = mw.util.addPortletLink('p-tb', '#', 'Sort cat', 't-sortcat');  $(portletlink).click(function(e) { e.preventDefault; getNonArticles(0); }); }); }

function getNonArticles { var loopflag = true; var ckey; var plist = ""; var k = 0; var ns = "0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|100|101|108" + "|109|118|119|446|447|710|711|828|829|2300|2301|2302|2303|2600";   var cat = "Category:Pages using infobox river with deprecated parameters"; cat = prompt("Category",cat); cat = cat.replace(/ /g, '_'); while(loopflag) { k = k + 1; var req = new XMLHttpRequest; var cstr = ""; if(k > 1) { cstr = "&cmcontinue=" + ckey; }   	req.open("GET", wgScriptPath + "/api.php?format=json" +    		"&action=query&continue=" + cstr +     		"&list=categorymembers&cmlimit=500&cmtitle=" + cat +    		"&cmnamespace=0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|100|101|108" +    		"|109|118|119|446|447|710|711|828|829|2300|2301|2302|2303|2600", false); req.send(null); var response = eval("(" + req.responseText + ")").query.categorymembers; for(var index in response) { var info = response[index]; plist = info.title + "\n" + plist; }   	if(eval("(" + req.responseText + ")").continue) { loopflag = true; ckey = eval("(" + req.responseText + ")").continue.cmcontinue; } else { loopflag = false; }	}	var parray = plist.split('\n'); parray.sort; alert(parray.join('\n')); } // //

});