Content deleted Content added
Don't run on COI requests |
Add suggestion to track page watchers & stop using byteoffset |
||
Line 49:
while (header == "");
let pageName = mw.config.values.wgPageName;
api.get( {
action: "parse",
Line 62 ⟶ 61:
}
editTemplate += "|answered=" + answered;
let wikitext = data.parse.wikitext["*"];▼
let sections = data.parse.sections;
let newRev = data.parse.revid;
let secIndx = sections[0
for (let j = 0; j < sections.length
}
}
action: "parse",
wikitext = wikitext.slice(wikitext.indexOf("=="));▼
page: pageName,
wikitext = wikitext.replace(/{{ *([SETFI]PER|Edit([ -]?[A-Z]+[ -]?| )Protected)\s*[^}}]*/i, editTemplate);▼
section: secIndx,
let editSummary = "/* " + header.replaceAll("_", " ") + " */ " + replyOption[2] + " ([[User:Terasail/Edit_Request_Tool|Edit Request Tool]])";▼
prop: "wikitext"
if (replyOption[1] != "Close") {▼
}).done(function(data) {
let lastMsg = wikitext.lastIndexOf("\n", wikitext.lastIndexOf("(UTC)")) + 1;▼
let wikitext =
▲ wikitext = wikitext.replace(/{{ *([SETFI]PER|Edit([ -]?[A-Z]+[ -]?| )Protected)\s*[^}}]*/i, editTemplate);
while(lastMsg == wikitext.indexOf(":", lastMsg)) {▼
▲ let editSummary = "/* " + header.replaceAll("_", " ") + " */ " + replyOption[2] + " ([[User:Terasail/Edit_Request_Tool|Edit Request Tool]])";
lastMsg++;▼
▲ let lastMsg = wikitext.lastIndexOf("\n", wikitext.lastIndexOf("(UTC)")) + 1;
▲ while(lastMsg == wikitext.indexOf(":", lastMsg)) {
▲ lastMsg++;
wikitext += ":";
}▼
if (replyOption[0] != "") { wikitext += "{{subst:" + dataERT.protections[boxType][1] + replyOption[0] + "}} "; }▼
if (inputText != "") { wikitext += inputText.replaceAll(/\s*~~~~\s*/g, "") + " "; }▼
wikitext += "~~~~";
editSummary = editSummary.replace(/[^]+\*\/ /, "");▼
}
infoBox.setType("success");▼
▲ if (replyOption[0] != "") { wikitext += "{{subst:" + dataERT.protections[boxType][1] + replyOption[0] + "}} "; }
infoBox.setLabel("Processing request — Saving changes to the talk page.");▼
▲ if (inputText != "") { wikitext += inputText.replaceAll(/\s*~~~~\s*/g, "") + " "; }
if (
postEdit(wikitext,
} else {
▲ editSummary = editSummary.replace(/[^]+\*\/ /, "");
OO.ui.confirm("There has been a new revision to the page, do you wish to continue?").done(function(revCon) {▼
if (revCon) { postEdit(wikitext, editSummary, pageName, secIndx); }▼
});
}
});
▲ infoBox.setType("success");
▲ infoBox.setLabel("Processing request — Saving changes to the talk page.");
if (newRev == mw.config.values.wgRevisionId) {▼
▲ } else {
▲ OO.ui.confirm("There has been a new revision to the page, do you wish to continue?").done(function(revCon) {
▲ if (revCon) { postEdit(wikitext, editSummary, pageName, secIndx); }
▲ });
▲ }
});
}
Line 113 ⟶ 112:
let boxType = currentBox.parentElement.dataset.origlevel;
let tableElem = currentBox.parentElement;
$('<table style="border:1px solid #A2A9B1; border-radius:2px; padding:12px 16px; margin:auto; max-width:55em; clear:both;"><tr><td style="color:#808080"><div style="font-style:italic; margin-left:1em;">' + pageWatchers + '</div><div>Quick options:</div></td></tr><tr style="display: flex; justify-content: center;"><td></td></tr><tr><td style="color:#808080">Custom response:</td></tr><tr style="text-align:center;"><td></td></tr><tr style="background:#F6F6F6;"><td style="display:none;"><div style="color:#808080">Preview:</div><div></div></td></tr><tr style="margin-top:5px; display: flex; justify-content: right;"><td></td></tr></table>').insertAfter(tableElem);
let responseTable = tableElem.nextElementSibling.children[0];
let firstRow = responseTable.children[1].children[0];
Line 131 ⟶ 130:
value: boxType,
options: tcOptions
});
typeChange.on("change", function() {
submitB.setDisabled(false);
});
typeChange.$element[0].style = "text-align:left; margin:auto";
Line 156 ⟶ 158:
allowArbitrary: true,
selected: pageLinks
});
targetPages.on("change", function() {
submitB.setDisabled(false);
});
targetPages.$element[0].style = "text-align:left; margin:5px auto";
Line 175 ⟶ 180:
$(secondRow).append(dropMenu.$element);
dropMenu.on("labelChange", function() {
submitB.setDisabled(false);
showOutput(inputText, responses[dropMenu.getLabel()], thirdRow, dataERT, typeChange.value);
});
Line 256 ⟶ 262:
flags: ["primary", "progressive"],
label: "Submit",
title: "Submit the response",
disabled: true
});
submitB.on("click", function() {
Line 321 ⟶ 328:
var editRequestBoxes = document.getElementsByClassName("plainlinks tmbox tmbox-notice editrequest");
if (editRequestBoxes.length != 0) {
api.get({
action: "query",
prop: "info",
pageids: pageID,
inprop: "watchers|visitingwatchers",
format: "json"
}).done(function(data) {
data = data.query.pages[pageID];
let watchers = data.watchers;
let visiting = data.visitingwatchers;
if (typeof(watchers) == "undefined") {
pageWatchers += "less than 30";
} else {
pageWatchers += watchers;
}
pageWatchers += " users watching this page (";
if (typeof(visiting) == "undefined") {
pageWatchers += "0";
} else {
pageWatchers += visiting;
}
pageWatchers += " have viewed recent edits).";
});
var jsonERTURL = "https://en.wikipedia.org/w/index.php?title=User:Terasail/Edit_Request_Tool.json&action=raw&ctype=text/json";
$.getJSON(jsonERTURL, function(dataERT) {
|