Content deleted Content added
Fix close template error |
Casual overhaul of script... |
||
Line 1:
//<nowiki>
var
"Already Done:": ["a", "clock", "Already Done", "|A"],
"Note:": ["note", "ellipsis", "Note
"Go ahead: I have reviewed these proposed changes and suggest that you go ahead and make the proposed changes to the page.": ["g", "edit", "Go ahead", "|G"],
"Not done:": ["n", "notice", "Not done", "|D"],
"Not done for now:": ["nfn", "notice", "Not done for now", "|D"],
"Not done for now: Please establish a consensus with editors engaged in the subject area before using the {{Request edit}} template for this proposed change.": ["c", "userGroup", "Not done – Needs consensus", "|D|C"],
"Not done for now: it's not clear what changes you want to be made. Please mention the specific changes in a 'change X to Y' format.": ["xy", "helpNotice", "Not done – Unclear request", "|D|Unclear request"],
"Undone: This request has been partially undone.": ["udp","undo", "Partly undone", "|D|The requested edit has been partially undone"],
"Undone: This request has been undone.": ["ud", "undo", "Undone", "|D|The requested edit has been undone"]
};
var COIResponse = [];
//selectedReply
function executeCOI(currentBox, replyOption, inputText, answered) {
OO.ui.confirm("Confirm in order to reply to this edit request.").done(function(confirmed) {
if (confirmed) {
Line 48 ⟶ 53:
action: "parse",
page: mw.config.values.wgPageName,
prop: "sections|wikitext",
}).done(function(data) {
infoBox.setLabel("Processing request — Making changes to the edit request");
var sections = data.parse.sections;
var wikitext = data.parse.wikitext["*"];
var sectionNum = -1;
var offset = 0;
Line 63 ⟶ 69:
}
}
offset = sections[sectionNum - 1].byteoffset;
wikitext = wikitext.slice(offset);
if (sectionNum < sections.length) {
offset = sections[sectionNum].byteoffset - offset;
}
var templateR = replyOption[3];
var tempType = "{{request edit";
if (templateS == -1) {
templateS = wikitextU.indexOf("{{COI");
}
if (templateS == -1) {
infoBox.setLabel('Failed to find {{Request edit}} template, please report to "User talk:Terasail/COI Request Tool"');
infoBox.setType("error");
} else {
var templateE = wikitextU.indexOf("}}", templateS) + 2;
if (answered == false) {
templateR = "";
}
if (templateR != "" || answered == false) {
wikitext = wikitext.slice(0, templateS) + "{{Request edit" + templateR + "}}" + wikitext.slice(templateE);
}
var editSummary = "/* " + header.replaceAll("_", " ") + " */ " + replyOption[2] + " ([[User:Terasail/COI_Request_Tool|COI Request Tool]])";
if (replyOption[1] != "Close") {
wikitext = wikitext.trim() + "\n:";
if (
wikitext += "{{subst:ECOI|" + replyOption[0] + "}}";
}
wikitext = wikitext.trim() + " ~~~~";
if (replyOption[1] == "Remove") {
wikitext = "";
}
}
if (infoBox.type != "error") {
infoBox.setType("success");
infoBox.setLabel("Saving '" + replyOption[2] + "' response to the talk page. (This may take a few seconds)");
api.postWithEditToken({
action: 'edit',
Line 130 ⟶ 119:
summary: editSummary
}).done(function(result) {
window.___location = "https" + "://en.wikipedia.org/w/index.php?title=" + mw.config.values.wgPageName.replaceAll("&", "%26") + "&type=revision&diff=cur&oldid=prev";
});
}
}
});
}
Line 140 ⟶ 129:
function loadButtons(currentBox) {
var replyListC = Object.entries(replyCOIT);
var mainResponseC = [[replyListC[8][1], "Go ahead", "User may make the change themselves"], [replyListC[12][1], "Unclear: X-Y", "Unclear request"], [replyListC[11][1], "WP:Consensus", "Change needs consensus"]];
$(currentBox).append('<tr><td colspan=2><div style="display: flex; justify-content: center;"></div></td></tr><tr style="display:none"><td colspan=2 style="padding-bottom:10px; text-align:center"></td></tr>');
var firstRowC = currentBox.children[1].children[0].children[0];
Line 147 ⟶ 138:
menu: {items: []}
});
for (var count = 2; count < replyListC.length; count++) {
var newOption = new OO.ui.MenuOptionWidget({
label:
icon:
});
dropMenu.menu.addItems(newOption);
}
dropMenu.$element[0].style = "text-align:left; margin:0px";
$(currentBox.children[2].children[0]).append(dropMenu.$element);
Line 173 ⟶ 164:
doneCB.on("click", function() {
if (doneCB.getLabel() == "Submit") {
executeCOI(currentBox, replyCOIT[dropMenu.getLabel()], inputText.value, answerCB.selected);
} else {
executeCOI(currentBox, replyListC[3][1], inputText.value, answerCB.selected);
}
});
hzCLayout.addItems([doneCB]);
//
mainResponseC.forEach(function(item) {
item[3] = new OO.ui.ButtonWidget({
label:
title: item[2]
item[3].on("click", function() {
executeCOI(currentBox, item[0], "", answerCB.selected);
});
hzCLayout.addItems([item[3]]);
});
//Responses button
Line 246 ⟶ 224:
$(currentBox.children[0].children[0]).append(closeB.$element);
closeB.on("click", function() {
executeCOI(currentBox,
});
//Remove request
Line 256 ⟶ 234:
});
removeB.$element[0].style = "margin:10px";
removeB.on("click", function() {
executeCOI(currentBox,
});
$(currentBox.children[0].children[0]).append(removeB.$element);
}
|