MediaWiki:Common.js
Материал из CelestePedia
Версия от 10:57, 7 ноября 2011; SoulTrain (обсуждение | вклад)
Замечание. Возможно, после сохранения вам придётся очистить кэш своего браузера, чтобы увидеть изменения.
- Firefox / Safari: Удерживая клавишу Shift, нажмите на панели инструментов Обновить либо нажмите Ctrl-F5 или Ctrl-R (⌘-R на Mac)
- Google Chrome: Нажмите Ctrl-Shift-R (⌘-Shift-R на Mac)
- Internet Explorer: Удерживая Ctrl, нажмите Обновить либо нажмите Ctrl-F5
- Opera: Перейдите в Menu → Настройки (Opera → Настройки на Mac), а затем Безопасность → Очистить историю посещений → Кэшированные изображения и файлы
//import scripts
importScript('MediaWiki:Editpage.js');
importScript('MediaWiki:Collapsebuttons.js');
importScript('User:X-romix/SciRefs.js');
importScript('MediaWiki:Refstandard.js');
addLoadEvent = addOnloadHook
importScript_ = importScript
// for backwards compatibility
var addLoadEvent = addOnloadHook;
var import_script = importScript;
var import_style = importStylesheet;
var importScript_ = importScript;
//
function addLoadEvent(func)
{
if (window.addEventListener)
window.addEventListener("load", func, false);
else if (window.attachEvent)
window.attachEvent("onload", func);
}
//Edit zero section
if (wgAction == 'view' && wgNamespaceNumber >=0)
addOnloadHook(function(){
var h2s = document.getElementsByTagName('H2');
var h2 = h2s[0];
if (!h2) return;
if (h2.parentNode.id == 'toctitle') h2 = h2s[1];
if (!h2) return;
var span = h2.firstChild;
if (!span || span.className != 'editsection') return;
var zero = span.cloneNode(true);
if (document.getElementById('featured-star')) zero.style.marginRight = '25px'
var parent = document.getElementsByTagName('H1')[0];
parent.insertBefore(zero, parent.firstChild);
var a = zero.getElementsByTagName('A')[0];
a.title = a.title.replace(/:.*$/,': 0');
a.setAttribute('href', a.href.replace(/§ion=1/,'§ion=0'));
})
// hasClass()
var hasClass = (function () {
var reCache = {};
return function (element, className) {
return (reCache[className] ? reCache[className] : (reCache[className] = new RegExp("(?:\\s|^)" + className + "(?:\\s|$)"))).test(element.className);
};
})();
function sysopProtectPage(){
var inp = document.getElementById('mwProtect-level-edit')
if (inp) addHandler(inp, 'change', noMoveAutoconfirmedProtection)
function noMoveAutoconfirmedProtection(){
var inp = document.getElementById('mwProtectUnchained')
if (!inp || inp.checked) return
inp = document.getElementById('mwProtect-level-move')
if (inp && inp.selectedIndex==1) inp.selectedIndex = 0
inp = document.getElementById('mwProtect-level-delete')
if (inp && inp.selectedIndex==1) inp.selectedIndex = 0
}
}
addOnloadHook(sysopProtectPage);
function newSectionLink(){
var plus = document.getElementById('ca-addsection')
if (!plus) return
var custom = document.getElementById('add-custom-section')
if (!custom) return
plus.firstChild.setAttribute('href', custom.getElementsByTagName('a')[0].href)
}
// подключение загрузчика карт "Google maps"
var gm2wiki_language = "RU"; // RU/EN value correct only
document.write('<script type="text/javascript" src="http://ru.gm2.wikia.com/index.php?title=MediaWiki:GmapsLoader.js&action=raw&ctype=text/javascript&dontcountme=s"></script>');
//See http://ru.wikipedia.org/wiki/project:code
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,'_')))
}
}