לדלג לתוכן

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

מתוך צפונות ויקי
אין תקציר עריכה
מ 317 גרסאות של הדף wikipedia:he:מדיה_ויקי:Gadget-WLM.js יובאו
 
(312 גרסאות ביניים של משתמש אחר אחד אינן מוצגות)
שורה 1: שורה 1:
if ( mw.config.get( 'wgPageName' ) == 'מיוחד:רשימת_המעקב') {
/* jshint maxerr: 999 */
$(function() { // Thanks to חיים 7
$(function() {
$('.mw-changeslist-line-watched td.mw-enhanced-rc')
var timestamp, langmark, newmap;
.before(
var isnewfilter = $('.mw-rcfilters-enabled')
$('<a>', {text: '♦', title: 'סמן עריכה כנצפתה', href: '#nw'})
.length == 1;
.css({marginLeft: '0.3em', marginRight: '0.1em', color: '#990066'})
var api = new mw.Api();
 
function i18n(name) {
var msg = {
mark: ['סימון כעריכה שנקראה', 'Mark as read'],
unmark: ['סימון כעריכה שלא נקראה', 'Mark as unread'],
close: ['הסתרת העריכה', 'Hide revision'],
markFlow: ['סימון זרימה כנקראה', 'Mark flow as read'],
markCat: ['סימון קטגוריה כנקראה', 'Mark categorization as read'],
manymarked: ['שורות סומנו', 'lines marked'],
goldbutton: ['פתיחה וסימון של כל העריכות בדף הזה',
'Open and mark all this page revisions'
],
jsonlost: ['קובץ קונפיגורציה לא אותר', 'Configuration file not found'],
hideAll: ['הסתרת עריכות שנקראו', 'Hide all read'],
showAll: ['הצגת עריכות שהוסתרו', 'Show all hidden'],
whatsnew: ['מה חדש?', "What's new?"],
rcfilters: ['מסננים', 'Filters'],
closenew: ['סגירת רשימת החדשים', "Close the bar"],
loga: ['שימו לב: רשימת המעקב כוללת רשומת יומן שלא נקראה. הדף הוא ',
'Pay attention: the watchlist includes unread log entry. Page name: '
],
logb: [', הפעולה שנעשתה היא: ', ', log action: '],
logc: ['(לפרטים)', '(details)'],
logd: [
'אם ברצונכם לסמן אותה כנקראה, בדקו כי אין עריכות אחרות של הדף הזה שלא נקראו,' +
' כי גם הן יסומנו. לאחר מכן לחצו ',
'If you want to mark it as read, check that there are' +
' no other unwatched revisions of this page, because they will be marked too. Then click '
],
loge: ['כאן', 'here'],
clear: ['ניקוי', 'clear'],
nointernet: ['אין תקשורת', 'No internet'],
help: ['לפרטים ראו עזרה:מנהל רשימת המעקב', '']
};
return msg[name][lang || 0];
}
 
function button(msg, icon) {
return $('<a>', {
text: langmark,
title: i18n(msg),
href: '#nw'
})
.addClass(icon + ' WLM-icon');
}
 
function seen(obj) {
obj.filter(function() {
return $(this)
.closest('.mw-changeslist-line-watched')
.filter(notcat)
.find('a[href*="diff"]')
.filter(notme)
.filter(function() {
return $(this)
.closest('.mw-enhanced-rc-nested')
.length <= 0;
})
.length > 0;
})
.before(button('mark', 'mark-edits')
.click(function() {
if (config.hidemarked.edit)
$('.yellowedit')
.hide();
var curid = /curid=([0-9]+)/.exec($(this)
.closest('table, li')
.find('a[href*="curid"]')
.filter(notme)
.prop('href'))[1];
var $this = $(this),
diff = /diff=([0-9]+)/.exec($this.parent()
.parent()
.find('a[href*="diff"]')
.filter(notme)
.prop('href'))[1],
name = $this.parent()
.find('.mw-changeslist-title')
.text(),
all = $('.mw-changeslist-line-watched .mw-changeslist-title')
.filter(function() {
var thediff = /.*diff=([0-9]+).*oldid.*/.exec($(this)
.closest('.mw-changeslist-line-watched')
.find('a[href*="diff"]')
.filter(notme)
.prop('href'));
return thediff && $(this)
.text() == name && thediff[1] <= diff;
})
.closest('.mw-changeslist-line-watched'),
allboth = $('.mw-changeslist-line-watched .mw-changeslist-title')
.filter(function() {
return $(this)
.text() == name;
})
.closest('.mw-changeslist-line-watched');
api.postWithToken('csrf', {
action: 'setnotificationtimestamp',
titles: name,
newerthanrevid: diff
})
.done(function() {
if (all.length > 1)
$this.closest('table, li')
.append($('<span>')
.text(' ' + all.length + ' ' + i18n('manymarked') + ' ')
.addClass('nowrap')
.css({
backgroundColor: 'red'
}));
all.removeClass('mw-changeslist-line-watched blueedit')
.addClass('mw-changeslist-line-not-watched yellowedit')
.show()
.find('.mark-edits')
.remove();
allboth.find('.gold-button')
.remove();
$('#gold-little-' + curid)
.find('a')
.remove();
defected[curid] = true;
unseen(all.find('span.mw-title'));
if (!config.hidemarked.wait)
all.hide();
});
}));
}
 
function unseen(obj) {
obj.filter(function() {
return $(this)
.closest('table, li')
.filter(notcat)
.find('a[href*="oldid"]')
.length > 0;
})
.before(button('unmark', 'unmark-edits')
.click(function() {
var curid = /curid=([0-9]+)/.exec($(this)
.closest('table, li')
.find('a[href*="curid"]')
.filter(notme)
.prop('href'))[1];
var $this = $(this),
diffcond = $this
.closest('.mw-changeslist-line-not-watched')
.find('abbr.newpage')
.length > 0,
oldrev = diffcond ? 0 : /oldid=([0-9]+)/.exec($this
.parent()
.parent()
.find('a[href*="oldid"]')
.filter(notme)
.prop('href'))[1],
diff = diffcond ? 0 : /diff=([0-9]+)/.exec($this
.parent()
.parent()
.find('a[href*="diff"]')
.filter(notme)
.prop('href'))[1],
name = $this
.next()
.text(),
all = $('.mw-changeslist-line-not-watched .mw-changeslist-title')
.filter(function() {
var thediff = /.*diff=([0-9]+).*oldid.*/.exec($(this)
.closest('.mw-changeslist-line-not-watched')
.find('a[href*="diff"]')
.filter(notme)
.prop('href'));
return thediff && $(this)
.text() == name && thediff[1] >= diff;
})
.closest('.mw-changeslist-line-not-watched'),
allboth = $('.mw-changeslist-line-watched .mw-changeslist-title')
.filter(function() {
return $(this)
.text() == name;
})
.closest('.mw-changeslist-line-watched');
api.postWithToken('csrf', {
action: 'setnotificationtimestamp',
titles: name,
newerthanrevid: oldrev
})
.done(function() {
if (all.length > 1)
$this.closest('table, li')
.append($('<span>')
.text(' ' + all.length + ' ' + i18n('manymarked') + ' ')
.addClass('nowrap')
);
all.removeClass('mw-changeslist-line-not-watched yellowedit')
.addClass('mw-changeslist-line-watched blueedit')
.show()
.find('.unmark-edits')
.remove();
allboth.find('.gold-button')
.remove();
$('#gold-little-' + curid)
.find('a')
.remove();
defected[curid] = true;
seen(all.find('span.mw-title'));
});
}));
}
 
function flowseen() {
$('.mw-changeslist-line-watched a.mw-title')
.parent()
.prepend(button('markFlow', 'mark-all-flow-edits')
.click(function() {
var $this = $(this),
topic = /title=[^:]*:(.+)&/.exec($this.parent()
.find('a[href*="fromnotif"]')
.prop('href')),
page = $this
.closest('.mw-changeslist-line-watched')
.find('a.mw-title')
.prop('title'),
titles = topic ? page + '|נושא:' + topic[1] : page;
api.postWithToken('csrf', {
action: 'setnotificationtimestamp',
titles: titles,
})
.done(function() {
if (config.hidemarked.flow)
$this.closest('.mw-changeslist-line-watched')
.hide();
$this.closest('.mw-changeslist-line-watched')
.removeClass('mw-changeslist-line-watched blueedit')
.addClass('mw-changeslist-line-not-watched yellowedit');
$this.remove();
});
}));
}
 
function categoryseen() {
$('.mw-changeslist-line-watched span.mw-title')
.filter(function() {
return ($(this)
.closest('.mw-changeslist-line-watched')
.find('a[href*="diff"]')
.length <= 0 && $(this)
.closest('.mw-changeslist-line-watched')
.find('abbr.newpage')
.length <= 0) ||
$(this)
.find('a.mw-changeslist-title')
.parent()
.next()
.text() == '. .';
})
.before(button('markCat', 'mark-cat-edits')
.click(function() {
var $this = $(this),
page = $this.parent()
.find('a.mw-changeslist-title')
.prop('title');
api.postWithToken('csrf', {
action: 'setnotificationtimestamp',
titles: page,
})
.done(function() {
if (config.hidemarked.categorization)
$this.closest('.mw-changeslist-line-watched')
.hide();
$this.closest('.mw-changeslist-line-watched')
.removeClass('mw-changeslist-line-watched blueedit')
.addClass('mw-changeslist-line-not-watched yellowedit');
$this.remove();
});
}));
}
 
function checklog() {
api.get({
action: 'query',
format: 'json',
list: 'watchlist',
indexpageids: 1,
wllimit: 500,
wlprop: 'title|loginfo',
wlshow: 'unread',
wltype: 'log'
})
.done(function(data) {
var firstname = data.query.watchlist;
if (firstname.length > 0) {
firstname = firstname.reverse()[0];
$('#WLM-table')
.parent()
.after($('<div>', {
id: 'logmessage'
})
.addClass('blueedit')
.append($('<span>')
.text(i18n('loga')))
.append($('<span>')
.text(firstname.title)
.css({
fontWeight: 'bold',
}))
.append($('<span>')
.text(i18n('logb') + firstname.logaction + ' '))
.append($('<a>', {
href: 'https://he.wikipedia.org//w/api.php?action=query&format=rawfm&list=watchlist&' +
'indexpageids=1&wllimit=500&wlprop=title%7Cloginfo%7Ctimestamp&wlshow=unread&wltype=log',
text: i18n('logc')
})
.attr({
target: '_blank'
}))
.append($('<span>')
.text('. ' + i18n('logd') + ' '))
.append($('<a>', {
target: '_blank'
})
.text(i18n('loge'))
.click(function() {
api.postWithToken('csrf', {
action: 'setnotificationtimestamp',
titles: firstname.title
})
.done(function() {
$('#logmessage')
.remove();
var all = $(
'.mw-changeslist-line-watched a.mw-changeslist-title')
.filter(function() {
return $(this)
.prop('title') == firstname.title;
})
.closest('.mw-changeslist-line-watched');
all.removeClass('mw-changeslist-line-watched blueedit')
.addClass('mw-changeslist-line-not-watched yellowedit')
.show()
.find('.unmark-edits')
.remove();
if (config.hidemarked.edit)
$('.yellowedit')
.hide();
seen(all.find('span.mw-title'));
if (all.length > 0)
$('#WLM-table')
.parent()
.after($('<div>')
.text(' ' + all.length + ' ' + i18n('manymarked') + ' ')
.addClass('nowrap')
)
.addClass('yellowedit');
checklog();
});
}))
.append($('<span>')
.text('.')
));
}
});
}
 
function goldbutton() {
$('.mw-changeslist-line-watched')
.find('abbr.newpage')
.each(function() {
var curid = /curid=([0-9]+)/.exec($(this)
.closest('table, li')
.find('a[href*="curid"]')
.filter(notme)
.prop('href'));
if (curid !== null && curid.length > 1)
defected[curid[1]] = true;
});
$('.close-edit')
.filter(function() {
return $(this)
.closest('.mw-changeslist-line-watched')
.filter(notcat)
.find('a[href*="diff"]')
.filter(notme)
.filter(function() {
return $(this)
.closest('.mw-enhanced-rc-nested')
.length <= 0;
})
.length > 0 &&
$(this)
.closest('.mw-changeslist-line-watched')
.find('a.mw-title')
.length <= 0;
})
.each(function() {
var curid = /curid=([0-9]+)/.exec($(this)
.closest('table, li')
.find('a[href*="curid"]')
.filter(notme)
.prop('href'))[1];
var name = $(this)
.closest('.mw-changeslist-line-watched')
.find('.mw-changeslist-title')
.text(),
checked = $('.mw-changeslist-title')
.filter(function() {
return $(this)
.text() == name;
})
.closest('.mw-changeslist-line-watched'),
nonew = checked
.find('abbr.newpage')
.length <= 0,
min = Infinity;
if (nonew) {
checked
.find('a[href*="oldid"]')
.filter(notme)
.filter(function() {
return ($(this)
.text() == messages.diff || $(this)
.text() == messages.last) &&
($(this)
.closest('.mw-enhanced-rc-nested')
.closest('.mw-enhanced-watched')
.length > 0 ||
$(this)
.closest('.mw-enhanced-rc-nested')
.length <= 0);
})
.each(function() {
var old = /oldid=([0-9]+)/.exec($(this)
.prop('href'));
min = old ? Math.min(min, old[1]) : min;
});
}
if (min > 0 && min != Infinity && nonew) {
$(this)
.after($('<a>', {
text: langmark,
title: i18n('goldbutton'),
target: '_blank',
href: 'https://he.wikipedia.org/w/index.php?title=' + name +
'&redirect=no&diff=cur&oldid=' + min
})
.addClass('gold-button WLM-icon gold-' + curid)
.click(function() {
if (config.hidemarked.edit)
$('.yellowedit')
.hide();
var all = $('.mw-changeslist-line-watched .mw-changeslist-title')
.filter(function() {
return $(this)
.text() == name;
})
.closest('.mw-changeslist-line-watched');
if (all.length > 1)
$(this)
.closest('table, li')
.append($('<span>')
.text(' ' + all.length + ' ' + i18n('manymarked') + ' ')
.addClass('nowrap')
.css({
backgroundColor: 'red'
}));
all.removeClass('mw-changeslist-line-watched blueedit')
.addClass('mw-changeslist-line-not-watched yellowedit')
.show()
.find('.mark-edits, .gold-button')
.remove();
$('.gold-' + curid)
.remove();
$('#gold-little-' + curid)
.remove();
unseen(all.find('span.mw-title'));
}));
}
});
}
 
function closeedit() {
var btn = button('close', 'close-edit')
.click(function() {
$(this)
.closest(
'.mw-changeslist-line-not-watched, .mw-changeslist-line-watched')
.hide();
});
$('li span.mw-changeslist-date')
.parent()
.prepend(btn);
$('td.mw-enhanced-rc')
.parent()
.filter(function() {
return $(this)
.find('td.mw-enhanced-rc-nested')
.length <= 0;
})
.prepend($('<td>')
.html(btn)
.css({
whiteSpace: 'nowrap'
}));
$('td.mw-enhanced-rc')
.parent()
.find('td.mw-enhanced-rc-nested')
.prev()
.before($('<td>'));
}
 
function notme() {
return !$(this)
.hasClass('WLM-icon');
}
 
function notcat() {
return $(this)
.find('a.mw-changeslist-title')
.parent()
.next()
.text() != '. .';
}
 
function whatsnew() {
$('.WLM-newrevs')
.remove();
api.get({
action: 'query',
format: 'json',
list: 'watchlist',
indexpageids: 1,
wldir: 'newer',
wllimit: 500,
wlprop: 'title|ids|notificationtimestamp',
wlshow: 'unread',
wltype: 'edit|new',
wlstart: timestamp,
wlallrev: 1,
errorformat: 'wikitext'
})
.fail(function() {
$('#WLM-table')
.parent()
.after($('<div>', {
id: 'newrevs',
text: i18n('nointernet')
})
.click(function() {
$('#newrevs')
.remove();
})
.addClass('blueedit WLM-newrevs'));
})
.done(function(data) {
var ans = data.query.watchlist;
newmap = {};
var notif = '';
Object.keys(ans)
.map(function(key) {
var id = ans[key].pageid;
var curnotif = ans[key].notificationtimestamp;
if (notif === '')
notif = curnotif;
else if (curnotif !== '' && notif > curnotif)
notif = curnotif;
if (id in newmap) {
if (ans[key].old_revid < newmap[id].oldid)
newmap[id].oldid = ans[key].old_revid;
} else {
newmap[id] = {
title: ans[key].title,
oldid: ans[key].old_revid,
notify: curnotif
};
}
});
api.get({
action: 'query',
format: 'json',
list: 'watchlist',
indexpageids: 1,
wldir: 'newer',
wllimit: 500,
wlprop: 'title|ids|notificationtimestamp',
wlshow: 'unread',
wltype: 'edit|new',
wlstart: notif,
wlallrev: 1,
errorformat: 'wikitext'
})
.done(function(data3) {
$('.WLM-newrevs')
.remove();
$('#WLM-table')
.parent()
.after($('<div>', {
id: 'newrevs',
text: '['
})
.addClass('blueedit WLM-newrevs'));
whatsnewrec(newmap, Object.keys(newmap), data3.query.watchlist);
});
});
}
 
function whatsnewrec(newmap, keys, notif) {
if (keys.length > 0) {
var data = keys[0];
var goldlength = $('.gold-' + data)
.length;
if (defected[data]) {
$('#newrevs')
.append($('<span>', {
text: newmap[data].title + ',' + langmark + ' '
}));
keys.shift();
whatsnewrec(newmap, keys, notif);
} else if (goldlength > 0) {
$('#newrevs')
.append($('<span>', {
text: newmap[data].title + ',' + langmark + ' ',
id: 'gold-little-' + data
})
.prepend($('.gold-' + data)
.clone(true, true)[0]));
keys.shift();
whatsnewrec(newmap, keys, notif);
} else {
var data3min = newmap[data].oldid;
Object.keys(notif)
.map(function(key) {
if (newmap[data].title == notif[key].title)
data3min = Math.min(data3min, notif[key].old_revid);
});
$('#newrevs')
.append($('<span>', {
text: ',' + langmark + ' '
})
.prepend($('<a>', {
text: newmap[data].title,
href: 'https://he.wikipedia.org/w/index.php?title=' +
newmap[data].title +
'&redirect=no&diff=cur&oldid=' + data3min,
target: '_blank'
})
.click(function() {
$(this)
.parent()
.remove();
$('.yellowedit')
.hide();
$('body')
.trigger('script-88-pretend-clicked');
})));
keys.shift();
whatsnewrec(newmap, keys, notif);
}
} else {
$('#newrevs')
.append($('<span>', {
text: langmark,
title: i18n('closenew'),
id: 'closenew'
})
.click(function() {
.click(function() {
var $this = $(this);
$('#newrevs')
$.getJSON($this.siblings('span.mw-title').find('a:first').attr('href'));
.remove();
$this.closest('.mw-changeslist-line-watched').hide().removeClass('.mw-changeslist-line-watched')
$('body')
.addClass('mw-changeslist-line-not-watched');
.trigger('script-88-pretend-clicked');
$this.remove();
})
)
.append(']');
$('body')
.trigger('script-88-pretend-clicked');
$('#td1')
.append($('.mw-rcfilters-ui-liveUpdateButtonWidget'));
}
}
 
function hider(state) {
$('#newrevs')
.remove();
$('.rcfilters-head')
.removeClass('rcfilters-head');
$(
'.mw-rcfilters-ui-filterWrapperWidget, .rcfilters-container'
)
.hide();
$('#mw-watchlist-form')
.hide();
if (config.edit[state])
$(
'table.mw-changeslist-line-not-watched, li.mw-changeslist-line-not-watched'
)
.filter(function() {
return $(this)
.find('abbr.wikibase-edit')
.length <= 0;
})
.hide();
if (config.log[state])
$('[class*="mw-changeslist-log"]')
.hide();
if (config.wikidata[state])
$('abbr.wikibase-edit')
.closest('.mw-changeslist-line-watched, .mw-changeslist-line-not-watched')
.hide();
$('#logmessage')
.hide();
$('#watchlist-preamble')
.hide();
if (config.hidingparts.markallhidetouchscreen)
$('.WLM-mobile input[name="mw-watchlist-reset-submit"]')
.hide();
if (!config.hidingparts.markallshowmouse)
$(
'.WLM-desktop input[name="mw-watchlist-reset-submit"], .mw-rcfilters-ui-markSeenButtonWidget'
)
.hide();
$('.mw-changeslist-legend')
.hide();
}
 
function unhider() {
whatsnew();
$('table.mw-changeslist-line-watched, li.mw-changeslist-line-watched')
.show();
$(
'.mw-rcfilters-ui-filterWrapperWidget, .rcfilters-container'
)
.show();
$('#mw-watchlist-form')
.show();
if (config.edit.show)
$(
'table.mw-changeslist-line-not-watched, li.mw-changeslist-line-not-watched'
)
.filter(function() {
return $(this)
.find('abbr.wikibase-edit')
.length <= 0;
})
.show();
if (config.log.show)
$('[class*="mw-changeslist-log"]')
.show();
if (config.wikidata.show)
$('abbr.wikibase-edit')
.closest('.mw-changeslist-line-not-watched')
.show();
$('#logmessage')
.show();
$('#watchlist-preamble')
.show();
$(
'input[name="mw-watchlist-reset-submit"], .mw-rcfilters-ui-markSeenButtonWidget'
)
.show();
$('.mw-changeslist-legend')
.show();
}
 
function main() {
defected = {};
api.get({
action: 'query',
format: 'json',
curtimestamp: 1
})
.done(function(data) {
timestamp = data.curtimestamp;
if (isnewfilter) {
$('.WLM-icon, .WLM-spaces')
.remove();
$('#td5')
.append($(
'.mw-rcfilters-ui-filterWrapperWidget-showNewChanges'));
if ($('#td5 span.oo-ui-element-hidden').length !== 0) {
$('#td5 span.oo-ui-element-hidden .oo-ui-labelElement-label')
.html('');
$('#td5 span.oo-ui-element-hidden')
.removeClass('oo-ui-element-hidden oo-ui-labelElement');
$('.mw-rcfilters-ui-filterWrapperWidget-showNewChanges')
.css('margin-top', '0px')
.removeClass('oo-ui-buttonElement-frameless')
.addClass('oo-ui-buttonElement-framed');
}
}
)
$('#td6')
);
.append($('.mw-rcfilters-ui-markSeenButtonWidget'));
});
}
mw.loader.using( 'mediawiki.util' ).done( function() {  
$('a.mw-unwatch-link')
$('.mw-changeslist-line-not-watched ').hide();
.each(function() {
$( mw.util.addPortletLink( 'p-cactions', '#', 'גלה עריכות שנקראו' ) )
$(this)
    .click( function() {
.prepend($('<span>')
$('.mw-changeslist-line-not-watched ').show();
.text('\xa0\xa0\xa0')
    } );
.addClass('WLM-spaces'))
} );
.insertAfter($(this)
}
.parent()
.parent()
.children()
.children()
.last());
});
$('.mw-rcfilters-ui-filterWrapperWidget-showNewChanges a')
.attr({accessKey:'k'});
seen($('.mw-changeslist-line-watched span.mw-title'));
unseen($('.mw-changeslist-line-not-watched span.mw-title'));
flowseen();
categoryseen();
closeedit();
goldbutton();
if (isnewfilter)
$('#td1')
.append($('.mw-rcfilters-ui-liveUpdateButtonWidget'));
hider('starthidden');
$('.mw-rcfilters-ui-changesListWrapperWidget-highlights, .mw-rcfilters-ui-highlights')
.remove();
});
}
 
function demo() {
$('.mark-edits')
.click(function() {
var id = $(this)
.parent()
.prop('id');
$(this)
.closest('table')
.find('.mark-edits')
.filter(function() {
return $(this)
.parent()
.prop('id') <= id;
})
.removeClass('mark-edits')
.addClass('unmark-edits')
.parent()
.removeClass('blueedit')
.addClass('yellowedit');
demo();
});
$('.unmark-edits')
.click(function() {
var id = $(this)
.parent()
.prop('id');
$(this)
.closest('table')
.find('.unmark-edits')
.filter(function() {
return $(this)
.parent()
.prop('id') >= id;
})
.removeClass('unmark-edits')
.addClass('mark-edits')
.parent()
.removeClass('yellowedit')
.addClass('blueedit');
demo();
});
}
 
mw.loader.load('ext.gadget.GlobalWatchlist');
if (mw.config.get('wgCanonicalSpecialPageName') == 'Watchlist') {
var langcode = mw.config.get('wgUserLanguage'),
lang = langcode == 'he' ? 0 : 1,
extendwatchlist = mw.user.options.get('extendwatchlist'),
defected, config, messages;
langmark = langcode == 'he' ? '\u200f' : '\u200e';
if (extendwatchlist == 1) {
$('.mw-body-content')
.addClass(typeof window.orientation == 'undefined' ? 'WLM-desktop' :
'WLM-mobile');
importStylesheet('מדיה ויקי:Gadget-WLM.css');
importStylesheet('משתמש:' + mw.config.get('wgUserName') + '/WLM.css');
importStylesheet('משתמש:' + mw.config.get('wgUserName') + '/common.css');
api.getMessages(['diff', 'last'], {
amlang: langcode
})
.then(function(result) {
messages = result;
})
.then(function() {
try {
config = require('./WLM.json');
} catch (err) {
config = null;
}
$.get(mw.util.wikiScript(), {
title: 'משתמש:' + mw.config.get('wgUserName') + '/WLM.json',
action: 'raw'
})
.done(function(data1) {
config = JSON.parse(data1);
})
.fail(function() {
if (config == null)
alert('ERR: ' + i18n('jsonlost'));
})
.always(function() {
if (isnewfilter) {
$('#td5')
.append($(
'.mw-rcfilters-ui-filterWrapperWidget-showNewChanges'));
mw.hook('wikipage.content')
.add(main);
} else
main();
});
});
var widgetWhatsnew = new OO.ui.ButtonWidget({
label: i18n('whatsnew'),
title: i18n('help'),
id: 'whatsnew',
accessKey: 'o'
});
widgetWhatsnew.on('click', whatsnew);
var widgetShowAll = new OO.ui.ButtonWidget({
label: i18n('showAll'),
title: i18n('help'),
id: 'showAll'
});
widgetShowAll.on('click', unhider);
var widgetHideAll = new OO.ui.ButtonWidget({
label: i18n('hideAll'),
title: i18n('help'),
id: 'hideAll'
});
widgetHideAll.on('click', function() {
hider('hide');
});
var widgetFilters;
$('#mw-watchlist-form')
.after($('<table>', {
html: $('<tr>', {
id: 'WLM-table'
})
}));
$('#WLM-table')
.append($('<td>', {
id: 'td1',
'class': 'WLM-cell'
}))
.append($('<td>', {
id: 'td2',
'class': 'WLM-cell'
}))
.append($('<td>', {
id: 'td3',
'class': 'WLM-cell'
}))
.append($('<td>', {
id: 'td4',
'class': 'WLM-cell'
}))
.append($('<td>', {
id: 'td5',
'class': 'WLM-cell'
}))
.append($('<td>', {
id: 'td6',
'class': 'WLM-cell'
}));
$('#td2')
.append(widgetWhatsnew.$element);
$('#td3')
.append(widgetShowAll.$element);
$('#td4')
.append(widgetHideAll.$element);
$('#td6')
.append($('#mw-watchlist-resetbutton'));
$('#mw-watchlist-resetbutton, .mw-rcfilters-ui-markSeenButtonWidget')
.children()
.css({
backgroundColor: "lightcoral"
});
if (!isnewfilter) {
widgetFilters = new OO.ui.ButtonWidget({
label: i18n('rcfilters'),
title: i18n('help'),
id: 'rcfilters'
});
widgetFilters.on('click', function() {
window.location.href = new mw.Uri()
.extend({
rcfilters: 1,
liveupdate: 1
});
});
$('#td1')
.append(widgetFilters.$element);
}
checklog();
}
} else if (mw.config.get('wgPageName') == 'עזרה:WLM') {
$('.prescell')
.attr('align', 'center')
.each(function() {
$(this)
.html($('<a>')
.addClass($(this)
.attr('class')));
$(this)
.removeClass('mark-edits unmark-edits');
});
$('#clear')
.prepend($('<input>', {
id: 'clearbutton',
type: 'submit'
})
.click(function() {
$('.blueedit, .yellowedit')
.removeClass('blueedit yellowedit');
}));
$('#clearbutton')
.attr('value', i18n('clear'));
demo();
}
});

