אונטערשייד צווישן ווערסיעס פון "מעדיעוויקי:Gadget-wikibugs-patrol-clone.js"
קפיצה לניווט
קפיצה לחיפוש
(געשאַפן בלאַט מיט 'var p_n = mw.config.get('wgPageName'); var pn = p_n.replace(/_/, ' '); if ( p_n.match(/^המכלול:תיקון_תקלדות_בקליק$/) || p_n.match(/^המכלול:תיקון_תקלדות_בקליק\/[0-9]+$/) ) { $(function(){ function reloadNotify(msg) { mw.notify(msg).done(function(){ window.location.reload(); }); } function removeSection(section, basetimestamp, starttimestamp, summ) { var api = new mw.Api(), pagename = this.curPage; api....') |
(עטוואס ווייטער צופאסונג) |
||
שורה 2: | שורה 2: | ||
var pn = p_n.replace(/_/, ' '); | var pn = p_n.replace(/_/, ' '); | ||
if ( p_n.match(/^המכלול: | if (p_n.match(/^המכלול:תיקון_סופרים$/) || p_n.match(/^המכלול:תיקון_סופרים\/[0-9]+$/)) { | ||
$(function () { | |||
function reloadNotify(msg) { | |||
mw.notify(msg).done(function () { window.location.reload(); }); | |||
} | |||
function removeSection(section, basetimestamp, starttimestamp, summ) { | |||
var api = new mw.Api(), pagename = this.curPage; | |||
api.postWithToken('csrf', { | |||
action: 'edit', | |||
title: pn, | |||
summary: summ, | |||
minor: 1, | |||
basetimestamp: basetimestamp, | |||
starttimestamp: starttimestamp, | |||
text: '', | |||
section: section | |||
}).done(function (d) { | |||
if (d && d.edit && d.edit.result == 'Success') { | |||
mw.notify('הוסר, יעודכן ברענון'); | |||
} | |||
}); | |||
} | |||
function removeSection2(section, basetimestamp, starttimestamp, summ) { | |||
var api = new mw.Api(), pagename = this.curPage; | |||
api.postWithToken('csrf', { | |||
action: 'edit', | |||
title: pn, | |||
summary: summ, | |||
minor: 1, | |||
basetimestamp: basetimestamp, | |||
starttimestamp: starttimestamp, | |||
text: '', | |||
section: section | |||
}).done(function (d) { | |||
if (d && d.edit && d.edit.result == 'Success') { | |||
reloadNotify('הוסר'); | |||
} | |||
}); | |||
} | |||
function removeSectionAfterCorrection(section, basetimestamp, starttimestamp, summ) { | |||
var api = new mw.Api(), pagename = this.curPage; | |||
api.postWithToken('csrf', { | |||
action: 'edit', | |||
title: pn, | |||
summary: summ, | |||
minor: 1, | |||
basetimestamp: basetimestamp, | |||
starttimestamp: starttimestamp, | |||
text: '', | |||
section: section | |||
}).done(function (d) { | |||
if (d && d.edit && d.edit.result == 'Success') { | |||
} | |||
}); | |||
} | |||
function removeSectionAfterCorrection2(section, basetimestamp, starttimestamp, summ) { | |||
var api = new mw.Api(), pagename = this.curPage; | |||
api.postWithToken('csrf', { | |||
action: 'edit', | |||
title: pn, | |||
summary: summ, | |||
minor: 1, | |||
basetimestamp: basetimestamp, | |||
starttimestamp: starttimestamp, | |||
text: '', | |||
section: section | |||
}).done(function (d) { | |||
if (d && d.edit && d.edit.result == 'Success') { | |||
} | |||
}); | |||
} | |||
function archiveToTalk(articleName, sectionTitle, content) { | |||
var talkPage = new mw.Title(articleName).getTalkPage(), | |||
newContent = content.replace(/== .+? ==\n+/, '').replace(/\{\{\/מצב\|.+?\}\}/, ''); | |||
return new mw.Api().post({ action: 'edit', minor: 1, title: talkPage.getPrefixedText(), summary: 'העברת חשד לתקלדה מ[[המכלול:תיקון תקלדות בקליק]]', token: mw.user.tokens.get('csrfToken'), section: 'new', sectiontitle: sectionTitle, text: ':דיווח מהדף [[המכלול:דיווח על תקלדות]]\n' + newContent }).then(function (d) { mw.notify($('<a>', { href: talkPage.getUrl(), target: '_blank' }).text('אורכב בהצלחה')); }); | |||
} | |||
function saveChangereload(articleName, content, suspect, correction) { | |||
return new mw.Api().post({ | |||
action: 'edit', | |||
minor: 1, | |||
title: articleName, | |||
summary: suspect + '->' + correction + ' - [[המכלול:תיקון סופרים|תיקון סופרים]]', | |||
token: mw.user.tokens.get('csrfToken'), | |||
text: content, | |||
// tags: 'תקלדה-בקליק' | |||
}).done(function (d) { | |||
reloadNotify($('<a>', { href: 'https://yi.hamichlol.org.il/w/index.php?title=' + articleName + '&diff=curr&oldid=prev', target: '_blank' }).text('תוקן! לחץ להשוואת גרסאות')); | |||
}); | |||
} | |||
function saveChangenoreload(articleName, content, suspect, correction) { | |||
return new mw.Api().post({ | |||
action: 'edit', | |||
minor: 1, | |||
title: articleName, | |||
summary: suspect + '->' + correction + ' - [[המכלול:תיקון סופרים|תיקון סופרים]]', | |||
token: mw.user.tokens.get('csrfToken'), | |||
text: content, | |||
// tags: 'תקלדה-בקליק' | |||
}).done(function (d) { | |||
mw.notify($('<a>', { href: 'https://yi.hamichlol.org.il/w/index.php?title=' + articleName + '&diff=curr&oldid=prev', target: '_blank' }).text('תוקן! לחץ להשוואת גרסאות')); | |||
}); | |||
} | |||
function saveChange(e) { | |||
var articleName = $(this).parents('h2').find('.mw-headline').text().replace(' (בלאַט עקזיסטירט נאכנישט)', ''), | |||
sectionNum = $(this).parent().find('a').attr('href').match(/section=([0-9]+)/)[1], | |||
api = new mw.Api(); | |||
api.get({ action: 'query', prop: 'revisions', titles: mw.config.get('wgPageName'), rvprop: 'content|timestamp', rvsection: sectionNum, curtimestamp: 1 }).done(function (data) { | |||
for (var rv in data.query.pages) { | |||
var sectionText = data.query.pages[rv].revisions[0]['*'], | |||
basetimestamp = data.query.pages[rv].revisions[0].timestamp; | |||
if ((sectionText.indexOf('== [[' + articleName + ']] ==') !== 0) && (sectionText.indexOf('== [[:' + articleName + ']] ==') !== 0)) { | |||
reloadNotify('הפסקה אינה קיימת עוד במקומה. מרענן את הדף'); | |||
} else { | |||
if (sectionText.indexOf('{{#lst:') != -1) { | |||
removeSection(sectionNum, basetimestamp, data.curtimestamp, '/* ' + articleName + ' */ ארכוב'); | |||
} else { | |||
var articleText = 'undefined', newArticleText = 'undefined', suspect = 'undefined', correction = 'wow', approvedCorrection = 'wow', oldcontext = 'wwowo', newcontext = 'undefined'; | |||
suspect = sectionText.replace(/.*\n.*?(.*)?\->.*\n.*\n.*/, "$1"); | |||
correction = sectionText.replace(/.*\n.*?>(.*)?\?.*\n.*\n.*/, "$1"); | |||
oldcontext = sectionText.replace(/.*\n.*\n.*? (.*) .*\n.*/, "$1"); | |||
newcontext = oldcontext.replace(suspect, correction); | |||
if (newcontext === oldcontext) { alert('המילה לא נמצאה בהקשר'); return; } | |||
approvedCorrection = prompt('ההקשר:\n' + oldcontext + '\n' + suspect + ' יוחלף ב:', suspect); | |||
if (approvedCorrection === null || approvedCorrection === suspect) return; | |||
newcontext = oldcontext.replace(suspect, approvedCorrection); | |||
var api = new mw.Api(); | |||
api.get({ | |||
action: 'query', prop: 'revisions', titles: articleName, rvprop: 'content', curtimestamp: 1 | |||
}).done(function (d) { | |||
for (var rv in d.query.pages) { | |||
articleText = d.query.pages[rv].revisions[0]["*"]; | |||
newArticleText = articleText.replace(oldcontext, newcontext); | |||
if (newArticleText === articleText) { | |||
alert('ההקשר לא נמצא בערך'); | |||
removeSection(sectionNum, basetimestamp, data.curtimestamp, suspect + ' לא נמצא') | |||
return; | |||
} | |||
saveChangenoreload(articleName, newArticleText, suspect, approvedCorrection) | |||
if (newArticleText != articleText) removeSectionAfterCorrection(sectionNum, basetimestamp, data.curtimestamp, suspect + '->' + approvedCorrection + ' תוקן!'); | |||
if (newArticleText === articleText) removeSectionAfterCorrection(sectionNum, basetimestamp, data.curtimestamp, suspect + '->' + approvedCorrection + ' לא תוקן!'); | |||
} | |||
}) | |||
} | |||
} | |||
} | |||
}); | |||
e.preventDefault(); | |||
} | |||
function saveChange2(e) { | |||
var articleName = $(this).parents('h2').find('.mw-headline').text().replace(' (בלאַט עקזיסטירט נאכנישט)', ''), | |||
sectionNum = $(this).parent().find('a').attr('href').match(/section=([0-9]+)/)[1], | |||
api = new mw.Api(); | |||
api.get({ action: 'query', prop: 'revisions', titles: mw.config.get('wgPageName'), rvprop: 'content|timestamp', rvsection: sectionNum, curtimestamp: 1 }).done(function (data) { | |||
for (var rv in data.query.pages) { | |||
var sectionText = data.query.pages[rv].revisions[0]['*'], | |||
basetimestamp = data.query.pages[rv].revisions[0].timestamp; | |||
if ((sectionText.indexOf('== [[' + articleName + ']] ==') !== 0) && (sectionText.indexOf('== [[:' + articleName + ']] ==') !== 0)) { | |||
reloadNotify('הפסקה אינה קיימת עוד במקומה. מרענן את הדף'); | |||
} else { | |||
if (sectionText.indexOf('{{#lst:') != -1) { | |||
removeSection(sectionNum, basetimestamp, data.curtimestamp, '/* ' + articleName + ' */ ארכוב'); | |||
} else { | |||
var articleText = 'undefined', newArticleText = 'undefined', suspect = 'undefined', correction = 'wow', oldcontext = 'wwowo', newcontext = 'undefined'; | |||
suspect = sectionText.replace(/.*\n.*?(.*)?\->.*\n.*\n.*/, "$1"); | |||
correction = sectionText.replace(/.*\n.*?>(.*)?\?.*\n.*\n.*/, "$1"); | |||
oldcontext = sectionText.replace(/.*\n.*\n.*? (.*) .*\n.*/, "$1"); | |||
newcontext = oldcontext.replace(suspect, correction); | |||
if (newcontext === oldcontext) { alert('המילה לא נמצאה בהקשר'); return; } | |||
var api = new mw.Api(); | |||
api.get({ | |||
action: 'query', prop: 'revisions', titles: articleName, rvprop: 'content', curtimestamp: 1 | |||
}).done(function (d) { | |||
for (var rv in d.query.pages) { | |||
articleText = d.query.pages[rv].revisions[0]["*"]; | |||
newArticleText = articleText.replace(oldcontext, newcontext); | |||
if (newArticleText === articleText) { | |||
alert('ההקשר לא נמצא בערך'); | |||
removeSection(sectionNum, basetimestamp, data.curtimestamp, suspect + ' לא נמצא') | |||
return; | |||
} | |||
saveChangereload(articleName, newArticleText, suspect, correction) | |||
if (newArticleText != articleText) removeSectionAfterCorrection(sectionNum, basetimestamp, data.curtimestamp, suspect + '->' + correction + ' תוקן!'); | |||
if (newArticleText === articleText) removeSectionAfterCorrection(sectionNum, basetimestamp, data.curtimestamp, suspect + '->' + correction + ' לא תוקן!'); | |||
} | |||
}) | |||
} | |||
} | |||
} | |||
}); | |||
e.preventDefault(); | |||
} | |||
function saveChange3(e) { | |||
var articleName = $(this).parents('h2').find('.mw-headline').text().replace(' (בלאַט עקזיסטירט נאכנישט)', ''), | |||
sectionNum = $(this).parent().find('a').attr('href').match(/section=([0-9]+)/)[1], | |||
api = new mw.Api(); | |||
api.get({ action: 'query', prop: 'revisions', titles: mw.config.get('wgPageName'), rvprop: 'content|timestamp', rvsection: sectionNum, curtimestamp: 1 }).done(function (data) { | |||
for (var rv in data.query.pages) { | |||
var sectionText = data.query.pages[rv].revisions[0]['*'], | |||
basetimestamp = data.query.pages[rv].revisions[0].timestamp; | |||
if ((sectionText.indexOf('== [[' + articleName + ']] ==') !== 0) && (sectionText.indexOf('== [[:' + articleName + ']] ==') !== 0)) { | |||
reloadNotify('הפסקה אינה קיימת עוד במקומה. מרענן את הדף'); | |||
} else { | |||
if (sectionText.indexOf('{{#lst:') != -1) { | |||
removeSection(sectionNum, basetimestamp, data.curtimestamp, suspect + ' לא תוקן'); | |||
} else { | |||
var articleText = 'undefined', newArticleText = 'undefined', suspect = 'undefined', correction = 'wow', oldcontext = 'wwowo', newcontext = 'undefined'; | |||
suspect = sectionText.replace(/.*\n.*?(.*)?\->.*\n.*\n.*/, "$1"); | |||
correction = sectionText.replace(/.*\n.*?>(.*)?\?.*\n.*\n.*/, "$1"); | |||
oldcontext = sectionText.replace(/.*\n.*\n.*? (.*) .*\n.*/, "$1"); | |||
newcontext = oldcontext.replace(suspect, correction); | |||
if (newcontext === oldcontext) { alert('המילה לא נמצאה בהקשר'); return; } | |||
var api = new mw.Api(); | |||
api.get({ | |||
action: 'query', prop: 'revisions', titles: articleName, rvprop: 'content', curtimestamp: 1 | |||
}).done(function (d) { | |||
for (var rv in d.query.pages) { | |||
articleText = d.query.pages[rv].revisions[0]["*"]; | |||
newArticleText = articleText.replace(oldcontext, newcontext); | |||
if (newArticleText === articleText) { | |||
alert('ההקשר לא נמצא בערך'); | |||
removeSection(sectionNum, basetimestamp, data.curtimestamp, suspect + ' לא נמצא') | |||
return; | |||
} | |||
saveChangenoreload(articleName, newArticleText, suspect, correction) | |||
if (newArticleText != articleText) removeSectionAfterCorrection2(sectionNum, basetimestamp, data.curtimestamp, suspect + '->' + correction + ' תוקן!'); | |||
if (newArticleText === articleText) removeSectionAfterCorrection2(sectionNum, basetimestamp, data.curtimestamp, suspect + '->' + correction + ' לא תוקן!'); | |||
} | |||
}) | |||
} | |||
} | |||
} | |||
}); | |||
e.preventDefault(); | |||
} | |||
function archiveReport(e) { | |||
var summ = 'חשד לתקלדה'; | |||
var articleName = $(this).parents('h2').find('.mw-headline').text().replace(' (בלאַט עקזיסטירט נאכנישט)', ''), | |||
sectionNum = $(this).parent().find('a').attr('href').match(/section=(.*)/)[1], | |||
api = new mw.Api(); | |||
api.get({ action: 'query', prop: 'revisions', titles: mw.config.get('wgPageName'), rvprop: 'content|timestamp', rvsection: sectionNum, curtimestamp: 1 }).done(function (data) { | |||
for (var rv in data.query.pages) { | |||
var sectionText = data.query.pages[rv].revisions[0]['*'], | |||
basetimestamp = data.query.pages[rv].revisions[0].timestamp; | |||
if ((sectionText.indexOf('== [[' + articleName + ']] ==') !== 0) && (sectionText.indexOf('== [[:' + articleName + ']] ==') !== 0)) { | |||
reloadNotify('הפסקה אינה קיימת עוד במקומה. מרענן את הדף'); | |||
} else { | |||
if (sectionText.indexOf('{{#lst:') != -1) { | |||
removeSection(sectionNum, basetimestamp, data.curtimestamp, suspect + ' לא תוקן'); | |||
} else { | |||
archiveToTalk(articleName, summ, sectionText).done(function () { removeSection(sectionNum, basetimestamp, data.curtimestamp, suspect + ' לא תוקן'); }); | |||
} | |||
} | |||
} | |||
}); | |||
e.preventDefault(); | |||
} | |||
function removeReport(e) { | |||
var articleName = $(this).parents('h2').find('.mw-headline').text().replace(' (בלאַט עקזיסטירט נאכנישט)', ''), | |||
sectionNum = $(this).parent().find('a').attr('href').match(/section=(.*)/)[1], | |||
api = new mw.Api(); | |||
api.get({ action: 'query', prop: 'revisions', titles: mw.config.get('wgPageName'), rvprop: 'content|timestamp', rvsection: sectionNum, curtimestamp: 1 }).done(function (data) { | |||
for (var rv in data.query.pages) { | |||
var sectionText = data.query.pages[rv].revisions[0]['*'], | |||
basetimestamp = data.query.pages[rv].revisions[0].timestamp; | |||
if ((sectionText.indexOf('== [[' + articleName + ']] ==') !== 0) && (sectionText.indexOf('== [[:' + articleName + ']] ==') !== 0)) { | |||
reloadNotify('הפסקה אינה קיימת עוד במקומה. מרענן את הדף'); | |||
} else { | |||
var suspect = sectionText.replace(/.*\n.*?(.*)?\->.*\n.*\n.*/, "$1"); | |||
removeSection(sectionNum, basetimestamp, data.curtimestamp, suspect + ' לא תוקן'); | |||
} | |||
} | |||
}); | |||
e.preventDefault(); | |||
} | |||
function removeReport2(e) { | |||
var articleName = $(this).parents('h2').find('.mw-headline').text().replace(' (בלאַט עקזיסטירט נאכנישט)', ''), | |||
sectionNum = $(this).parent().find('a').attr('href').match(/section=(.*)/)[1], | |||
api = new mw.Api(); | |||
api.get({ action: 'query', prop: 'revisions', titles: mw.config.get('wgPageName'), rvprop: 'content|timestamp', rvsection: sectionNum, curtimestamp: 1 }).done(function (data) { | |||
for (var rv in data.query.pages) { | |||
var sectionText = data.query.pages[rv].revisions[0]['*'], | |||
basetimestamp = data.query.pages[rv].revisions[0].timestamp; | |||
if ((sectionText.indexOf('== [[' + articleName + ']] ==') !== 0) && (sectionText.indexOf('== [[:' + articleName + ']] ==') !== 0)) { | |||
reloadNotify('הפסקה אינה קיימת עוד במקומה. מרענן את הדף'); | |||
} else { | |||
var suspect = sectionText.replace(/.*\n.*?(.*)?\->.*\n.*\n.*/, "$1"); | |||
removeSection2(sectionNum, basetimestamp, data.curtimestamp, suspect + ' לא תוקן'); | |||
} | |||
} | |||
}); | |||
e.preventDefault(); | |||
} | |||
$('h2').each(function () { | |||
var archive = $('<a>לבדיקה</a>').attr({ href: '#' }).css({ 'font-size': 'large', 'margin-right': '20px' }).click(archiveReport), | |||
removeReportBtn = $('<a>הסר-</a>').attr({ href: '#' }).css({ 'font-size': 'large', 'margin-right': '20px' }).click(removeReport), | |||
removeReportBtn2 = $('<a>הסר</a>').attr({ href: '#' }).css({ 'font-size': 'large', 'margin-right': '20px' }).click(removeReport2), | |||
saveChangeBtn = $('<a>טפל<a>').attr({ href: '#' }).css({ 'font-size': 'large', 'margin-right': '20px' }).click(saveChange), | |||
saveChangeBtn2 = $('<a>החלף<a>').attr({ href: '#' }).css({ 'font-size': 'large' }).click(saveChange2), | |||
saveChangeBtn3 = $('<a>החלף-<a>').attr({ href: '#' }).css({ 'font-size': 'large', 'margin-right': '20px' }).click(saveChange3); | |||
$(this).find('.mw-editsection').append(['<br><br>', removeReportBtn, saveChangeBtn, saveChangeBtn3, saveChangeBtn2, removeReportBtn2, archive]); | |||
}); | |||
}); | |||
} | } |
רעוויזיע פון 13:05, 21 יאנואר 2024
var p_n = mw.config.get('wgPageName');
var pn = p_n.replace(/_/, ' ');
if (p_n.match(/^המכלול:תיקון_סופרים$/) || p_n.match(/^המכלול:תיקון_סופרים\/[0-9]+$/)) {
$(function () {
function reloadNotify(msg) {
mw.notify(msg).done(function () { window.location.reload(); });
}
function removeSection(section, basetimestamp, starttimestamp, summ) {
var api = new mw.Api(), pagename = this.curPage;
api.postWithToken('csrf', {
action: 'edit',
title: pn,
summary: summ,
minor: 1,
basetimestamp: basetimestamp,
starttimestamp: starttimestamp,
text: '',
section: section
}).done(function (d) {
if (d && d.edit && d.edit.result == 'Success') {
mw.notify('הוסר, יעודכן ברענון');
}
});
}
function removeSection2(section, basetimestamp, starttimestamp, summ) {
var api = new mw.Api(), pagename = this.curPage;
api.postWithToken('csrf', {
action: 'edit',
title: pn,
summary: summ,
minor: 1,
basetimestamp: basetimestamp,
starttimestamp: starttimestamp,
text: '',
section: section
}).done(function (d) {
if (d && d.edit && d.edit.result == 'Success') {
reloadNotify('הוסר');
}
});
}
function removeSectionAfterCorrection(section, basetimestamp, starttimestamp, summ) {
var api = new mw.Api(), pagename = this.curPage;
api.postWithToken('csrf', {
action: 'edit',
title: pn,
summary: summ,
minor: 1,
basetimestamp: basetimestamp,
starttimestamp: starttimestamp,
text: '',
section: section
}).done(function (d) {
if (d && d.edit && d.edit.result == 'Success') {
}
});
}
function removeSectionAfterCorrection2(section, basetimestamp, starttimestamp, summ) {
var api = new mw.Api(), pagename = this.curPage;
api.postWithToken('csrf', {
action: 'edit',
title: pn,
summary: summ,
minor: 1,
basetimestamp: basetimestamp,
starttimestamp: starttimestamp,
text: '',
section: section
}).done(function (d) {
if (d && d.edit && d.edit.result == 'Success') {
}
});
}
function archiveToTalk(articleName, sectionTitle, content) {
var talkPage = new mw.Title(articleName).getTalkPage(),
newContent = content.replace(/== .+? ==\n+/, '').replace(/\{\{\/מצב\|.+?\}\}/, '');
return new mw.Api().post({ action: 'edit', minor: 1, title: talkPage.getPrefixedText(), summary: 'העברת חשד לתקלדה מ[[המכלול:תיקון תקלדות בקליק]]', token: mw.user.tokens.get('csrfToken'), section: 'new', sectiontitle: sectionTitle, text: ':דיווח מהדף [[המכלול:דיווח על תקלדות]]\n' + newContent }).then(function (d) { mw.notify($('<a>', { href: talkPage.getUrl(), target: '_blank' }).text('אורכב בהצלחה')); });
}
function saveChangereload(articleName, content, suspect, correction) {
return new mw.Api().post({
action: 'edit',
minor: 1,
title: articleName,
summary: suspect + '->' + correction + ' - [[המכלול:תיקון סופרים|תיקון סופרים]]',
token: mw.user.tokens.get('csrfToken'),
text: content,
// tags: 'תקלדה-בקליק'
}).done(function (d) {
reloadNotify($('<a>', { href: 'https://yi.hamichlol.org.il/w/index.php?title=' + articleName + '&diff=curr&oldid=prev', target: '_blank' }).text('תוקן! לחץ להשוואת גרסאות'));
});
}
function saveChangenoreload(articleName, content, suspect, correction) {
return new mw.Api().post({
action: 'edit',
minor: 1,
title: articleName,
summary: suspect + '->' + correction + ' - [[המכלול:תיקון סופרים|תיקון סופרים]]',
token: mw.user.tokens.get('csrfToken'),
text: content,
// tags: 'תקלדה-בקליק'
}).done(function (d) {
mw.notify($('<a>', { href: 'https://yi.hamichlol.org.il/w/index.php?title=' + articleName + '&diff=curr&oldid=prev', target: '_blank' }).text('תוקן! לחץ להשוואת גרסאות'));
});
}
function saveChange(e) {
var articleName = $(this).parents('h2').find('.mw-headline').text().replace(' (בלאַט עקזיסטירט נאכנישט)', ''),
sectionNum = $(this).parent().find('a').attr('href').match(/section=([0-9]+)/)[1],
api = new mw.Api();
api.get({ action: 'query', prop: 'revisions', titles: mw.config.get('wgPageName'), rvprop: 'content|timestamp', rvsection: sectionNum, curtimestamp: 1 }).done(function (data) {
for (var rv in data.query.pages) {
var sectionText = data.query.pages[rv].revisions[0]['*'],
basetimestamp = data.query.pages[rv].revisions[0].timestamp;
if ((sectionText.indexOf('== [[' + articleName + ']] ==') !== 0) && (sectionText.indexOf('== [[:' + articleName + ']] ==') !== 0)) {
reloadNotify('הפסקה אינה קיימת עוד במקומה. מרענן את הדף');
} else {
if (sectionText.indexOf('{{#lst:') != -1) {
removeSection(sectionNum, basetimestamp, data.curtimestamp, '/* ' + articleName + ' */ ארכוב');
} else {
var articleText = 'undefined', newArticleText = 'undefined', suspect = 'undefined', correction = 'wow', approvedCorrection = 'wow', oldcontext = 'wwowo', newcontext = 'undefined';
suspect = sectionText.replace(/.*\n.*?(.*)?\->.*\n.*\n.*/, "$1");
correction = sectionText.replace(/.*\n.*?>(.*)?\?.*\n.*\n.*/, "$1");
oldcontext = sectionText.replace(/.*\n.*\n.*? (.*) .*\n.*/, "$1");
newcontext = oldcontext.replace(suspect, correction);
if (newcontext === oldcontext) { alert('המילה לא נמצאה בהקשר'); return; }
approvedCorrection = prompt('ההקשר:\n' + oldcontext + '\n' + suspect + ' יוחלף ב:', suspect);
if (approvedCorrection === null || approvedCorrection === suspect) return;
newcontext = oldcontext.replace(suspect, approvedCorrection);
var api = new mw.Api();
api.get({
action: 'query', prop: 'revisions', titles: articleName, rvprop: 'content', curtimestamp: 1
}).done(function (d) {
for (var rv in d.query.pages) {
articleText = d.query.pages[rv].revisions[0]["*"];
newArticleText = articleText.replace(oldcontext, newcontext);
if (newArticleText === articleText) {
alert('ההקשר לא נמצא בערך');
removeSection(sectionNum, basetimestamp, data.curtimestamp, suspect + ' לא נמצא')
return;
}
saveChangenoreload(articleName, newArticleText, suspect, approvedCorrection)
if (newArticleText != articleText) removeSectionAfterCorrection(sectionNum, basetimestamp, data.curtimestamp, suspect + '->' + approvedCorrection + ' תוקן!');
if (newArticleText === articleText) removeSectionAfterCorrection(sectionNum, basetimestamp, data.curtimestamp, suspect + '->' + approvedCorrection + ' לא תוקן!');
}
})
}
}
}
});
e.preventDefault();
}
function saveChange2(e) {
var articleName = $(this).parents('h2').find('.mw-headline').text().replace(' (בלאַט עקזיסטירט נאכנישט)', ''),
sectionNum = $(this).parent().find('a').attr('href').match(/section=([0-9]+)/)[1],
api = new mw.Api();
api.get({ action: 'query', prop: 'revisions', titles: mw.config.get('wgPageName'), rvprop: 'content|timestamp', rvsection: sectionNum, curtimestamp: 1 }).done(function (data) {
for (var rv in data.query.pages) {
var sectionText = data.query.pages[rv].revisions[0]['*'],
basetimestamp = data.query.pages[rv].revisions[0].timestamp;
if ((sectionText.indexOf('== [[' + articleName + ']] ==') !== 0) && (sectionText.indexOf('== [[:' + articleName + ']] ==') !== 0)) {
reloadNotify('הפסקה אינה קיימת עוד במקומה. מרענן את הדף');
} else {
if (sectionText.indexOf('{{#lst:') != -1) {
removeSection(sectionNum, basetimestamp, data.curtimestamp, '/* ' + articleName + ' */ ארכוב');
} else {
var articleText = 'undefined', newArticleText = 'undefined', suspect = 'undefined', correction = 'wow', oldcontext = 'wwowo', newcontext = 'undefined';
suspect = sectionText.replace(/.*\n.*?(.*)?\->.*\n.*\n.*/, "$1");
correction = sectionText.replace(/.*\n.*?>(.*)?\?.*\n.*\n.*/, "$1");
oldcontext = sectionText.replace(/.*\n.*\n.*? (.*) .*\n.*/, "$1");
newcontext = oldcontext.replace(suspect, correction);
if (newcontext === oldcontext) { alert('המילה לא נמצאה בהקשר'); return; }
var api = new mw.Api();
api.get({
action: 'query', prop: 'revisions', titles: articleName, rvprop: 'content', curtimestamp: 1
}).done(function (d) {
for (var rv in d.query.pages) {
articleText = d.query.pages[rv].revisions[0]["*"];
newArticleText = articleText.replace(oldcontext, newcontext);
if (newArticleText === articleText) {
alert('ההקשר לא נמצא בערך');
removeSection(sectionNum, basetimestamp, data.curtimestamp, suspect + ' לא נמצא')
return;
}
saveChangereload(articleName, newArticleText, suspect, correction)
if (newArticleText != articleText) removeSectionAfterCorrection(sectionNum, basetimestamp, data.curtimestamp, suspect + '->' + correction + ' תוקן!');
if (newArticleText === articleText) removeSectionAfterCorrection(sectionNum, basetimestamp, data.curtimestamp, suspect + '->' + correction + ' לא תוקן!');
}
})
}
}
}
});
e.preventDefault();
}
function saveChange3(e) {
var articleName = $(this).parents('h2').find('.mw-headline').text().replace(' (בלאַט עקזיסטירט נאכנישט)', ''),
sectionNum = $(this).parent().find('a').attr('href').match(/section=([0-9]+)/)[1],
api = new mw.Api();
api.get({ action: 'query', prop: 'revisions', titles: mw.config.get('wgPageName'), rvprop: 'content|timestamp', rvsection: sectionNum, curtimestamp: 1 }).done(function (data) {
for (var rv in data.query.pages) {
var sectionText = data.query.pages[rv].revisions[0]['*'],
basetimestamp = data.query.pages[rv].revisions[0].timestamp;
if ((sectionText.indexOf('== [[' + articleName + ']] ==') !== 0) && (sectionText.indexOf('== [[:' + articleName + ']] ==') !== 0)) {
reloadNotify('הפסקה אינה קיימת עוד במקומה. מרענן את הדף');
} else {
if (sectionText.indexOf('{{#lst:') != -1) {
removeSection(sectionNum, basetimestamp, data.curtimestamp, suspect + ' לא תוקן');
} else {
var articleText = 'undefined', newArticleText = 'undefined', suspect = 'undefined', correction = 'wow', oldcontext = 'wwowo', newcontext = 'undefined';
suspect = sectionText.replace(/.*\n.*?(.*)?\->.*\n.*\n.*/, "$1");
correction = sectionText.replace(/.*\n.*?>(.*)?\?.*\n.*\n.*/, "$1");
oldcontext = sectionText.replace(/.*\n.*\n.*? (.*) .*\n.*/, "$1");
newcontext = oldcontext.replace(suspect, correction);
if (newcontext === oldcontext) { alert('המילה לא נמצאה בהקשר'); return; }
var api = new mw.Api();
api.get({
action: 'query', prop: 'revisions', titles: articleName, rvprop: 'content', curtimestamp: 1
}).done(function (d) {
for (var rv in d.query.pages) {
articleText = d.query.pages[rv].revisions[0]["*"];
newArticleText = articleText.replace(oldcontext, newcontext);
if (newArticleText === articleText) {
alert('ההקשר לא נמצא בערך');
removeSection(sectionNum, basetimestamp, data.curtimestamp, suspect + ' לא נמצא')
return;
}
saveChangenoreload(articleName, newArticleText, suspect, correction)
if (newArticleText != articleText) removeSectionAfterCorrection2(sectionNum, basetimestamp, data.curtimestamp, suspect + '->' + correction + ' תוקן!');
if (newArticleText === articleText) removeSectionAfterCorrection2(sectionNum, basetimestamp, data.curtimestamp, suspect + '->' + correction + ' לא תוקן!');
}
})
}
}
}
});
e.preventDefault();
}
function archiveReport(e) {
var summ = 'חשד לתקלדה';
var articleName = $(this).parents('h2').find('.mw-headline').text().replace(' (בלאַט עקזיסטירט נאכנישט)', ''),
sectionNum = $(this).parent().find('a').attr('href').match(/section=(.*)/)[1],
api = new mw.Api();
api.get({ action: 'query', prop: 'revisions', titles: mw.config.get('wgPageName'), rvprop: 'content|timestamp', rvsection: sectionNum, curtimestamp: 1 }).done(function (data) {
for (var rv in data.query.pages) {
var sectionText = data.query.pages[rv].revisions[0]['*'],
basetimestamp = data.query.pages[rv].revisions[0].timestamp;
if ((sectionText.indexOf('== [[' + articleName + ']] ==') !== 0) && (sectionText.indexOf('== [[:' + articleName + ']] ==') !== 0)) {
reloadNotify('הפסקה אינה קיימת עוד במקומה. מרענן את הדף');
} else {
if (sectionText.indexOf('{{#lst:') != -1) {
removeSection(sectionNum, basetimestamp, data.curtimestamp, suspect + ' לא תוקן');
} else {
archiveToTalk(articleName, summ, sectionText).done(function () { removeSection(sectionNum, basetimestamp, data.curtimestamp, suspect + ' לא תוקן'); });
}
}
}
});
e.preventDefault();
}
function removeReport(e) {
var articleName = $(this).parents('h2').find('.mw-headline').text().replace(' (בלאַט עקזיסטירט נאכנישט)', ''),
sectionNum = $(this).parent().find('a').attr('href').match(/section=(.*)/)[1],
api = new mw.Api();
api.get({ action: 'query', prop: 'revisions', titles: mw.config.get('wgPageName'), rvprop: 'content|timestamp', rvsection: sectionNum, curtimestamp: 1 }).done(function (data) {
for (var rv in data.query.pages) {
var sectionText = data.query.pages[rv].revisions[0]['*'],
basetimestamp = data.query.pages[rv].revisions[0].timestamp;
if ((sectionText.indexOf('== [[' + articleName + ']] ==') !== 0) && (sectionText.indexOf('== [[:' + articleName + ']] ==') !== 0)) {
reloadNotify('הפסקה אינה קיימת עוד במקומה. מרענן את הדף');
} else {
var suspect = sectionText.replace(/.*\n.*?(.*)?\->.*\n.*\n.*/, "$1");
removeSection(sectionNum, basetimestamp, data.curtimestamp, suspect + ' לא תוקן');
}
}
});
e.preventDefault();
}
function removeReport2(e) {
var articleName = $(this).parents('h2').find('.mw-headline').text().replace(' (בלאַט עקזיסטירט נאכנישט)', ''),
sectionNum = $(this).parent().find('a').attr('href').match(/section=(.*)/)[1],
api = new mw.Api();
api.get({ action: 'query', prop: 'revisions', titles: mw.config.get('wgPageName'), rvprop: 'content|timestamp', rvsection: sectionNum, curtimestamp: 1 }).done(function (data) {
for (var rv in data.query.pages) {
var sectionText = data.query.pages[rv].revisions[0]['*'],
basetimestamp = data.query.pages[rv].revisions[0].timestamp;
if ((sectionText.indexOf('== [[' + articleName + ']] ==') !== 0) && (sectionText.indexOf('== [[:' + articleName + ']] ==') !== 0)) {
reloadNotify('הפסקה אינה קיימת עוד במקומה. מרענן את הדף');
} else {
var suspect = sectionText.replace(/.*\n.*?(.*)?\->.*\n.*\n.*/, "$1");
removeSection2(sectionNum, basetimestamp, data.curtimestamp, suspect + ' לא תוקן');
}
}
});
e.preventDefault();
}
$('h2').each(function () {
var archive = $('<a>לבדיקה</a>').attr({ href: '#' }).css({ 'font-size': 'large', 'margin-right': '20px' }).click(archiveReport),
removeReportBtn = $('<a>הסר-</a>').attr({ href: '#' }).css({ 'font-size': 'large', 'margin-right': '20px' }).click(removeReport),
removeReportBtn2 = $('<a>הסר</a>').attr({ href: '#' }).css({ 'font-size': 'large', 'margin-right': '20px' }).click(removeReport2),
saveChangeBtn = $('<a>טפל<a>').attr({ href: '#' }).css({ 'font-size': 'large', 'margin-right': '20px' }).click(saveChange),
saveChangeBtn2 = $('<a>החלף<a>').attr({ href: '#' }).css({ 'font-size': 'large' }).click(saveChange2),
saveChangeBtn3 = $('<a>החלף-<a>').attr({ href: '#' }).css({ 'font-size': 'large', 'margin-right': '20px' }).click(saveChange3);
$(this).find('.mw-editsection').append(['<br><br>', removeReportBtn, saveChangeBtn, saveChangeBtn3, saveChangeBtn2, removeReportBtn2, archive]);
});
});
}