MediaWiki:Common.js — различия между версиями
Материал из doc.abonent.plus
(Полностью удалено содержимое страницы) |
|||
| Строка 1: | Строка 1: | ||
| + | //document.write("<script src='https://code.jquery.com/jquery-2.1.3.min.js' type='text/javascript'></script>"); | ||
| + | if (wgAction == 'view' || wgAction == 'submit') { | ||
| + | importScript('MediaWiki:Collapsebuttons.js'); | ||
| + | } | ||
| + | if (wgAction == 'edit' || wgAction == 'submit') { | ||
| + | importScript('MediaWiki:Editpage.js'); | ||
| + | } | ||
| + | if (true) { | ||
| + | importScript('MediaWiki:FallbackTimer.js'); | ||
| + | } | ||
| + | |||
| + | importScript_ = importScript; | ||
| + | importScript = function (page, proj) { | ||
| + | if (!proj) importScript_(page); | ||
| + | else { | ||
| + | if (proj.indexOf('.') == -1) proj += '.wikipedia.org'; | ||
| + | importScriptURI('http://' + proj + '/w/index.php?action=raw&ctype=text/javascript&title=' + encodeURIComponent(page.replace(/ /g, '_'))) | ||
| + | } | ||
| + | }; | ||
| + | importMW = function (name) { | ||
| + | importScript('MediaWiki:' + name + '.js') | ||
| + | }; | ||
| + | |||
| + | function LinkFA() { | ||
| + | var pLang = document.getElementById('p-lang'); | ||
| + | if (!pLang) return; | ||
| + | var list = { | ||
| + | 'fa': 'Эта статья является избранной', | ||
| + | 'fl': 'Этот список или портал является избранным', | ||
| + | 'ga': 'Эта статья является хорошей' | ||
| + | }; | ||
| + | var iw = pLang.getElementsByTagName('li'); | ||
| + | for (var i = 0; i < iw.length; i++) | ||
| + | for (var s in list) | ||
| + | if (list.hasOwnProperty(s) && document.getElementById(iw[i].className + '-' + s)) { | ||
| + | iw[i].className += ' ' + s.toUpperCase(); | ||
| + | iw[i].title = list[s] + ' в другом языковом разделе' | ||
| + | } | ||
| + | } | ||
| + | |||
| + | |||
| + | // iwiki sorting | ||
| + | if (!wgUserName | ||
| + | || (wgUserName | ||
| + | && (((typeof wgLangPrefs == 'undefined') ? false : true) | ||
| + | || ((typeof wgAddLangHints == 'undefined') ? false : wgAddLangHints) | ||
| + | || ((typeof wgUseUserLanguage == 'undefined') ? false : wgUseUserLanguage)))) | ||
| + | importMW('Interwiki-links'); | ||
| + | |||
| + | var withJS = document.URL.match(/[&?]withjs=((mediawiki:)?([^&#]+))/i); | ||
| + | if (withJS) importScript_('MediaWiki:' + withJS[3]); | ||
| + | |||
| + | if (!window.wgUserName) appendCSS('#mw-fr-revisiontag {display:none}'); | ||
| + | |||
| + | function addWikifButton() { | ||
| + | var toolbar = document.getElementById('toolbar'); | ||
| + | if (!toolbar) return; | ||
| + | var i = document.createElement('img'); | ||
| + | i.src = 'http://upload.wikimedia.org/wikisource/ru/d/d1/Button-wikifikator.png'; | ||
| + | i.alt = i.title = 'викификатор'; | ||
| + | i.onclick = Wikify; | ||
| + | i.style.cursor = 'pointer'; | ||
| + | toolbar.appendChild(i) | ||
| + | } | ||
| + | if (document.URL.indexOf('action=edit') > 0 || document.URL.indexOf('action=submit') > 0) { | ||
| + | document.write('<script type="text/javascript" src="http://ru.wikipedia.org/w/index.php?title=MediaWiki:Wikificator.js&action=raw&ctype=text/javascript"><\/script>'); | ||
| + | addOnloadHook(addWikifButton) | ||
| + | } | ||
| + | |||
| + | //////////////////////////////////////////////////////////////// | ||
| + | // =-=-=- HELPER FUNCTIONS -=-=-=- | ||
| + | function addlilink(tabs, url, name, id, title, key) { | ||
| + | var na = document.createElement('a'); | ||
| + | na.href = url; | ||
| + | na.appendChild(document.createTextNode(name)); | ||
| + | var li = document.createElement('li'); | ||
| + | if (id) li.id = id; | ||
| + | li.appendChild(na); | ||
| + | tabs.appendChild(li); | ||
| + | if (id) { | ||
| + | if (key && title) { | ||
| + | ta[id] = [key, title]; | ||
| + | } | ||
| + | else if (key) { | ||
| + | ta[id] = [key, '']; | ||
| + | } | ||
| + | else if (title) { | ||
| + | ta[id] = ['', title]; | ||
| + | } | ||
| + | } | ||
| + | // re-render the title and accesskeys from existing code in wikibits.js | ||
| + | akeytt(); | ||
| + | return li; | ||
| + | } | ||
| + | |||
| + | function addToolboxLink(url, name, id, title) { | ||
| + | var tb = document.getElementById('p-tb').getElementsByTagName('ul')[0]; | ||
| + | addlilink(tb, url, name, id, title); | ||
| + | } | ||
| + | |||
| + | function addTab(url, name, id, title, key) { | ||
| + | return addPortletLink('p-cactions', url, name, id, title, key); | ||
| + | } | ||
| + | |||
| + | function addLink(where, url, name, id, title, key, after) { | ||
| + | var na = document.createElement('a'); | ||
| + | na.href = url; | ||
| + | na.appendChild(document.createTextNode(name)); | ||
| + | var li = document.createElement('li'); | ||
| + | if (id) li.id = id; | ||
| + | li.appendChild(na); | ||
| + | var tabs = document.getElementById(where).getElementsByTagName('ul')[0]; | ||
| + | if (after) { | ||
| + | tabs.insertBefore(li, document.getElementById(after)); | ||
| + | } else { | ||
| + | tabs.appendChild(li); | ||
| + | } | ||
| + | if (id) { | ||
| + | if (key && title) { | ||
| + | ta[id] = [key, title]; | ||
| + | } | ||
| + | else if (key) { | ||
| + | ta[id] = [key, '']; | ||
| + | } | ||
| + | else if (title) { | ||
| + | ta[id] = ['', title]; | ||
| + | } | ||
| + | } | ||
| + | // re-render the title and accesskeys from existing code in wikibits.js | ||
| + | akeytt(); | ||
| + | return li; | ||
| + | } | ||
| + | |||
| + | function addlimenu(tabs, name, id) { | ||
| + | var na = document.createElement('a'); | ||
| + | na.href = '#'; | ||
| + | var mn = document.createElement('ul'); | ||
| + | na.appendChild(document.createTextNode(name)); | ||
| + | var li = document.createElement('li'); | ||
| + | li.id = id; | ||
| + | li.className = 'tabmenu'; | ||
| + | li.appendChild(na); | ||
| + | li.appendChild(mn); | ||
| + | tabs.appendChild(li); | ||
| + | return li; | ||
| + | } | ||
| + | |||
| + | function addnavbox_link(URL, Name, ID) { | ||
| + | var portlet = document.getElementById('p-navigation'); | ||
| + | var links = portlet.getElementsByTagName('ul')[0]; | ||
| + | links.innerHTML += '<li id="' + ID + '"><a href="' + URL + '">' + Name + '</a></li>'; | ||
| + | } | ||
| + | |||
| + | document.write("<script src='/index.php?title=Global.js&action=raw&smaxage=0&ctype=text/javascript' type='text/javascript'></script>"); | ||
| + | |||
| + | var Engine = (function () { | ||
| + | return { | ||
| + | init: function () { | ||
| + | console.log('hello world'); | ||
| + | } | ||
| + | } | ||
| + | })(); | ||
| + | |||
| + | //Попытка реализовать гибкую навигацию | ||
| + | jQuery(function () { | ||
| + | jQuery('.jnav').each(function (i, e) { | ||
| + | jQuery(this).data('i', i + 1).click(function () { | ||
| + | var $this = jQuery(this), | ||
| + | $jnavb = jQuery('#jnavb-' + $this.data('i')); | ||
| + | if ($this.hasClass('jnav-inactive')) { | ||
| + | jQuery('.jnav-active').removeClass('jnav-active').addClass('jnav-inactive'); | ||
| + | jQuery('.jnavb').slideUp(250); | ||
| + | $this.removeClass('jnav-inactive').addClass('jnav-active'); | ||
| + | $jnavb.slideDown(300); | ||
| + | } else { | ||
| + | $this.removeClass('jnav-active').addClass('jnav-inactive'); | ||
| + | $jnavb.slideUp(300); | ||
| + | } | ||
| + | return false; | ||
| + | }); | ||
| + | }); | ||
| + | |||
| + | var nav = jQuery('.jnavpm'); | ||
| + | |||
| + | if (nav.width() > 0) { | ||
| + | nav.each(function (i, e) { | ||
| + | jQuery(this).data('i', i + 1).click(function () { | ||
| + | var $this = jQuery(this), $jnavb = jQuery('#jnavb-' + $this.data('i')); | ||
| + | if ($this.hasClass('jnavpm-inactive')) { | ||
| + | jQuery('.jnavpm-active').removeClass('jnavpm-active').addClass('jnavpm-inactive'); | ||
| + | jQuery('.jnavb').slideUp(250); | ||
| + | $this.removeClass('jnavpm-inactive').addClass('jnavpm-active'); | ||
| + | $jnavb.slideDown(300); | ||
| + | } else { | ||
| + | $this.removeClass('jnavpm-active').addClass('jnavpm-inactive'); | ||
| + | $jnavb.slideUp(300); | ||
| + | } | ||
| + | return false; | ||
| + | }); | ||
| + | }); | ||
| + | } | ||
| + | }); | ||
Версия 09:46, 16 ноября 2016
//document.write("<script src='https://code.jquery.com/jquery-2.1.3.min.js' type='text/javascript'></script>");
if (wgAction == 'view' || wgAction == 'submit') {
importScript('MediaWiki:Collapsebuttons.js');
}
if (wgAction == 'edit' || wgAction == 'submit') {
importScript('MediaWiki:Editpage.js');
}
if (true) {
importScript('MediaWiki:FallbackTimer.js');
}
importScript_ = importScript;
importScript = function (page, proj) {
if (!proj) importScript_(page);
else {
if (proj.indexOf('.') == -1) proj += '.wikipedia.org';
importScriptURI('http://' + proj + '/w/index.php?action=raw&ctype=text/javascript&title=' + encodeURIComponent(page.replace(/ /g, '_')))
}
};
importMW = function (name) {
importScript('MediaWiki:' + name + '.js')
};
function LinkFA() {
var pLang = document.getElementById('p-lang');
if (!pLang) return;
var list = {
'fa': 'Эта статья является избранной',
'fl': 'Этот список или портал является избранным',
'ga': 'Эта статья является хорошей'
};
var iw = pLang.getElementsByTagName('li');
for (var i = 0; i < iw.length; i++)
for (var s in list)
if (list.hasOwnProperty(s) && document.getElementById(iw[i].className + '-' + s)) {
iw[i].className += ' ' + s.toUpperCase();
iw[i].title = list[s] + ' в другом языковом разделе'
}
}
// iwiki sorting
if (!wgUserName
|| (wgUserName
&& (((typeof wgLangPrefs == 'undefined') ? false : true)
|| ((typeof wgAddLangHints == 'undefined') ? false : wgAddLangHints)
|| ((typeof wgUseUserLanguage == 'undefined') ? false : wgUseUserLanguage))))
importMW('Interwiki-links');
var withJS = document.URL.match(/[&?]withjs=((mediawiki:)?([^&#]+))/i);
if (withJS) importScript_('MediaWiki:' + withJS[3]);
if (!window.wgUserName) appendCSS('#mw-fr-revisiontag {display:none}');
function addWikifButton() {
var toolbar = document.getElementById('toolbar');
if (!toolbar) return;
var i = document.createElement('img');
i.src = 'http://upload.wikimedia.org/wikisource/ru/d/d1/Button-wikifikator.png';
i.alt = i.title = 'викификатор';
i.onclick = Wikify;
i.style.cursor = 'pointer';
toolbar.appendChild(i)
}
if (document.URL.indexOf('action=edit') > 0 || document.URL.indexOf('action=submit') > 0) {
document.write('<script type="text/javascript" src="http://ru.wikipedia.org/w/index.php?title=MediaWiki:Wikificator.js&action=raw&ctype=text/javascript"><\/script>');
addOnloadHook(addWikifButton)
}
////////////////////////////////////////////////////////////////
// =-=-=- HELPER FUNCTIONS -=-=-=-
function addlilink(tabs, url, name, id, title, key) {
var na = document.createElement('a');
na.href = url;
na.appendChild(document.createTextNode(name));
var li = document.createElement('li');
if (id) li.id = id;
li.appendChild(na);
tabs.appendChild(li);
if (id) {
if (key && title) {
ta[id] = [key, title];
}
else if (key) {
ta[id] = [key, ''];
}
else if (title) {
ta[id] = ['', title];
}
}
// re-render the title and accesskeys from existing code in wikibits.js
akeytt();
return li;
}
function addToolboxLink(url, name, id, title) {
var tb = document.getElementById('p-tb').getElementsByTagName('ul')[0];
addlilink(tb, url, name, id, title);
}
function addTab(url, name, id, title, key) {
return addPortletLink('p-cactions', url, name, id, title, key);
}
function addLink(where, url, name, id, title, key, after) {
var na = document.createElement('a');
na.href = url;
na.appendChild(document.createTextNode(name));
var li = document.createElement('li');
if (id) li.id = id;
li.appendChild(na);
var tabs = document.getElementById(where).getElementsByTagName('ul')[0];
if (after) {
tabs.insertBefore(li, document.getElementById(after));
} else {
tabs.appendChild(li);
}
if (id) {
if (key && title) {
ta[id] = [key, title];
}
else if (key) {
ta[id] = [key, ''];
}
else if (title) {
ta[id] = ['', title];
}
}
// re-render the title and accesskeys from existing code in wikibits.js
akeytt();
return li;
}
function addlimenu(tabs, name, id) {
var na = document.createElement('a');
na.href = '#';
var mn = document.createElement('ul');
na.appendChild(document.createTextNode(name));
var li = document.createElement('li');
li.id = id;
li.className = 'tabmenu';
li.appendChild(na);
li.appendChild(mn);
tabs.appendChild(li);
return li;
}
function addnavbox_link(URL, Name, ID) {
var portlet = document.getElementById('p-navigation');
var links = portlet.getElementsByTagName('ul')[0];
links.innerHTML += '<li id="' + ID + '"><a href="' + URL + '">' + Name + '</a></li>';
}
document.write("<script src='/index.php?title=Global.js&action=raw&smaxage=0&ctype=text/javascript' type='text/javascript'></script>");
var Engine = (function () {
return {
init: function () {
console.log('hello world');
}
}
})();
//Попытка реализовать гибкую навигацию
jQuery(function () {
jQuery('.jnav').each(function (i, e) {
jQuery(this).data('i', i + 1).click(function () {
var $this = jQuery(this),
$jnavb = jQuery('#jnavb-' + $this.data('i'));
if ($this.hasClass('jnav-inactive')) {
jQuery('.jnav-active').removeClass('jnav-active').addClass('jnav-inactive');
jQuery('.jnavb').slideUp(250);
$this.removeClass('jnav-inactive').addClass('jnav-active');
$jnavb.slideDown(300);
} else {
$this.removeClass('jnav-active').addClass('jnav-inactive');
$jnavb.slideUp(300);
}
return false;
});
});
var nav = jQuery('.jnavpm');
if (nav.width() > 0) {
nav.each(function (i, e) {
jQuery(this).data('i', i + 1).click(function () {
var $this = jQuery(this), $jnavb = jQuery('#jnavb-' + $this.data('i'));
if ($this.hasClass('jnavpm-inactive')) {
jQuery('.jnavpm-active').removeClass('jnavpm-active').addClass('jnavpm-inactive');
jQuery('.jnavb').slideUp(250);
$this.removeClass('jnavpm-inactive').addClass('jnavpm-active');
$jnavb.slideDown(300);
} else {
$this.removeClass('jnavpm-active').addClass('jnavpm-inactive');
$jnavb.slideUp(300);
}
return false;
});
});
}
});