МедияУики:Common.js
Забележка: За да се видят промените, необходимо е след публикуване на страницата, кешът на браузъра да бъде изтрит.
- Firefox / Safari: Задържа се клавиш Shift и се щраква върху Презареждане (Reload) или чрез клавишната комбинация Ctrl-F5 or Ctrl-R (⌘-R за Mac);
- Google Chrome: клавишна комбинация Ctrl-Shift-R (⌘-Shift-R за Mac)
- Internet Explorer / Edge: Задържа се клавиш Ctrl и се щраква върху Refresh или чрез клавишната комбинация Ctrl-F5;
- Opera: Press Ctrl-F5.
/* Този файл съдържа код на Джаваскрипт и се зарежда при всички потребители. */
// --- Support for the Мнения namespace --- //
// <source lang="JavaScript">
// I would assume this script is
// under the GFDL. it was originally at [[commons:MediaWiki:Extra-tabs.js]]
// written by Dbenbenn, Avatar, Duesentrieb and Arnomane
// modified by User:en:bawolff for en.wikinews and User:Jurock for es.wikinews. Ajax stuff added by
// User:en:TheFearrow
//subsequently futher heavily modified. looks nothing like original.
// Switch for people that don't want the extra tabs.
if (!window.load_extratabs && !mw.config.get('wgIsMainPage') )
{
// Translations (variables for internationalisation and localisation):
var commentsPreload = 'template:Comments_preload';
var commentsIntro = 'template:Comments_intro';
var load_opinionTabs = function() {
// extract the namespace
// var title = global_get_tidy_title();
var title = wgPageName;
var portlet = 'p-cactions';
var insertBefore = null;
if (skin !== 'vector') {
insertBefore = document.getElementById('ca-edit');
}
else {
portlet = 'p-namespaces';
}
// Namespace numbers are (see [[m:Help:Variables]]):
// -1: Special
// 0: Article (main)
// 1: talk
// 2: User
// 3: User_talk
// 6: Image
// 7: Image_talk
// 14: Category
switch(wgNamespaceNumber)
{
case 0:
mw.util.addPortletLink(portlet, wgScript + '?preload=' + commentsPreload + '&editintro=' + commentsIntro + '&title=' + encodeURIComponent(wgFormattedNamespaces[102] + ':') + wgPageName, wgFormattedNamespaces[102], 'ca-commenttab-view', null, null, insertBefore);
checkCommentaryPageExist(mw.Title.newFromText( wgTitle, 102 ).getPrefixedText(), 'ca-commenttab-view');
break;
case 1:
mw.util.addPortletLink(portlet, wgScript + '?preload=' + commentsPreload + '&editintro=' + commentsIntro + '&title=' + encodeURIComponent(wgFormattedNamespaces[102] + ':' + wgTitle.replace(/ /g, '_')), wgFormattedNamespaces[102], 'ca-commenttab-view', null, null, insertBefore);
checkCommentaryPageExist(mw.Title.newFromText( wgTitle, 102 ).getPrefixedText(), 'ca-commenttab-view');
break;
case 102:
mw.util.addPortletLink(portlet, wgScript + '?title=' + encodeURIComponent(wgFormattedNamespaces[1] + ':' + wgTitle.replace(/ /g, '_')), 'Беседа', 'ca-nstab-maintalk', null, null, document.getElementById('ca-nstab-мнения'));
mw.util.addPortletLink(portlet, wgScript + '?title=' + encodeURIComponent(wgTitle.replace(/ /g, '_')), 'Страница', 'ca-nstab-main', null, null, document.getElementById('ca-nstab-maintalk'));
//only check talk. we assume main ns exists.
checkCommentaryPageExist(mw.Title.newFromText( wgTitle, 1 ).getPrefixedText(), 'ca-nstab-maintalk');
break;
default:
// nothing
}
};
// The following two functions run a background check of api.php to see
// if the particular page exists, so a non-existing comment page can be red,
// and an existing comment page will look like a normal tab.
//Takes arguments for talk ns name, and Comment subpage name so I can define them all in one spot
var checkCommentaryPageExist = function( pageName, id ) {
mw.loader.using( 'mediawiki.api', function () {
new mw.Api().get( {
titles: pageName,
maxlag: 7,
maxage: 40,
smaxage: 10,
formatversion: 2
} ).done( function ( data ) {
if ( data.query.pages[0].missing !== undefined ) {
var elm = document.getElementById( id );
elm.className = 'new';
elm.firstChild.href += '&action=edit&redlink=1';
}
} );
} );
};
$( load_opinionTabs);
}
// END: MediaWiki interface button definition for comments. this was modified
// by Bawolff for en.wikinews comments from [[commons:Mediawiki:extra-tabs.js]]. Translated (up to
// now by Jurock).
// ========================================================================
// </source>
// --- End of support for Мнения namespace --- //