Content deleted Content added
Fixed error with reopening requests |
Same updates as ERT |
||
Line 15:
function executeCOI(currentBox, selectedReply, inputText, answered) {
if (confirmed) {
currentBox.getElementsByTagName('tr')[2].remove();
var infoBox = new OO.ui.MessageWidget( {
type: 'notice',
label: 'Processing request — Edit request starting, getting section data to edit.'
});
var firstRowC = currentBox.children[1].children[0];
firstRowC.style = "padding-bottom:10px";
firstRowC.innerHTML = "";
progressBar = new OO.ui.ProgressBarWidget( {
progress: false
});
$(firstRowC).append(progressBar.$element
$(firstRowC).append(infoBox.$element);
progressBar.$element[0].style = "margin:auto";
infoBox.$element[0].style = "margin:10px auto 0px; max-width:50em; text-align:left";
var header = "";
var curElement =
do {
if (curElement.getElementsByClassName("mw-headline").length == 1) {
header = curElement.getElementsByClassName("mw-headline")[0].id;
}
}
while (header == "");
var api = new mw.Api();
api.get( {
action: "parse",
page: mw.config.values.wgPageName,
prop: "
}).done(function(data) {
infoBox.setLabel("Processing request — Making changes to the edit request");
var sections = data.parse.sections;
var
var
for (var j = 0; j < sections.length; j++) {
if (sections[j].anchor == header) {
sectionNum = j + 1;
sectionNum -= offset;
}
if (sections[j].fromtitle != mw.config.values.wgPageName) {
offset++;
}
}
infoBox.setLabel("Processing request — Getting information from section: " + sectionNum + ".");
api.get( {
page: mw.config.values.wgPageName,
section: sectionNum
}).done( function(data) {
infoBox.setLabel("Processing request — Making changes to the edit request.");
var wikitext = data.parse.wikitext
var
if (answered || selectedReply == "
}
if (wikitext.search(tempType) == -1) {
infoBox.setLabel('Failed to find {{Request edit}} template, please report to "User talk:Terasail/COI Request Tool"');
infoBox.setType("error");
} else {
wikitext = wikitext.replace(tempType, "{{Request edit" + tempStr);
if (selectedReply == "REMOVE") {
wikitext = "";
editSummary = "Removed edit request";
selectedReply = -1;
} else if (selectedReply == "CLOSEREQ") {
editSummary += "Closed edit request";
selectedReply = -1;
} else {
if (selectedReply == 0) { //Do not add response template
wikitext += "\n:{{subst:ECOI|" + COIResponse[selectedReply][0] + "}}";
if (inputText != "") {
wikitext += " " + inputText.value;
}
}
wikitext += " ~~~~";
editSummary += COIResponse[selectedReply][2];
}
editSummary += " ([[User:Terasail/COI_Request_Tool|COI Request Tool]])";
if (selectedReply != -1 && infoBox.type != "error") {
infoBox.setType("success");
infoBox.setLabel("Processing '" + COIResponse[selectedReply][2] + "' request — Saving changes to the talk page. (This may take a few seconds)");
}
api.postWithEditToken({
action: 'edit',
title: mw.config.values.wgPageName,
text: wikitext,
section: sectionNum,
summary: editSummary
}).done(function(result) {
window.___location = "https" + "://en.wikipedia.org/w/index.php?title=" + mw.config.values.wgPageName + "&type=revision&diff=cur&oldid=prev";
});
}
});
});
}
}); }
function loadButtons(currentBox) {
$(currentBox).append('<tr><td colspan=2
var
//Create dropdown menu
var dropMenu = new OO.ui.DropdownWidget( {
Line 142:
$(currentBox.children[2].children[0]).append(dropMenu.$element);
//Create input box
var inputText = new OO.ui.MultilineTextInputWidget({autosize: true, label: "'~~
inputText.$element[0].style = "margin:auto";
$(currentBox.children[2].children[0]).append(inputText.$element);
//Create horizontal layout
var hzCLayout = new OO.ui.HorizontalLayout();
//Toggle answer button
var
//Done button
var
icon: "checkAll",
flags: ["primary", "progressive"],
label: "Done",
title: "Mark as done"
});
if (
for (var k = 0; k < COIResponse.length; k++) {
executeCOI(currentBox, k, inputText, answerCB.selected);
}
}
} else {
executeCOI(currentBox, 1, inputText,
}
});
hzCLayout.addItems([doneCB]);
//Go ahead button
var gaB = new OO.ui.ButtonWidget( {
icon: "edit",
label: "Go ahead",
title: "Approve to make change themselves"
});
hzCLayout.addItems([gaB]);
gaB.on("click", function() {
executeCOI(currentBox, 5, inputText,
});
//Consensus button
var conB = new OO.ui.ButtonWidget( {
icon: "userGroup",
label: "WP:Consensus",
title: "Change needs consensus"
});
hzCLayout.addItems([conB]);
conB.on("click", function() {
executeCOI(currentBox, 9, inputText,
});
//Responses button
var
icon: "add",
label: "
title: "Extra reply options"
});
hzCLayout.addItems([respondCB]);
if (currentBox.children[2].style.display == "") {
respondCB.setLabel("More");
currentBox.children[2].style = "display:none";
doneCB.setTitle("Mark as done");
} else {
respondCB.setLabel("Less");
currentBox.children[2].style = "";
doneCB.setTitle("Submit response");
}
});
hzCLayout.addItems([answerCB, new OO.ui.LabelWidget({label: "Close"})]);
//Create first row fieldset
var fieldsetC = new OO.ui.FieldsetLayout();
// Add an horizontal field layout
fieldsetC.addItems([
new OO.ui.FieldLayout(
new OO.ui.Widget({
content: [hzCLayout]
}),
)
]);
$(firstRowC).append(fieldsetC.$element);
//Close request
var closeB = new OO.ui.ButtonWidget( {
icon: "unFlag",
invisibleLabel: true,
title: "Mark as answered"
});
closeB.$element[0].style = "margin:10px 10px 0px";
$(currentBox.children[0].children[0]).append(closeB.$element);
closeB.on("click", function() {
executeCOI(currentBox, "CLOSEREQ", "",
});
//Remove request
Line 227 ⟶ 237:
icon: "trash",
flags: ["primary", "destructive"],
invisibleLabel: true,
title: "Remove entire section!"
});
removeB.$element[0].style = "margin:10px";
$(currentBox.children[0].children[0]).append(removeB.$element);
removeB.on("click", function() {
executeCOI(currentBox, "REMOVE", "",
});
}
Line 259 ⟶ 270:
var COIRequestBoxes = document.getElementsByClassName("plainlinks tmbox tmbox-notice editrequest");
if (COIRequestBoxes) {
mw.loader.using(["oojs-ui-core", "oojs-ui-widgets", "oojs-ui-windows"]).done(function() {
mw.loader.load(["oojs-ui.styles.icons-alerts", "oojs-ui.styles.icons-interactions", "oojs-ui.styles.icons-moderation", "oojs-ui.styles.icons-user", "oojs-ui.styles.icons-editing-core"]);
for (var i = 0; i < COIRequestBoxes.length; i++) {
var currentBox = COIRequestBoxes[i].children[0];
var edReqCheck = currentBox.children[0].children[1];
|