/* Размещённый здесь код JavaScript будет загружен всем пользователям при обращении к какой-либо странице */
//кнопка викификатора
/*WikiEditor/Викификатор*/
/*WikiEditor/Викификатор*/
if ( $.inArray( mw.config.get( 'wgAction' ), ['edit', 'submit'] ) !== -1 ) {
}
} );
};
/*
Добавление разметки вводной.
*/
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'section': 'advanced',
'group': 'insert',
'tools':
{
'intro':
{
label: 'Разметить вводную',
type: 'button',
icon: '/w/images/7/70/Intro_icon.png',
'action': {
'type': 'encapsulate',
'options': {
'pre': "<section begin=вводная />\n",
'post': "<section end=вводная />"
}
}
},
'image':
{
label: 'Разметить заглавную иллюстрацию',
type: 'button',
icon: '/w/images/f/f0/Image_icon.png',
'action': {
'type': 'encapsulate',
'options': {
'pre': "<section begin=иллюстрация />\n",
'post': "<section end=иллюстрация />"
}
}
}
}
});
};
if ( $.inArray( mw.config.get( 'wgAction' ), ['edit', 'submit'] ) !== -1 ) {
mw.loader.using( 'user.options', function () {
if ( mw.user.options.get('usebetatoolbar') ) {
mw.loader.using( 'ext.wikiEditor.toolbar', function () {
$(document).ready( customizeToolbar );
} );
}
} );
}
//Кнопки быстрого описания правки
//список кнопок
function SummaryButtons(){
var wpSummary = document.getElementById('wpSummary')
if (!wpSummary || (wpSummary.form.wpSection && wpSummary.form.wpSection.value == 'new')) return
wpSummaryBtn = document.createElement('span') //global var
wpSummaryBtn.id = 'userSummaryButtonsA'
// +Рекомендация
var wpSummaryBtnRec = document.createElement('i')
wpSummaryBtnRec.appendChild(document.createTextNode('Пожалуйста, если вы не торопитесь, опишите вашу правку подробно: например, не «дополнение», а «+персонажи».'))
wpSummaryBtnRec.appendChild(document.createElement('br'))
wpSummaryBtn.appendChild(wpSummaryBtnRec)
wpSummary.parentNode.insertBefore(wpSummaryBtn, wpSummary.nextSibling)
wpSummary.parentNode.insertBefore(document.createElement('br'), wpSummary.nextSibling)
addSumButton('викиф.', 'викификация', 'Произведена викификация')
addSumButton('оформл.', 'оформление', 'Оформление')
addSumButton('стиль', 'стилевые правки', 'Стилевые правки')
addSumButton('орфогр.', 'орфография', 'Поправлена орфография')
addSumButton('пункт.', 'пунктуация', 'Изменена пунктуация')
addSumButton('интервики', 'интервики', 'Изменены межъязыковые ссылки (интервики)')
addSumButton('кат.', 'правка категорий', 'Изменены категории')
addSumButton('шаб.', 'шаблон', 'Добавлен / изменён шаблон')
addSumButton('к удал.', 'к удалению', 'Страница предложена к удалению')
addSumButton('доп.', 'дополнение', 'Добавлены новые сведения')
addSumButton('иллюстрация', 'иллюстрация', 'Размещена иллюстрация')
addSumButton('обнов.', 'обновление данных', 'Обновлены устаревшие данные')
addSumButton('разметка', 'правка разметки', 'Изменение разметки')
}
//код вставки кнопок быстрого описания
function addSumButton(name, text, title) {
var btn = document.createElement('a')
btn.appendChild(document.createTextNode(name))
btn.title = title
btn.onclick = function(){insertSummary(text)}
wpSummaryBtn.appendChild(btn)
}
//код вставки описания
function insertSummary(text) {
var wpSummary = document.getElementById('wpSummary')
if (wpSummary.value.indexOf(text) != -1) return
if (wpSummary.value.match(/[^,; \/]$/)) wpSummary.value += ','
if (wpSummary.value.match(/[^ ]$/)) wpSummary.value += ' '
wpSummary.value += text
}
//вызов функции вставки кнопок быстрого описания правки при загрузке страницы
addOnloadHook(SummaryButtons)
//перемещение ссылок "править" влево, к заголовку секции, для борьбы с багом движка
addOnloadHook(function() {
if (typeof oldEditsectionLinks != 'undefined' && oldEditsectionLinks) return;
var spans = document.getElementsByTagName("span");
for (var i=0; i<spans.length; i++) {
var span = spans[i];
if (span.className != "editsection") continue;
span.style.fontSize = "x-small";
span.style.fontWeight = "normal";
span.style.styleFloat = "none"; // IE-Fix für die folgende Zeile
span.style.cssFloat = "none";
span.style.marginLeft = "0px";
span.parentNode.appendChild(document.createTextNode(" "));
span.parentNode.appendChild(span);
}
});
//Скрываемый текст; этот код лучше стандартного тем, что без включённых скриптов показывает всё (без скриптов человек можно не может переключить видимость, так что по умолчанию всё должно показываться), а также работает с картинками.
var NavigationBarHide = '[скрыть]'
var NavigationBarShow = '[показать]'
var hasClass = (function (){
var reCache = {}
return function (element, className){
return (reCache[className] ? reCache[className] : (reCache[className] = new RegExp("(?:\\s|^)" + className + "(?:\\s|$)"))).test(element.className)
}
})()
var $IE6 = false;
if (typeof document.addEventListener != 'function') $IE6=true;
function collapsibleDivs(){
var navIdx = 0, colNavs = [], i, NavFrame
var content=document.getElementById('content');
if (!content) content=document.getElementById('mw_content');
var divs = content.getElementsByTagName('div')
for (i=0; NavFrame = divs[i]; i++) {
if (!hasClass(NavFrame, 'NavFrame')) continue;
if ( (hasClass(NavFrame, 'nsfw'))&&($IE6) ) continue;
NavFrame.id = 'NavFrame' + navIdx
var a = document.createElement('a')
a.className = 'NavToggle tinytext'
a.id = 'NavToggle' + navIdx
a.href = 'javascript:collapseDiv(' + navIdx + ');'
a.appendChild(document.createTextNode(NavigationBarShow))
for (var j=0; j < NavFrame.childNodes.length; j++)
if (hasClass(NavFrame.childNodes[j], 'NavHead'))
{
NavFrame.childNodes[j].appendChild(document.createTextNode(' '))
NavFrame.childNodes[j].appendChild(a)
}
colNavs[navIdx++] = NavFrame
}
var $hidespoilers, $temp;
$temp=readCookie('showNSFW');
if ($temp=='yes') $hidespoilers=false;
else if ($temp=='no') $hidespoilers=true;
else
{
$temp=document.getElementById('spoilerbuttons_defhidden');
if ($temp) $hidespoilers=true; else $hidespoilers=false;
}
for (i=0; i < navIdx; i++)
{
for (var child = colNavs[i].firstChild; child != null; child = child.nextSibling)
{
if (hasClass(child, 'NavContent')) child.style.display='none';
else if (hasClass(child, 'NavHead')) child.style.display='block';
else if (hasClass(child, 'NavDefval')) child.style.display='none';
else if (hasClass(child, 'NavPic')) child.style.display='block';
}
if (hasClass(colNavs[i], 'spoilerblock')) collapseDiv(i, !$hidespoilers)
else if (hasClass(colNavs[i], 'expanded')) collapseDiv(i, true)
else if (hasClass(colNavs[i], 'collapsed')) collapseDiv(i, false)
}
}
function collapseDiv(idx) {
var div = document.getElementById('NavFrame' + idx)
var btn = document.getElementById('NavToggle' + idx)
if (!div || !btn) return false
var isShown = (btn.firstChild.data == NavigationBarHide)
if ((typeof(arguments[1])=='boolean')&&(arguments[1]==isShown)) return true;
btn.firstChild.data = isShown ? NavigationBarShow : NavigationBarHide
var disp = isShown ? 'none' : 'block', $temp
for (var child = div.firstChild; child != null; child = child.nextSibling)
if (hasClass(child, 'NavContent'))
child.style.display = disp
else if (hasClass(child, 'NavPic'))
{
$temp=getInnerTags(child, 'NavPicHolder', 'div', 1);
if ($temp) $temp.className=isShown ? 'NavPicHolder transparent' : 'NavPicHolder';
}
}
//вызов функций для скрываемого текста
addOnloadHook(collapsibleDivs)
// функция для поиска тэга определённого класса.
function getInnerTags($source, $class)
{
var $list=$source.childNodes, $result=new Array(), $rec=new Array();
var $limit=0, $tag='SPAN';
if (typeof(arguments[2])=='string') $tag=arguments[2].toUpperCase();
if (typeof(arguments[3])=='number') $limit=arguments[3];
for (var $i=0; $i<$list.length; $i++)
{
if (($list[$i].tagName==$tag)&&(hasClass($list[$i], $class))) $result[$result.length]=$list[$i];
if (($limit>0)&&($result.length>=$limit)) break;
$rec=getInnerTags($list[$i], $class, $tag, $limit-$result.length);
if ($rec) $result=$result.concat($rec);
if (($limit>0)&&($result.length>=$limit)) break;
}
if ($limit==1) return $result[0];
else return $result;
}
// Функции для скрывания и показыания части статьи одной кнопкой.
function hideSpoilers()
{
createCookie('showNSFW','no',null);
manageSpoilers(false);
}
function showSpoilers()
{
createCookie('showNSFW','yes',null);
manageSpoilers(true);
}
function manageSpoilers($visibility)
{
var $list=getInnerTags(document.body, 'spoilerline', 'span');
var $num=$list.length;
for (var $x=0; $x<$num; $x++)
{
if (!$visibility) $list[$x].className='spoilerline hiddenline';
else $list[$x].className='spoilerline';
}
$list=getInnerTags(document.body, 'spoilerblock', 'DIV');
$num=$list.length; var $id;
for (var $x=0; $x<$num; $x++)
{
$id=$list[$x].id.substr(8);
collapseDiv($id, $visibility);
}
}
function setSpoilerButtons()
{
var $holder=document.getElementById('spoilerbuttons'), $defhidden='';
if (!$holder) { $holder=document.getElementById('spoilerbuttons_defhidden'); $defhidden='_defhidden'; }
if ($holder)
{
$holder.innerHTML='<u><span id="showspoilers'+$defhidden+'" style="cursor:pointer;">Показать</span></u> <u><span id="hidespoilers" style="cursor:pointer;">Скрыть</span></u>';
var $button=document.getElementById('showspoilers'+$defhidden);
if ($button.addEventListener) $button.addEventListener('click', showSpoilers, false);
else if ($button.attachEvent)$button.attachEvent('onclick', showSpoilers);
$button=document.getElementById('hidespoilers');
if ($button.addEventListener) $button.addEventListener('click', hideSpoilers, false);
else if ($button.attachEvent)$button.attachEvent('onclick', hideSpoilers);
}
}
if ((wgNamespaceNumber===0)&&(!$IE6))
{
addOnloadHook(setSpoilerButtons);
}
/** Collapsible tables *********************************************************
*
* Description: Allows tables to be collapsed, showing only the header. See
* http://www.mediawiki.org/wiki/Manual:Collapsible_tables.
* Maintainers: [[en:User:R. Koot]]
*/
var autoCollapse = 0;
var collapseCaption = 'Скрыть';
var expandCaption = 'Показать';
function collapseTable( tableIndex ) {
var Button = document.getElementById( 'collapseButton' + tableIndex );
var Table = document.getElementById( 'collapsibleTable' + tableIndex );
if ( !Table || !Button ) {
return false;
}
var Rows = Table.rows;
if ( Button.firstChild.data == collapseCaption ) {
for ( var i = 1; i < Rows.length; i++ ) {
Rows[i].style.display = 'none';
}
Button.firstChild.data = expandCaption;
} else {
for ( var i = 1; i < Rows.length; i++ ) {
Rows[i].style.display = Rows[0].style.display;
}
Button.firstChild.data = collapseCaption;
}
}
function createCollapseButtons() {
var tableIndex = 0;
var NavigationBoxes = new Object();
var Tables = document.getElementsByTagName( 'table' );
for ( var i = 0; i < Tables.length; i++ ) {
if ( hasClass( Tables[i], 'collapsible' ) ) {
/* only add button and increment count if there is a header row to work with */
var HeaderRow = Tables[i].getElementsByTagName( 'tr' )[0];
if ( !HeaderRow ) {
continue;
}
var Header = HeaderRow.getElementsByTagName( 'th' )[0];
if ( !Header ) {
continue;
}
NavigationBoxes[tableIndex] = Tables[i];
Tables[i].setAttribute( 'id', 'collapsibleTable' + tableIndex );
var Button = document.createElement( 'span' );
var ButtonLink = document.createElement( 'a' );
var ButtonText = document.createTextNode( collapseCaption );
Button.className = 'collapseButton tinytext'; // Styles are declared in [[MediaWiki:Common.css]]
ButtonLink.style.color = Header.style.color;
ButtonLink.setAttribute( 'id', 'collapseButton' + tableIndex );
// ButtonLink.setAttribute( 'href', '#' );
ButtonLink.addEventListener('click', new Function( 'evt', 'collapseTable(' + tableIndex + ' ); return killEvt( evt );' ) );
ButtonLink.appendChild( ButtonText );
Button.appendChild( document.createTextNode( '[' ) );
Button.appendChild( ButtonLink );
Button.appendChild( document.createTextNode( ']' ) );
Header.insertBefore( Button, Header.childNodes[0] );
tableIndex++;
}
}
for ( var i = 0; i < tableIndex; i++ ) {
if ( hasClass( NavigationBoxes[i], 'collapsed' ) || ( tableIndex >= autoCollapse && hasClass( NavigationBoxes[i], 'autocollapse' ) ) ) {
collapseTable( i );
} else if ( hasClass( NavigationBoxes[i], 'innercollapse' ) ) {
var element = NavigationBoxes[i];
while ( element = element.parentNode ) {
if ( hasClass( element, 'outercollapse' ) ) {
collapseTable( i );
break;
}
}
}
}
}
addOnloadHook( createCollapseButtons );
/** Test if an element has a certain class **************************************
*
* Description: Uses regular expressions and caching for better performance.
* Maintainers: [[User:Mike Dillon]], [[User:R. Koot]], [[User:SG]]
*/
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 createCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}
function eraseCookie(name) {
createCookie(name,"",-1);
}
/*
Bilingual links
Functions through the DoubleWiki extension.
Author: wikisource:fr:ThomasV, jQuery version by wikipedia:en:GreenReaper
*/
$(function(){
var doc_url = document.URL;
// iterate over all interlanguage links
$('.interlanguage-link>a[hreflang]').each(function() {
var lang = this.getAttribute("hreflang");
var qm = doc_url.indexOf( doc_url.indexOf('?title=') != -1 ? '&match=' : '?' );
var url = doc_url+"?match="+lang;
if( qm != -1 ) url = doc_url.substring(0,qm)+"?match="+lang;
this.outerHTML += "<a href='"+url+"'> ⇔</a>";
})
})
// Use to insert a div used as a trigger by this script
// to hide namespace prefixes in the lists of pages in a category function
function catnoprefix() {
if( !document.getElementById('catnoprefix' ) ) {
return;
}
var anchors = document.getElementById( 'mw-pages' );
if (!anchors) return
anchors=anchors.getElementsByTagName( 'a' );
for( var i = 0; i < anchors.length; i++ ) {
if( anchors[i].innerHTML.indexOf( ':' ) != -1 ) {
anchors[i].innerHTML = anchors[i].innerHTML.substring( anchors[i].innerHTML.indexOf( ':' ) + 1 );
}
}
}
$(document).ready( catnoprefix );
|