מדיה ויקי:Gadget-Watchlist.js: הבדלים בין גרסאות בדף
מראה
wl_from_rc: מעקב מתוך שינויים אחרונים. |
גם הסר, למה לא. |
||
| שורה 4: | שורה 4: | ||
var span = this.span; | var span = this.span; | ||
var textNode = span.firstChild; | var textNode = span.firstChild; | ||
if (textNode) | if (textNode) | ||
textNode. textContent = textNode. innerText = '[ | textNode. textContent = textNode. innerText = span.following ? '[עקוב]' : '[הסר]'; | ||
span.source.style.fontWeight = span.following ? 'normal' : 'bolder'; | |||
span.style.color = span.following ? 'blue' : 'red'; | |||
span | span.following ^= true; | ||
} | } | ||
function wlinrc_watchme() { | function wlinrc_watchme() { | ||
var ajax = sajax_init_object(); | var ajax = sajax_init_object(); | ||
ajax.open('GET', 'http://he.wikipedia.org/w/api.php?action=watch' + | |||
'&title=' + this.target.replace(' ', '_') + | |||
(this.following ? '&unwatch=' : '')); | |||
ajax.open('GET', 'http://he.wikipedia.org/w/api.php?action=watch&title=' + target); | |||
ajax.onreadystatechange = wlinrc_done; | ajax.onreadystatechange = wlinrc_done; | ||
ajax.span = this; | ajax.span = this; | ||
this.firstChild.textContent = this.firstChild.innerText = '[נשלח...]'; | |||
this.style.color = 'orange'; | |||
ajax.send(null); | ajax.send(null); | ||
} | } | ||
function wlinrc_addWatchListLink(li) { | function wlinrc_addWatchListLink(li) { | ||
var anchors = li.getElementsByTagName('a'); | var anchors = li.getElementsByTagName('a'); | ||
var link = '', source = null; | var link = '', source = null; | ||
| שורה 46: | שורה 38: | ||
return; | return; | ||
var span = document.createElement(span); | var span = document.createElement(span); | ||
span.appendChild(document.createTextNode('[עקוב]')); | span.following = getElementsByClassName(li, 'strong', 'mw-watched').length > 0; | ||
$.extend(span.style, {cursor: 'pointer', color:' | span.appendChild(document.createTextNode(span.following ? '[הסר]' : '[עקוב]')); | ||
$.extend(span.style, {cursor: 'pointer', color: span.following ? 'red' : 'blue'}); | |||
$.extend(span, {onclick: wlinrc_watchme, target: link, source: source}); | $.extend(span, {onclick: wlinrc_watchme, target: link, source: source}); | ||
li.appendChild(span); | li.appendChild(span); | ||
גרסה מ־19:34, 29 במרץ 2011
function wlinrc_done() {
if (this.readyState != 4) // this is some ajax incantation - ony "4" is good.
return;
var span = this.span;
var textNode = span.firstChild;
if (textNode)
textNode. textContent = textNode. innerText = span.following ? '[עקוב]' : '[הסר]';
span.source.style.fontWeight = span.following ? 'normal' : 'bolder';
span.style.color = span.following ? 'blue' : 'red';
span.following ^= true;
}
function wlinrc_watchme() {
var ajax = sajax_init_object();
ajax.open('GET', 'http://he.wikipedia.org/w/api.php?action=watch' +
'&title=' + this.target.replace(' ', '_') +
(this.following ? '&unwatch=' : ''));
ajax.onreadystatechange = wlinrc_done;
ajax.span = this;
this.firstChild.textContent = this.firstChild.innerText = '[נשלח...]';
this.style.color = 'orange';
ajax.send(null);
}
function wlinrc_addWatchListLink(li) {
var anchors = li.getElementsByTagName('a');
var link = '', source = null;
for (var i = 0; i < anchors.length; i++) {
var anchor = anchors[i];
var linkString = anchor.href;
if (linkString && linkString.indexOf('/wiki/', 0) > 0) {
link = anchor.title;
source = anchor;
break;
}
}
if (!link)
return;
var span = document.createElement(span);
span.following = getElementsByClassName(li, 'strong', 'mw-watched').length > 0;
span.appendChild(document.createTextNode(span.following ? '[הסר]' : '[עקוב]'));
$.extend(span.style, {cursor: 'pointer', color: span.following ? 'red' : 'blue'});
$.extend(span, {onclick: wlinrc_watchme, target: link, source: source});
li.appendChild(span);
}
function wlinrc_addWatchListLinks() {
var kinds = ['mw-line-even', 'mw-line-odd'];
for (var i in kinds) {
var links = getElementsByClassName(document, 'li', kinds[i]);
for (var l in links)
wlinrc_addWatchListLink(links[l]);
}
}
if (wgCanonicalSpecialPageName == 'Recentchanges')
hookEvent("load", wlinrc_addWatchListLinks);