ব্যবহারকারী:Maruf/twinkle.js
অবয়ব
লক্ষ্য করুন: প্রকাশ করার পর, পরিবর্তনগুলো দেখতে আপনাকে আপনার ব্রাউজারের ক্যাশে পরিষ্কার করার প্রয়োজন হতে পারে।
- ফায়ারফক্স / সাফারি: পুনরায় লোড-এ ক্লিক করার সময় শিফট টিপে ধরে রাখুন, অথবা হয় Ctrl-F5 বা Ctrl-R টিপুন (ম্যাকে ⌘-R টিপুন)
- গুগল ক্রোম: Ctrl-Shift-R (ম্যাকে ⌘-Shift-R) টিপুন
- এজ: Ctrl ধরে রাখা অবস্থায় Refresh-এ ক্লিক করুন, অথবা Ctrl-F5 টিপুন।
- অপেরা: Ctrl-F5 টিপুন।
/**
* TwinkleLite module for MediaWiki
*
* This module loads the necessary scripts and initializes the Twinkle interface.
*
* @author মোহাম্মদ মারুফ
* @created 02 July, 2024
*
* @example
* To use this module, simply include it in your MediaWiki page.
* The Twinkle interface will be loaded automatically.
*
* @requires MediaWiki
* @requires jQuery
*/
TwinkleLite = window.TwinkleLite || {};
function load(name, type) {
mw.loader.load(
"/w/index.php?title=ব্যবহারকারী:মোহাম্মদ মারুফ/" +
name +
"&action=raw&ctype=" +
type,
type
);
}
/**
* Load the Morebits script
*
* @param {string} url - The URL of the script to load
* @param {string} type - The type of script to load (e.g. "text/javascript")
*/
load("morebits.js", "text/javascript");
/**
* Load the Tag script
*
* @param {string} url - The URL of the script to load
* @param {string} type - The type of script to load (e.g. "text/javascript")
*/
load("tag.js", "text/javascript");
/*
* Load stylesheet
*
* @param {string} url - The URL of the script to load
* @param {string} type - The type of script to load (e.g. "text/javascript")
*/
load("twinkleLite.css", "text/css");
//namespace of the page
const namespace = mw.config.get("wgNamespaceNumber");
var denoder;
/**
* Initialize the Twinkle interface
*
* This function is called when the Morebits script is loaded.
*
* @param {function} callback - The callback function to execute when the interface is initialized
*/
mw.loader.using(["jquery.ui"]).then(function () {
(function ($, mw) {
/**
* Twinkle module
*
* This module initializes the Twinkle interface and loads the necessary scripts.
*
* @param {object} $ - The jQuery object
* @param {object} mw - The MediaWiki object
*/
const skin = mw.config.get("skin");
const pagename = mw.config.get("wgPageName");
const user = mw.config.get("wgUserName");
var area = skin === "minerva" ? "p-personal" : "right-navigation";
/**
* Loop function to wait for the denoder variable to be set
*
* @param {function} callback - The callback function to execute when the denoder variable is set
*/
function loop(callback) {
if (!denoder) {
setTimeout(function () {
loop(callback);
}, 300);
} else {
callback();
}
}
/**
* Load the Morebits script and initialize the Twinkle interface
*
* @param {function} callback - The callback function to execute when the interface is initialized
*/
loop(function () {
if (skin)
loadMorebits((functions) => {
// Program goes from here
if (mw.config.get("wgAction") === "view") {
var button = $(
mw.util.addPortletLink(area, "#", "টুইংকেল", "twinkle", "টুইংকেল")
);
button.on("click", () => {
var text = "{{";
var usermsg = "";
var summery = "";
var dltcause = "";
var disscution = false;
TwinkleLite.twinkle((data) => {
if (data.type == "sdlist") {
text +=
"দ্রুঅপ|নীতিমালা=" +
data.array[0].id +
"|কারণ=" +
data.array[0].cause +
"}}\n";
usermsg =
"{{subst:" +
"অপ-নোটিশ|" +
pagename +
"|date={{subst:" +
"CURRENTDAY}} {{subst:" +
"CURRENTMONTHNAME}} {{subst:" +
"CURRENTYEAR" +
"}}" +
"}}~~" +
"~~";
summery =
pagename +
" পাতাটি দ্রুত অপসারণের জন্য মনোনীত হওয়ায় বার্তা প্রদান";
} else if (data.type == "dlist") {
text +=
"অপ|নীতিমালা=" +
data.array[0].id +
"|কারণ=" +
data.array[0].cause +
"}}\n";
summery =
pagename +
" পাতাটি অপসারণের জন্য মনোনীত হওয়ায় বার্তা প্রদান";
disscution = true;
dltcause = "পাতা" + data.array[0].cause;
usermsg = "{{subst:" + "অপ-নোটিশ|" + pagename + "}}~~" + "~~";
} else if (data.type == "tag") {
text = "";
for (i in data.array) {
text +=
"{{" +
data.array[i].title +
"|date={{subst:" +
"CURRENTMONTHNAME}} {{subst:" +
"CURRENTYEAR" +
"}}}}\n";
}
} else {
text += "অপসারণ|কারণ=" + data.array[0] + "}}\n";
summery =
pagename +
" পাতাটি অপসারণের জন্য মনোনীত হওয়ায় বার্তা প্রদান";
dltcause = "পাতা" + data.array[0];
disscution = true;
usermsg = "{{subst:" + "অপ-নোটিশ|" + pagename + "}}~~" + "~~";
}
functions.page.edit(
pagename,
{
pre: text,
},
(msg) => {
if (msg == "Success") {
if (usermsg) {
functions.page.getCreator(pagename, (creatordata) => {
var date = functions.tech.translateDate(
new Date(creatordata.timestamp)
);
TwinkleLite.manage(
`পাতাটি ব্যবহারকারী:${creatordata.creator}, ${date.day} ${date.month} ${date.year} তারিখে তৈরি করেছেন`
);
functions.page.edit(
"ব্যবহারকারী আলাপ:" + creatordata.creator,
{ post: usermsg },
(msg) => {
if (msg == "Success") {
TwinkleLite.manage(
`ব্যবহারকারী:${creatordata.creator} কে সফলভাবে বার্তা প্রদান করা হয়েছে।`
);
if (disscution) {
functions.page.create(
"উইকিউক্তি:অপসারণ প্রস্তাবনা/" + pagename,
(msg) => {
if (msg == "Success") {
var title = `উইকিউক্তি:অপসারণ প্রস্তাবনা/${pagename}`;
TwinkleLite.manage(
`আলোচনার জন্য <a title="${title}" href="/w/index.php?title=${title}" >${title}</a> পাতাটি তৈরি করা হয়েছে।`
);
}
functions.page.edit(
"উইকিউক্তি:অপসারণ প্রস্তাবনা/" +
date.year,
{
post:
"{{উইকিউক্তি:অপসারণ প্রস্তাবনা/" +
pagename +
"}}\n",
},
(msg) => {
if (msg == "Seccess")
location.reload();
else console.log(msg);
}
);
},
"== " +
pagename +
" ==\n" +
"{{la|" +
pagename +
"}}" +
dltcause +
"~~" +
"~~",
pagename +
"পাতাটির জন্য অপসারণ প্রস্তাবনা দেওয়া হচ্ছে"
);
} else {
location.reload();
}
} else {
console.log(msg);
}
},
""
);
});
} else {
console.log(usermsg);
}
} else {
console.log(msg);
}
},
summery
);
});
});
}
});
});
})(jQuery, mediaWiki);
});