मीडियाविकि:Gadget-friendlystubtag.js
नोट: प्रकाशित करे के बाद, बदलाव देखे खातिर आपके अपने ब्राउजर के कैशे खाली करे के पड़ सकत बा।
- फायरफॉक्स / सफारी:शिफ्ट दबा के रीलोड पर क्लिक करीं, या फिर Ctrl-F5 या Ctrl-R दबाईं (मैक पर ⌘-R)
- गूगल क्रोम: Ctrl-Shift-R दबाईं (मैक पर ⌘-Shift-R)
- इंटरनेट एक्स्प्लोरर/एज़: Ctrl दबा के Refresh पर क्लिक करीं, या Ctrl-F5 दबईं
- ओपेरा: Menu → Settings में जाईं (मैक में Opera → Preferences) आ एकरे बाद Privacy & security → Clear browsing data → Cached images and files क्लिक करीं।
//<nowiki>
(function($){
/*
****************************************
*** friendlystubtag.js: stubtag module
****************************************
* Mode of invocation: Tab ("stubtag")
* Active on: Existing articles; file pages with a corresponding file
* which is local (not on Commons); existing subpages of
* {Wikipedia|Wikipedia talk}:Articles for creation;
* all redirects
* Config directives in: FriendlyConfig
*/
Twinkle.stubtag = function friendlystubtag() {
// redirect stubtagging
// article/draft article stubtagging
Twinkle.stubtag.mode = 'लेख';
Twinkle.addPortletLink( Twinkle.stubtag.callback, "आधारटैग", "friendly-stubtag", "लेख में आधारटैग जोड़ीं");
};
Twinkle.stubtag.callback = function friendlystubtagCallback() {
var Window = new Morebits.simpleWindow( 630, (Twinkle.stubtag.mode === "लेख") ? 500 : 400 );
Window.setScriptName( "ट्विंकल" );
// anyone got a good policy/guideline/info page/instructional page link??
Window.addFooterLink( "ट्विंकल मदद", "WP:TW/DOC#stubtag" );
var form = new Morebits.quickForm( Twinkle.stubtag.callback.evaluate );
if (document.getElementsByClassName("patrollink").length) {
form.append( {
type: 'checkbox',
list: [
{
label: 'पन्ना के जाँचल चिन्हित करीं',
value: 'patrolPage',
name: 'patrolPage',
checked: Twinkle.getFriendlyPref('markstubtaggedPagesAsPatrolled')
}
]
} );
}
switch( Twinkle.stubtag.mode ) {
case 'लेख':
Window.setTitle( "लेख रखरखाव आधारटैग जोड़ल" );
form.append({
type: 'select',
name: 'sortorder',
label: 'एह लिस्ट के देखे के तरीका बीछीं:',
tooltip: 'आप एह लिस्ट सभ के देखे के तरीका के डिफॉल्ट सेटिंग अपना ट्विंकल पसंदसेटिंग (WP:TWPREFS) में जा के बदल सकत बानी।',
event: Twinkle.stubtag.updateSortOrder,
list: [
{ type: 'option', value: 'cat', label: 'बिसय अनुसार बाँट के देखावल लिस्ट', selected: Twinkle.getFriendlyPref('stubtagArticleSortOrder') === 'cat' },
{ type: 'option', value: 'alpha', label: 'अच्छर के क्रम में देखावल लिस्ट', selected: Twinkle.getFriendlyPref('stubtagArticleSortOrder') === 'alpha' }
]
});
form.append({
type: 'div',
id: 'stubtagWorkArea',
className: 'morebits-scrollbox',
style: 'max-height: 28em'
});
form.append( {
type: 'checkbox',
list: [
{
label: 'अगर एक से बेसी आधार टैग जोड़े के होखे, बक्सा चेक करीं। तीन से ढेर टैग ना जोड़ल जा सकत बा।',
value: 'group',
name: 'group',
tooltip: 'अगर एक्के साथ कई गो आधार टैग जोड़ब तब एह बक्सा में सही के निशान (चेक) रही तबे कौनों कार्रवाई होखी।',
checked: Twinkle.getFriendlyPref('groupByDefault')
}
]
}
);
break;
default:
alert("Twinkle.stubtag: unknown mode " + Twinkle.stubtag.mode);
break;
}
form.append( { type:'submit' } );
var result = form.render();
Window.setContent( result );
Window.display();
if (Twinkle.stubtag.mode === "लेख") {
// fake a change event on the sort dropdown, to initialize the stubtag list
var evt = document.createEvent("Event");
evt.initEvent("change", true, true);
result.sortorder.dispatchEvent(evt);
}
};
Twinkle.stubtag.checkedstubtags = [];
Twinkle.stubtag.updateSortOrder = function(e) {
var sortorder = e.target.value;
Twinkle.stubtag.checkedstubtags = e.target.form.getChecked("articlestubtags");
if (!Twinkle.stubtag.checkedstubtags) {
Twinkle.stubtag.checkedstubtags = [];
}
var container = new Morebits.quickForm.element({ type: "fragment" });
// function to generate a checkbox, with appropriate subgroup if needed
var makeCheckbox = function(stubtag, description) {
var checkbox = { value: stubtag, label: "{{" + stubtag + "}}: " + description };
if (Twinkle.stubtag.checkedstubtags.indexOf(stubtag) !== -1) {
checkbox.checked = true;
}
switch (stubtag) {
case "stub":
checkbox.subgroup = {
name: 'stub',
type: 'input',
label: 'Specific stubtag is needed: ',
tooltip: 'Required.',
size: 35
};
break;
default:
break;
}
return checkbox;
};
// categorical sort order
if (sortorder === "cat") {
// function to iterate through the stubtags and create a checkbox for each one
var doCategoryCheckboxes = function(subdiv, array) {
var checkboxes = [];
$.each(array, function(k, stubtag) {
var description = Twinkle.stubtag.article.stubtags[stubtag];
checkboxes.push(makeCheckbox(stubtag, description));
});
subdiv.append({
type: "checkbox",
name: "articlestubtags",
list: checkboxes
});
};
var i = 0;
// go through each category and sub-category and append lists of checkboxes
$.each(Twinkle.stubtag.article.stubtagCategories, function(title, content) {
container.append({ type: "header", id: "stubtagHeader" + i, label: title });
var subdiv = container.append({ type: "div", id: "stubtagSubdiv" + i++ });
if ($.isArray(content)) {
doCategoryCheckboxes(subdiv, content);
} else {
$.each(content, function(subtitle, subcontent) {
subdiv.append({ type: "div", label: [ Morebits.htmlNode("b", subtitle) ] });
doCategoryCheckboxes(subdiv, subcontent);
});
}
});
}
// alphabetical sort order
else {
var checkboxes = [];
$.each(Twinkle.stubtag.article.stubtags, function(stubtag, description) {
checkboxes.push(makeCheckbox(stubtag, description));
});
container.append({
type: "checkbox",
name: "articlestubtags",
list: checkboxes
});
}
// append any custom stubtags
if (Twinkle.getFriendlyPref('customstubtagList').length) {
container.append({ type: 'header', label: 'निजी पसंद अनुसार टैग' });
container.append({ type: 'checkbox', name: 'articlestubtags', list: Twinkle.getFriendlyPref('customstubtagList') });
}
var $workarea = $(e.target.form).find("div#stubtagWorkArea");
var rendered = container.render();
$workarea.empty().append(rendered);
// style adjustments
$workarea.find("h5").css({ 'font-size': '110%' });
$workarea.find("h5:not(:first-child)").css({ 'margin-top': '1em' });
$workarea.find("div").filter(":has(span.quickformDescription)").css({ 'margin-top': '0.4em' });
// add a link to each template's description page
$.each(Morebits.quickForm.getElements(e.target.form, "articlestubtags"), function(index, checkbox) {
var $checkbox = $(checkbox);
var link = Morebits.htmlNode("a", ">");
link.setAttribute("class", "stubtag-template-link");
link.setAttribute("href", mw.util.getUrl("Template:" +
Morebits.string.toUpperCaseFirstChar(checkbox.values)));
link.setAttribute("target", "_blank");
$checkbox.parent().append(["\u00A0", link]);
});
};
// stubtags for ARTICLES start here
Twinkle.stubtag.article = {};
// A list of all article stubtags, in alphabetical order
// To ensure stubtags appear in the default "categorized" view, add them to the stubtagCategories hash below.
Twinkle.stubtag.article.stubtags = {
"geo-stub": "1. भूगोल बिसय भा, 2. कौनों अइसन जगह से संबंधित लेख जेकरे लायक जगह अनुसार खास कौनों टैग न मिले",
"india-stub": "भारत से संबंधित लेख",
"bio-stub": "जीवनी से संबंधित लेख"
};
// A list of stubtags in order of category
// stubtags should be in alphabetical order within the categories
// Add new categories with discretion - the list is long enough as is!
Twinkle.stubtag.article.stubtagCategories = {
"भूगोल अउरी जगह से संबंधित": {
"भारत के जगह संबंधित": [
"UP-geo-stub", // has a subgroup with text input
"Bihar-geo-stub" // has a subgroup with text input
],
"भूगोल बिसय से संबंधित": [
"Geomorphology-stub",
"Climate-stub", // has a subgroup with text input
]
},
"लोग आ लोगन के जीवनी संबंधित": {
"पेशा अनुसार": [
"actor-stub",
"poet-stub",
"philosopher-stub",
"singer-stub",
"writer-stub" // has a subgroup with subcategories
],
"जब ऊपर वालन में से कौनों लागू न होखे": [
"bio-stub"
]
},
"साहित्य, किताब, कला आ दर्शन संबंधी": {
"Language and literature": [
"lang-stub", // has a subgroup with several options
"book-stub", // has a subgroup with several options
"writer-stub"
]
},
};
Twinkle.stubtag.callbacks = {
main: function( pageobj ) {
var params = pageobj.getCallbackParameters(),
stubtagRe, stubtagText = '', summaryText = 'आधार टैग',
stubtags = [], groupablestubtags = [], i, totalstubtags;
// Remove stubtags that become superfluous with this action
var pageText = pageobj.getPageText().replace(/\{\{\s*([Nn]ew unreviewed article|[Uu]nreviewed|[Uu]serspace draft|[Ss]tub)\s*(\|(?:\{\{[^{}]*\}\}|[^{}])*)?\}\}\s*/g, "");
var addstubtag = function friendlystubtagAddstubtag( stubtagIndex, stubtagName ) {
var currentstubtag = "";
pageText += '\n\n{{' + stubtagName + '}}';
if ( stubtagIndex > 0 ) {
if( stubtagIndex === (totalstubtags - 1) ) {
summaryText += ' आ';
} else if ( stubtagIndex < (totalstubtags - 1) ) {
summaryText += ',';
}
}
summaryText += ' {{[[';
summaryText += (stubtagName.indexOf(":") !== -1 ? stubtagName : ("टेम्पलेट:" + stubtagName + "|" + stubtagName));
summaryText += ']]}}';
};
if( Twinkle.stubtag.mode !== 'redirect' ) {
// Check for preexisting stubtags and separate stubtags into groupable and non-groupable arrays
for( i = 0; i < params.stubtags.length; i++ ) {
stubtagRe = new RegExp( '(\\{\\{' + params.stubtags[i] + '(\\||\\}\\})|\\|\\s*' + params.stubtags[i] + '\\s*=[a-z ]+\\d+)', 'im' );
if( !stubtagRe.exec( pageText ) ) {
stubtags = stubtags.concat( params.stubtags[i] );
} else {
Morebits.status.warn( 'जानकारी', 'पहिलहीं से {{' + params.stubtags[i] +
'}} लेख में मौजूद बा...छोड़ल जा रहल बा' );
}
}
var miTest = /\{\{(multiple ?issues|article ?issues|mi)[^}]+\{/im.exec(pageText);
var miOldStyleRegex = /\{\{(multiple ?issues|article ?issues|mi)\s*\|([^{]+)\}\}/im;
var miOldStyleTest = miOldStyleRegex.exec(pageText);
stubtags = stubtags.concat( groupablestubtags );
} else {
// Redirect stubtagging: Check for pre-existing stubtags
for( i = 0; i < params.stubtags.length; i++ ) {
stubtagRe = new RegExp( '(\\{\\{' + params.stubtags[i] + '(\\||\\}\\}))', 'im' );
if( !stubtagRe.exec( pageText ) ) {
stubtags = stubtags.concat( params.stubtags[i] );
} else {
Morebits.status.warn( 'Info', 'Found {{' + params.stubtags[i] +
'}} on the redirect already...excluding' );
}
}
}
stubtags.sort();
totalstubtags = stubtags.length;
$.each(stubtags, addstubtag);
if( Twinkle.stubtag.mode === 'redirect' ) {
pageText += stubtagText;
} else {
// smartly insert the new stubtags after any hatnotes. Regex is a bit more
// complicated than it'd need to be, to allow templates as parameters,
// and to handle whitespace properly.
pageText = pageText.replace(/^\s*(?:((?:\s*\{\{\s*(?:about|correct title|dablink|distinguish|for|other\s?(?:hurricaneuses|people|persons|places|uses(?:of)?)|redirect(?:-acronym)?|see\s?(?:also|wiktionary)|selfref|the)\d*\s*(\|(?:\{\{[^{}]*\}\}|[^{}])*)?\}\})+(?:\s*\n)?)\s*)?/i,
"$1" + stubtagText);
}
summaryText += ( stubtags.length > 0 ? ' जोड़ल' + ( stubtags.length > 1 ? ' गइलें' : ' गइल' ) : ' गइल' );
// avoid truncated summaries
if (summaryText.length > (254 - Twinkle.getPref('summaryAd').length)) {
summaryText = summaryText.replace(/\[\[[^\|]+\|([^\]]+)\]\]/g, "$1");
}
pageobj.setPageText(pageText);
pageobj.setEditSummary(summaryText + Twinkle.getPref('summaryAd'));
pageobj.setWatchlist(Twinkle.getFriendlyPref('watchstubtaggedPages'));
pageobj.setMinorEdit(Twinkle.getFriendlyPref('markstubtaggedPagesAsMinor'));
pageobj.setCreateOption('nocreate');
pageobj.save(function() {
// special functions for merge stubtags
});
if( params.patrol ) {
pageobj.patrol();
}
},
};
Twinkle.stubtag.callback.evaluate = function friendlystubtagCallbackEvaluate(e) {
var form = e.target;
var params = {};
if (form.patrolPage) {
params.patrol = form.patrolPage.checked;
}
switch (Twinkle.stubtag.mode) {
case 'लेख':
params.stubtags = form.getChecked( 'articlestubtags' );
params.group = form.group.checked;
params.stubtagParameters = {
notability: form["articlestubtags.notability"] ? form["articlestubtags.notability"].value : null
};
break;
case 'redirect':
alert("Twinkle.stubtag: धियान दीं, अनुप्रेषण पन्ना पर आधार टैग ना जोड़ल जाला " + Twinkle.stubtag.mode);
break;
default:
alert("Twinkle.stubtag: unknown mode " + Twinkle.stubtag.mode);
break;
}
// form validation
if( !params.stubtags.length ) {
alert( 'आपके कम से कम एक ठो आधार टैग बीछे के पड़ी!' );
return;
}
// form validation
if( params.stubtags.length >=4) {
alert( 'तीन गो से अधिका आधार टैग ना जोड़ल जा सके ला!' );
return;
}
Morebits.simpleWindow.setButtonsEnabled( false );
Morebits.status.init( form );
Morebits.wiki.actionCompleted.redirect = Morebits.pageNameNorm;
Morebits.wiki.actionCompleted.notice = "आधार टैगिंग पूरा भइल, कुछे सेकेंड में लेख दोबारा लोड होखी";
var wikipedia_page = new Morebits.wiki.page(Morebits.pageNameNorm, "लेख के आधार टैगिंग");
wikipedia_page.setCallbackParameters(params);
switch (Twinkle.stubtag.mode) {
case 'लेख':
/* falls through */
case 'article':
/* falls through */
case 'redirect':
wikipedia_page.load(Twinkle.stubtag.callbacks.main);
return;
case 'file':
wikipedia_page.load(Twinkle.stubtag.callbacks.file);
return;
default:
alert("Twinkle.stubtag: unknown mode " + Twinkle.stubtag.mode);
break;
}
};
})(jQuery);
//</nowiki>