אונטערשייד צווישן ווערסיעס פון "מעדיעוויקי:Gadget-wikibugs-patrol-clone.js"

פון המכלול
קפיצה לניווט קפיצה לחיפוש
קאין תקציר עריכה
(p)
צייכן: צוריקגעשטעלט
שורה 311: שורה 311:


         $('h2').each(function () {
         $('h2').each(function () {
             var archive = $('<a>לבדיקה</a>').attr({ href: '#' }).css({ 'font-size': 'large', 'margin-right': '20px' }).click(archiveReport),
             var archive = $('<a>לבדיקה</a>').attr({ href: '#' }).css({ 'display': 'inline-block', 'padding': '10px 20px', 'text-align': 'center', 'text-decoration': 'none', 'background-color': '#007bff', 'color': '#fff', 'border': 'none', 'border-radius': '5px' }).click(archiveReport),
                 removeReportBtn = $('<a>אראפנעמען-</a>').attr({ href: '#' }).css({ 'font-size': 'large', 'margin-right': '20px' }).click(removeReport),
                 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),
                 removeReportBtn2 = $('<a>אראפנעמען</a>').attr({ href: '#' }).css({ 'font-size': 'large', 'margin-right': '20px' }).click(removeReport2),
שורה 317: שורה 317:
                 saveChangeBtn2 = $('<a>טוישט<a>').attr({ href: '#' }).css({ 'font-size': 'large' }).click(saveChange2),
                 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);
                 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]);
             $(this).find('.mw-editsection').append([removeReportBtn, saveChangeBtn, saveChangeBtn3, saveChangeBtn2, removeReportBtn2, archive]);
         });
         });
     });
     });
}
}

רעוויזיע פון 16:30, 22 יאנואר 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({ 'display': 'inline-block', 'padding': '10px 20px', 'text-align': 'center', 'text-decoration': 'none', 'background-color': '#007bff', 'color': '#fff', 'border': 'none', 'border-radius': '5px' }).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([removeReportBtn, saveChangeBtn, saveChangeBtn3, saveChangeBtn2, removeReportBtn2, archive]);
        });
    });
}