משתמש:Yova/common.js/watchlistNotifier.js/modernForm.js
הערה: לאחר הפרסום, ייתכן שיהיה צורך לנקות את זיכרון המטמון (cache) של הדפדפן כדי להבחין בשינויים.
- פיירפוקס / ספארי: להחזיק את המקש Shift בעת לחיצה על טעינה מחדש (Reload) או ללחוץ על צירוף המקשים Ctrl-F5 או Ctrl-R (במחשב מק: ⌘-R).
- גוגל כרום: ללחוץ על צירוף המקשים Ctrl-Shift-R (במחשב מק: ⌘-Shift-R).
- אינטרנט אקספלורר / אדג': להחזיק את המקש Ctrl בעת לחיצה על רענן (Refresh) או ללחוץ על צירוף המקשים Ctrl-F5.
- אופרה: ללחוץ על Ctrl-F5.
(function() {
function WatchlistItem(item) {
this.cookieName = 'watchlistAnnounce_' + encodeURI(wgUserName).replace(/%/g, '');
$.extend(this, item);
this.wasThere = function() {
if (this.title == wgPageName.replace(/_/g, ' '))
return true;
var cookie = $.cookie(this.cookieName);
if (!cookie)
return false;
var ar = cookie.split('\t');
return wgUserName == ar[0]
&& this.title == ar[1]
&& this.timestamp == ar[2]
&& ar[3] == "was there";
}
this.sizeSpan = function() {
var
d = this.newlen - this.oldlen,
color = d < 0 ? 'red' : d > 0 ? 'green' : 'grey',
sign = d < 0 ? '-' : d > 0 ? '+' : '';
return $('<span>').css({color: color}).text(' (' + d + sign + ') ');
}
this.makeLine = function() {
var
page = $('<a>', {href: mw.util.getUrl(this.title), text: this.title}),
user = $('<a>', {href: mw.util.getUrl('User:' + this.user), text: this.user}),
ts = new Date(this.timestamp);
return $('<div>')
.append('רשימת מעקב: ')
.append(ts.getHours() + ':' + ts.getMinutes() + ' ')
.append(' ')
.append(page)
.append(this.sizeSpan())
.append(user)
.append(' ')
.append('(' + this.comment + ')')
.html();
}
var ar = [wgUserName, this.title, this.timestamp, this.wasThere() ? "was there" : ""];
$.cookie(this.cookieName, ar.join('\t'), {path: '/', expires: 3});
}
function checkWatchlist() {
$.getJSON(mw.util.wikiScript('api'), {
action: 'query',
list: 'watchlist',
wllimit: 1,
wlexcludeuser: wgUserName,
wlprop: 'user|title|timestamp|comment|sizes|ids',
format: 'json'
},
function(data) {
if (data && data.query && data.query.watchlist) {
var item = new WatchlistItem(data.query.watchlist[0]);
if (!item.wasThere()) {
var message = $('#watchlistAnnouncer');
if (!message.length)
message = $('<div>', {id: 'watchlistAnnouncer'})
.addClass('usermessage')
.css({fontSize: '75%', lineHeight: 1})
.insertAfter('#siteNotice');
message.html(item.makeLine());
}
}
}
);
}
if (wgCanonicalSpecialPageName != "Watchlist") {
checkWatchlist();
setInterval(checkWatchlist, 5000);
}
})();