Content deleted Content added
m Change indentation |
Account for Template:Sudo |
||
(3 intermediate revisions by the same user not shown) | |||
Line 4:
*/
var dataERT;
var userSignauteERT = "";
var editRequestBoxes = $('.editrequest');
var editRequests = [];
Line 23 ⟶ 24:
$.getJSON("https://en.wikipedia.org/w/index.php?title=User:Terasail/Edit_Request_Tool.json&action=raw&ctype=text/json", function (newData) {
dataERT = newData;
});▼
ApiGetERT({
action: "parse",
title: mw.config.get("wgPageName"),
text: "~~~~",
pst: "true",
disablelimitreport: "true",
disableeditsection: "true",
preview: "true"
}).then(function(data){
userSignauteERT = data.parse.text["*"].replaceAll(/([^]+(?=<p>)<p>|<\/div>)/g, " ");
});
});
Line 69 ⟶ 81:
let boxType = editRequest.dataset.origlevel;
boxType = boxType.replace("full", "fully");
$('<table style="border:1px solid #A2A9B1; border-radius:2px; padding:10px 16px 0; margin:auto; max-width:55em; width:100%; clear:both;"><tr><td
let responseBox = editRequest.nextElementSibling;
let responseQuick = $(responseBox).find('.response-quick')[0];
Line 290 ⟶ 302:
function previewERT(inputText, replyOption, tableRow, template) {
var restTransform = "https://en.wikipedia.org/api/rest_v1/transform/wikitext/to/html/" + encodeURIComponent(mw.config.get('wgPageName'));
let preview =
template = dataERT.protections[template][1];
if (typeof (replyOption) != "undefined") {
preview
}
if (preview != "") {
▲ });
preview = preview.replaceAll(/{{subst:/gi, "{{");
$.post(restTransform, 'wikitext=' + encodeURIComponent(preview) + '&body_only=true',
Line 322 ⟶ 313:
if (inputText.value != "" || typeof (replyOption) != "undefined") {//Stops preview appearing with empty input box
tableRow.style = "padding:8px 1em 2px;";
tableRow.children[1].innerHTML = html.replace("</p>", userSignauteERT);
}
}
Line 356 ⟶ 347:
//Set preview for output
if (responseOption[0] != "") {//Don't preview a non-response
let tempValue = {value:responseText};
previewERT(
}
//Find header
Line 375 ⟶ 367:
sectionIndex = parseInt(tempElement.parentElement.dataset.mwSectionId);
} else {
header = tempElement.getElementsByClassName("mw-headline")[0].id;
} else { //Vector Legacy
header = $(tempElement).find("h1,h2,h3,h4,h5,h6")[0].id;
▲ }
for (let i = 0; i < sections.length; i++) {
if (sections[i].anchor == header) {
Line 405 ⟶ 401:
editTemplate += "|answered=no";
}
wikitext = wikitext.replace(/{{ *([SETFI]PER|Edit([ -]?[A-Z]+[ -]?|[- ])Protected|Sudo)\s*[^}}]*/i, editTemplate);
if (responseOption[1] != "Close") {
wikitext = wikitext.trim() + "\n:";
Line 449 ⟶ 445:
apiParams.watchlistexpiry = watchValue;
}
let reloadURL = "/w/index.php?title=" + encodeURI(mw.config.get("wgPageName")) + "&type=revision&diff=cur&oldid=prev";▼
new mw.Api().postWithEditToken(apiParams).done(function () {
▲
});
}
|