User:Writ Keeper/Scripts/liveWatchlist.js

watchlistLastRetrieved; apiProps = {"action":"query","list":"watchlist","wlprop":"ids|title|user|comment|timestamp|sizes","wlallrev":"true"} watchlistUpdateClass= "watchlistUpdate";

function refreshWatchlist { } function populateWatchlist {	if($("#mw-liveWatchlistUL").length > 0) {		$.post("\w\api.php",apiProps, function(response)		{			watchlistLastRetrieved = new Date(Date.now).toISOString;		}); } } function renderWatchlistEntry(var watchListJSON) {	var resultString = ""; var editTime = new Date(watchlistJSON.timestamp); var editDelta = watchlistJSON.newlen - watchlistJSON.oldlen; if(watchlistJSON.type === "edit") {		resultString = '(diff | hist). .  [ inspect diff ]  ' + watchlistJSON.title + ';  ‎; ' + editTime.getHours + ':' + editTime.getMinutes + '. . = 0 ? 'pos' : 'neg') + '" title="' + watchlistJSON.newLen + '" bytes after change">(' + (editDelta >= 0 ? '+' : '' + editDelta) + ') ‎ . . ‎ ' + watchlistJSON.user + '  (talk | contribs |<a href="/wiki/Special:Block/' + watchlistJSON.user + '" class="mw-usertoollinks-block nonimage" title="Special:Block/' + watchlistJSON.user + '">block</a>) ‎ (' + watchlistJSON.comment + ') </li>';	}	else if (watchlistJSON.type === "new") {		resultString = '<li class="mw-changeslist-liu mw-changeslist-src-mw-new">(diff | <a href="/w/index.php?title=' + watchlistJSON.title + '&curid=' + watchlistJSON.pageid + '&action=history" class="mw-changeslist-history nonimage" title="' + watchlistJSON.title + '">hist</a>). . <abbr class="newpage" title="This edit created a new page">N <a href="/wiki/' + watchlistJSON.title + '" class="mw-changeslist-title nonimage" title="' + watchlistJSON.title + '">' + watchlistJSON.title + '; </a> ‎; ' + editTime.getHours + ':' + editTime.getMinutes + '. . <span dir="ltr" class="mw-plusminus-pos" title="' + watchlistJSON.newlen + ' bytes after change">(+' + watchlistJSON.newlen + ') ‎. . ‎<a href="/wiki/User:' + watchlistJSON.user + '" class="mw-userlink nonimage userlink protection-edit-sysop-indef protection-edit-sysop protection-move-sysop-indef protection-move-sysop" title="User:' + watchlistJSON.user + '"> ' + watchlistJSON.user + ' </a> (<a href="/wiki/User_talk:' + watchlistJSON.user + '" class="mw-usertoollinks-talk nonimage userlink" title="User talk:' + watchlistJSON.user + '">talk</a> | <a href="/wiki/Special:Contributions/' + watchlistJSON.user + '" class="mw-usertoollinks-contribs nonimage userlink" title="Special:Contributions/' + watchlistJSON.user + '">contribs</a> | <a href="/wiki/Special:Block/' + watchlistJSON.user + '" class="mw-usertoollinks-block nonimage" title="Special:Block/' + watchlistJSON.user + '">block</a>) ‎ (' + watchlistJSON.comment + ') </li>'; }	else if (watchlistJSON.type === "log") {		resultString = '<li class="mw-changeslist-liu mw-changeslist-src-mw-log">(log); ' + editTime.getHours + ':' + editTime.getMinutes + '. . <a href="/wiki/User:' + watchlistJSON.user + '" class="mw-userlink nonimage userlink protection-edit-sysop-indef protection-edit-sysop protection-move-sysop-indef protection-move-sysop" title="User:' + watchlistJSON.user + '"> ' + watchlistJSON.user + ' </a> (<a href="/wiki/User_talk:' + watchlistJSON.user + '" class="mw-usertoollinks-talk nonimage userlink" title="User talk:' + watchlistJSON.user + '">talk</a> | <a href="/wiki/Special:Contributions/' + watchlistJSON.user + '" class="mw-usertoollinks-contribs nonimage userlink" title="Special:Contributions/' + watchlistJSON.user + '">contribs</a> | <a href="/wiki/Special:Block/' + watchlistJSON.user + '" class="mw-usertoollinks-block nonimage" title="Special:Block/' + watchlistJSON.user + '">block</a>) did something to <a href="/wiki/' + watchlistJSON.title + '" class="mw-userlink nonimage userlink" > ' + watchlistJSON.title + ' </a>with the comment: "‎ ' + watchlistJSON.comment + ' "</li>'; }	return resultString; }