משתמש:Crazy Ivan/watchlist-indicator.js
הערה: לאחר הפרסום, ייתכן שיהיה צורך לנקות את זיכרון המטמון (cache) של הדפדפן כדי להבחין בשינויים.
- פיירפוקס / ספארי: להחזיק את המקש Shift בעת לחיצה על טעינה מחדש (Reload) או ללחוץ על צירוף המקשים Ctrl-F5 או Ctrl-R (במחשב מק: ⌘-R).
- גוגל כרום: ללחוץ על צירוף המקשים Ctrl-Shift-R (במחשב מק: ⌘-Shift-R).
- אינטרנט אקספלורר / אדג': להחזיק את המקש Ctrl בעת לחיצה על רענן (Refresh) או ללחוץ על צירוף המקשים Ctrl-F5.
- אופרה: ללחוץ על Ctrl-F5.
/* הקישור לרשימת המעקב בראש הדף מופיע מודגש כאשר השינוי האחרון ברשימה טרם נקרא.
* מבוסס על [[en:User:Ais523/watchlistnotifier.js]].
*/
var wmwpajax;
// From [[en:WP:US]] mainpage (wpajax renamed to wmwpajax)
wmwpajax={
download:function(bundle) {
// mandatory: bundle.url
// optional: bundle.onSuccess (xmlhttprequest, bundle)
// optional: bundle.onFailure (xmlhttprequest, bundle)
// optional: bundle.otherStuff OK too, passed to onSuccess and onFailure
var x = window.XMLHttpRequest ? new XMLHttpRequest()
: window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP")
: false;
if (x) {
x.onreadystatechange=function() {
x.readyState==4 && wmwpajax.downloadComplete(x,bundle);
};
x.open("GET",bundle.url,true);
x.send(null);
}
return x;
},
downloadComplete:function(x,bundle) {
x.status==200 && ( bundle.onSuccess && bundle.onSuccess(x,bundle) || true )
|| ( bundle.onFailure && bundle.onFailure(x,bundle) || alert(x.statusText+': '+bundle.url));
}
};
// End of [[en:WP:US]] quote
function wmWatchEditFound(xmlreq, data) {
//alert(xmlreq.responseText);
var timestamp = xmlreq.responseText;
timestamp = timestamp.substring(timestamp.indexOf("item notificationtimestamp=")+28);
timestamp = timestamp.substring(0,timestamp.indexOf("\""));
if (""!=timestamp)
{
var watchlist = document.getElementById("pt-watchlist");
watchlist.setAttribute("style", "font-weight: bold;");
}
}
$(function() {
/* Find the top item in the watchlist. We only need one item, so
set the limit to 1 to ease the load on the server. */
wmwpajax.download({url: mw.config.get('wgScriptPath') + '/api.php?action=query&list=watchlist&wllimit=1&'+
'wldir=older&format=xml&wlprop=notificationtimestamp', onSuccess: wmWatchEditFound});
});