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

Content deleted Content added
Fix page watching with quick responses.
Change indentation
Line 125:
//Response dropdown
let responseDropdown = new OO.ui.DropdownWidget({
label: "Select reply option - Add additional text below",
menu: {items: []}
}).on("labelChange", function () {
submitButton.setDisabled(false);
previewCOI(responseDropdown.menu.findSelectedItem().getData(), responseText.value, responsePreview);
});
for (let i = 0; i < responseCOI.length; i++) {
let tempWidget = new OO.ui.MenuOptionWidget({
Line 148:
previewCOI(responseDropdown.menu.findSelectedItem().getData(), responseText.value, responsePreview);
}
});
responseText.$element[0].style = "margin:5px auto;";
$(responseCustom).append(responseText.$element);
Line 177:
}
let watchlistLayout = new OO.ui.HorizontalLayout();
let watchlistDropdown = new OO.ui.DropdownInputWidget({
value: watchValue,
options: watchOptions,
disabled: (watchStatus[2] == undefined)
});
watchlistLayout.addItems([watchlistDropdown]);
//Watchlist checkbox & label
Line 213:
let nickname = " " + mw.user.options.values.nickname;
if (nickname == " ") {//Create default signature if no nickname
nickname = mw.user.getName();
nickname = " [[User:" + nickname + "|" + nickname + "]] ([[User talk:" + nickname + "|talk]])";
}
}
let dateObj = new Date();
let dateNow = dateObj.toLocaleDateString('en-GB', {
timeZone: 'UTC',
year: 'numeric',
month: 'long',
day: 'numeric'
});
let timeNow = dateObj.toLocaleTimeString('en-GB', {timeZone: 'UTC', hour: '2-digit', minute: '2-digit'});
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',
function (html) {
tableCell.style = "padding:8px 1em 2px;";
tableCell.children[1].innerHTML = html;
}
}
);
);
} else {
tableCell.style = "display:none;";
}
}
}
 
Line 331:
}
let apiParams = {
action: 'edit',
title: mw.config.get("wgPageName"),
text: wikitext,
section: sectionIndex,
summary: editSummary,
watchlist: watchPage
};
if (watchPage == "watch") {
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 () {
window.___location = reloadURL;
});
}