User:Bawolff/sandbox/catdates.js

//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);