User:Tim Starling/all rc.js

/*

Tool to show a recent changes feed using the RSS feed. Based on User:Lupin/recent2.js but shows all edits.



//

//DOWNLOADER

function recent2_download(bundle) { // mandatory: bundle.url // bundle.onSuccess // bundle.onFailure // bundle.otherStuff OK too

var x = window.XMLHttpRequest ? new XMLHttpRequest : window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : false;

if (x) { x.onreadystatechange=function { x.readyState==4 && recent2_downloadComplete(x,bundle); };   x.open("GET",bundle.url,true); // x.setRequestHeader('Accept','text/*'); x.send(null); } }

function recent2_downloadComplete(x,bundle) { x.status==200 && ( bundle.onSuccess && bundle.onSuccess(x,bundle) || true ) || ( bundle.onFailure && bundle.onFailure(x,bundle) || alert(x.statusText)); }

window.gettingBadWords=false; window.badWords=null; function getBadWords { window.gettingBadWords=true; recent2_download( { url: 'http://en.wikipedia.org/w/index.php?title=User:Lupin/badwords&action=raw&ctype=text/css',             onSuccess: processBadWords, onFailure: function  { recent2_runOnce(getBadWords, 15000); return true;}}); } function processBadWords(d) { var data=d.responseText.split('\n'); var ret=[]; for (var i=0; i.*(([^-{}.\s'=wI:*#0-9A-F])\\2{2,}|\\b(" + ret.join('|') + ")[\\b\\|]).* ", 'im'); }

function recent2_runOnce(f, time) { var i=recent2_runOnce.timers.length; var ff = function { clearInterval(recent2_runOnce.timers[i]); f }; var timer=setInterval(ff, time); recent2_runOnce.timers.push(timer); } recent2_runOnce.timers=[];

var feed='http://en.wikipedia.org/w/index.php?title=Special:Recentchanges&feed=rss';

function grabRecentChanges(feed) { if (! window.badWords && ! window.gettingBadWords) { getBadWords; return recent2_runOnce(function{grabRecentChanges(feed);}, 500); } var h1=document.getElementsByTagName('h1')[0]; var output=document.createElement('div'); h1.parentNode.insertBefore(output, h1.nextSibling); var status=document.createElement('div'); h1.parentNode.insertBefore(status, h1.nextSibling); status.innerHTML=greyFont+'(' + count + ') updating... ';

recent2_download({url: feed, onSuccess: processRecentChanges, output: output, status: status, onFailure: feedFailed}); }

var greyFont='';

function feedFailed(x,bundle) { try { bundle.status.innerHTML+=greyFont+'failed: '+x.statusText + ' '; } catch (err) { bundle.status.innerHTML+=greyFont+'failed badly: '+err+' '; } return true; }

window.recent2_newWindows=true;

function linkmaker(url, text) { var s='' + text + ''; return s; }

function processRecentChanges(req, bundle){ var doc=req.responseXML.documentElement; var items=doc.getElementsByTagName('item'); var latest=processRecentChanges.lastDate; bundle.output.innerHTML+=' '; for (var i=0; i< items.length; ++i) { var timestamp = Date.parse(getFirstTagContent(items[i],'pubDate')); if (timestamp <= processRecentChanges.lastDate) continue; latest = (timestamp > latest) ? timestamp : latest; var diffText=getFirstTagContent(items[i],'description').split(' ').join(' \n'); var editSummary=diffText.replace(RegExp('^ (.*?) [\\s\\S]*'), '$1'); var badMatch=diffText.match(badWords);

var article=getFirstTagContent(items[i], 'link'); var articleTitle=getFirstTagContent(items[i], 'title'); var editor=getFirstTagContent(items[i], 'creator'); var id=processRecentChanges.id; var badWord, badDiffFragment; if (badMatch) { badWord = badMatch[1]; badDiffFragment = badMatch[0]; } else { badWord = ''; badDiffFragment = ''; }

bundle.output.innerHTML+= recent2_doLine({timestamp: timestamp, article:article, articleTitle:articleTitle,                      editor:editor, id:id, badWord:badWord, badDiffFragment:badDiffFragment, badDiff:diffText,                      summary:editSummary}); processRecentChanges.id++; } bundle.output.innerHTML+=''; recent2_runOnce(function {recent2_doPopups(bundle.output)}, 300); processRecentChanges.lastDate=latest; bundle.status.innerHTML+=greyFont+'done up to ' + formatTime(latest) + ' '; }

function toggleSysopEdits { var divs=document.getElementsByTagName('div'); for (var i=0; i' : '') + '' + formatTime(bundle.timestamp) + ' ' + //latest + ' ' + processRecentChanges.lastDate + ' ' + linkmaker(lastDiffPage, bundle.articleTitle) + (bundle.badWord == '' ? ' . . ' : ' matched ' + bundle.badWord + ' . . ' ) + linkmaker(wikiBase + 'User:' + bundle.editor,          bundle.editor)     + ' ('  +  linkmaker(wikiBase + 'User_talk:' + bundle.editor,             'talk')     + ' | ' +  linkmaker(wikiBase + 'User_talk:' + bundle.editor + '?action=edit' + '&autoedit=s#$#\\n' + bundle.articleTitle + '%20~#&autosummary=Your%20recent%20edits', 'warn')    + ' | ' +  linkmaker(wikiBase + 'Special:Contributions/' + bundle.editor, 'contribs') + ' | ' +  linkmaker(wikiBase + 'Special:Blockip/' + bundle.editor,       'block')    +  '). . ' + ( bundle.summary ? '('+bundle.summary+') . . ' : '') + 'show details' + ' [rollback]' + ' ' + bundle.badDiffFragment + bundle.badDiff + ' ' + ( sysop ? ' ' : '') ; }

window.saveBundle= function(bundle) { var z={}; for (var prop in bundle) { z[prop]=bundle[prop]; } window.bundles[bundle.id]=z; }

window.tryRollback=function(id) { var b=window.bundles[id]; if (!b) { alert('No bundle! Please tell Lupin how to reproduce this error - it should not really happen.'); return; }

var summary = prompt('Enter edit summary for rollback of article "' + b.articleTitle + '" (leave blank for default):'); if (summary == null) { return; } var onSuccess=function (x,bundle) { var rollRe=RegExp(']*>)?(.*?)? ');   // match[0]: useless    // match[1]: url (escaped)    // match[2]: last editor (escaped)    // match[4]: last edit summary    var match=rollRe.exec(x.responseText);    if (!match) {      alert('no rollback link found');      return;    }    var lastEditor=match[2].split('+').join(' ');    var lastSummary=match[4];    var vandal=b.editor; // from the closure    if (lastEditor != vandal) {      alert( 'Could not rollback - someone else has edited since the vandal.\n\nPage: '+ b.articleTitle +             '\nVandal: '+vandal+'\nLast editor: '+lastEditor+'\nEdit summary: '+lastSummary);      return;    }    var rollbackUrl=unescape(match[1]).split('&amp;').join('&');    if (summary != '') {      rollbackUrl += '&summary=' + escape(summary);    }    // confirm('Rollback edits by '+vandal + ' to '+b.articleTitle+'?') && window.open(rollbackUrl, '_blank'); } var onFailure = function(x,bundle) { alert('HTTP failed when trying to get rollback link in url\n' + bundle.url +         '\n\nHTTP status text: ' + x.statusText); return true; } recent2_download({ url:b.url, onSuccess: onSuccess, id: b.id, onFailure:onFailure}); }

function recent2_doPopups(div) { if (typeof(mouseOverWikiLink)!='undefined' &&      typeof(mouseOutWikiLink) !='undefined' &&       typeof(killPopup)        !='undefined') { var anchors=div.getElementsByTagName('A'); for (var i=0; i<anchors.length; ++i) { var a=anchors[i]; if (a.href.indexOf('javascript')==0) continue; a.onmouseover=mouseOverWikiLink; a.onmouseout= mouseOutWikiLink; a.onclick= killPopup; } } }

function formatTime(timestamp) { var date=new Date(timestamp); nums=[date.getHours, date.getMinutes, date.getSeconds]; for (var i=0; i<nums.length; ++i) if (nums[i]<10) nums[i]='0'+nums[i]; return nums.join(':'); }

window.showHideDetail = function(id) { var div=document.getElementById('diff_div_' + id); var lk=document.getElementById('showdiff_link_' + id); if (!div) return; if (div.style.display=='none') { div.style.display='inline'; lk.innerHTML='hide details'; } else                          { div.style.display='none';   lk.innerHTML='show details'; } }

processRecentChanges.lastDate=0; processRecentChanges.id=0;

function getFirstTagContent(parent, tag) { var e=parent.getElementsByTagName(tag); if (e && (e=e[0]) ) { var ret = e.textContent || e.innerText; if (typeof ret != typeof ) return ; return ret; } } //grabRecentChanges(feed);

var count=0; function loopRecentChanges(url, iterations) { if (!iterations) iterations=20; grabRecentChanges(url); recent2_runOnce(function {     if (++count >= iterations && ! confirm('Continue monitoring recent changes?') ) return;    count %= iterations; loopRecentChanges(url, iterations);  }, 30000); } function marvin { loopRecentChanges(feed, 200); }

// loopRecentChanges(feed, 20);

// ************************************************** // Installation // **************************************************

function recent2_addlilink(tabs, url, name, id, title, key){ var na = document.createElement('a'); na.href = url; na.appendChild(document.createTextNode(name)); var li = document.createElement('li'); if(id) li.id = id; li.appendChild(na); tabs.appendChild(li); if(id) { if(key && title) ta[id] = [key, title]; else if(key)    ta[id] = [key, '']; else if(title)  ta[id] = ['', title]; }   // re-render the title and accesskeys from existing code in wikibits.js    akeytt; return li; }

function recent2_addToolboxLink(url, name, id){ var tb = document.getElementById('p-tb').getElementsByTagName('ul')[0]; recent2_addlilink(tb, url, name, id); }

function addMarvin { recent2_addToolboxLink('#', 'Filter changes live', 'toolbox_filter_changes'); document.getElementById('toolbox_filter_changes').onclick=marvin; }

( window.addEventListener && window.addEventListener("load", addMarvin, false) ) || ( window.attachEvent     && window.attachEvent("onload", addMarvin)           );

var sysops=RegExp("^(\\-\\- April|23skidoo|A Man In Black|ABCD|ALoan|Academic Challenger|Acetic Acid|Adam Bishop|Ahoerstemeier|Alabamaboy|Alai|AlainV|Alex S|Alex756|AlistairMcMillan|Alkivar|Allen3|AllyUnion|Alteripse|Ambi|Ams80|Andres|Andrevan|Andrew Yong|Andrewa|Andris|Android79|Angela|Angr|Antandrus|Anthere|AntonioMartin|Aranel|Arcadian|Aris Katsaris|Arminius|Arvindn|Arwel Parry|Asbestos|AstroNomer|Ausir|AxelBoldt|BanyanTree|BaronLarf|Bcorr|Bdesham|Bearcat|Beland|Benc|Bhadani|Biekko|BillyH|Bishonen|Bkonrad|Blankfaze|Bluemoose|Bmicomp|Bovlb|Bratsche|Brian Kendig|Brian0918|BrianSmithson|Briangotts|Brighterorange|Brion VIBBER|Brockert|BrokenSegue|Brookie|Bryan Derksen|Bumm13|Burgundavia|CJCurrie|COGDEN|CSTAR|CYD|Cacycle|Caltrop|CambridgeBayWeather|Camembert|Canderson7|Capitalistroadster|Carbonite|Carnildo|Catbar|CatherineMunro|Cburnett|Cdc|Cecropia|Cedar\\-Guardian|Celestianpower|CesarB|Cgs|Chadloder|Chancemill|Changlc|Charles Matthews|Chmod007|Chris 73|Chris Roy|ChrisO|Christopher Mahan|Chuck SMITH|Chuq|Cimon avaro|Clarkk|Clifford Adams|ClockworkSoul|Commander Keane|ContiE|Cool Hand Luke|Cprompt|Craigy144|Cryptic|CryptoDerk|Curps|Cutler|Cyan|Cyberjunkie|CyborgTosser|Cyp|Cyrius|DESiegel|DF08|DJ Clayworth|Dale Arnett|Dan100|DanKeshet|Daniel Quinlan|DanielCD|Danny|Dante Alighieri|Darwinek|Dave souza|David Gerard|David Newton|David\\.Monniaux|DavidLevinson|DavidWBrooks|Davidcannon|Davodd|Dbachmann|Dbenbenn|Dbiv|Dcoetzee|Deb|Decumanus|Delirium|Denelson83|Denni|Derek Ross|Dgrant|Diberri|Dieter Simon|Dino|Dmcdevit|Dmn|Doc glasgow|Docu|Dori|Dpbsmith|DrBob|DragonflySixtyseven|Dragons flight|Drini|DropDeadGorgias|Duk|Duncharris|Durin|Dvyost|Dwheeler|Dysprosia|Earl Andrew|Ed Poor|Ed g2s|Edcolins|Edward|Efghij|Egil|El C|Elf|Ellsworth|Eloquence|Enchanter|Essjay|Eugene van der Pijll|Evercat|Everyking|Evil Monkey|Evil saltine|Evilphoenix|Exploding Boy|Ezhiki|FCYTravis|Fabiform|Fantasy|Fastfission|Fawcett5|Feco|FeloniousMonk|Fennec|Ferkelparade|Fernando Rizo|Ffirehorse|Filiocht|Finlay McWalter|Fire Star|FireFox|Flcelloguy|Flockmeal|Francs2000|Frazzydee|Fred Bauder|Fredrik|Freestylefrappe|FreplySpang|Friday|Func|Furrykef|Fuzheado|Fvw|G\\-Man|Gabbe|Gadfium|Gamaliel|Garzo|Gaz|Gdr|GeneralPatton|Geni|Gentgeen|Geogre|Gerald Farinas|Goatasaur|Golbez|Graft|GregAsche|GregRobson|Grenavitar|Grm wnr|Ground Zero|Grue|Grunt|Grutness|Gtrmp|Guettarda|Gwalla|Gyrofrog|Hadal|Hajor|Hall Monitor|HappyCamper|Hashar|Hawstom|Hcheney|Hedley|Hemanshu|Henrygb|Hephaestos|Hermione1980|Heron|Homeontherange|Humblefool|Hyacinth|Icairns|IceKarma|Ihcoyc|Ike9898|Ilyanep|Improv|Imran|Infrogmation|Ingoolemo|Inter|Isomorphic|Ixfd64|J\\.J\\.|JCarriker|JHK|JIP|JRM|JYolkowski|Jake Nelson|Jallan|JamesTeterenko|Jamesday|Jasonr|Jaxl|Jay|Jayjg|Jcw69|Jdavidb|Jdforrester|JeLuF|Jeffrey O\\. Gustafson|Jengod|JeremyA|Jeronimo|Jerzy|JesseW|Jfdwolff|Jiang|Jimbo Wales|Jimfbleak|Jimregan|Jinian|Jitse Niesen|Jmabel|Jnc|Jni|JoJan|John Kenney|JohnOwens|Johnleemk|Johntex|JonMoore|Jondel|Joolz|Josh Grosse|Jossifresco|Journalist|Joy|Joy Stovall|Jpgordon|Jrdioko|Jredmond|Jtdirl|Jtkiefer|Justinc|Jwrosenzweig|K1Bond007|KF|Kaihsu|Kaldari|Karada|Karen Johnson|Karmafist|Katefan0|Kbdank71|Kelly Martin|Khaosworks|Khendon|Khym Chanur|Kingturtle|Kirill Lokshin|Kmccoy|Knowledge Seeker|Kosebamse|Ktsquare|Kwamikagami|Kzollman|LC|Lachatdelarue|Lacrimosus|Lectonar|Lee Daniel Crocker|Lexor|Linuxbeak|LittleDan|Llywrch|Lommer|Longhair|Lord Emsworth|LordAmeth|LouI|Lowellian|Lucky 6\\.9|Ludraman|Lupin|Lupo|MC MasterChef|MacGyverMagic|Mackensen|Mackeriv|Madchester|Magnus Manske|Mailer diablo|Mairi|Malcolm Farmer|Manning Bartlett|Marianocecowski|Marine 69\\-71|Mark|Mark Christensen|Mark Dingemanse|Mark Richards|MarkSweep|Markalexander100|Marshman|Marudubshinki|Marumari|Master Thief Garrett|Matt Crypto|Maury Markowitz|Maveric149|Maximus Rex|Mbecker|Meelar|Mel Etitis|Menchi|Merovingian|Merphant|Mic|Michael Hardy|Michael Snow|Mike Halterman|Mikkalai|Mindspillage|Minesweeper|Mintguy|Mirv|Mirwin|Mkmcconn|Mkweise|Modemac|Moink|Moncrief|Montrealais|Moriori|Morven|Morwen|Mulad|Mustafaa|MyRedDice|MykReeve|Mysekurity|Mzajac|Nabla|Nandesuka|Nanobug|Necrothesp|Neutrality|Ngb|Nichalp|NicholasTurnbull|Nickptar|Nickshanks|Niteowlneils|Nohat|Noldoaran|Notheruser|Nufy8|Nunh\\-huh|Nv8200p|Oberiko|OldakQuill|Oleg Alexandrov|Oliver Pereira|Olivier|Omegatron|Optim|Ortolan88|Oven Fresh|OwenX|PFHLai|PMA|PRueda29|PZFUN|Pakaran|Pamri|Patrick|Paul A|Paul August|Pcb21|PedanticallySpeaking|Petaholmes|Peter Winnberg|Pfortuny|Pharos|Phil Bordelon|Phil Boswell|Phils|Philwelch|Phroziac|Physchim62|PierreAbbat|Piotrus|Pjacobi|Pollinator|Poor Yorick|Postdlf|Pratyeka|Premeditated Chaos|Proteus|Psy guy|Qaz|Quadell|Quercusrobur|R\\. fiend|R3m0t|RHaworth|RJFJR|RN|Radiant\\!|RadicalBender|Ragib|Ral315|Ram\\-Man|Rama|Ramallite|Ran|Raul654|Rbrwr|Rd232|Rdsmith4|RedWolf|RedWordSmith|Redux|Redwolf24|Refdoc|Reflex Reaction|Rfl|Rhobite|Rholton|Rhymeless|Rich Farmbrough|Rick Block|RickK|Rje|Rlandmann|Rlquall|Rmhermen|Roadrunner|RobLa|Robchurch|Robert Merkel|RobertG|Robin Patterson|RobyWayne|Roozbeh|RoseParks|Rossami|RoyBoy|RoySmith|Rx StrangeLove|Ryan Delaney|SD6\\-Agent|SWAdair|Salsa Shark|Sam Hocevar|Sam Korn|Sango123|Sannse|Sarge Baldy|Sasquatch|Schissel|Schneelocke|Scimitar|Scipius|Scott Burley|ScottDavis|Seabhcan|Sebastiankessel|Secretlondon|Seglea|Sesel|Seth Ilys|Sfoskett|Shanes|Shauri|Sheldon Rampton|Shimgray|SimonP|Siroxo|Sj|Sjakkalle|Sjc|Slambo|SlimVirgin|Slowking Man|Slrubenstein|Smith03|Sn0wflake|Snowspinner|Snoyes|Solipsist|Someone else|Sortior|Spangineer|Spencer195|Splash|Ssd|Stan Shebs|Starblind|Stevenj|Stevertigo|Stewartadcock|Stormie|Sugarfish|Sundar|Sverdrup|TPK|TUF\\-KAT|Ta bu shi da yu|Talrias|Tannin|Tarquin|Taw|Taxman|TenOfAllTrades|Texture|Thames|The Anome|The Cunctator|The Epopt|The Singing Badger|The wub|TheCoffee|TheoClarke|Theresa knott|Thryduulf|Thue|Thunderbrand|Tillwe|Tim Ivorson|Tim Starling|Timc|Timrollpickering|Timshell|Timwi|Titoxd|Tkinias|Toby Bartels|Tom\\-|Tomf688|Tompagenet|Tony Sidaway|Topbanana|Tregoweth|Trevor macinnis|Triddle|Trilobite|Tristanb|Ugen64|Ulayiti|Uncle G|UninvitedCompany|Urhixidur|Utcursch|UtherSRG|Vague Rant|VampWillow|Vancouverguy|Vaoverland|Viajero|Vicki Rosenzweig|Violetriga|Visorstuff|Voice of All\\(MTG\\)|Vsmith|Waltpohl|Wapcaplet|Warofdreams|Wayward|Wernher|Wesley|WhisperToMe|Who|Wiglaf|Wikiacc|Wikibofh|Wile E\\. Heresiarch|Wilfried Derksen|Willmcw|Woggly|WojPob|Woohookitty|Worldtraveller|Ww|Wwoods|XJamRastafire|Xezbeth|Y0u|Yacht|Zanimum|Zero0000|Zippy|Zocky|Zoe|Zoicon5|Zoney|Zscout370|Zzyzx11)$");

//

/// Local Variables: /// /// mode:c /// /// fill-prefix:"// " /// /// End: ///