Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump.
This code will be executed when previewing this page.
This code will be executed when previewing this page.
This user script seems to have a documentation page at User:CanonNi/WIP/EFFPR.
// A wizard for users to submit reports at [[Wikipedia:Edit filter/False positives/Reports]]
// <nowiki>
$.when($.ready, mw.loader.using(["mediawiki.api", "mediawiki.util", "mediawiki.widgets"])).then(function () {
if (mw.config.get("wgPageName") != "User:CanonNi/WIP/EFFPR") return;
var api = new mw.Api();
var forSelf = null;
var myselfButton = new OO.ui.ButtonWidget({
label: "Myself",
flags: ["primary", "progressive"],
});
var othersButton = new OO.ui.ButtonWidget({
label: "Someone else",
flags: ["progressive"],
});
var menu = new OO.ui.FieldsetLayout();
menu.addItems([
new OO.ui.MessageWidget({
type: "notice",
inline: true,
label: "Thank you for reporting a false positive.",
}),
new OO.ui.LabelWidget({ label: "This wizard will guide you through filling out a report. First things first, are you reporting a false positive that blocked your edit, or one that affected someone else?" }),
new OO.ui.FieldsetLayout(new OO.ui.ActionFieldLayout(myselfButton, othersButton, { align: "inline" })),
]);
$("#effpr-wizard-container").empty().append(menu.$element);
$("#catlinks").remove();
function nextPage() {
var fieldset = new OO.ui.FieldsetLayout();
if (!forSelf) {
var user = new mw.widgets.UserInputWidget({
required: true,
});
var filterid = new OO.ui.TextInputWidget({
placeholder: "Leave blank if you're not sure.",
required: false,
type: "number",
});
var logid = new OO.ui.TextInputWidget({
placeholder: "Leave blank if you're not sure.",
required: false,
type: "number",
});
fieldset.addItems([
new OO.ui.FieldLayout(user, {
label: "Username of the account:",
align: "top",
}),
new OO.ui.FieldLayout(filterid, {
label: "Filter ID:",
align: "top",
}),
new OO.ui.FieldLayout(logid, {
label: "Filter log entry ID:",
align: "top",
}),
]);
}
var title = new mw.widgets.TitleInputWidget({
value: mw.util.getParamValue("page") || "",
required: true,
});
var comment = new OO.ui.MultilineTextInputWidget({
placeholder: "Anything else you'd like the reviewer to know. For example, what was the edit trying to do?",
required: false,
});
var submitButton = new OO.ui.ButtonWidget({
label: "Submit report",
flags: ["progressive", "primary"],
});
fieldset.addItems([
new OO.ui.FieldLayout(title, {
label: "Title of the page:",
align: "top",
}),
new OO.ui.FieldLayout(comment, {
label: "Additional comments:",
align: "top",
}),
submitButton,
]);
$("#effpr-wizard-container").empty().append(fieldset.$element);
function makeWikitext() {
var titleValue = title.getValue().trim();
var commentValue = comment.getValue().trim();
if (!forSelf) {
return "{{subst:False positive other| filterid = " + filterid.getValue() || "" + " | logid = " + logid.getValue() || "" + " | username = " + user.getValue().trim() + " | page = " + titleValue + " | description = " + commentValue + " }}";
} else {
return "{{subst:False positive | page = " + titleValue + " | description = " + commentValue + " }}";
}
}
submitButton.on("click", function () {
submitButton.setDisabled(true);
submitButton.setLabel("Submitting...");
api.edit("User:CanonNi/WIP/EFFPR", function () {
return {
appendtext: "\n\n" + makeWikitext(),
summary: "[[User:CanonNi/WIP/EFFPR|Reporting a false positive]] on [[" + title.getValue().trim() + "]]",
};
})
.then(function () {
window.location.href = mw.util.getUrl("User:CanonNi/WIP/EFFPR#" + mw.config.get("wgUserName"));
window.location.reload();
})
.catch(function (err) {
submitButton.setDisabled(false);
submitButton.setLabel("Retry submitting");
fieldset.addItems([
new OO.ui.MessageWidget({
type: "error",
label: "An error occurred: " + err,
}),
]);
});
});
$(window).on("beforeunload", function (evt) {
if (title.getValue().length > 0 || comment.getValue().length > 0) {
evt.preventDefault();
evt.returnValue = "The report has not yet been submitted. Are you sure you want to leave?";
}
});
}
myselfButton.on("click", function () {
forSelf = true;
nextPage();
});
othersButton.on("click", function () {
forSelf = false;
nextPage();
});
});
// </nowiki>