User:Joshua Scott/Scripts/pendingchanges.js: Difference between revisions

Content deleted Content added
m Reverted edits by Joshua Scott (talk) to last version by He7d3r
Move beta to prod. Uses JSON, some other fixes to make it work again.
Line 7:
var pendch_diffonly;
 
var pendch_str_no_ajax = "There seems to be a problem using the PendingChangespendingchanges script. Your browser is not supported.";
var pendch_str_box_title = "Pending changes";
var pendch_str_box_title_updating = "Pending ch.changes (upd.updating)";
var pendch_str_box_title_failed = "Pending changes (update failed)";
var pendch_str_enable = "Enable this box";
var pendch_str_disable = "Disable this box";
 
$(document).ready( pendch_init );
/* initalise */
Line 27:
}
}
 
// allow user settings through
if (pendch_enabled == null) {
Line 43 ⟶ 44:
pendch_diffonly = 1;
}
 
// A few limits to be nice to the servers
if (pendch_num_pages > 50) {
Line 135:
}
}
 
// Get the current time
var dateobj = new Date();
var now = Math.floor(dateobj.getTime() / 1000.0);
 
// Go back 5 mins in time
//now -= (60 * 5);
 
// Then make the request
pendch_http.open("GET", "/w/api.php?action=query&format=xmljson&list=oldreviewedpages&ornamespace=0|4&orlimit=" + pendch_num_pages, true);
pendch_http.send(null);
}
Line 217 ⟶ 214:
/* Draw response (monobook) */
function pendch_ajax_response_monobook() {
 
var resp = JSON.parse(pendch_http.responseText);
var items = pendch_http.responseXML.getElementsByTagName('p');
var items = resp.query.oldreviewedpages;
 
// create the div that holds all the pending changesnewpage links
var link_div = document.createElement('div');
link_div.className = 'pBody';
Line 228 ⟶ 226:
// populate the list with 10 links.
for (var i = 0; i < items.length; i++) {
var item_nameitem = items[i].getAttribute('title');
var old_iditem_name = items[i]item.getAttribute('stable_revid')title;
var under_reviewold_id = items[i]item.getAttribute('under_review')stable_revid;
 
item_name = item_name.replace(/&/, "%26");
var item_url = 'http://en.wikipedia.org/w/index.php?title=' + item_name + '&diff=cur&oldid=' + old_id + '&diffonly=' + pendch_diffonly;
a = document.createElement('a');
Line 241 ⟶ 239:
var li = document.createElement('li');
li.appendChild(a);
if (under_review == "1") {
li.setAttribute('style','background-color: yellow;');
}
list.appendChild(li);
}
Line 313 ⟶ 308:
}
 
if( typeof $j != 'undefined' && wgVectorEnabledModules.collapsiblenav ) {
$('#p-pendingchanges > h5').keydown( function( event ) {
if ( event.which == 13 /* Enter */ || event.which == 32 /* Space */ ) {
Line 332 ⟶ 327:
function pendch_ajax_response_vector() {
var resp = JSON.parse(pendch_http.responseText);
var items = pendch_http.responseXML.getElementsByTagName('p');
var items = resp.query.oldreviewedpages;
 
// create the div that holds all the pending changesnewpage links
var link_div = document.createElement('div');
link_div.className = 'body';
Line 343 ⟶ 339:
// populate the list with 10 links.
for (var i = 0; i < items.length; i++) {
var item_nameitem = items[i].getAttribute('title');
var old_iditem_name = items[i]item.getAttribute('stable_revid')title;
var under_reviewold_id = items[i]item.getAttribute('under_review')stable_revid;
 
item_name = item_name.replace(/&/, "%26");
var item_url = 'http://en.wikipedia.org/w/index.php?title=' + item_name + '&diff=cur&oldid=' + old_id + '&diffonly=' + pendch_diffonly;
a = document.createElement('a');
Line 357 ⟶ 353:
var li = document.createElement('li');
li.appendChild(a);
if(under_review == "1") {
li.setAttribute('style','background-color: yellow;');
}
list.appendChild(li);
}
Line 393 ⟶ 386:
}
 
if( typeof $j != 'undefined' && wgVectorEnabledModules.collapsiblenav ) {
$('#p-pendingchanges > h5').keydown( function( event ) {
if ( event.which == 13 /* Enter */ || event.which == 32 /* Space */ ) {