प्रयोगकर्ता:SM7/stubsorter.js
पठन सेटिंग्स
टिप्पणी: संरक्षणक बाद, अहाँक परिवर्तन देखबा लेल अपन ब्राउजरक उपस्मृतिक हटबए पडत। फायरफक्स/ सफारी: सिफ्टके दाबि रिलोड, वा Ctrl-F5 वा Ctrl-R (म्याकपर ⌘-R) गुगल क्रोम: Ctrl-Shift-R दाबी(म्याकपर ⌘-Shift-R) इन्टरनेट एक्सप्लोरर: Refresh क्लिक करि Ctrl दाबि, वा Ctrl-F5 दाबी ओपेरा: Menu → Settings पर जाए (म्याकपर Opera → Preferences) आ ओकर बाद Privacy & security → Clear browsing data → Cached images and files
।
// Stub tag tab. Original version by [[:en:User:ais523]], on a request by [[:en:User:thesublime514]].
// Enhancements made on requests by [[:en:User:Alai]] and [[:en:User:jj137]].
// ([[:en:User:ais523/stubtagtab2.js]])
// Edited version [[:en:User:MC10/stubtagtab.js]]
// Modified and Localized for bh.wikipedia by [[User:SM7]] last Updated Sep 2018.
(function ($) { // Wrap with anonymous function
function stubTagTab() {
var $h, $hb, $newa,
// A list of subpages of WikiProject Stub sorting/Stub types/ that are relevant to this
a = ['Alpha', 'Categories'];
$h = $("<div></div>", { "id": "stubtagtab" })
.css({
"color": "#000000",
"background-color": "#fff8f8",
"text-align": "center"
});
for (var i = 0; i < a.length; i++) {
$newa = $("<a href=\"#\"></a>");
$newa.click(function (e) {
e.preventDefault();
stubTagMenu($(this).text());
});
$newa.text(a[i]);
$h.append($newa);
if ((i + 1) < a.length) {
$h.append(" • ");
}
}
$("#contentSub").append($h);
$hb = $("<div></div>", {
"color": "#000000",
"background-color": "#fffff8"
});
$hb.attr("id", "stubtagmenu");
$("#contentSub").append($hb);
}
function stubTagMenuRender(data) {
var $parseData = $(data.parse.text["*"]);
$parseData.find("a").each(function () {
var link = $(this).attr("href"),
index = link.indexOf("F:");
if (index === -1) {
$(this).attr({
"href": null,
"title": null
});
$(this).css({
"color": "#000000",
"text-decoration": "none"
});
} else {
$(this).attr("href", mw.config.get("wgServer") + mw.config.get("wgScript")
+ "?title=" + encodeURIComponent(mw.config.get("wgPageName"))
+ "&action=edit&autoaddstubtag=" + encodeURIComponent(link.slice(index + 2)));
}
});
$("#stubtagmenu").html($parseData);
}
function stubTagMenuFail() {
$("#stubtagmenu").html("Failed to load stub tags.");
}
function stubTagMenu(stubType) {
// Add loading message
$("#stubtagmenu").html("Loading stub tags, please wait...");
// Fetch the relevant subpage of the WikiProject
$.ajax({
url: mw.config.get("wgServer") + mw.config.get("wgScriptPath") + '/api.php?action=parse&prop=text&text=' + encodeURIComponent('__NOTOC____NOEDITSECTION__\{\{प्रयोगकर्ता:SM7/Stubtypes/' + stubType + '}}') + '&format=json',
dataType: "json",
success: stubTagMenuRender,
error: stubTagMenuFail
});
}
$(function () {
if (mw.config.get("wgNamespaceNumber") === 0 && mw.config.get("wgAction") === "view"
&& $("#ca-edit").length !== 0) {
var portletLink = mw.util.addPortletLink('p-cactions', '#', 'स्टब छँटाई', 'ca-stubtag', 'Add a stub tag to this page', '');
$(portletLink).click(function (e) {
e.preventDefault();
if (!$("#stubtagtab").length) {
stubTagTab();
}
});
}
if (location.href.indexOf("&autoaddstubtag=") !== -1 && $("#wpTextbox1").length !== 0) {
var x = decodeURIComponent(location.href.split("&autoaddstubtag=")[1]);
if (x.indexOf("-stub") === -1) {
x += "-stub";
}
var txt = document.editform.wpTextbox1; //Get text for replacing pre-existing stub tags
txt.value = txt.value.replace(/\{\{\s*([a-zA-Z0-9\u0900-\u097F]*-[a-zA-Z0-9\u0900-\u097F]*-)(आधार|stub)?\}\}\s*/ig, ""); //replace three syllable stubtags
txt.value = txt.value.replace(/\{\{\s*([a-zA-Z0-9\u0900-\u097F]*-)(आधार|stub)?\}\}\s*/ig, ""); //replace two syllable stubtags
txt.value = txt.value.replace(/\{\{\s*(आधार|stub)?\}\}\s*/ig, ""); //replace one syllable stubtags
$("#wpTextbox1").val($("#wpTextbox1").val() + "\n{" + "{" + x + "}}"); // add to the end of the article
$("#wpSummary").val("[[User:SM7/stubsorter|Stubsorter]] क मदद सँ {" + "{" + x + "}} जोड़ल गेल।");
$("#wpPreview").trigger("click");
}
});
} (jQuery)); // End wrap with anonymous function
// [[श्रेणी:विकिपिडिया स्क्रिप्ट]]