Content deleted Content added
Update to support new parser format |
Account for {{COI edit}} |
||
(5 intermediate revisions by the same user not shown) | |||
Line 60:
if (expiry) {
watched = Math.ceil((new Date(expiry).getTime() - Date.now()) / 1000 / 60 / 60 / 24) + " days";
if (watched == undefined && typeof(autoWatchRequests) != "undefined" && autoWatchRequests == true) {
watched = '';
}
watchStatus.push(watchData.watchers || "less than 30", watchData.visitingwatchers || "<30", watched);
Line 79 ⟶ 82:
function loadCOIResponse(COIRequest, respondButton, watchStatus) {
let responseBoxHTML = '<table class="response-box" style="border:1px solid #A2A9B1; border-radius:2px; padding:10px 16px 0; margin:auto; max-width:55em; width:100%; clear:both;"><tr><td
$(responseBoxHTML).insertAfter(COIRequest, respondButton);
let responseBox = COIRequest.nextElementSibling;
Line 125 ⟶ 128:
//Response dropdown
let responseDropdown = new OO.ui.DropdownWidget({
previewCOI(responseDropdown.menu.findSelectedItem().getData(), responseText.value, responsePreview);
for (let i = 0; i < responseCOI.length; i++) {
let tempWidget = new OO.ui.MenuOptionWidget({
Line 148 ⟶ 151:
previewCOI(responseDropdown.menu.findSelectedItem().getData(), responseText.value, responsePreview);
}
responseText.$element[0].style = "margin:5px auto;";
$(responseCustom).append(responseText.$element);
Line 177 ⟶ 180:
}
let watchlistLayout = new OO.ui.HorizontalLayout();
value: watchValue,
watchlistLayout.addItems([watchlistDropdown]);
//Watchlist checkbox & label
Line 189 ⟶ 192:
watchlistDropdown.setDisabled(!newStatus);
});
let watchlistLabel = new OO.ui.LabelWidget({label: "Watch this page"})
▲ });
//Submit Button
let submitButton = new OO.ui.ButtonWidget({
Line 213 ⟶ 214:
let nickname = " " + mw.user.options.values.nickname;
if (nickname == " ") {//Create default signature if no nickname
}
let dateObj = new Date();
responseText = responseText + nickname + " " + timeNow + ", " + dateNow + " (UTC)";
responseText = responseText.replaceAll(/{{subst:/gi, "{{");
responseText = responseText.replaceAll(/\s*~~~~\s*/g, "");
$.post(restTransform, 'wikitext=' + encodeURIComponent(responseText) + '&body_only=true',
}
);
} else {
}
}
Line 278 ⟶ 279:
if (tempElement.parentElement.tagName == "SECTION") { //Need to support both while new parser is being implemented
header = $(tempElement).find("h1,h2,h3,h4,h5,h6")[0].id;
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 302 ⟶ 307:
if (responseOption.parameter != "") {
let template = "{{Edit COI|" + responseOption.parameter + "}}";
wikitext = wikitext.replace(/{{ *(Edit[ _])?COI(-protected|([ _](edit|request)){1,2})?( *\| *([=A-Z])*)* *}}/i, template);
}
if (responseOption.response != "") {
Line 324 ⟶ 329:
}
if (watchPage) {
if (
watchPage = "watch";
}
Line 333 ⟶ 336:
}
let apiParams = {
}
}
|