User:Terasail/COI Request Tool.js: Difference between revisions

Content deleted Content added
Casual overhaul of script...
Fix section edit errors
Line 49:
}
while (header == "");
var conVal = mw.config.values;
var api = new mw.Api();
api.get( {
action: "parse",
page: mw.config.valuesconVal.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 sectionNumsectionIndx = -1;
var offsetsectionNum = 0;-1
var endSection = -1;
for (var j = 0; j < sections.length; j++) {
ifvar tempSec = (sections[j].anchor == header) {;
if (tempSec.anchor == header && !isNaN(Number(tempSec.index))) {
sectionNum = j + 1;
sectionNum -= offsettempSec.number;
sectionIndx = tempSec.index;
}
endSection = sectionIndx;
if (sections[j].fromtitle != mw.config.values.wgPageName) {
} else if (tempSec.number.indexOf(sectionNum) == 0) {
offset++;
endSection = tempSec.index;
}
}
var offset = sections[sectionNumsectionIndx - 1].byteoffset;
if (endSection < sections.length) {
wikitext = wikitext.slice(offset);
if wikitext = wikitext.slice(sectionNum <offset, sections[endSection].lengthbyteoffset) {;
} else {
offset = sections[sectionNum].byteoffset - offset;
wikitext = wikitext.slice(0offset, offsetwikitext.length);
}
var templateR = replyOption[3];
Line 98 ⟶ 101:
var editSummary = "/* " + header.replaceAll("_", " ") + " */ " + replyOption[2] + " ([[User:Terasail/COI_Request_Tool|COI Request Tool]])";
if (replyOption[1] != "Close") {
var lastMsg = wikitext.lastIndexOf("\n", wikitext.lastIndexOf("(UTC)")) + 1;
wikitext = wikitext.trim() + "\n:";
while(lastMsg == wikitext.indexOf(":", lastMsg)) {
offset lastMsg++;
wikitext += ":";
}
if (replyOption[0] != "") {
wikitext += "{{subst:ECOI|" + replyOption[0] + "}}";
Line 114 ⟶ 122:
api.postWithEditToken({
action: 'edit',
title: mw.config.valuesconVal.wgPageName,
text: wikitext,
section: sectionNumsectionIndx,
summary: editSummary
}).done(function(result) {
Line 148 ⟶ 156:
$(currentBox.children[2].children[0]).append(dropMenu.$element);
//Create input box
var inputText = new OO.ui.MultilineTextInputWidget({autosize: true, label: "'~~~~'Automatically is automatically addedsigned"});
inputText.$element[0].style = "margin:auto";
$(currentBox.children[2].children[0]).append(inputText.$element);