מדיה ויקי:Gadget-watchlistMark.js: הבדלים בין גרסאות בדף

מ ויקיפדיה:סקריפטים/58 הועבר למדיה ויקי:Gadget-watchlistMark.js: במטרה להפוך לגדג'ט
מ 12 גרסאות של הדף wikipedia:he:מדיה_ויקי:Gadget-watchlistMark.js יובאו
 
(5 גרסאות ביניים של 2 משתמשים אינן מוצגות)
שורה 7: שורה 7:


function readWatchList(continuation) {
function readWatchList(continuation) {
var params = {action: 'query', list: 'watchlistraw', wrlimit: 500, format: 'json'};
var params = { action: 'query', list: 'watchlistraw', wrlimit: 'max', format: 'json', rawcontinue: 1 };
if (continuation)
if (continuation)
params.wrcontinue = continuation;
params.wrcontinue = continuation;
שורה 18: שורה 18:
colorWatched();
colorWatched();
});
});
}
}


function watchText(watch) { return (isCat ? ' ':'') + (watch ? '[עקוב]' : '[הסר]');}
function watchText(watch) { return (isCat ? ' ':'') + (watch ? '[עקוב]' : '[הסר]');}
שורה 24: שורה 24:


function colorWatched() {
function colorWatched() {
var pagesList = isCat ? $('#mw-pages').find('li') : $('#bodyContent > ul > li');
 
var all = [];
var  
var all = pagesList.each(function() {
pagesList = isCat ? $('#mw-pages').find('li') : mw.util.$content.find('ul > li'),
all = pagesList.each(function() {
var li = $(this);
var li = $(this);
var line = li.children().filter('a:last');
var line = li.children().filter('a:last');
שורה 35: שורה 36:
var watchLink = $('<span>', {'class': watched? 'unwatchit-link' : 'watchit-link', title: watchTitle( !watched)})
var watchLink = $('<span>', {'class': watched? 'unwatchit-link' : 'watchit-link', title: watchTitle( !watched)})
.text(watchText(! watched))
.text(watchText(! watched))
.click(function() {watchIt($(this), page, line)})
.click(function() {watchIt($(this), page)});
li.append(watchLink);
li.append(watchLink);
});
}),
showLink = $('<a>', {href: '#', text:'הצג קישוריות מעקב'}).click(
function(){
mw.util.addCSS('.unwatchit-link,.watchit-link{display:inline;}');
$(this).remove();
}
);
if ($('#contentSub a').length)
$('#contentSub a:last').after(showLink).after(' | ');
else
$('#contentSub').append(showLink);
}
}
 
function watchIt(span, page, line) {
function watchIt(span, page) {
var watched = span.hasClass('unwatchit-link');
var watched = span.hasClass('unwatchit-link');
var params = {action: 'watch', title: page, format: 'json'};
var params = {action: 'watch', title: page, format: 'json'};
שורה 48: שורה 60:
params.token = mw.user.tokens.get('watchToken');
params.token = mw.user.tokens.get('watchToken');
$.post(mw.util.wikiScript('api'), params, function() {
$.post(mw.util.wikiScript('api'), params, function() {
span.toggleClass('unwatchit-link  watchit-link')
var lines=$('a').filter(function(){return $(this).text()==page});
lines.parent().children('span.watchit-link, span.unwatchit-link')
.toggleClass('unwatchit-link  watchit-link')
.text(watchText(watched))
.text(watchText(watched))
.attr({title: watchTitle(watched)});
.attr({title: watchTitle(watched)});
line.toggleClass('iswatched');
lines.toggleClass('iswatched');
});
});
}
}
 
$("<style type='text/css'> \n" +
mw.util.addCSS(
".unwatchit-link{color:#a00; cursor: pointer; font-size: 70%;}  \n" +
".unwatchit-link{color:#a00; cursor: pointer; font-size: 70%;display:none}  \n" +
".watchit-link{color:#008; cursor: pointer; font-size: 70%;}  \n" +
".watchit-link{color:#008; cursor: pointer; font-size: 70%;display:none}  \n" +
".iswatched{font-weight: bolder;} \n" +
".iswatched{font-weight: bolder;}"
"</style> "
);
).appendTo("head");
readWatchList();
readWatchList();
 
}); // document ready
}); // document ready