"मेडियाविकि:Gadget-Twinkle.js" के अवतरणसभमे अन्तर

Content deleted Content added
Updating per enwiki to fix (Repo at 17d664f)
Updating per enwiki to fix (Repo at 17d664f)
पङ्क्त्ति ३:
* | === WARNING: GLOBAL GADGET FILE === |
* | Changes to this page affect many users. |
* | Please discuss changes at [[विWT:ट्विङ्कलTW]] before editing. |
* +-------------------------------------------------------------------------+
*
* Imported from github [https://github.com/azatoth/twinkle].
* All changes should be made in the repository, otherwise they will be lost.
*
* To update this script from github, you must have a local repository set up. Then
* follow the instructions at [https://github.com/azatoth/twinkle/blob/master/README.md].
*
* ----------
*
* This is AzaToth's Twinkle, the popular script sidekick for newbies, admins, and
* every Wikipedian in between. Visit [[विWP:ट्विङ्कलTW]] for more information.
*/
// <nowiki>
 
//<nowiki>
/* global Morebits */
 
( function ( window, document, $, undefined ) { // Wrap with anonymous function
 
// Check if account is experienced enough to use Twinkle
if (!Morebits.userIsInGroup('autoconfirmed') && !Morebits.userIsInGroup('confirmed')) {
return;
}
 
var Twinkle = {};
window.Twinkle = Twinkle; // allow global access
 
// Check if account is experienced enough to use Twinkle
Twinkle.userAuthorized = Morebits.userIsInGroup( "autoconfirmed" ) || Morebits.userIsInGroup( "confirmed" );
 
// for use by custom modules (normally empty)
Twinkle.initCallbacks = [];
Twinkle.addInitCallback = function twinkleAddInitCallback( func ) {
Twinkle.initCallbacks.push( func );
};
 
Twinkle.defaultConfig = {};
/**
* Twinkle.defaultConfig.twinkle and Twinkle.defaultConfig.friendly
* This holds the default set of preferences used by Twinkle.
*
* This holds the default set of preferences used by Twinkle. (The |friendly| object holds preferences stored in the FriendlyConfig object.)
* It is important that all new preferences added here, especially admin-only ones, are also added to
* |Twinkle.config.sections| in twinkleconfig.js, so they are configurable via the Twinkle preferences panel.
* For help on the actual preferences, see the comments in twinkleconfig.js.
*
* Formerly Twinkle.defaultConfig.twinkle and Twinkle.defaultConfig.friendly
*/
Twinkle.defaultConfig.twinkle = {
// General
summaryAd: '" ([[विविकिपिडिया:ट्विङ्कल|ट्विङ्कलTW]])'",
deletionSummaryAd: '" ([[विWP:ट्विङ्कलTW|ट्विङ्कलTW]])'",
protectionSummaryAd: '" ([[विWP:ट्विङ्कलTW|ट्विङ्कलTW]])'",
userTalkPageMode: 'tab'"window",
dialogLargeFont: false,
// ARV
disabledModules: [],
spiWatchReport: "yes",
disabledSysopModules: [],
// Fluff (revert and rollback)
 
openTalkPage: [ "agf", "norm", "vand" ],
// ARV
spiWatchReport: 'yes',
 
// Block
defaultToPartialBlocks: false,
blankTalkpageOnIndefBlock: false,
 
// Fluff (revert and rollback)
autoMenuAfterRollback: false,
openTalkPage: [ 'agf', 'norm', 'vand' ],
openTalkPageOnAutoRevert: false,
markRevertedPagesAsMinor: [ '"vand'" ],
watchRevertedPages: [ '"agf'", '"norm'", '"vand'", '"torev'" ],
offerReasonOnNormalRevert: true,
confirmOnFluff: false,
showRollbackLinks: [ '"diff'", '"others'" ],
// DI (twinkleimage)
 
// DI (twinkleimage)
notifyUserOnDeli: true,
deliWatchPage: '"default'",
deliWatchUser: '"default'",
// PROD
 
// पीआरओडी
watchProdPages: true,
prodReasonDefault: "",
markProdPagesAsPatrolled: false,
prodReasonDefault: '',
logProdPages: false,
prodLogPageName: 'पीआरओडी"PROD लग'log",
// CSD
 
speedySelectionStyle: "buttonClick",
// शीमे
watchSpeedyPages: [ "व3", "व4", "व6", "व6ल", "व6स", "व6फ" ],
speedySelectionStyle: 'buttonClick',
markSpeedyPagesAsPatrolled: true,
watchSpeedyPages: [ 'सा३', 'सा५', 'सा१०', 'सा११', 'सा१२' ],
markSpeedyPagesAsPatrolled: false,
 
// these next two should probably be identical by default
notifyUserOnSpeedyDeletionNomination: [ "शिमे", "व1", "व2", "व3", "व4", "व5", "व6", "ल1", "ल2", "ल4", "व6ल", "फ1", "फ2", "फ3", "फ4", "फ5", "फ6", "व6फ", "सा1", "स2", "व6स" ],
welcomeUserOnSpeedyDeletionNotification: [ 'शीमे', 'सा१', 'सा२', 'सा३', 'सा४', 'सा६', 'सा१०', 'सा११', 'सा१२', 'सा१३', 'सा१४', 'ले१', 'ले२', 'ले३', 'ले५', 'ले७', 'ले९', 'ले१०', 'ले११', 'फा१', 'फा२', 'फा३', 'फा७', 'फा९', 'फा१०', 'प्र३', 'प्र५', 'ढाँ२', 'ढाँ३', 'पो१', 'पो२' ],
welcomeUserOnSpeedyDeletionNotification: [ "शिमे", "व1", "व2", "व3", "व4", "व5", "व6", "ल1", "ल2", "ल4", "व6ल", "फ1", "फ2", "फ3", "फ4", "फ5", "फ6", "व6फ", "सा1", "स2", "व6स" ],
notifyUserOnSpeedyDeletionNomination: [ 'शीमे', 'सा१', 'सा२', 'सा३', 'सा४', 'सा६', 'सा१०', 'सा११', 'सा१२', 'सा१३', 'सा१४', 'ले१', 'ले२', 'ले३', 'ले५', 'ले७', 'ले९', 'ले१०', 'ले११', 'फा१', 'फा२', 'फा३', 'फा७', 'फा९', 'फा१०', 'प्र३', 'प्र५', 'ढाँ२', 'ढाँ३', 'पो१', 'पो२' ],
promptForSpeedyDeletionSummary: [ "db", "g1", "g2", "g3", "g4", "g6", "g7", "g8", "g10", "g11", "g12", "a1", "a2", "a3", "a5", "a7", "a9", "a10", "a11", "f2", "f4", "f7", "f8", "f10", "u5", "t2", "t3", "p1", "p2" ],
warnUserOnSpeedyDelete: [ 'शीमे', 'सा१', 'सा२', 'सा३', 'सा४', 'सा६', 'सा१०', 'सा११', 'सा१२', 'सा१३', 'सा१४', 'ले१', 'ले२', 'ले३', 'ले५', 'ले७', 'ले९', 'ले१०', 'ले११', 'फा१', 'फा२', 'फा३', 'फा७', 'फा९', 'फा१०', 'प्र३', 'प्र५', 'ढाँ२', 'ढाँ३', 'पो१', 'पो२' ],
openUserTalkPageOnSpeedyDelete: [ "शिमे", "व1", "व2", "व3", "व4", "व5", "व6", "ल1", "ल2", "ल4", "व6ल", "फ1", "फ2", "फ3", "फ4", "फ5", "फ6", "व6फ", "सा1", "स2", "व6स" ],
promptForSpeedyDeletionSummary: [],
deleteTalkPageOnDelete: truefalse,
deleteRedirectsOnDelete: true,
deleteSysopDefaultToDeletedeleteSysopDefaultToTag: false,
speedyWindowHeight: 500,
speedyWindowWidth: 800,
logSpeedyNominations: false,
speedyLogPageName: 'शीमे"शिमे लग'",
noLogOnSpeedyNomination: [ 'प्र१'"स1" ],
// Unlink
 
unlinkNamespaces: [ "0", "10", "100", "118" ],
// Unlink
// Warn
unlinkNamespaces: [ '0', '10', '100', '118' ],
defaultWarningGroup: "1",
 
// Warn
defaultWarningGroup: '1',
combinedSingletMenus: false,
showSharedIPNotice: true,
watchWarnings: true,
oldSelectblankTalkpageOnIndefBlock: false,
customWarningList: [],
// XfD
 
xfdWatchDiscussion: "default",
// XfD
xfdWatchList: "no",
xfdWatchDiscussion: 'default',
xfdWatchPage: "default",
xfdWatchList: 'no',
xfdWatchPagexfdWatchUser: '"default'",
// Hidden preferences
xfdWatchUser: 'default',
xfdWatchRelated: 'default',
markXfdPagesAsPatrolled: true,
 
// Hidden preferences
revertMaxRevisions: 50,
batchdeleteChunks: 50,
batchDeleteMinCutOff: 5,
batchMax: 5000,
batchdeleteChunks: 50,
batchProtectChunks: 50,
batchProtectMinCutOff: 5,
batchundeleteChunks: 50,
batchUndeleteMinCutOff: 5,
proddeleteChunks: 50,
deliChunks: 500,
deliMax: 5000,
proddeleteChunks: 50
};
 
// now some skin dependent config.
// Formerly defaultConfig.friendly:
if ( mw.config.get( "skin" ) === "vector" ) {
Twinkle.defaultConfig.twinkle.portletArea = "right-navigation";
Twinkle.defaultConfig.twinkle.portletId = "p-twinkle";
Twinkle.defaultConfig.twinkle.portletName = "TW";
Twinkle.defaultConfig.twinkle.portletType = "menu";
Twinkle.defaultConfig.twinkle.portletNext = "p-search";
} else {
Twinkle.defaultConfig.twinkle.portletArea = null;
Twinkle.defaultConfig.twinkle.portletId = "p-cactions";
Twinkle.defaultConfig.twinkle.portletName = null;
Twinkle.defaultConfig.twinkle.portletType = null;
Twinkle.defaultConfig.twinkle.portletNext = null;
}
 
Twinkle.defaultConfig.friendly = {
// Tag
// Tag
groupByDefault: true,
watchTaggedPages: true,
Line १३६ ⟶ १३५:
markTaggedPagesAsMinor: false,
markTaggedPagesAsPatrolled: true,
tagArticleSortOrder: '"cat'",
customTagList: [],
// Welcome
customFileTagList: [],
customRedirectTagList: [],
 
// Welcome
topWelcomes: false,
watchWelcomes: true,
welcomeHeading: 'स्वागतम्'"स्वागत",
insertHeadings: true,
insertUsername: true,
insertSignature: true, // sign welcome templates, where appropriate
quickWelcomeMode: '"norm'",
quickWelcomeTemplate: '"welcome'",
customWelcomeList: [],
customWelcomeSignature: true,
// Talkback
 
// Talkback
markTalkbackAsMinor: true,
insertTalkbackSignature: true, // always sign talkback templates
talkbackHeading: 'नयाँ "सन्देश ' + mw.config.get('wgUserName')",
adminNoticeHeading: 'सूचना'"Notice",
mailHeading: "तपाईँलाईYou've चिठीgot पत्र छmail!",
// Shared
 
// Shared
markSharedIPAsMinor: true
};
 
Twinkle.getPref = function twinkleGetPref( name ) {
// now some skin dependent config.
var result;
switch (mw.config.get('skin')) {
if ( typeof Twinkle.prefs === "object" && typeof Twinkle.prefs.twinkle === "object" ) {
case 'vector':
// look in Twinkle.prefs (twinkleoptions.js)
Twinkle.defaultConfig.portletArea = 'right-navigation';
Twinkle.defaultConfig.portletIdresult = 'p-Twinkle.prefs.twinkle'[name];
} else if ( typeof window.TwinkleConfig === "object" ) {
Twinkle.defaultConfig.portletName = 'ट्विङ्कल';
// look in TwinkleConfig
Twinkle.defaultConfig.portletType = 'menu';
result = window.TwinkleConfig[name];
Twinkle.defaultConfig.portletNext = 'p-search';
}
break;
case 'timeless':
Twinkle.defaultConfig.portletArea = '#page-tools .sidebar-inner';
Twinkle.defaultConfig.portletId = 'p-twinkle';
Twinkle.defaultConfig.portletName = 'ट्विङ्कल';
Twinkle.defaultConfig.portletType = null;
Twinkle.defaultConfig.portletNext = 'p-userpagetools';
break;
default:
Twinkle.defaultConfig.portletArea = null;
Twinkle.defaultConfig.portletId = 'p-cactions';
Twinkle.defaultConfig.portletName = null;
Twinkle.defaultConfig.portletType = null;
Twinkle.defaultConfig.portletNext = null;
}
 
if ( result === undefined ) {
return Twinkle.defaultConfig.twinkle[name];
}
return result;
};
 
Twinkle.getPrefgetFriendlyPref = function twinkleGetPreftwinkleGetFriendlyPref(name) {
var result;
if (typeof Twinkle.prefs === 'object' && Twinkle.prefs[name] !== undefined) {
if ( typeof Twinkle.prefs === "object" && typeof Twinkle.prefs.friendly === "object" ) {
return Twinkle.prefs[name];
// look in Twinkle.prefs (twinkleoptions.js)
result = Twinkle.prefs.friendly[ name ];
} else if ( typeof window.FriendlyConfig === "object" ) {
// look in FriendlyConfig
result = window.FriendlyConfig[ name ];
}
 
// Old preferences format, used before twinkleoptions.js was a thing
if ( result === undefined ) {
if (typeof window.TwinkleConfig === 'object' && window.TwinkleConfig[name] !== undefined) {
return windowTwinkle.TwinkleConfigdefaultConfig.friendly[ name ];
}
return result;
if (typeof window.FriendlyConfig === 'object' && window.FriendlyConfig[name] !== undefined) {
return window.FriendlyConfig[name];
}
return Twinkle.defaultConfig[name];
};
 
 
 
Line २३३ ⟶ २२१:
* @return Node -- the DOM node of the new item (a DIV element) or null
*/
Twinkle.addPortlet = function( navigation, id, text, type, nextnodeid) {)
{
// sanity checks, and get required DOM nodes
//sanity checks, and get required DOM nodes
var root = document.getElementById(navigation) || document.querySelector(navigation);
var root = document.getElementById( navigation );
if (!root) {
if ( !root ) {
return null;
}
 
var item = document.getElementById( id );
if ( item ) {
if ( item.parentNode && item.parentNode === root ) {
return item;
}
Line २४९ ⟶ २३८:
 
var nextnode;
if ( nextnodeid ) {
nextnode = document.getElementById(nextnodeid);
}
Line ३५० ⟶ ३३९:
* @param task: Either a URL for the portlet link or a function to execute.
*/
Twinkle.addPortletLink = function( task, text, id, tooltip) {)
{
if (Twinkle.getPref('portletArea') !== null) {
if ( Twinkle.getPref("portletArea") !== null ) {
Twinkle.addPortlet( Twinkle.getPref(' "portletArea'" ), Twinkle.getPref(' "portletId'" ), Twinkle.getPref(' "portletName'" ), Twinkle.getPref(' "portletType'" ), Twinkle.getPref(' "portletNext'" ));
}
var link = mw.util.addPortletLink( Twinkle.getPref(' "portletId'" ), typeof task === '"string'" ? task : '"#'", text, id, tooltip );
if ( $.isFunction( task ) ) {
$('.client-js .skin-vector #p-cactions').css('margin-right', 'initial');
$( link ).click(function ( ev ) {
if (typeof task === 'function') {
$(link).click(function (ev) {
task();
ev.preventDefault();
});
}
if ( $.collapsibleTabs ) {
$.collapsibleTabs.handleResize();
}
Line ३७३ ⟶ ३६२:
*/
 
var scriptpathbefore = mw.util.wikiScript(' "index'" ) + '"?title='",
scriptpathafter = '"&action=raw&ctype=text/javascript&happy=yes'";
 
// Retrieve the user's Twinkle preferences
$.ajax({
url: scriptpathbefore + '"User:'" + encodeURIComponent( mw.config.get('"wgUserName'")) + '"/twinkleoptions.js'" + scriptpathafter,
dataType: '"text'"
})
.fail(function () { mw.util.jsMessage( "Could not load twinkleoptions.js" ); })
.done(function ( optionsText ) {
mw.notify('Could not load twinkleoptions.js');
})
.done(function (optionsText) {
 
// Quick pass if user has no options
if ( optionsText === ''"" ) {
return;
}
 
// Twinkle options are basically a JSON object with some comments. Strip those:
optionsText = optionsText.replace( /(?:^(?:\/\/[^\n]*\n)*\n*|(?:\/\/[^\n]*(?:\n|$))*$)/g, ''"" );
 
// First version of options had some boilerplate code to make it eval-able -- strip that too. This part may become obsolete down the line.
if ( optionsText.lastIndexOf(' "window.Twinkle.prefs = '", 0 ) === 0 ) {
optionsText = optionsText.replace( /(?:^window.Twinkle.prefs = |;\n*$)/g, ''"" );
}
 
try {
var options = JSON$.parseparseJSON( optionsText );
 
if (options) {
// Assuming that our options evolve, we will want to transform older versions:
if (options.twinkle || options.friendly) { // Old preferences format
//if ( options.optionsVersion === undefined ) {
Twinkle.prefs = $.extend(options.twinkle, options.friendly);
}// else {...
Twinkle// options.prefsoptionsVersion = options1;
//}
//if ( options.optionsVersion === 1 ) {
// v2 established after unification of Twinkle/Friendly objects
// ...
Twinkle.prefs.optionsVersion = Twinkle.prefs.optionsVersion || 1;
// options.optionsVersion = 2;
//}
// At the same time, twinkleconfig.js needs to be adapted to write a higher version number into the options.
 
if ( options ) {
Twinkle.prefs = options;
}
}
catch ( e ) {
mw.notifyutil.jsMessage('"Could not parse twinkleoptions.js'");
}
})
.always(function () {
$( Twinkle.load );
});
 
Line ४२२ ⟶ ४१६:
 
Twinkle.load = function () {
// Don't activate on special pages other than those"Contributions" onso thethat whitelistthey soload thatfaster, especially the watchlist.
var isSpecialPage = ( mw.config.get('wgNamespaceNumber') === -1
// they load faster, especially the watchlist.
&& mw.config.get('wgCanonicalSpecialPageName') !== "Contributions"
var specialPageWhitelist = [ 'Block', 'Contributions' ]; // wgRelevantUserName defined for non-sysops on Special:Block
&& mw.config.get('wgCanonicalSpecialPageName') !== "Prefixindex" ),
if (Morebits.userIsSysop) {
 
specialPageWhitelist = specialPageWhitelist.concat([ 'DeletedContributions', 'Prefixindex' ]);
// Also, Twinkle is incompatible with Internet Explorer versions 8 or lower, so don't load there either.
}
isOldIE = ( $.client.profile().name === 'msie' && $.client.profile().versionNumber < 9 );
if (mw.config.get('wgNamespaceNumber') === -1 &&
specialPageWhitelist.indexOf(mw.config.get('wgCanonicalSpecialPageName')) === -1) {
return;
}
 
// Prevent users that are not autoconfirmed from loading Twinkle as well.
// Prevent clickjacking
if ( isSpecialPage || isOldIE || !Twinkle.userAuthorized ) {
if (window.top !== window.self) {
return;
}
 
// Set custom Api-User-Agent header, for server-side logging purposes
Morebits.wiki.api.setApiUserAgent( 'Twinkle/2.0 (' + mw.config.get( 'wgDBname' ) + ')' );
 
// Load all the modules in the order that the tabs should appear
var twinkleModules = [
// User/user talk-related
'arv', 'warn', 'block', 'welcome', 'shared', 'talkback',
// Deletion
'speedy', 'prod', 'xfd', 'image',
// Maintenance
'protect', 'tag',
// Misc. ones last
'diff', 'unlink', 'fluff', 'deprod', 'batchdelete', 'batchprotect', 'batchundelete'
];
// Don't load modules users have disabled
var disabledModules = Twinkle.getPref('disabledModules').concat(Twinkle.getPref('disabledSysopModules'));
twinkleModules.filter(function(mod) {
return disabledModules.indexOf(mod) === -1;
}).forEach(function(module) {
Twinkle[module]();
});
Twinkle.config.init(); // Can't turn off
 
// Load the modules in the order that the tabs should appears
// User/user talk-related
Twinkle.arv();
Twinkle.warn();
Twinkle.welcome();
Twinkle.shared();
Twinkle.talkback();
// Deletion
Twinkle.speedy();
Twinkle.prod();
Twinkle.xfd();
Twinkle.image();
// Maintenance
Twinkle.protect();
Twinkle.tag();
// Misc. ones last
Twinkle.diff();
Twinkle.unlink();
Twinkle.config.init();
Twinkle.fluff.init();
if ( Morebits.userIsInGroup('sysop') ) {
Twinkle.delimages();
Twinkle.deprod();
Twinkle.batchdelete();
Twinkle.batchprotect();
Twinkle.batchundelete();
}
// Run the initialization callbacks for any custom modules
$( Twinkle.initCallbacks ).forEacheach(function (func k, v ) { v(); });
Twinkle.addInitCallback = function ( func ) { func(); };
func();
});
Twinkle.addInitCallback = function (func) {
func();
};
 
// Increases text size in Twinkle dialogs, if so configured
if ( Twinkle.getPref(' "dialogLargeFont'" ) ) {
mw.util.addCSS(' ".morebits-dialog-content, .morebits-dialog-footerlinks { font-size: 100% !important; } '" +
'".morebits-dialog input, .morebits-dialog select, .morebits-dialog-content button { font-size: inherit !important; }'" );
}
 
// Hide the lingering space if the TW menu is empty
if (mw.config.get('skin') === 'vector' && Twinkle.getPref('portletType') === 'menu' && $('#p-twinkle').length === 0) {
$('#p-cactions').css('margin-right', 'initial');
}
};
 
} ( window, document, jQuery )); // End wrap with anonymous function
 
// </nowiki>