לדלג לתוכן

מדיה ויקי:Gadget-Watchlist.js

מתוך צפונות ויקי
גרסה מ־17:27, 29 במרץ 2011 מאת wikipedia:he>קיפודנחש (wl_from_rc: מעקב מתוך שינויים אחרונים.)
(הבדל) → הגרסה הקודמת | הגרסה האחרונה (הבדל) | הגרסה הבאה ← (הבדל)

הערה: לאחר הפרסום, ייתכן שיהיה צורך לנקות את זיכרון המטמון (cache) של הדפדפן כדי להבחין בשינויים.

  • פיירפוקס / ספארי: להחזיק את המקש Shift בעת לחיצה על טעינה מחדש (Reload) או ללחוץ על צירוף המקשים Ctrl-F5 או Ctrl-R (במחשב מק: ⌘-R).
  • גוגל כרום: ללחוץ על צירוף המקשים Ctrl-Shift-R (במחשב מק: ⌘-Shift-R).
  • אדג': להחזיק את המקש Ctrl בעת לחיצה על רענן (Refresh) או ללחוץ על צירוף המקשים Ctrl-F5.
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.style.color = 'green';
	}
	span.source.style.fontWeight = 'bolder';
}

function wlinrc_watchme() {
	var ajax = sajax_init_object();
	var target = this.target;
	if (!target)
		return;
	target = target.replace(' ', '_');
	ajax.open('GET', 'http://he.wikipedia.org/w/api.php?action=watch&title=' + target);
	ajax.onreadystatechange = wlinrc_done;
	ajax.span = this;
	var textNode = this.firstChild;
	if (textNode) {
		textNode. textContent = textNode. innerText = '[נשלח...]';
		this.style.color = 'orange';
	}
	ajax.send(null);	
}

function wlinrc_addWatchListLink(li) {
	var isWatched = getElementsByClassName(li, 'strong', 'mw-watched').length > 0;
	if (isWatched)
		return;
	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.appendChild(document.createTextNode('[עקוב]'));
	$.extend(span.style, {cursor: 'pointer', color:'blue', 'text-decoration': 'underline'});
	$.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);