User:Bawolff/sandbox/catdates.js
From Wikinews, the free news source you can write!
< User:Bawolff | sandbox
Note: After saving, you may have to bypass your browser's cache to see the changes. Mozilla / Firefox / Safari: hold down Shift while clicking Reload, or press Ctrl-Shift-R (Cmd-Shift-R on Apple Mac); IE: hold Ctrl while clicking Refresh, or press Ctrl-F5; Konqueror:: simply click the Reload button, or press F5; Opera users may need to completely clear their cache in Tools→Preferences. — More skins
//Make categories sort by category add date (and possibly last edit) instead of alphabetical //this is probably something that should be done server side, but js is what i know, and can happen instantly, so... catdates = {}; catdates.getCats = function(cat, order, callback) { //get first two hundred or so pages in a category. //returns object page_name => date (or other order method) var xmlhttp = sajax_init_object(); xmlhttp.self = this; xmlhttp.open( 'GET' , 'http://en.wikinews.org/w/api.php?action=query&format=json&list=categorymembers&cmsort=timestamp&cmprop=timestamp|title&cmdir=desc&cmtitle=' + "Category:" + cat, true ); xmlhttp.onload = callback; //does this work everywhere, or should it be onstatuschange xmlhttp.send( null ); //lastedit http://en.wikinews.org/w/api.php?action=query&generator=categorymembers&gcmtitle=Category:Physics&prop=revisions&rvprop=timestamp } catdates.sortPages = function(pageList) { } /* Date(Date.UTC(foo.query.categorymembers[1].timestamp.substring(0,4), foo.query.categorymembers[1].timestamp.substring(5,7)-1, foo.query.categorymembers[1].timestamp.substring(8,10), foo.query.categorymembers[1].timestamp.substring(11,13), foo.query.categorymembers[1].timestamp.substring(14,16), foo.query.categorymembers[1].timestamp.substring(17,19))); */ catdates.getCats("Published", null, null);
