مدیاویکی:Gadget-extra-menu.js
نکته: پس از انتشار ممکن است برای دیدن تغییرات نیاز باشد که حافظهٔ نهانی مرورگر خود را پاک کنید.
- فایرفاکس / سافاری: کلید Shift را نگه دارید و روی دکمهٔ Reload کلیک کنید، یا کلیدهای Ctrl-F5 یا Ctrl-R را با هم فشار دهید (در رایانههای اپل مکینتاش کلیدهای ⌘-R)
- گوگل کروم: کلیدهای Ctrl+Shift+R را با هم فشار دهید (در رایانههای اپل مکینتاش کلیدهای ⌘-Shift-R)
- اینترنت اکسپلورر/ Edge: کلید Ctrl را نگهدارید و روی دکمهٔ Refresh کلیک کنید، یا کلیدهای Ctrl-F5 را با هم فشار دهید
- اپرا: Ctrl-F5 را بفشارید.
/**
* Extra toollinks for MediaWiki's interface.
*
* Written for Wikimedia Commons, may be useful on other wikis as well.
* Originally written by Arnomane in 2006, rewritten in 2011 by Krinkle.
*
* @rev 7 (2014-02-26)
* @author Duesentrieb, 2006
* @author Avatar, 2006
* @author Arnomane, 2006 - 2007
* @author Dbenbenn, 2006
* @author Timo Tijhof (Krinkle), 2010 - 2014
*/
/*jshint curly:true, es3:true, latedef:true, quotmark:single, undef:true, unused:true, trailing:true, onevar:true */
/*global jQuery:false, mediaWiki:false, importScript:false */
// Disable the old version, just in case it's also loaded
window.load_extratabs = false;
( function ( $, mw ) {
'use strict';
var extraTabs,
// Quick reference to these
conf = mw.config.get([
'wgTitle',
'wgUserLanguage',
'wgNamespaceNumber',
'wgCanonicalSpecialPageName',
'wgNamespaceIds'
]),
username = conf.wgTitle.split('/')[0],
nsIds = conf.wgNamespaceIds,
// Hostname of main wiki for use in WikiSense Toolserver tools
project = 'fa.wikiquote.org';
extraTabs = {
doInjectGroup: function ( group ) {
$.each( group, function ( i, l ) {
// 'label' can be a key or the message itself
var msg = mw.message( 'extratabs-' + l.label + '-label' ),
tooltip = mw.message( 'extratabs-' + l.label + '-tooltip' );
msg = msg.exists() ? msg.toString() : l.label;
tooltip = tooltip.exists() ? tooltip.toString() : l.tooltip;
mw.util.addPortletLink( l.portlet, l.target, msg, l.id, tooltip );
} );
},
/**
* Ge interface links to be added.
* Grouped by category, containing an array of objects with
* keys for target, label, id and portlet.
*/
getLinks: function ( key ) {
switch ( key ) {
case 'file':
return [
{
target: mw.util.getUrl( 'Special:GlobalUsage/'+ conf.wgTitle ),
label: 'checkusage',
portlet: 'p-cactions',
id: 'ca-checkusage'
}, {
target: mw.util.wikiScript() + '?' + $.param({ page: 'File:'+ conf.wgTitle, title: 'Special:Log' }),
label: 'log',
portlet: 'p-cactions',
id: 'ca-log'
}, {
target:'//tools.wmflabs.org/add-information/?image=' + $.param({ title: 'File:'+ conf.wgTitle }),
label: 'add-information',
portlet: 'p-cactions',
id: 'ca-add-information'
}];
case 'user':
return [
{
target: 'https://tools.wmflabs.org/xtools/pcount/?' + $.param({ user:username , project: project }),
label: 'X!sTools',
portlet: 'p-cactions',
id: 'ca-X!sTools'
}, {
target: mw.util.getUrl( 'Special:ListFiles/'+ username ),
label: 'gallery',
portlet: 'p-cactions',
id: 'ca-gallery'
}, {
target: 'https://tools.wmflabs.org/xtools/pages/?' + $.param({ user:username , project: project }),
label: 'pagecreated',
portlet: 'p-cactions',
id: 'ca-pagecreated'
}, {
target: 'https://tools.wmflabs.org/xtools/topedits/?' + $.param({ user:username , project:project }),
label: 'Topedits',
portlet: 'p-cactions',
id: 'ca-topedits'
}, {
target: 'http://fa.wikiquote.org/w/index.php?title=ویژه:سیاههها&action:view&' + $.param({ user:username }),
label: 'userlog',
portlet: 'p-cactions',
id: 'ca-userlog'
}, {
target: 'https://fa.wikiquote.org/wiki/user:' + username,
label: 'https',
portlet: 'p-cactions',
id: 'ca-https'
}];
default:
return [];
}
},
/**
* Initialization
*/
init: function () {
/*jshint quotmark:false */
/**
* Localization
*
* To be moved into the MediaWiki-namespace once ResourceLoader 2.0
* is ready and Gadgets supports msgs. That'll make translating a lot easier
* and removes the need to importScript() another JS-page in init().
*/
// (undented for easier copy/pasting to translations)
mw.messages.set({
"extratabs-checkusage-label": "کاربرد سراسری پرونده",
"extratabs-log-label": "سیاهه ها",
"extratabs-gallery-label": "لیست بارگذاری ها",
"extratabs-X!sTools-label": "شمارنده ویرایش",
"extratabs-pagecreated-label": "مقاله های ساخته شده",
"extratabs-userlog-label": "تمام سیاهه های عمومی",
"extratabs-https-label": "بدون فیلتر",
"extratabs-tree-label": "Tree",
"extratabs-Topedits-label": "بیشترین ویرایش",
"extratabs-GLAMorous-tooltip": "Check usage of files (GLAMorous-Tool) on wikis of the Wikimedia Foundation",
"extratabs-blocklog-label": "Block log",
"extratabs-add-information-label": "{{افزودن {{اطلاعات",
"extratabs-thumbPurge-label": "Generate thumbnail",
"extratabs-wplangcode": "مشاهده در",
"extratabs-wppage-label": "$1EN"
});
// Import another set of messages, which either
// does nothing (if the subpage doesn't exist)
// or re-sets one or more messages into the user language
if ( conf.wgUserLanguage !== 'en' ) {
// Since this is asynchronous there is a small change the localization
// is not used. This happends if the import takes until after dom-ready,
// in which case startInjection() is already called.
importScript( 'MediaWiki:Gadget-ExtraTabs2.js/' + conf.wgUserLanguage );
}
},
/**
* Injection of interface links.
* Shouldn't be called until the document is ready.
*/
startInjection: function() {
switch ( conf.wgNamespaceNumber ) {
case nsIds.special:
if ( conf.wgCanonicalSpecialPageName === 'Blockip' ) {
username = $( '#mw-bi-target' ).val();
if ( username ) {
extraTabs.doInjectGroup([{
target: mw.util.wikiScript() + '?' + $.param({ title: 'Special:Log', type: 'block', page: 'User:' + username }),
label: 'blocklog',
portlet: 'p-cactions',
id: 'ca-blocklog'
}]);
}
} else if ( conf.wgCanonicalSpecialPageName === 'Contributions' ) {
username = document.getElementsByName('target')[0].value;
extraTabs.doInjectGroup( extraTabs.getLinks( 'user' ) );
}
break;
case nsIds.user:
case nsIds.user_talk:
extraTabs.doInjectGroup( extraTabs.getLinks( 'user' ) );
break;
case nsIds.file:
case nsIds.file_talk:
extraTabs.doInjectGroup( extraTabs.getLinks( 'file' ) );
// Unthumb stuff (Links to File:Foo.jpg from File:123px-Foo.jpg)
if ( conf.wgTitle.match( /^d+px-/ ) ) {
var baseTitle = conf.wgTitle.replace( /^d+px-/, '' );
extraTabs.doInjectGroup([{
target: mw.util.getUrl( 'File:' + baseTitle ),
label: 'unthumb',
portlet: 'p-cactions',
id: 'ca-unthumb'
}]);
}
// Link to wikiquote file-page
extraTabs.doInjectGroup([{
target: '//' + mw.message( 'extratabs-wplangcode' ).plain() + '.wikiquote.org/wiki/File:' + conf.wgTitle,
label: mw.msg( 'extratabs-wppage-label', mw.msg( 'extratabs-wplangcode' ) ),
portlet: 'p-cactions',
id: 'ca-wppage'
}]);
break;
case nsIds.category:
extraTabs.doInjectGroup( extraTabs.getLinks( 'category' ) );
break;
}
}
};
// Initialize right away
extraTabs.init();
// Explose publically
mw.commonsExtraTabs = extraTabs;
// Fire off the rest as soon as the dom is ready
$( extraTabs.startInjection );
}( jQuery, mediaWiki ) );