User:Microsoft for POTUS/vector.js/icu.js/unminified.js
< User:Microsoft for POTUS | vector.js | icu.js
Jump to navigation
Jump to search
Note: After saving, you have to bypass your browser's cache to see the changes.
- Internet Explorer: hold down the Ctrl key and click the Refresh or Reload button, or press Ctrl+F5.
- Firefox: hold down the Shift key while clicking Reload; alternatively press Ctrl+F5 or Ctrl-Shift-R.
- Opera, Konqueror and Safari users can just click the Reload button.
- Chrome: press Ctrl+F5 or Shift+F5
if (
(mw.config.values.wgUserGroups.includes("extendedconfirmed") ||
mw.config.values.wgUserGroups.includes("rollback") ||
mw.config.values.wgUserGroups.includes("sysop")) &&
document.querySelectorAll("#ca-icu").length == 0 && // prevent duplication, mainly for me, because the site-wide vector.js code also happens to be my personal vector.js code
mw.config.values.wgNamespaceNumber != -1 // do not want this on special pages
) {
mw.loader.using("oojs-ui-core").done(function () {
if (document.querySelectorAll("#ca-icu").length != 0) return;
$(function () {
var dropDown = new OO.ui.DropdownWidget({
label: "Select an option",
menu: {
items: [
new OO.ui.MenuOptionWidget({
data: "random",
label: "The truth is funnier than nonsense",
}),
new OO.ui.MenuOptionWidget({
data: "format",
label: "Very poorly formatted",
}),
new OO.ui.MenuOptionWidget({
data: "short",
label: "Very short",
}),
new OO.ui.MenuOptionWidget({
data: "notfunny",
label: "Not funny",
}),
new OO.ui.MenuOptionWidget({
data: "list",
label: "Random lists are not funny",
}),
new OO.ui.MenuOptionWidget({
data: "encyclopedic",
label: "This does not look like an article parodying Wikipedia",
}),
],
},
});
itemSelected = function (value) {
swal.close();
loadingDialog = document.createElement("p");
loadingDialog.innerHTML =
'<span style="margin-right:8px;"><img src="https://images.uncyclomedia.co/uncyclopedia/en/4/42/Loading.gif"></span><span>Adding template...</span>';
swal({ content: loadingDialog, buttons: {} });
new mw.Api()
.edit(mw.config.values.wgPageName, function (revision) {
return {
text:
revision.content +
`{{ICU|${atob("fn5+fn4=")}|sub=${value.data}}}`, // the atob is because you can't add the time signature in mediawiki code without breaking it
summary: "Adding an [[ICU]] tag",
minor: true,
};
})
.then(function () {
swal("Done. Would you like to refresh this page?", {
buttons: {
yes: "Yes",
no: "No",
},
}).then(function (value) {
if (value == "yes") {
location.reload();
}
});
});
};
dropDown.getMenu().on("select", itemSelected);
icuActionButton = document.createElement("li");
icuActionButton.innerHTML = '<a title="Mark for ICU">Mark for ICU</a>';
icuActionButton.id = "ca-icu";
icuActionButton.onclick = function () {
swal({
text: "Select a reason from the dropdown to add an ICU tag, or press cancel to cancel and close the dialog",
content: dropDown.$element[0],
buttons: {
cancel: true,
confirm: false,
},
});
};
if (document.querySelectorAll("#ca-icu").length == 0) {
document
.querySelector(
"#p-cactions > .body.vector-menu-content > .menu.vector-menu-content-list"
)
.append(icuActionButton);
}
});
});
}