גרסה אחרונה מ־13:16, 5 בדצמבר 2022

/* jshint maxerr: 999 */
$(function() {
	var timestamp, langmark, newmap;
	var isnewfilter = $('.mw-rcfilters-enabled')
		.length == 1;
	var api = new mw.Api();

	function i18n(name) {
		var msg = {
			mark: ['סימון כעריכה שנקראה', 'Mark as read'],
			unmark: ['סימון כעריכה שלא נקראה', 'Mark as unread'],
			close: ['הסתרת העריכה', 'Hide revision'],
			markFlow: ['סימון זרימה כנקראה', 'Mark flow as read'],
			markCat: ['סימון קטגוריה כנקראה', 'Mark categorization as read'],
			manymarked: ['שורות סומנו', 'lines marked'],
			goldbutton: ['פתיחה וסימון של כל העריכות בדף הזה',
				'Open and mark all this page revisions'
			],
			jsonlost: ['קובץ קונפיגורציה לא אותר', 'Configuration file not found'],
			hideAll: ['הסתרת עריכות שנקראו', 'Hide all read'],
			showAll: ['הצגת עריכות שהוסתרו', 'Show all hidden'],
			whatsnew: ['מה חדש?', "What's new?"],
			rcfilters: ['מסננים', 'Filters'],
			closenew: ['סגירת רשימת החדשים', "Close the bar"],
			loga: ['שימו לב: רשימת המעקב כוללת רשומת יומן שלא נקראה. הדף הוא ',
				'Pay attention: the watchlist includes unread log entry. Page name: '
			],
			logb: [', הפעולה שנעשתה היא: ', ', log action: '],
			logc: ['(לפרטים)', '(details)'],
			logd: [
				'אם ברצונכם לסמן אותה כנקראה, בדקו כי אין עריכות אחרות של הדף הזה שלא נקראו,' +
				' כי גם הן יסומנו. לאחר מכן לחצו ',
				'If you want to mark it as read, check that there are' +
				' no other unwatched revisions of this page, because they will be marked too. Then click '
			],
			loge: ['כאן', 'here'],
			clear: ['ניקוי', 'clear'],
			nointernet: ['אין תקשורת', 'No internet'],
			help: ['לפרטים ראו עזרה:מנהל רשימת המעקב', '']
		};
		return msg[name][lang || 0];
	}

	function button(msg, icon) {
		return $('<a>', {
				text: langmark,
				title: i18n(msg),
				href: '#nw'
			})
			.addClass(icon + ' WLM-icon');
	}

	function seen(obj) {
		obj.filter(function() {
				return $(this)
					.closest('.mw-changeslist-line-watched')
					.filter(notcat)
					.find('a[href*="diff"]')
					.filter(notme)
					.filter(function() {
						return $(this)
							.closest('.mw-enhanced-rc-nested')
							.length <= 0;
					})
					.length > 0;
			})
			.before(button('mark', 'mark-edits')
				.click(function() {
					if (config.hidemarked.edit)
						$('.yellowedit')
						.hide();
					var curid = /curid=([0-9]+)/.exec($(this)
						.closest('table, li')
						.find('a[href*="curid"]')
						.filter(notme)
						.prop('href'))[1];
					var $this = $(this),
						diff = /diff=([0-9]+)/.exec($this.parent()
							.parent()
							.find('a[href*="diff"]')
							.filter(notme)
							.prop('href'))[1],
						name = $this.parent()
						.find('.mw-changeslist-title')
						.text(),
						all = $('.mw-changeslist-line-watched .mw-changeslist-title')
						.filter(function() {
							var thediff = /.*diff=([0-9]+).*oldid.*/.exec($(this)
								.closest('.mw-changeslist-line-watched')
								.find('a[href*="diff"]')
								.filter(notme)
								.prop('href'));
							return thediff && $(this)
								.text() == name && thediff[1] <= diff;
						})
						.closest('.mw-changeslist-line-watched'),
						allboth = $('.mw-changeslist-line-watched .mw-changeslist-title')
						.filter(function() {
							return $(this)
								.text() == name;
						})
						.closest('.mw-changeslist-line-watched');
					api.postWithToken('csrf', {
							action: 'setnotificationtimestamp',
							titles: name,
							newerthanrevid: diff
						})
						.done(function() {
							if (all.length > 1)
								$this.closest('table, li')
								.append($('<span>')
									.text(' ' + all.length + ' ' + i18n('manymarked') + ' ')
									.addClass('nowrap')
									.css({
										backgroundColor: 'red'
									}));
							all.removeClass('mw-changeslist-line-watched blueedit')
								.addClass('mw-changeslist-line-not-watched yellowedit')
								.show()
								.find('.mark-edits')
								.remove();
							allboth.find('.gold-button')
								.remove();
							$('#gold-little-' + curid)
								.find('a')
								.remove();
							defected[curid] = true;
							unseen(all.find('span.mw-title'));
							if (!config.hidemarked.wait)
								all.hide();
						});
				}));
	}

	function unseen(obj) {
		obj.filter(function() {
				return $(this)
					.closest('table, li')
					.filter(notcat)
					.find('a[href*="oldid"]')
					.length > 0;
			})
			.before(button('unmark', 'unmark-edits')
				.click(function() {
					var curid = /curid=([0-9]+)/.exec($(this)
						.closest('table, li')
						.find('a[href*="curid"]')
						.filter(notme)
						.prop('href'))[1];
					var $this = $(this),
						diffcond = $this
						.closest('.mw-changeslist-line-not-watched')
						.find('abbr.newpage')
						.length > 0,
						oldrev = diffcond ? 0 : /oldid=([0-9]+)/.exec($this
							.parent()
							.parent()
							.find('a[href*="oldid"]')
							.filter(notme)
							.prop('href'))[1],
						diff = diffcond ? 0 : /diff=([0-9]+)/.exec($this
							.parent()
							.parent()
							.find('a[href*="diff"]')
							.filter(notme)
							.prop('href'))[1],
						name = $this
						.next()
						.text(),
						all = $('.mw-changeslist-line-not-watched .mw-changeslist-title')
						.filter(function() {
							var thediff = /.*diff=([0-9]+).*oldid.*/.exec($(this)
								.closest('.mw-changeslist-line-not-watched')
								.find('a[href*="diff"]')
								.filter(notme)
								.prop('href'));
							return thediff && $(this)
								.text() == name && thediff[1] >= diff;
						})
						.closest('.mw-changeslist-line-not-watched'),
						allboth = $('.mw-changeslist-line-watched .mw-changeslist-title')
						.filter(function() {
							return $(this)
								.text() == name;
						})
						.closest('.mw-changeslist-line-watched');
					api.postWithToken('csrf', {
							action: 'setnotificationtimestamp',
							titles: name,
							newerthanrevid: oldrev
						})
						.done(function() {
							if (all.length > 1)
								$this.closest('table, li')
								.append($('<span>')
									.text(' ' + all.length + ' ' + i18n('manymarked') + ' ')
									.addClass('nowrap')
								);
							all.removeClass('mw-changeslist-line-not-watched yellowedit')
								.addClass('mw-changeslist-line-watched blueedit')
								.show()
								.find('.unmark-edits')
								.remove();
							allboth.find('.gold-button')
								.remove();
							$('#gold-little-' + curid)
								.find('a')
								.remove();
							defected[curid] = true;
							seen(all.find('span.mw-title'));
						});
				}));
	}

	function flowseen() {
		$('.mw-changeslist-line-watched a.mw-title')
			.parent()
			.prepend(button('markFlow', 'mark-all-flow-edits')
				.click(function() {
					var $this = $(this),
						topic = /title=[^:]*:(.+)&/.exec($this.parent()
							.find('a[href*="fromnotif"]')
							.prop('href')),
						page = $this
						.closest('.mw-changeslist-line-watched')
						.find('a.mw-title')
						.prop('title'),
						titles = topic ? page + '|נושא:' + topic[1] : page;
					api.postWithToken('csrf', {
							action: 'setnotificationtimestamp',
							titles: titles,
						})
						.done(function() {
							if (config.hidemarked.flow)
								$this.closest('.mw-changeslist-line-watched')
								.hide();
							$this.closest('.mw-changeslist-line-watched')
								.removeClass('mw-changeslist-line-watched blueedit')
								.addClass('mw-changeslist-line-not-watched yellowedit');
							$this.remove();
						});
				}));
	}

	function categoryseen() {
		$('.mw-changeslist-line-watched span.mw-title')
			.filter(function() {
				return ($(this)
						.closest('.mw-changeslist-line-watched')
						.find('a[href*="diff"]')
						.length <= 0 && $(this)
						.closest('.mw-changeslist-line-watched')
						.find('abbr.newpage')
						.length <= 0) ||
					$(this)
					.find('a.mw-changeslist-title')
					.parent()
					.next()
					.text() == '. .';
			})
			.before(button('markCat', 'mark-cat-edits')
				.click(function() {
					var $this = $(this),
						page = $this.parent()
						.find('a.mw-changeslist-title')
						.prop('title');
					api.postWithToken('csrf', {
							action: 'setnotificationtimestamp',
							titles: page,
						})
						.done(function() {
							if (config.hidemarked.categorization)
								$this.closest('.mw-changeslist-line-watched')
								.hide();
							$this.closest('.mw-changeslist-line-watched')
								.removeClass('mw-changeslist-line-watched blueedit')
								.addClass('mw-changeslist-line-not-watched yellowedit');
							$this.remove();
						});
				}));
	}

	function checklog() {
		api.get({
				action: 'query',
				format: 'json',
				list: 'watchlist',
				indexpageids: 1,
				wllimit: 500,
				wlprop: 'title|loginfo',
				wlshow: 'unread',
				wltype: 'log'
			})
			.done(function(data) {
				var firstname = data.query.watchlist;
				if (firstname.length > 0) {
					firstname = firstname.reverse()[0];
					$('#WLM-table')
						.parent()
						.after($('<div>', {
								id: 'logmessage'
							})
							.addClass('blueedit')
							.append($('<span>')
								.text(i18n('loga')))
							.append($('<span>')
								.text(firstname.title)
								.css({
									fontWeight: 'bold',
								}))
							.append($('<span>')
								.text(i18n('logb') + firstname.logaction + ' '))
							.append($('<a>', {
									href: 'https://he.wikipedia.org//w/api.php?action=query&format=rawfm&list=watchlist&' +
										'indexpageids=1&wllimit=500&wlprop=title%7Cloginfo%7Ctimestamp&wlshow=unread&wltype=log',
									text: i18n('logc')
								})
								.attr({
									target: '_blank'
								}))
							.append($('<span>')
								.text('. ' + i18n('logd') + ' '))
							.append($('<a>', {
									target: '_blank'
								})
								.text(i18n('loge'))
								.click(function() {
									api.postWithToken('csrf', {
											action: 'setnotificationtimestamp',
											titles: firstname.title
										})
										.done(function() {
											$('#logmessage')
												.remove();
											var all = $(
													'.mw-changeslist-line-watched a.mw-changeslist-title')
												.filter(function() {
													return $(this)
														.prop('title') == firstname.title;
												})
												.closest('.mw-changeslist-line-watched');
											all.removeClass('mw-changeslist-line-watched blueedit')
												.addClass('mw-changeslist-line-not-watched yellowedit')
												.show()
												.find('.unmark-edits')
												.remove();
											if (config.hidemarked.edit)
												$('.yellowedit')
												.hide();
											seen(all.find('span.mw-title'));
											if (all.length > 0)
												$('#WLM-table')
												.parent()
												.after($('<div>')
													.text(' ' + all.length + ' ' + i18n('manymarked') + ' ')
													.addClass('nowrap')
												)
												.addClass('yellowedit');
											checklog();
										});
								}))
							.append($('<span>')
								.text('.')
							));
				}
			});
	}

	function goldbutton() {
		$('.mw-changeslist-line-watched')
			.find('abbr.newpage')
			.each(function() {
				var curid = /curid=([0-9]+)/.exec($(this)
					.closest('table, li')
					.find('a[href*="curid"]')
					.filter(notme)
					.prop('href'));
				if (curid !== null && curid.length > 1)
					defected[curid[1]] = true;
			});
		$('.close-edit')
			.filter(function() {
				return $(this)
					.closest('.mw-changeslist-line-watched')
					.filter(notcat)
					.find('a[href*="diff"]')
					.filter(notme)
					.filter(function() {
						return $(this)
							.closest('.mw-enhanced-rc-nested')
							.length <= 0;
					})
					.length > 0 &&
					$(this)
					.closest('.mw-changeslist-line-watched')
					.find('a.mw-title')
					.length <= 0;
			})
			.each(function() {
				var curid = /curid=([0-9]+)/.exec($(this)
					.closest('table, li')
					.find('a[href*="curid"]')
					.filter(notme)
					.prop('href'))[1];
				var name = $(this)
					.closest('.mw-changeslist-line-watched')
					.find('.mw-changeslist-title')
					.text(),
					checked = $('.mw-changeslist-title')
					.filter(function() {
						return $(this)
							.text() == name;
					})
					.closest('.mw-changeslist-line-watched'),
					nonew = checked
					.find('abbr.newpage')
					.length <= 0,
					min = Infinity;
				if (nonew) {
					checked
						.find('a[href*="oldid"]')
						.filter(notme)
						.filter(function() {
							return ($(this)
									.text() == messages.diff || $(this)
									.text() == messages.last) &&
								($(this)
									.closest('.mw-enhanced-rc-nested')
									.closest('.mw-enhanced-watched')
									.length > 0 ||
									$(this)
									.closest('.mw-enhanced-rc-nested')
									.length <= 0);
						})
						.each(function() {
							var old = /oldid=([0-9]+)/.exec($(this)
								.prop('href'));
							min = old ? Math.min(min, old[1]) : min;
						});
				}
				if (min > 0 && min != Infinity && nonew) {
					$(this)
						.after($('<a>', {
								text: langmark,
								title: i18n('goldbutton'),
								target: '_blank',
								href: 'https://he.wikipedia.org/w/index.php?title=' + name +
									'&redirect=no&diff=cur&oldid=' + min
							})
							.addClass('gold-button WLM-icon gold-' + curid)
							.click(function() {
								if (config.hidemarked.edit)
									$('.yellowedit')
									.hide();
								var all = $('.mw-changeslist-line-watched .mw-changeslist-title')
									.filter(function() {
										return $(this)
											.text() == name;
									})
									.closest('.mw-changeslist-line-watched');
								if (all.length > 1)
									$(this)
									.closest('table, li')
									.append($('<span>')
										.text(' ' + all.length + ' ' + i18n('manymarked') + ' ')
										.addClass('nowrap')
										.css({
											backgroundColor: 'red'
										}));
								all.removeClass('mw-changeslist-line-watched blueedit')
									.addClass('mw-changeslist-line-not-watched yellowedit')
									.show()
									.find('.mark-edits, .gold-button')
									.remove();
								$('.gold-' + curid)
									.remove();
								$('#gold-little-' + curid)
									.remove();
								unseen(all.find('span.mw-title'));
							}));
				}
			});
	}

	function closeedit() {
		var btn = button('close', 'close-edit')
			.click(function() {
				$(this)
					.closest(
						'.mw-changeslist-line-not-watched, .mw-changeslist-line-watched')
					.hide();
			});
		$('li span.mw-changeslist-date')
			.parent()
			.prepend(btn);
		$('td.mw-enhanced-rc')
			.parent()
			.filter(function() {
				return $(this)
					.find('td.mw-enhanced-rc-nested')
					.length <= 0;
			})
			.prepend($('<td>')
				.html(btn)
				.css({
					whiteSpace: 'nowrap'
				}));
		$('td.mw-enhanced-rc')
			.parent()
			.find('td.mw-enhanced-rc-nested')
			.prev()
			.before($('<td>'));
	}

	function notme() {
		return !$(this)
			.hasClass('WLM-icon');
	}

	function notcat() {
		return $(this)
			.find('a.mw-changeslist-title')
			.parent()
			.next()
			.text() != '. .';
	}

	function whatsnew() {
		$('.WLM-newrevs')
			.remove();
		api.get({
				action: 'query',
				format: 'json',
				list: 'watchlist',
				indexpageids: 1,
				wldir: 'newer',
				wllimit: 500,
				wlprop: 'title|ids|notificationtimestamp',
				wlshow: 'unread',
				wltype: 'edit|new',
				wlstart: timestamp,
				wlallrev: 1,
				errorformat: 'wikitext'
			})
			.fail(function() {
				$('#WLM-table')
					.parent()
					.after($('<div>', {
							id: 'newrevs',
							text: i18n('nointernet')
						})
						.click(function() {
							$('#newrevs')
								.remove();
						})
						.addClass('blueedit WLM-newrevs'));
			})
			.done(function(data) {
				var ans = data.query.watchlist;
				newmap = {};
				var notif = '';
				Object.keys(ans)
					.map(function(key) {
						var id = ans[key].pageid;
						var curnotif = ans[key].notificationtimestamp;
						if (notif === '')
							notif = curnotif;
						else if (curnotif !== '' && notif > curnotif)
							notif = curnotif;
						if (id in newmap) {
							if (ans[key].old_revid < newmap[id].oldid)
								newmap[id].oldid = ans[key].old_revid;
						} else {
							newmap[id] = {
								title: ans[key].title,
								oldid: ans[key].old_revid,
								notify: curnotif
							};
						}
					});
					api.get({
						action: 'query',
						format: 'json',
						list: 'watchlist',
						indexpageids: 1,
						wldir: 'newer',
						wllimit: 500,
						wlprop: 'title|ids|notificationtimestamp',
						wlshow: 'unread',
						wltype: 'edit|new',
						wlstart: notif,
						wlallrev: 1,
						errorformat: 'wikitext'
					})
					.done(function(data3) {
						$('.WLM-newrevs')
							.remove();
						$('#WLM-table')
							.parent()
							.after($('<div>', {
									id: 'newrevs',
									text: '['
								})
								.addClass('blueedit WLM-newrevs'));
						whatsnewrec(newmap, Object.keys(newmap), data3.query.watchlist);
					});
			});
	}

	function whatsnewrec(newmap, keys, notif) {
		if (keys.length > 0) {
			var data = keys[0];
			var goldlength = $('.gold-' + data)
				.length;
			if (defected[data]) {
				$('#newrevs')
					.append($('<span>', {
						text: newmap[data].title + ',' + langmark + ' '
					}));
				keys.shift();
				whatsnewrec(newmap, keys, notif);
			} else if (goldlength > 0) {
				$('#newrevs')
					.append($('<span>', {
							text: newmap[data].title + ',' + langmark + ' ',
							id: 'gold-little-' + data
						})
						.prepend($('.gold-' + data)
							.clone(true, true)[0]));
				keys.shift();
				whatsnewrec(newmap, keys, notif);
			} else {
				var data3min = newmap[data].oldid;
				Object.keys(notif)
					.map(function(key) {
						if (newmap[data].title == notif[key].title)
							data3min = Math.min(data3min, notif[key].old_revid);
					});
					$('#newrevs')
						.append($('<span>', {
								text: ',' + langmark + ' '
							})
							.prepend($('<a>', {
									text: newmap[data].title,
									href: 'https://he.wikipedia.org/w/index.php?title=' +
										newmap[data].title +
										'&redirect=no&diff=cur&oldid=' + data3min,
									target: '_blank'
								})
								.click(function() {
									$(this)
										.parent()
										.remove();
									$('.yellowedit')
										.hide();
									$('body')
										.trigger('script-88-pretend-clicked');
								})));
						keys.shift();
						whatsnewrec(newmap, keys, notif);
			}
		} else {
			$('#newrevs')
				.append($('<span>', {
						text: langmark,
						title: i18n('closenew'),
						id: 'closenew'
					})
					.click(function() {
						$('#newrevs')
							.remove();
						$('body')
							.trigger('script-88-pretend-clicked');
					})
				)
				.append(']');
			$('body')
				.trigger('script-88-pretend-clicked');
			$('#td1')
				.append($('.mw-rcfilters-ui-liveUpdateButtonWidget'));
		}
	}

	function hider(state) {
		$('#newrevs')
			.remove();
		$('.rcfilters-head')
			.removeClass('rcfilters-head');
		$(
				'.mw-rcfilters-ui-filterWrapperWidget, .rcfilters-container'
			)
			.hide();
		$('#mw-watchlist-form')
			.hide();
		if (config.edit[state])
			$(
				'table.mw-changeslist-line-not-watched, li.mw-changeslist-line-not-watched'
			)
			.filter(function() {
				return $(this)
					.find('abbr.wikibase-edit')
					.length <= 0;
			})
			.hide();
		if (config.log[state])
			$('[class*="mw-changeslist-log"]')
			.hide();
		if (config.wikidata[state])
			$('abbr.wikibase-edit')
			.closest('.mw-changeslist-line-watched, .mw-changeslist-line-not-watched')
			.hide();
		$('#logmessage')
			.hide();
		$('#watchlist-preamble')
			.hide();
		if (config.hidingparts.markallhidetouchscreen)
			$('.WLM-mobile input[name="mw-watchlist-reset-submit"]')
			.hide();
		if (!config.hidingparts.markallshowmouse)
			$(
				'.WLM-desktop input[name="mw-watchlist-reset-submit"], .mw-rcfilters-ui-markSeenButtonWidget'
			)
			.hide();
		$('.mw-changeslist-legend')
			.hide();
	}

	function unhider() {
		whatsnew();
		$('table.mw-changeslist-line-watched, li.mw-changeslist-line-watched')
			.show();
		$(
				'.mw-rcfilters-ui-filterWrapperWidget, .rcfilters-container'
			)
			.show();
		$('#mw-watchlist-form')
			.show();
		if (config.edit.show)
			$(
				'table.mw-changeslist-line-not-watched, li.mw-changeslist-line-not-watched'
			)
			.filter(function() {
				return $(this)
					.find('abbr.wikibase-edit')
					.length <= 0;
			})
			.show();
		if (config.log.show)
			$('[class*="mw-changeslist-log"]')
			.show();
		if (config.wikidata.show)
			$('abbr.wikibase-edit')
			.closest('.mw-changeslist-line-not-watched')
			.show();
		$('#logmessage')
			.show();
		$('#watchlist-preamble')
			.show();
		$(
				'input[name="mw-watchlist-reset-submit"], .mw-rcfilters-ui-markSeenButtonWidget'
			)
			.show();
		$('.mw-changeslist-legend')
			.show();
	}

	function main() {
		defected = {};
		api.get({
				action: 'query',
				format: 'json',
				curtimestamp: 1
			})
			.done(function(data) {
				timestamp = data.curtimestamp;
				if (isnewfilter) {
					$('.WLM-icon, .WLM-spaces')
						.remove();
					$('#td5')
						.append($(
							'.mw-rcfilters-ui-filterWrapperWidget-showNewChanges'));
					if ($('#td5 span.oo-ui-element-hidden').length !== 0) {
						$('#td5 span.oo-ui-element-hidden .oo-ui-labelElement-label')
							.html('');
						$('#td5 span.oo-ui-element-hidden')
							.removeClass('oo-ui-element-hidden oo-ui-labelElement');
						$('.mw-rcfilters-ui-filterWrapperWidget-showNewChanges')
							.css('margin-top', '0px')
							.removeClass('oo-ui-buttonElement-frameless')
							.addClass('oo-ui-buttonElement-framed');
					}
					$('#td6')
						.append($('.mw-rcfilters-ui-markSeenButtonWidget'));
				}
				$('a.mw-unwatch-link')
					.each(function() {
						$(this)
							.prepend($('<span>')
								.text('\xa0\xa0\xa0')
								.addClass('WLM-spaces'))
							.insertAfter($(this)
								.parent()
								.parent()
								.children()
								.children()
								.last());
					});
				$('.mw-rcfilters-ui-filterWrapperWidget-showNewChanges a')
					.attr({accessKey:'k'});
				seen($('.mw-changeslist-line-watched span.mw-title'));
				unseen($('.mw-changeslist-line-not-watched span.mw-title'));
				flowseen();
				categoryseen();
				closeedit();
				goldbutton();
				if (isnewfilter)
					$('#td1')
					.append($('.mw-rcfilters-ui-liveUpdateButtonWidget'));
				hider('starthidden');
				$('.mw-rcfilters-ui-changesListWrapperWidget-highlights, .mw-rcfilters-ui-highlights')
					.remove();
			});
	}

	function demo() {
		$('.mark-edits')
			.click(function() {
				var id = $(this)
					.parent()
					.prop('id');
				$(this)
					.closest('table')
					.find('.mark-edits')
					.filter(function() {
						return $(this)
							.parent()
							.prop('id') <= id;
					})
					.removeClass('mark-edits')
					.addClass('unmark-edits')
					.parent()
					.removeClass('blueedit')
					.addClass('yellowedit');
				demo();
			});
		$('.unmark-edits')
			.click(function() {
				var id = $(this)
					.parent()
					.prop('id');
				$(this)
					.closest('table')
					.find('.unmark-edits')
					.filter(function() {
						return $(this)
							.parent()
							.prop('id') >= id;
					})
					.removeClass('unmark-edits')
					.addClass('mark-edits')
					.parent()
					.removeClass('yellowedit')
					.addClass('blueedit');
				demo();
			});
	}

	mw.loader.load('ext.gadget.GlobalWatchlist');
	if (mw.config.get('wgCanonicalSpecialPageName') == 'Watchlist') {
		var langcode = mw.config.get('wgUserLanguage'),
			lang = langcode == 'he' ? 0 : 1,
			extendwatchlist = mw.user.options.get('extendwatchlist'),
			defected, config, messages;
		langmark = langcode == 'he' ? '\u200f' : '\u200e';
		if (extendwatchlist == 1) {
			$('.mw-body-content')
				.addClass(typeof window.orientation == 'undefined' ? 'WLM-desktop' :
					'WLM-mobile');
			importStylesheet('מדיה ויקי:Gadget-WLM.css');
			importStylesheet('משתמש:' + mw.config.get('wgUserName') + '/WLM.css');
			importStylesheet('משתמש:' + mw.config.get('wgUserName') + '/common.css');
			api.getMessages(['diff', 'last'], {
					amlang: langcode
				})
				.then(function(result) {
					messages = result;
				})
				.then(function() {
					try {
						config = require('./WLM.json');
					} catch (err) {
						config = null;
					}
					$.get(mw.util.wikiScript(), {
							title: 'משתמש:' + mw.config.get('wgUserName') + '/WLM.json',
							action: 'raw'
						})
						.done(function(data1) {
							config = JSON.parse(data1);
						})
						.fail(function() {
							if (config == null)
								alert('ERR: ' + i18n('jsonlost'));
						})
						.always(function() {
							if (isnewfilter) {
								$('#td5')
									.append($(
										'.mw-rcfilters-ui-filterWrapperWidget-showNewChanges'));
								mw.hook('wikipage.content')
									.add(main);
							} else
								main();
						});
				});
			var widgetWhatsnew = new OO.ui.ButtonWidget({
				label: i18n('whatsnew'),
				title: i18n('help'),
				id: 'whatsnew',
				accessKey: 'o'
			});
			widgetWhatsnew.on('click', whatsnew);
			var widgetShowAll = new OO.ui.ButtonWidget({
				label: i18n('showAll'),
				title: i18n('help'),
				id: 'showAll'
			});
			widgetShowAll.on('click', unhider);
			var widgetHideAll = new OO.ui.ButtonWidget({
				label: i18n('hideAll'),
				title: i18n('help'),
				id: 'hideAll'
			});
			widgetHideAll.on('click', function() {
				hider('hide');
			});
			var widgetFilters;
			$('#mw-watchlist-form')
				.after($('<table>', {
					html: $('<tr>', {
						id: 'WLM-table'
					})
				}));
			$('#WLM-table')
				.append($('<td>', {
					id: 'td1',
					'class': 'WLM-cell'
				}))
				.append($('<td>', {
					id: 'td2',
					'class': 'WLM-cell'
				}))
				.append($('<td>', {
					id: 'td3',
					'class': 'WLM-cell'
				}))
				.append($('<td>', {
					id: 'td4',
					'class': 'WLM-cell'
				}))
				.append($('<td>', {
					id: 'td5',
					'class': 'WLM-cell'
				}))
				.append($('<td>', {
					id: 'td6',
					'class': 'WLM-cell'
				}));
			$('#td2')
				.append(widgetWhatsnew.$element);
			$('#td3')
				.append(widgetShowAll.$element);
			$('#td4')
				.append(widgetHideAll.$element);
			$('#td6')
				.append($('#mw-watchlist-resetbutton'));
			$('#mw-watchlist-resetbutton, .mw-rcfilters-ui-markSeenButtonWidget')
				.children()
				.css({
					backgroundColor: "lightcoral"
				});
			if (!isnewfilter) {
				widgetFilters = new OO.ui.ButtonWidget({
					label: i18n('rcfilters'),
					title: i18n('help'),
					id: 'rcfilters'
				});
				widgetFilters.on('click', function() {
					window.location.href = new mw.Uri()
						.extend({
							rcfilters: 1,
							liveupdate: 1
						});
				});
				$('#td1')
					.append(widgetFilters.$element);
			}
			checklog();
		}
	} else if (mw.config.get('wgPageName') == 'עזרה:WLM') {
		$('.prescell')
			.attr('align', 'center')
			.each(function() {
				$(this)
					.html($('<a>')
						.addClass($(this)
							.attr('class')));
				$(this)
					.removeClass('mark-edits unmark-edits');
			});
		$('#clear')
			.prepend($('<input>', {
					id: 'clearbutton',
					type: 'submit'
				})
				.click(function() {
					$('.blueedit, .yellowedit')
						.removeClass('blueedit yellowedit');
				}));
		$('#clearbutton')
			.attr('value', i18n('clear'));
		demo();
	}
});