Content deleted Content added
Changes to improve section detection & var -> let |
Fix error caused by section detection |
||
Line 39:
};
function postEdit(wikitext, editSummary, pageName,
let api = new mw.Api();
api.postWithEditToken({
Line 45:
title: pageName,
text: wikitext,
section:
summary: editSummary
}).done(function(result) {
Line 102:
}
editTemplate += "|answered=" + answered;
let sections = data.parse.sections;▼
let wikitext = data.parse.wikitext["*"];
▲ let sections = data.parse.sections;
sections[sections.length] = {byteoffset: wikitext.length};//Add last value to be pagelength
let newRev = data.parse.revid;
let secIndx = sections[0], endIndx =
for (let j = 0; j < sections.length - 1; j++) {//Run for all except last value
let tempSec = sections[j];
if (tempSec.anchor == header && !isNaN(Number(tempSec.index))) {
secIndx = tempSec;
endIndx = sections[j + 1];
} else if (tempSec.number.slice(0, secIndx.number.length) ==
endIndx = sections[j + 1];
}
}
wikitext = wikitext.replace(/{{ *([SETFI]PER|Edit[ -]?[A-Z]+[ -]?Protected)\s*[^}}]*/i, editTemplate);
let editSummary = "/* " + header.replaceAll("_", " ") + " */ " + replyOption[2] + " ([[User:Terasail/Edit_Request_Tool|Edit Request Tool]])";
Line 138 ⟶ 136:
infoBox.setType("success");
infoBox.setLabel("Processing '" + replyOption[2] + "' request — Saving changes to the talk page.");
secIndx = parseInt(secIndx.index);
if (newRev == mw.config.values.wgRevisionId) {
postEdit(wikitext, editSummary, pageName, secIndx);
Line 226 ⟶ 225:
execute(currentBox, replyERT[dropMenu.getLabel()], inputText.value, toggleAns.selected, typeChange.value, targetPages.getValue());
} else if (typeChange.value != typeChange.defaultValue) {
execute(currentBox, replyERT.Change, "",
}
let newTargets = false;
Line 238 ⟶ 237:
}
if (newTargets) {
execute(currentBox, replyERT.ChangeTarget, "",
}
} else {
|