ၽူႈၸႂ်ႉတိုဝ်း:Erutuon/scripts/addAutoCat.js
မၢႆတွင်း: ဝၢႆးသေသိမ်းပၼ်ယဝ်ႉ၊ တွၼ်ႈတႃႇ ၸဝ်ႈၵဝ်ႇ တေႁၼ်လႆႈ လွင်ႈလႅၵ်ႈလၢႆႈၼၼ်ႉ ၸဝ်ႈၵဝ်ႇတေၸၢင်ႈလႆႈလတ်းၶၢမ်ႈ ၶႅတ်ႉၶျ် တူဝ်ပိုတ်ႇဝႅပ်ႉၸဝ်ႈၵဝ်ႇယဝ်ႉ။
- ၽွင်းမိူဝ်ႈတိုၵ်ႉၼဵၵ်း Reload တီႈ Firefox / Safari: ၼၼ်ႉ ၼဵၵ်းဝႆႉပႃး Shift ၊ဢမ်ႇၼၼ် ၼဵၵ်းပၼ် Ctrl-F5 ဢမ်ႇၼၼ် Ctrl-R (တီႈၼႂ်း Mac ၼႆ ၼဵၵ်းပၼ်⌘-R)
- တီႈၼႂ်း Google Chrome: ၼဵၵ်းပၼ် Ctrl-Shift-R (တီႈၼႂ်း Mac ၼႆႉ ၼဵၵ်းပၼ်⌘-Shift-R )
- ၽွင်းမိူဝ်ႈ တိုၵ်ႉၼဵၵ်း Refreshတီႈ Internet Explorer/ Edge: ၼဵၵ်းဝႆႉပၼ် Ctrl ဢမ်ႇၼၼ် ၼဵၵ်းပၼ် Ctrl-F5
- တီႈၼႂ်း Opera: ၵႂႃႇၸူးတီႈ Menu → Settings (ပေႃးပဵၼ်တီႈၼႂ်း Mac ၸိုင် Opera → Preferences ) သေ သိုပ်ႇၵႂႃႇ Privacy & security → Clear browsing data → Cached images and files ၼၼ်ႉလႄႈ။
/* jshint esversion: 6, undef: true, unused: true, varstmt: true */
/* globals $, mw, OO */
// <nowiki>
(function addAutoCatIIFE () {
"use strict";
if (mw.config.get("wgNamespaceNumber") !== 14)
return;
const autoCatEditSummary = typeof window.autoCatEditSummary == "undefined"
? false : window.autoCatEditSummary;
const $textBox = $("#wpTextbox1");
const $editSummaryBox = $("#wpSummary");
function fillAutoCat(autoSave) {
$textBox.val("{{auto cat}}");
if ( autoCatEditSummary )
$editSummaryBox.val("added [[T:auto cat]] with [[User:Erutuon/scripts/addAutoCat.js|JavaScript]]");
$(autoSave ? "#wpSave" : "#wpPreview").click();
}
const action = mw.config.get("wgAction");
mw.loader.using("oojs-ui").done(() => {
if (mw.config.get("wgCurRevisionId") === 0) { // new page
$(() => {
const buttons = [];
if (action === "edit") {
const button1 = new OO.ui.ButtonWidget({
label: "Add auto cat and save",
});
const button2 = new OO.ui.ButtonWidget({
label: "or preview",
});
button1.$element
.click(() => fillAutoCat(true))
.attr("title", "Create this category using topic cat");
button2.$element
.click(() => fillAutoCat(false))
.attr("title", "Create this category using topic cat");
buttons.push(button1.$element);
buttons.push(button2.$element);
} else if (action === "view") {
const button = new OO.ui.ButtonWidget({
label: "Add auto cat and edit",
});
button.$element.click(() => {
location.href = new mw.Uri(location.href).extend({
action: "edit",
preloadtext: "{{autocat}}",
}).toString();
});
buttons.push(button.$element);
}
if (buttons.length > 0) {
const div = $("<div>").append(buttons);
$("#firstHeading").after(div);
}
});
} else if (action === "edit" && !$textBox.val().includes("auto cat")) {
$(() => {
const button = new OO.ui.ButtonWidget({
label: "Replace with autocat",
id: "add-autocat",
});
button.$element.click(() => $textBox.val("{{auto cat}}"));
$("#editform").prepend(button.$element);
});
}
});
})();
// </nowiki>