Добро пожаловать на Lesta Games Wiki!

MediaWiki:Common.js — различия между версиями

Перейти к: навигация, поиск
Версия 19:14, 24 сентября 2015Текущая версия на 12:35, 18 апреля 2024 
не показано 28 промежуточных версии 7 участников
Строка 1:Строка 1:
 /* Размещённый здесь JavaScript код будет загружаться всем пользователям при обращении к каждой странице */ /* Размещённый здесь JavaScript код будет загружаться всем пользователям при обращении к каждой странице */
? + 
  
 /* Добавление кнопки и функционала Викификатора в режиме редактирования */ /* Добавление кнопки и функционала Викификатора в режиме редактирования */
?if ( $.inArray( mw.config.get( 'wgAction' ), ['edit', 'submit'] ) !== -1 ) {+if ($.inArray( mw.config.get( 'wgAction' ), ['edit', 'submit'] ) !== -1 ) {
? mw.loader.load( '//ru.wikipedia.org/w/index.php?title=MediaWiki:Wikificator.js&action=raw&ctype=text/javascript' );+ mw.loader.load('//ru.wikipedia.org/w/index.php?title=MediaWiki:Wikificator.js&action=raw&ctype=text/javascript');
 } }
? + 
 var customizeToolbar = function() { var customizeToolbar = function() {
? + $('#wpTextbox1').wikiEditor('addToToolbar', {
?$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {+ 'section': 'advanced',
? 'section': 'advanced',+ 'group': 'format',
? 'group': 'format',+ 'tools': {
? 'tools': {+ 'wikify': {
? 'wikify': {+ label: 'Викификатор',
? label: 'Викификатор',+ type: 'button',
? type: 'button',+ icon: '//upload.wikimedia.org/wikipedia/commons/0/06/Wikify-toolbutton.png',
? icon: '//upload.wikimedia.org/wikipedia/commons/0/06/Wikify-toolbutton.png',+ action: {
? action: {+ type: 'callback',
? type: 'callback',+ execute: function(context) {
? execute: function(context){+ Wikify();
? Wikify();+ }
? } + }
  }  }
  }  }
? }+ });
?} );+
 }; };
? + 
?if ( $.inArray( mw.config.get( 'wgAction' ), ['edit', 'submit'] ) !== -1 ) {+if ($.inArray(mw.config.get('wgAction'), ['edit', 'submit']) !== -1) {
? mw.loader.using( 'user.options', function () {+ mw.loader.using('user.options', function () {
? mw.loader.using( 'ext.wikiEditor.toolbar', function () {+ mw.loader.using('ext.wikiEditor.toolbar', function () {
? $(document).ready( customizeToolbar );+ $(document).ready(customizeToolbar);
? } );+ });
? } );+ });
 } }
  
Строка 42:Строка 41:
  if (logout != null) {  if (logout != null) {
  document.getElementById('footer-wot-link').style.display = 'none';  document.getElementById('footer-wot-link').style.display = 'none';
? } + }
  } catch(e) {  } catch(e) {
  return;  return;
Строка 52:Строка 51:
 var mapImages = new Array(); var mapImages = new Array();
  
?function tacticNext() { +function tacticNext() {
  document.getElementById('step' + tacticCounter).style.display = 'none';  document.getElementById('step' + tacticCounter).style.display = 'none';
  
? if (tacticCounter < mapImages.length - 1) { + if (tacticCounter < mapImages.length - 1) {
? tacticCounter++ ;+ tacticCounter++;
  if (tacticCounter == mapImages.length - 1) document.getElementById('nextsteplink').innerHTML = 'В начало';  if (tacticCounter == mapImages.length - 1) document.getElementById('nextsteplink').innerHTML = 'В начало';
? } else { + } else {
? tacticCounter = 1; + tacticCounter = 1;
  document.getElementById('nextsteplink').innerHTML = 'Продолжить »';  document.getElementById('nextsteplink').innerHTML = 'Продолжить »';
  }  }
Строка 77:Строка 76:
  mapDiv.innerHTML = '';  mapDiv.innerHTML = '';
  mapDiv.style.background = 'url(' + mapImages[0] + ') top no-repeat';  mapDiv.style.background = 'url(' + mapImages[0] + ') top no-repeat';
? var imgNode = document.createElement( 'img' );+ var imgNode = document.createElement('img');
  imgNode.id = 'tacticimg';  imgNode.id = 'tacticimg';
  imgNode.src = mapImages[1];  imgNode.src = mapImages[1];
? mapDiv.appendChild( imgNode );+ mapDiv.appendChild(imgNode);
  
? var aNode = document.createElement( 'a' ); + var aNode = document.createElement('a');
? aNode.setAttribute( 'id', 'nextsteplink' );+ aNode.setAttribute('id', 'nextsteplink');
? aNode.setAttribute( 'href', '#' );+ aNode.setAttribute('href', '#');
? aNode.setAttribute( 'onClick', 'return tacticNext();' );+ aNode.setAttribute('onClick', 'return tacticNext();');
  aNode.appendChild(document.createTextNode('Продолжить »'));  aNode.appendChild(document.createTextNode('Продолжить »'));
  document.getElementById('nextstep').appendChild(aNode);  document.getElementById('nextstep').appendChild(aNode);
Строка 95:Строка 94:
 /* переключение ТТХ топ/сток */ /* переключение ТТХ топ/сток */
 function tthTopStock() { function tthTopStock() {
? $('#toStock').click(function(){+ $('#toStock').click(function() {
? $('#stockTTH').show();+ $('#stockTTH').show();
? $('#topTTH').hide();+ $('#topTTH').hide();
? });+ });
? $('#toTop').click(function(){+ $('#toTop').click(function() {
? $('#stockTTH').hide();+ $('#stockTTH').hide();
? $('#topTTH').show();+ $('#topTTH').show();
? });+ });
 } }
  
 function gunShellsBlock() { function gunShellsBlock() {
? $('.gunTd span').click(function(){+ $('.gunTd span').click(function() {
  if ($(this).parent().hasClass("shellsClosed")) {  if ($(this).parent().hasClass("shellsClosed")) {
  $('#block-' + $(this).data("guncode")).show();  $('#block-' + $(this).data("guncode")).show();
  } else {  } else {
  $('#block-' + $(this).data("guncode")).hide();  $('#block-' + $(this).data("guncode")).hide();
? } + }
  $(this).parent().toggleClass("shellsClosed shellsOpened");  $(this).parent().toggleClass("shellsClosed shellsOpened");
  });  });
Строка 117:Строка 116:
  
 //Messages //Messages
?var NavigationBarHide = '[скрыть]'+var NavigationBarHide = '[скрыть]';
?var NavigationBarShow = '[показать]'+var NavigationBarShow = '[показать]';
?var NavigationBarShowDefault = 2+var NavigationBarShowDefault = 2;
  
 /* Функционал раскрывающихся блоков (спойлеры) */ /* Функционал раскрывающихся блоков (спойлеры) */
 //Collapsiblе //Collapsiblе
  
?var hasClass = (function (){+var hasClass = (function () {
? var reCache = {}+ var reCache = {}
? return function (element, className){+ return function (element, className) {
? return (reCache[className] ? reCache[className] : (reCache[className] = new RegExp("(?:\\s|^)" + className + "(?:\\s|$)"))).test(element.className)+ return (reCache[className] ? reCache[className] : (reCache[className] = new RegExp("(?:\\s|^)" + className + "(?:\\s|$)"))).test(element.className)
  }  }
?})()+})();
  
 /* /*
?$(document).ready(function(){+$(document).ready(function() {
? $("table.collapsible").each(function(idx, table){+ $("table.collapsible").each(function(idx, table) {
? $(table).attr( "id", 'collapsibleTable' + idx );+ $(table).attr("id", 'collapsibleTable' + idx);
? });+ });
 }); });
? 
 */ */
?$(document).ready(function(){+ 
? /*Chrome font bug hack*/+$(document).ready(function() {
? if ($.browser.chrome) {+ /*Chrome font bug hack*/
? var DALEY_FOR_CHROME_FONT_CORRECTION = 2000;+ if ($.browser.chrome) {
? setTimeout(function () {+ var DALEY_FOR_CHROME_FONT_CORRECTION = 2000;
? $('body')+ setTimeout(function () {
? .addClass('temp')+ $('body')
? .removeClass('temp');+ .addClass('temp')
? }, DALEY_FOR_CHROME_FONT_CORRECTION);+ .removeClass('temp');
? }+ }, DALEY_FOR_CHROME_FONT_CORRECTION);
 + }
 }); });
  
?function collapsibleTables(){+function collapsibleTables() {
? var Table, HRow, HCell, btn, a, tblIdx = 0, colTables = []+ var Table, HRow, HCell, btn, a, tblIdx = 0, colTables = [];
? var allTables = document.getElementsByTagName('table')+ var allTables = document.getElementsByTagName('table');
? for (var i=0; Table = allTables[i]; i++){+ for (var i=0; Table = allTables[i]; i++) {
? if (!hasClass(Table, 'collapsible')) continue+ if (!hasClass(Table, 'collapsible')) continue;
? if (!(HRow=Table.rows[0])) continue+ if (!(HRow=Table.rows[0])) continue;
? if (!(HCell=HRow.getElementsByTagName('th')[0])) continue+ if (!(HCell=HRow.getElementsByTagName('th')[0])) continue;
? Table.id = 'collapsibleTable' + tblIdx+ Table.id = 'collapsibleTable' + tblIdx;
? btn = document.createElement('span')+ btn = document.createElement('span');
? btn.style.cssText = 'float:right; font-weight:normal; font-size:smaller'+ btn.style.cssText = 'float:right; font-weight:normal; font-size:smaller';
? a = document.createElement('a')+ a = document.createElement('a');
? a.id = 'collapseButton' + tblIdx+ a.id = 'collapseButton' + tblIdx;
? a.href = 'javascript:collapseTable(' + tblIdx + ');'+ a.href = 'javascript:collapseTable(' + tblIdx + ');';
? a.style.color = HCell.style.color+ a.style.color = HCell.style.color;
? a.appendChild(document.createTextNode(NavigationBarHide))+ a.appendChild(document.createTextNode(NavigationBarHide));
? btn.appendChild(a)+ btn.appendChild(a);
? HCell.insertBefore(btn, HCell.childNodes[0])+ HCell.insertBefore(btn, HCell.childNodes[0]);
? colTables[tblIdx++] = Table+ colTables[tblIdx++] = Table;
? }+ }
? for (var i=0; i < tblIdx; i++)+ for (var i=0; i < tblIdx; i++) {
? if ((tblIdx > NavigationBarShowDefault && hasClass(colTables[i], 'autocollapse')) || hasClass(colTables[i], 'collapsed'))+ if ((tblIdx > NavigationBarShowDefault && hasClass(colTables[i], 'autocollapse')) || hasClass(colTables[i], 'collapsed')) {
? collapseTable(i)+ collapseTable(i)
 + }
 + }
 } }
  
?function collapseTable (idx){+function collapseTable(idx) {
? var Table = document.getElementById('collapsibleTable' + idx)+ var Table = document.getElementById('collapsibleTable' + idx);
? var btn = document.getElementById('collapseButton' + idx)+ var btn = document.getElementById('collapseButton' + idx);
? if (!Table || !btn) return false+ if (!Table || !btn) {return false;}
? var Rows = Table.rows+ var Rows = Table.rows;
? var isShown = (btn.firstChild.data == NavigationBarHide)+ var isShown = (btn.firstChild.data == NavigationBarHide);
? btn.firstChild.data = isShown ? NavigationBarShow : NavigationBarHide+ btn.firstChild.data = isShown ? NavigationBarShow : NavigationBarHide;
? var disp = isShown ? 'none' : Rows[0].style.display+ var disp = isShown ? 'none' : Rows[0].style.display;
? for (var i=1; i < Rows.length; i++)+ for (var i=1; i < Rows.length; i++) {
  Rows[i].style.display = disp  Rows[i].style.display = disp
 + }
 } }
  
?function collapsibleDivs(){+function collapsibleDivs() {
? var navIdx = 0, colNavs = [], i, NavFrame+ var navIdx = 0, colNavs = [], i, NavFrame;
? var divs = document.getElementById('content').getElementsByTagName('div')+ var divs = document.getElementById('content').getElementsByTagName('div');
? for (i=0; NavFrame = divs[i]; i++) {+ for (i=0; NavFrame = divs[i]; i++) {
? if (!hasClass(NavFrame, 'NavFrame')) continue+ if (!hasClass(NavFrame, 'NavFrame')) continue;
? NavFrame.id = 'NavFrame' + navIdx+ NavFrame.id = 'NavFrame' + navIdx;
? var a = document.createElement('a')+ var a = document.createElement('a');
? a.className = 'NavToggle'+ a.className = 'NavToggle';
? a.id = 'NavToggle' + navIdx+ a.id = 'NavToggle' + navIdx;
? a.href = 'javascript:collapseDiv(' + navIdx + ');'+ a.href = 'javascript:collapseDiv(' + navIdx + ');';
? a.appendChild(document.createTextNode(NavigationBarHide))+ a.appendChild(document.createTextNode(NavigationBarHide));
? for (var j=0; j < NavFrame.childNodes.length; j++)+ for (var j=0; j < NavFrame.childNodes.length; j++) {
? if (hasClass(NavFrame.childNodes[j], 'NavHead'))+ if (hasClass(NavFrame.childNodes[j], 'NavHead')) {
? NavFrame.childNodes[j].appendChild(a)+ NavFrame.childNodes[j].appendChild(a);
? colNavs[navIdx++] = NavFrame+ }
? }+ }
? for (i=0; i < navIdx; i++)+ colNavs[navIdx++] = NavFrame;
? if ((navIdx > NavigationBarShowDefault && !hasClass(colNavs[i], 'expanded')) || hasClass(colNavs[i], 'collapsed'))+ }
? collapseDiv(i)+ for (i=0; i < navIdx; i++) {
 + if ((navIdx > NavigationBarShowDefault && !hasClass(colNavs[i], 'expanded')) || hasClass(colNavs[i], 'collapsed')) {
 + collapseDiv(i);
 + }
 + }
 } }
  
 function collapseDiv(idx) { function collapseDiv(idx) {
? var div = document.getElementById('NavFrame' + idx)+ var div = document.getElementById('NavFrame' + idx);
? var btn = document.getElementById('NavToggle' + idx)+ var btn = document.getElementById('NavToggle' + idx);
? if (!div || !btn) return false+ if (!div || !btn) {return false;}
? var isShown = (btn.firstChild.data == NavigationBarHide)+ var isShown = (btn.firstChild.data == NavigationBarHide);
? btn.firstChild.data = isShown ? NavigationBarShow : NavigationBarHide+ btn.firstChild.data = isShown ? NavigationBarShow : NavigationBarHide;
? var disp = isShown ? 'none' : 'block'+ var disp = isShown ? 'none' : 'block';
? for (var child = div.firstChild; child != null; child = child.nextSibling)+ for (var child = div.firstChild; child != null; child = child.nextSibling) {
? if (hasClass(child, 'NavPic') || hasClass(child, 'NavContent'))+ if (hasClass(child, 'NavPic') || hasClass(child, 'NavContent')) {
? child.style.display = disp+ child.style.display = disp;
 + }
 + }
 } }
  
Строка 224:Строка 232:
  
 $('.commentDrop').hover( $('.commentDrop').hover(
?function(){+ function() {
? if (!isDropDownBox) {+ if (!isDropDownBox) {
? $('#bodyContent').append('<div id="dropDownBox" style="position:absolute;"></div>');+ $('#bodyContent').append('<div id="dropDownBox" style="position:absolute;"></div>');
? isDropDownBox = true;+ isDropDownBox = true;
? }+ }
? var offset = $(this).position();+ var offset = $(this).position();
? var top = offset.top + $(this).height();+ var top = offset.top + $(this).height();
? + var obj = $.parseJSON($(this).find(".commentData").text());
? var obj = $.parseJSON($(this).find(".commentData").text());+ var str = '<div style="border:1px dotted;background:#efefef;padding:5px 1em;"><p style="text-align:center;"><b>' + obj.type + ' ' + obj.mark + '</b></p> <dl>';
? + var items = [];
? var str = '<div style="border:1px dotted;background:#efefef;padding:5px 1em;"><p style="text-align:center;"><b>' + $.each(obj.data, function(key, val) {
? + obj.type + ' ' + obj.mark + '</b></p> <dl>';+ items.push('<dt>' + key + ':</dt><dd>' + val + '</dd>');
? + });
? var items = [];+ str += items.join('') + ' </dl></div><p>&nbsp;</p>';
? $.each(obj.data, function(key, val){+ $("#dropDownBox").html(str);
? items.push('<dt>' + key + ':</dt><dd>' + val + '</dd>');+ $("#dropDownBox").css({"top": top + "px", "left":offset.left + "px"})
 + $("#dropDownBox").show();
 + },
 + function() {
 + $("#dropDownBox").hide();
  });  });
? 
? str += items.join('') + ' </dl></div><p>&nbsp;</p>'; 
? 
? $("#dropDownBox").html(str); 
? $("#dropDownBox").css({"top": top + "px", "left":offset.left + "px"}) 
? $("#dropDownBox").show(); 
?}, 
?function(){ 
? $("#dropDownBox").hide(); 
?}); 
  
 /* Функционал всплывающих подсказок с ТТХ модулей для World of Warships */ /* Функционал всплывающих подсказок с ТТХ модулей для World of Warships */
Строка 268:Строка 270:
  
 $('.commentDrop_wows').hover( $('.commentDrop_wows').hover(
?function(){+ function() {
? if (!isDropDownBox) {+ if (!isDropDownBox) {
? $('#bodyContent').append('<div id="dropDownBox" style="position:absolute;"></div>');+ $('#bodyContent').append('<div id="dropDownBox" style="position:absolute;"></div>');
? isDropDownBox = true;+ isDropDownBox = true;
? }+ }
? var offset = $(this).position();+ var offset = $(this).position();
 + var top = offset.top + $(this).height();
 + var obj = $.parseJSON($(this).find(".commentData_wows").text());
 + var str = '<div class="d-comment"><div class="d-comment-head"><div class="d-comment-img">' + '<img width="60" height="60" src="' + moduleImages[obj.type] + '" alt="">' + '</div><div class="d-comment-name"><h3>' + obj.type + '</h3><span>' + obj.mark + '</span></div></div><div class="b-performance_text d-comment-body"><table class="t-performance">';
 + var items = [];
  
? var top = offset.top + $(this).height();+ $.each(obj.data, function(key, val) {
 + items.push('<tr><td><span class="t-performance_right">' + val + '</span><span class="t-performance_left">' + key + '</span></td></tr>');
 + });
  
? var obj = $.parseJSON($(this).find(".commentData_wows").text());+ str += items.join('') + '</table></div></div>';
  
? var str = '<div class="d-comment"><div class="d-comment-head"><div class="d-comment-img">' + '<img width="60" height="60" src="' + moduleImages[obj.type] + '" alt="">' + '</div><div class="d-comment-name"><h3>' + obj.type + '</h3><span>' + obj.mark + '</span></div></div><div class="b-performance_text d-comment-body"><table class="t-performance">';+ $("#dropDownBox").html(str);
? + $("#dropDownBox").css({"top": top + "px", "left":offset.left + "px"})
? var items = [];+ $("#dropDownBox").show();
? + },
? $.each(obj.data, function(key, val){+ function() {
? items.push('<tr><td><span class="t-performance_right">' + val + '</span><span class="t-performance_left">' + key + '</span></td></tr>');+ $("#dropDownBox").hide();
? });+ }
? +);
? str += items.join('') + '</table></div></div>';+
? +
? $("#dropDownBox").html(str);+
? $("#dropDownBox").css({"top": top + "px", "left":offset.left + "px"})+
? $("#dropDownBox").show();+
?},+
?function(){+
? $("#dropDownBox").hide();+
?});+
  
 /* /*
Строка 304:Строка 303:
  
  
?/* Добавление комплектации в Edittools */+/* Добавление комплектации в Edittools */
 function addAdditionalEdittools() { function addAdditionalEdittools() {
  try{  try{
Строка 360:Строка 359:
  
  etElem.push({text: '</p>'});  etElem.push({text: '</p>'});
? + 
  for ( key in etElem ) {  for ( key in etElem ) {
? insertLeft = etElem[key].insertLeft!==undefined?etElem[key].insertLeft:''; insertRight = etElem[key].insertRight!==undefined?etElem[key].insertRight:'';+ insertLeft = etElem[key].insertLeft!==undefined?etElem[key].insertLeft:''; insertRight = etElem[key].insertRight!==undefined?etElem[key].insertRight:'';
? insert = etElem[key].insert!==undefined?etElem[key].insert:''; title = etElem[key].title!==undefined?etElem[key].title:insertLeft+insert+insertRight;+ insert = etElem[key].insert!==undefined?etElem[key].insert:''; title = etElem[key].title!==undefined?etElem[key].title:insertLeft+insert+insertRight;
? + 
  if ((insertLeft+insert+insertRight)!='') {resultText += '<a onclick="insertTags(\''+insertLeft+'\',\''+insertRight+'\',\''+insert+'\');return false;" title="'+title+'" href="#">';}  if ((insertLeft+insert+insertRight)!='') {resultText += '<a onclick="insertTags(\''+insertLeft+'\',\''+insertRight+'\',\''+insert+'\');return false;" title="'+title+'" href="#">';}
  if (etElem[key].img !== undefined) {resultText += '<img src="'+etElem[key].img+'" />';}  if (etElem[key].img !== undefined) {resultText += '<img src="'+etElem[key].img+'" />';}
Строка 406:Строка 405:
  
 /* Прячет не заданные характеристики в ТТХ */ /* Прячет не заданные характеристики в ТТХ */
?function hideNoDataInfoInTankPerformance() { +function hideNoDataInfoInTankPerformance() {
? $('.TankPerformance td span').each(function(key, value) { + $('.TankPerformance td span').each(function(key, value) {
  if ($(value).text().indexOf('не задано')+1) $(value).parent().parent().hide();  if ($(value).text().indexOf('не задано')+1) $(value).parent().parent().hide();
  });  });
Строка 416:Строка 415:
  $('body').append(  $('body').append(
  '<div id="popupImageWindow"><table><tr><td style="vertical-align: middle;">'+  '<div id="popupImageWindow"><table><tr><td style="vertical-align: middle;">'+
? '<div id="popupImageOverlay"></div>'++ '<div id="popupImageOverlay"></div>'+
? '<div id="popupImageWrapper">'++ '<div id="popupImageWrapper">'+
? '<img id="popupImage" src="" />'++ '<img id="popupImage" src="" />'+
? '<img src="//wikicdn.wargaming.net/images/b/bd/Close.png" class="closeBtn">'++ '<img src="//wiki.gcdn.co/images/b/bd/Close.png" class="closeBtn">'+
? '<a id="popupImageLeft" href="javascript:;">'++ '<a id="popupImageLeft" href="javascript:;">'+
? '<span id="popupImageIcoLeft" class="popupImageIco"></span>'++ '<span id="popupImageIcoLeft" class="popupImageIco"></span>'+
? '</a>'++ '</a>'+
? '<a id="popupImageRight" href="javascript:;">'++ '<a id="popupImageRight" href="javascript:;">'+
? '<span id="popupImageIcoRight" class="popupImageIco"></span>'++ '<span id="popupImageIcoRight" class="popupImageIco"></span>'+
? '</a>'++ '</a>'+
? '<div id="popupImageInfo"></div>'++ '<div id="popupImageInfo"></div>'+
? '</div>'++ '</div>'+
  '</td></tr></table></div>'+  '</td></tr></table></div>'+
  '<div id="popupImageButtons"><a id="openImageFile" href="javascript:;">Файл</a></div>'  '<div id="popupImageButtons"><a id="openImageFile" href="javascript:;">Файл</a></div>'
Строка 434:Строка 433:
  
 var gallersArray = [], // Массив галерей, в которых массив объектов (src, text, href) var gallersArray = [], // Массив галерей, в которых массив объектов (src, text, href)
? currentGalleryIndex = 0, currentImageIndex = 0;+ currentGalleryIndex = 0, currentImageIndex = 0;
  
 /* Открывает картинку */ /* Открывает картинку */
 function setImage(indexGallery, indexImage) { function setImage(indexGallery, indexImage) {
? currentGalleryIndex = indexGallery;+ currentGalleryIndex = indexGallery;
? currentImageIndex = indexImage;+ currentImageIndex = indexImage;
? $('#popupImage').width('1px');+ $('#popupImage').width('1px');
? $('#popupImage').height('1px');+ $('#popupImage').height('1px');
? $('#popupImageOverlay').css('background-image', 'url('+imageLoaderUrl+')');+ $('#popupImageOverlay').css('background-image', 'url('+imageLoaderUrl+')');
? $('#popupImage').attr('src', gallersArray[indexGallery][indexImage].src);+ $('#popupImage').attr('src', gallersArray[indexGallery][indexImage].src);
? $('#popupImageButtons a#openImageFile').attr('href', gallersArray[indexGallery][indexImage].href);+ $('#popupImageButtons a#openImageFile').attr('href', gallersArray[indexGallery][indexImage].href);
? $('#popupImageInfo').html(gallersArray[indexGallery][indexImage].text);+ $('#popupImageInfo').html(gallersArray[indexGallery][indexImage].text);
? if (gallersArray[indexGallery].length < indexImage + 2) { // Если нет следующей картинки убираем кнопку+ if (gallersArray[indexGallery].length < indexImage + 2) { // Если нет следующей картинки убираем кнопку
? $('#popupImageRight').hide();+ $('#popupImageRight').hide();
? } else {+ } else {
? $('#popupImageRight').show();+ $('#popupImageRight').show();
? }+ }
? if (indexImage - 1 < 0) { // Если нет предыдущей картинки убираем кнопку+ if (indexImage - 1 < 0) { // Если нет предыдущей картинки убираем кнопку
? $('#popupImageLeft').hide();+ $('#popupImageLeft').hide();
? } else {+ } else {
? $('#popupImageLeft').show();+ $('#popupImageLeft').show();
? }+ }
? $('#popupImageWrapper').hide();+ $('#popupImageWrapper').hide();
? $('#popupImageWindow').show();+ $('#popupImageWindow').show();
? $('#popupImageButtons').show();+ $('#popupImageButtons').show();
 } }
  
 /* добавляет функционал просмотра увеличенных изображений без перехода на другую страницу */ /* добавляет функционал просмотра увеличенных изображений без перехода на другую страницу */
 function addImagePopups() { function addImagePopups() {
? addImagePopupWindow();+ addImagePopupWindow();
  
? // Для галерей+ // Для галерей
? $.each($('ul.gallery'), function(indexGallery, valueGallery) {+ $.each($('ul.gallery'), function(indexGallery, valueGallery) {
? gallersArray[indexGallery] = [];+ gallersArray[indexGallery] = [];
? $.each($(valueGallery).find('li.gallerybox'), function(indexImage, valueImage) {+ $.each($(valueGallery).find('li.gallerybox'), function(indexImage, valueImage) {
? var Image = new Object();+ var Image = new Object();
? var srcStr = $(valueImage).find('a.image img').attr('src');+ var srcStr = $(valueImage).find('a.image img').attr('src');
? if (typeof srcStr !== 'undefined') {+ if (typeof srcStr !== 'undefined') {
? if (srcStr.indexOf('thumb/')+1 > 0) {+ if (srcStr.indexOf('thumb/')+1 > 0) {
? srcStr = srcStr.replace(/thumb\//gi, '');+ srcStr = srcStr.replace(/thumb\//gi, '');
? srcStr = srcStr.substring(0, srcStr.lastIndexOf("/"));+ srcStr = srcStr.substring(0, srcStr.lastIndexOf("/"));
? }+ }
? }+ }
? Image.src = srcStr;+ Image.src = srcStr;
? Image.text = $(valueImage).find('div.gallerytext').text().trim();+ Image.text = $(valueImage).find('div.gallerytext').text().trim();
? Image.href = $(valueImage).find('a.image').attr('href');+ Image.href = $(valueImage).find('a.image').attr('href');
? if (typeof Image.src !== 'undefined') {+ if (typeof Image.src !== 'undefined') {
? gallersArray[indexGallery][indexImage] = Image;+ gallersArray[indexGallery][indexImage] = Image;
? $(valueImage).find('a.image').click(function(index) {+ $(valueImage).find('a.image').click(function(index) {
? setImage(indexGallery, indexImage);+ setImage(indexGallery, indexImage);
? return false;+ return false;
? });+
? }+
  });  });
 + }
  });  });
 + });
  
? // Для одиночных эскизров+ // Для одиночных эскизров
? $.each($('a.image').not($('.js-vehicles_by_types a.image')).not($('ul.gallery a.image')), function(index, value) {+ $.each($('a.image').not($('.js-vehicles_by_types a.image')).not($('ul.gallery a.image')), function(index, value) {
? var indexGallery = gallersArray.length;+ var indexGallery = gallersArray.length;
? gallersArray[indexGallery] = [];+ gallersArray[indexGallery] = [];
? var Image = new Object();+ var Image = new Object();
? var srcStr = $(value).find('img').attr('src');+ var srcStr = $(value).find('img').attr('src');
? if (typeof srcStr !== 'undefined') {+ if (typeof srcStr !== 'undefined') {
? if (srcStr.indexOf('thumb/')+1 > 0) {+ if (srcStr.indexOf('thumb/')+1 > 0) {
? srcStr = srcStr.replace(/thumb\//gi, '');+ srcStr = srcStr.replace(/thumb\//gi, '');
? srcStr = srcStr.substring(0, srcStr.lastIndexOf("/"));+ srcStr = srcStr.substring(0, srcStr.lastIndexOf("/"));
? }+ }
? }+ }
? Image.src = srcStr;+ Image.src = srcStr;
? var titleStr = ''; //Подпись+ var titleStr = ''; //Подпись
? if ($(this).next('div.thumbcaption').length > 0) {+ if ($(this).next('div.thumbcaption').length > 0) {
? titleStr = $(this).next('div.thumbcaption').text().trim();+ titleStr = $(this).next('div.thumbcaption').text().trim();
? } else if($(this).parent().parent().parent().children('div.gallerytext').length > 0) {+ } else if($(this).parent().parent().parent().children('div.gallerytext').length > 0) {
? titleStr = $(this).parent().parent().parent().children('div.gallerytext').text().trim();+ titleStr = $(this).parent().parent().parent().children('div.gallerytext').text().trim();
? }+ }
? Image.text = titleStr;+ Image.text = titleStr;
? Image.href = $(value).attr('href');+ Image.href = $(value).attr('href');
? if (typeof Image.src !== 'undefined') {+ if (typeof Image.src !== 'undefined') {
? gallersArray[indexGallery][0] = Image;+ gallersArray[indexGallery][0] = Image;
? $(value).click(function(index) {+ $(value).click(function(index) {
? setImage(indexGallery, 0);+ setImage(indexGallery, 0);
? return false;+ return false;
? });+ });
? }+ }
? });+ });
  
? // После загрузки картинки показываем её+ // После загрузки картинки показываем её
? $('#popupImage').load(function() {+ $('#popupImage').load(function() {
? $('#popupImage').width('');+ $('#popupImage').width('').height('');
? $('#popupImage').height('');+ $(this).css('max-width', (self.innerWidth-100)+'px');
? $(this).css('max-width', (self.innerWidth-100)+'px');+ $(this).css('max-height',(self.innerHeight-100)+'px');
? $(this).css('max-height',(self.innerHeight-100)+'px');+ $('#popupImageOverlay').css('background-image', '');
? $('#popupImageOverlay').css('background-image', '');+ $('#popupImageWrapper').show();
? $('#popupImageWrapper').show();+ });
? });+
  
? //Закрыть попап кнопкой+ //Закрыть попап кнопкой
? $('.closeBtn').click(function(index) {+ $('.closeBtn').click(function(index) {
? $('#popupImageWindow').hide();+ $('#popupImageWindow').hide();
? $('#popupImageButtons').hide();+ $('#popupImageButtons').hide();
? $('#popupImageButtons a').attr('href', '#');+ $('#popupImageButtons a').attr('href', '#');
? $('#popupImageInfo').text('');+ $('#popupImageInfo').text('');
? $('#popupImage').attr('src', '');+ $('#popupImage').attr('src', '');
? });+ });
  
? //Закрыть попап фоном+ //Закрыть попап фоном
? $('#popupImageOverlay').click(function(index) {+ $('#popupImageOverlay').click(function(index) {
? $('#popupImageWindow').hide();+ $('#popupImageWindow').hide();
? $('#popupImageButtons').hide();+ $('#popupImageButtons').hide();
? $('#popupImageButtons a').attr('href', '#');+ $('#popupImageButtons a').attr('href', '#');
? $('#popupImageInfo').text('');+ $('#popupImageInfo').text('');
? $('#popupImage').attr('src', '');+ $('#popupImage').attr('src', '');
? });+ });
  
? // Предыдущую картинку+ // Предыдущую картинку
? $('a#popupImageLeft').click(function(index) {+ $('a#popupImageLeft').click(function(index) {
? setImage(currentGalleryIndex, currentImageIndex - 1);+ setImage(currentGalleryIndex, currentImageIndex - 1);
? });+ });
? +
? // Следующую картинку+
? $('a#popupImageRight').click(function(index) {+
? setImage(currentGalleryIndex, currentImageIndex + 1);+
? });+
?};+
  
 + // Следующую картинку
 + $('a#popupImageRight').click(function(index) {
 + setImage(currentGalleryIndex, currentImageIndex + 1);
 + });
 +}
  
 /* Дерево модулей */ /* Дерево модулей */
? 
 function modulesBlock() { function modulesBlock() {
? var currentModulesBlock = 1; + var currentModulesBlock = 1;
  var modulesBlock = [];  var modulesBlock = [];
  modulesBlock[1] = $('#modulesBlock').html();  modulesBlock[1] = $('#modulesBlock').html();
  modulesBlock[2] = false;  modulesBlock[2] = false;
? var vehicle = $('#codeValue').text();+ var vehicle = $('#codeValue').text();
? + 
  $('#modulesBlockH2').append('<span id="modulesBlockChange"><div class="switcherCtrlBtn active" id="modulesBlockChange_1"><span>список</span></div><div class="switcherCtrlBtn" id="modulesBlockChange_2"><span>дерево развития</span></div></span>');  $('#modulesBlockH2').append('<span id="modulesBlockChange"><div class="switcherCtrlBtn active" id="modulesBlockChange_1"><span>список</span></div><div class="switcherCtrlBtn" id="modulesBlockChange_2"><span>дерево развития</span></div></span>');
? + 
? $('#modulesBlockChange .switcherCtrlBtn').click(function(){+ $('#modulesBlockChange .switcherCtrlBtn').click(function() {
? if ($(this).hasClass('active')) return false;+ if ($(this).hasClass('active')) {return false;}
  currentModulesBlock = $(this).attr("id") == 'modulesBlockChange_1' ? 1 : 2;  currentModulesBlock = $(this).attr("id") == 'modulesBlockChange_1' ? 1 : 2;
  if (modulesBlock[currentModulesBlock] == false ) {  if (modulesBlock[currentModulesBlock] == false ) {
? modulesBlock[currentModulesBlock] = '<iframe frameborder="0" style="border-width: 0; width: 100%; min-width: 780px; height: 620px;" src="https://armor.kiev.ua/wot/tanks/modulestree.php?vehicle=' + vehicle + '"></iframe>'; + modulesBlock[currentModulesBlock] = '<iframe frameborder="0" style="border-width: 0; width: 100%; min-width: 780px; height: 620px;" src="https://armor.kiev.ua/wot/tanks/modulestree.php?vehicle=' + vehicle + '"></iframe>';
  }  }
  $('#modulesBlock').html(modulesBlock[currentModulesBlock]);  $('#modulesBlock').html(modulesBlock[currentModulesBlock]);
Строка 583:Строка 579:
  });  });
  
? $('.treeFrame').each(function(indx){+ $('.treeFrame').each(function(indx) {
? $(this).html('<iframe frameborder="0" style="border-width: 0; width: 1645px; min-width: 1010px; height: 750px;" src="' + $(this).html() + '"></iframe>'); + $(this).html('<iframe frameborder="0" style="border-width: 0; width: 1645px; min-width: 1010px; height: 750px;" src="' + $(this).html() + '"></iframe>');
  });  });
? $('.modulesTreeFrame').each(function(indx){+ $('.modulesTreeFrame').each(function(indx) {
? $(this).html('<iframe frameborder="0" style="border-width: 0; width: 100%; min-width: 820px; height: 620px;" src="' + $(this).html() + '"></iframe>'); + $(this).html('<iframe frameborder="0" style="border-width: 0; width: 100%; min-width: 820px; height: 620px;" src="' + $(this).html() + '"></iframe>');
  });  });
 } }
Строка 598:Строка 594:
  var sHeight = $(this).find('.sw_data-height').text();  var sHeight = $(this).find('.sw_data-height').text();
  var sMenuposition = $(this).find('.sw_data-menuposition').text();  var sMenuposition = $(this).find('.sw_data-menuposition').text();
? + 
? if (sWidth!=""){+ if (sWidth != "") {
  $(this).find('.switcherWrap').css('width',sWidth);  $(this).find('.switcherWrap').css('width',sWidth);
  $(this).find('.subSwitcher').css('width',sWidth);  $(this).find('.subSwitcher').css('width',sWidth);
  }  }
? if (sHeight!=""){+ if (sHeight != "") {
  $(this).find('.switcherFrame').css('height',sHeight);  $(this).find('.switcherFrame').css('height',sHeight);
  $(this).find('.subSwitcher').css('height',sHeight);  $(this).find('.subSwitcher').css('height',sHeight);
  }  }
? + 
  $(this).find('.subSwitcher:first').show();  $(this).find('.subSwitcher:first').show();
  $(this).find('.switcherControlButton:first').addClass('active');  $(this).find('.switcherControlButton:first').addClass('active');
? + 
  if (sMenuposition != "") {  if (sMenuposition != "") {
? if (sMenuposition=='top') {+ if (sMenuposition == 'top') {
  $(this).find('.switcherControl').detach().prependTo($(this).find('.switcherWrap'));  $(this).find('.switcherControl').detach().prependTo($(this).find('.switcherWrap'));
  }  }
  }  }
? + 
  if ($(this).find('.subSwitcherBackground a img').length) {  if ($(this).find('.subSwitcherBackground a img').length) {
  $(this).find('.switcherFrame').css('backgroundImage', 'url('+$(this).find('.subSwitcherBackground a img').attr('src')+')');  $(this).find('.switcherFrame').css('backgroundImage', 'url('+$(this).find('.subSwitcherBackground a img').attr('src')+')');
  }  }
? + 
  $(this).removeClass('hidden');  $(this).removeClass('hidden');
  })  })
? + 
? $('.switcherControlButton').click(function (){+ $('.switcherControlButton').click(function () {
  var buttonCkickId=$(this).find('.sw_data-id').text();  var buttonCkickId=$(this).find('.sw_data-id').text();
? $(this).parent().children('.switcherControlButton').removeClass('active'); //hurr+ $(this).parent().children('.switcherControlButton').removeClass('active'); //hurr
  $(this).addClass('active');  $(this).addClass('active');
? $(this).parent().parent().find('.subSwitcher').each(function() { //durr+ $(this).parent().parent().find('.subSwitcher').each(function() { //durr
  if(buttonCkickId == $(this).find('.sw_data-id').text()) $(this).show();  if(buttonCkickId == $(this).find('.sw_data-id').text()) $(this).show();
  else $(this).hide();  else $(this).hide();
Строка 634:Строка 630:
  });  });
 } }
? 
  
 function switcher_original() { function switcher_original() {
  try{if (localStorage.o_debug_switcher == 1) {return 0;}} catch (e) {} // дебаг  try{if (localStorage.o_debug_switcher == 1) {return 0;}} catch (e) {} // дебаг
  $('.switcher').each(function () {  $('.switcher').each(function () {
? if ($(this).data('width')!=undefined && $(this).data('width')!=""){+ if ($(this).data('width') != undefined && $(this).data('width') != "") {
  $(this).find('.switcherWrap').css('width',$(this).data('width'));  $(this).find('.switcherWrap').css('width',$(this).data('width'));
  $(this).find('.subSwitcher').css('width',$(this).data('width'));  $(this).find('.subSwitcher').css('width',$(this).data('width'));
  }  }
? if ($(this).data('height')!=undefined && $(this).data('height')!=""){+ if ($(this).data('height') != undefined && $(this).data('height') != "") {
  $(this).find('.switcherFrame').css('height',$(this).data('height'));  $(this).find('.switcherFrame').css('height',$(this).data('height'));
  $(this).find('.subSwitcher').css('height',$(this).data('height'));  $(this).find('.subSwitcher').css('height',$(this).data('height'));
  }  }
? + 
  $(this).find('.subSwitcher:first').show();  $(this).find('.subSwitcher:first').show();
  $(this).find('.switcherControlButton:first').addClass('active');  $(this).find('.switcherControlButton:first').addClass('active');
? + 
  if ($(this).data('menuposition') !== undefined) {  if ($(this).data('menuposition') !== undefined) {
? if ($(this).data('menuposition')=='top') {+ if ($(this).data('menuposition') == 'top') {
  $(this).find('.switcherControl').detach().prependTo($(this).find('.switcherWrap'));  $(this).find('.switcherControl').detach().prependTo($(this).find('.switcherWrap'));
  }  }
  }  }
? + 
  console.log($(this).find('.subSwitcherBackground a img').length);  console.log($(this).find('.subSwitcherBackground a img').length);
  if ($(this).find('.subSwitcherBackground a img').length) {  if ($(this).find('.subSwitcherBackground a img').length) {
  $(this).find('.switcherFrame').css('backgroundImage', 'url('+$(this).find('.subSwitcherBackground a img').attr('src')+')');  $(this).find('.switcherFrame').css('backgroundImage', 'url('+$(this).find('.subSwitcherBackground a img').attr('src')+')');
  }  }
? + 
  $(this).removeClass('hidden');  $(this).removeClass('hidden');
  })  })
? + 
? $('.switcherControlButton').click(function (){+ $('.switcherControlButton').click(function () {
  var buttonCkickId=$(this).data('id');  var buttonCkickId=$(this).data('id');
? $(this).parent().children('.switcherControlButton').removeClass('active'); //hurr+ $(this).parent().children('.switcherControlButton').removeClass('active'); //hurr
  $(this).addClass('active');  $(this).addClass('active');
? $(this).parent().parent().find('.subSwitcher').each(function() { //durr+ $(this).parent().parent().find('.subSwitcher').each(function() { //durr
? if(buttonCkickId == $(this).data('id')) $(this).show();+ if (buttonCkickId == $(this).data('id')) {
? else $(this).hide();+ $(this).show();
 + } else {
 + $(this).hide();
 + }
  });  });
  });  });
 } }
  
?/* Улучшение панели */+/* Улучшение панели */
 function improvedPanelEditTools() { function improvedPanelEditTools() {
  try {  try {
Строка 685:Строка 683:
  $('#editPanel').addClass('improved'); $('.templatesUsed ul').addClass('improved');  $('#editPanel').addClass('improved'); $('.templatesUsed ul').addClass('improved');
  
? $('.mw-editTools').appendTo('#editPanel'); + $('.mw-editTools').appendTo('#editPanel');
  if (localStorage['o_improvedEditPanelDownKey'] != 1) { $('.editOptions').appendTo('#editPanel'); }  if (localStorage['o_improvedEditPanelDownKey'] != 1) { $('.editOptions').appendTo('#editPanel'); }
? + 
  if (localStorage['o_improvedEditPanelShowRight'] != 1) {  if (localStorage['o_improvedEditPanelShowRight'] != 1) {
  $("#editPanel").mouseenter(function(){ $('#editPanel').stop(true,true); $('#editPanel').animate({bottom: '0px'}, animateSpeed); })  $("#editPanel").mouseenter(function(){ $('#editPanel').stop(true,true); $('#editPanel').animate({bottom: '0px'}, animateSpeed); })
? .mouseleave(function(){ $('#editPanel').stop(true,true); $('#editPanel').animate({bottom: '-'+($('#editPanel').height()-10)+'px'}, animateSpeed); });+ .mouseleave(function(){ $('#editPanel').stop(true,true); $('#editPanel').animate({bottom: '-'+($('#editPanel').height()-10)+'px'}, animateSpeed); });
  $('#editPanel').animate({bottom: '-'+($('#editPanel').height()-10)+'px'}, animateSpeed);  $('#editPanel').animate({bottom: '-'+($('#editPanel').height()-10)+'px'}, animateSpeed);
  } else {  } else {
  $("#editPanel").mouseenter(function(){ $('#editPanel').stop(true,true); $('#editPanel').animate({right: '0px'}, animateSpeed); })  $("#editPanel").mouseenter(function(){ $('#editPanel').stop(true,true); $('#editPanel').animate({right: '0px'}, animateSpeed); })
? .mouseleave(function(){ $('#editPanel').stop(true,true); $('#editPanel').animate({right: '-'+($('#editPanel').width()-10)+'px'}, animateSpeed); });+ .mouseleave(function(){ $('#editPanel').stop(true,true); $('#editPanel').animate({right: '-'+($('#editPanel').width()-10)+'px'}, animateSpeed); });
  $('#editPanel').animate({right: '-'+($('#editPanel').width()-10)+'px'}, animateSpeed);  $('#editPanel').animate({right: '-'+($('#editPanel').width()-10)+'px'}, animateSpeed);
  }  }
Строка 706:Строка 704:
  if ($('#wpTextbox1')[0].scrollHeight > $('#wpTextbox1')[0].offsetHeight) { $('#wpTextbox1').css('height',($('#wpTextbox1')[0].scrollHeight+200)+'px'); }  if ($('#wpTextbox1')[0].scrollHeight > $('#wpTextbox1')[0].offsetHeight) { $('#wpTextbox1').css('height',($('#wpTextbox1')[0].scrollHeight+200)+'px'); }
 } }
? 
  
 /* Доходность (шаблон) */ /* Доходность (шаблон) */
 function profitPanel() { function profitPanel() {
  $('.profitMore').toggle(  $('.profitMore').toggle(
? function() {$(this).prev().prev().show();$(this).text('Подробнее');},+ function() {$(this).prev().prev().show();$(this).text('&#9650; Подробнее');},
? function() {$(this).prev().prev().hide();$(this).text('Подробнее');}+ function() {$(this).prev().prev().hide();$(this).text('&#9660; Подробнее');}
  );  );
 } }
? 
  
 /* Прозвища ajax */ /* Прозвища ajax */
 function getAlias() { function getAlias() {
? try {+ try {
? if ( $('div.TankPerformance').length ) {+ if ( $('div.TankPerformance').length ) {
? var codeValue = $('#codeValue').text();+ var codeValue = $('#codeValue').text();
? var nationValue = $('#nationValue').text();+ var nationValue = $('#nationValue').text();
? $('div.TankPerformance table tbody').eq(1).prepend(''++ $('div.TankPerformance table tbody').eq(1).prepend(''+
? '<tr><th class="center group alias aliasHeader" colspan="2">Прозвища в игре <div class="editLink">[<a href="/WoT:Прозвища">править</a>]</div></th></tr>'++ '<tr><th class="center group alias aliasHeader" colspan="2">Прозвища в игре <div class="editLink">[<a href="/WoT:Прозвища">править</a>]</div></th></tr>'+
? '<tr><td class="alias aliasContent" colspan="2"></td></tr>'++ '<tr><td class="alias aliasContent" colspan="2"></td></tr>'
? '');+ );
? $('div.TankPerformance table tbody').eq(4).prepend(''++ $('div.TankPerformance table tbody').eq(4).prepend(''+
? '<tr><th class="center group alias aliasHeader" colspan="2">Прозвища в игре <div class="editLink">[<a href="/WoT:Прозвища">править</a>]</div></th></tr>'++ '<tr><th class="center group alias aliasHeader" colspan="2">Прозвища в игре <div class="editLink">[<a href="/WoT:Прозвища">править</a>]</div></th></tr>'+
? '<tr><td class="alias aliasContent" colspan="2"></td></tr>'++ '<tr><td class="alias aliasContent" colspan="2"></td></tr>'
? '');+ );
? $.get('/WoT:Прозвища/'+nationValue)+ $.get('/WoT:Прозвища/'+nationValue)
? .done(function(data) { + .done(function(data) {
? var obj = $.parseJSON(jQuery(data).find("div.mw-content-ltr p").text());+ var obj = $.parseJSON(jQuery(data).find("div.mw-content-ltr p").text());
? if (obj[codeValue] !== undefined) { $('.aliasContent').text(obj[codeValue]); }+ if (obj[codeValue] !== undefined) { $('.aliasContent').text(obj[codeValue]); }
? })+ })
? .always(function() { if ($('.aliasContent').text() != '') {$('.alias').fadeIn();} });+ .always(function() { if ($('.aliasContent').text() != '') {$('.alias').fadeIn();} });
 + }
 + } catch (e) {
 + console.log("Что-то пошло не так. Пичалька, прозвища ниработают");
  }  }
? } catch (e) { 
? console.log("Что-то пошло не так. Пичалька, прозвища ниработают"); 
? } 
 } }
  
? +/* Установка дефолтных настроек */
?/* Установка дефолтных настроек */+
 function setDefaultjsOptions() { function setDefaultjsOptions() {
  try{  try{
  lsElement = new Array(  lsElement = new Array(
? {param:'o_showJsOptionsPanel', value:1}, + {param:'o_showJsOptionsPanel', value:1},
? {param:'o_additionalEditPanelButtons', value:1}, + {param:'o_additionalEditPanelButtons', value:1},
? {param:'o_improvedEditPanel', value:0}, {param:'o_improvedEditPanelDownKey', value:0}, {param:'o_improvedEditPanelShowRight', value:0}, + {param:'o_improvedEditPanel', value:0}, {param:'o_improvedEditPanelDownKey', value:0}, {param:'o_improvedEditPanelShowRight', value:0},
  {param:'o_spellCheck', value:0}, {param:'o_spellCheckIgnoreUppercase', value:0}  {param:'o_spellCheck', value:0}, {param:'o_spellCheckIgnoreUppercase', value:0}
  );  );
Строка 757:Строка 752:
 } }
  
? +/* Панелька настроек */
?/* Панелька настроек */+
 function jsOptionsPanel() { function jsOptionsPanel() {
  try {  try {
Строка 769:Строка 763:
  '&nbsp; <input type="checkbox" id="o_improvedEditPanelShowRight" name="o_improvedEditPanelShowRight" /><label for="o_improvedEditPanelShowRight"> Отображать панель справа</label><br>'+  '&nbsp; <input type="checkbox" id="o_improvedEditPanelShowRight" name="o_improvedEditPanelShowRight" /><label for="o_improvedEditPanelShowRight"> Отображать панель справа</label><br>'+
  '<input type="checkbox" id="o_additionalEditPanelButtons" name="o_additionalEditPanelButtons" /><label for="o_additionalEditPanelButtons"> Дополнительные кнопки редактирования</label><br>'+  '<input type="checkbox" id="o_additionalEditPanelButtons" name="o_additionalEditPanelButtons" /><label for="o_additionalEditPanelButtons"> Дополнительные кнопки редактирования</label><br>'+
? '</fieldset>');+ '</fieldset>');
? + 
  $('#js_options input[type="checkbox"]').each(function (index) { if (localStorage[$(this).attr('name')]==1) { $(this).attr('checked','checked');} })  $('#js_options input[type="checkbox"]').each(function (index) { if (localStorage[$(this).attr('name')]==1) { $(this).attr('checked','checked');} })
? + 
  $('#js_options input[type="checkbox"]').bind('change', function() {  $('#js_options input[type="checkbox"]').bind('change', function() {
  if ($(this).is(':checked')) { localStorage[$(this).attr('name')] = 1; }  if ($(this).is(':checked')) { localStorage[$(this).attr('name')] = 1; }
Строка 780:Строка 774:
 } }
  
?/* Вводная инструкция по редактированию */+/* Вводная инструкция по редактированию */
 function KMVAlert() { function KMVAlert() {
? try {+ try {
? if(!$('#editform').length) {return 0;}+ if(!$('#editform').length) {return 0;}
? var oToday = new Date();+ var oToday = new Date();
? if (localStorage['o_lastShownKMVAlertDate']==undefined) {localStorage['o_lastShownKMVAlertDate'] = 0;}+ if (localStorage['o_lastShownKMVAlertDate']==undefined) {localStorage['o_lastShownKMVAlertDate'] = 0;}
? var lastShownKMVAlertDate = new Date(); lastShownKMVAlertDate.setTime(localStorage['o_lastShownKMVAlertDate']);+ var lastShownKMVAlertDate = new Date(); lastShownKMVAlertDate.setTime(localStorage['o_lastShownKMVAlertDate']);
? var nDaysLeft = lastShownKMVAlertDate < oToday ? Math.ceil((oToday-lastShownKMVAlertDate) / (1000 * 60 * 60 * 24)) : 0;+ var nDaysLeft = lastShownKMVAlertDate < oToday ? Math.ceil((oToday-lastShownKMVAlertDate) / (1000 * 60 * 60 * 24)) : 0;
? if (nDaysLeft>30) {+ if (nDaysLeft>30) {
? $('body').append('<div id="alertMessage" style="position:fixed; top:0px; left:0px; right:0px; bottom:0px; z-index:9050; background:RGBA(0,0,0,0.4); padding: 50px; overflow:auto;">'++ $('body').append('<div id="alertMessage" style="position:fixed; top:0; left:0; right:0; bottom:0; z-index:9050; background:RGBA(0,0,0,0.4); padding: 50px; overflow:auto;">'+
? '<div class="content" style="padding: 17px; background: white; min-height:300px; font-size: 80%;">'++ '<div class="content" style="padding: 17px; background: white; min-height:300px; font-size: 80%;">'+
? 'Загрузка'++ 'Загрузка'+
? '</div><div style="text-align:center;padding: 0px 0px 100px;"><a class="closeBtn" style="padding:12px; background:#FF3333; color:#000000;" onclick="var oToday = new Date(); localStorage[\'o_lastShownKMVAlertDate\'] = oToday.getTime(); $(\'#alertMessage\').hide(); return false;" href="#">Я всё понял</a></div>'++ '</div><div style="text-align:center;padding: 0 0 100px;"><a class="closeBtn" style="padding:12px; background:#FF3333; color:#000000;" onclick="var oToday = new Date(); localStorage[\'o_lastShownKMVAlertDate\'] = oToday.getTime(); $(\'#alertMessage\').hide(); return false;" href="#">Я всё понял</a></div>'+
? '</div>');+ '</div>');
? $('#alertMessage .content').load('/WoT:Краткая_вводная div.mw-content-ltr', function() {});+ $('#alertMessage .content').load('/WoT:Краткая_вводная div.mw-content-ltr', function() {});
? + } else {
? } else {+ localStorage['o_lastShownKMVAlertDate'] = oToday.getTime();
? localStorage['o_lastShownKMVAlertDate'] = oToday.getTime();+ }
 + } catch (e) {
 + console.log("КМВ: Что-то пошло не так");
  }  }
? } catch (e) { 
? console.log("КМВ: Что-то пошло не так"); 
? } 
 } }
  
? +/* Конфиг */
? +var imageLoaderUrl = '/Loading.gif';
?/* Конфиг */+
?var imageLoaderUrl = '//wikicdn.wargaming.net/images/4/42/Loading.gif';+
 var isRotate = false; var isRotate = false;
  
 function addRotatorPopupWindow() { function addRotatorPopupWindow() {
  $('body').append('<div id="popupRotatorWindow"><table><tr><td><div id="popupRotatorWrapper">'+  $('body').append('<div id="popupRotatorWindow"><table><tr><td><div id="popupRotatorWrapper">'+
? '<div id="rotatorTarget"></div><img src="//wikicdn.wargaming.net/images/b/bd/Close.png" class="closeBtn"></div>'++ '<div id="rotatorTarget"></div><img src="//wiki.gcdn.co/images/b/bd/Close.png" class="closeBtn" alt="Закрыть"></div>'+
? '</td></tr></table></div>'+ '</td></tr></table></div>'
  );  );
 +}
 +
 +/* Popup */
 +function addPopupWindow() {
 + $('body').append(
 + '<div id="popupWindow"><table><tr><td style="vertical-align: middle;">'+
 + '<div id="popupOverlay"></div>'+
 + '<div id="popupWrapper">'+
 + '<div id="popupContent"></div>'+
 + '<img src="//wiki.gcdn.co/images/b/bd/Close.png" class="closeBtn" alt="Закрыть">'+
 + '</div>'+
 + '</td></tr></table></div>'
 + );
 + //Закрыть попап кнопкой
 + $('.closeBtn').click(function(index) {
 + $('#popupWindow').hide();
 + });
 +
 + //Закрыть попап фоном
 + $('#popupOverlay').click(function(index) {
 + $('#popupWindow').hide();
 + });
 +}
 +
 +/* Шаблон Model3DViewer */
 +function addModel3DViewer() {
 + $('.Model3DViewer').click(function(){
 + document.getElementById("popupContent").innerHTML = '<iframe width="'+(document.documentElement.clientWidth-150)+'px" height="'+(document.documentElement.clientHeight-150)+'px" id="Model3D" src="https://sketchfab.com/models/'+$(this).children('div.Model3D').text()+'/embed?autostart=1&amp;preload=1" frameborder="0" allowfullscreen mozallowfullscreen="true" webkitallowfullscreen="true" onmousewheel=""></iframe>';
 + $('#popupWrapper').show();
 + $('#popupWindow').show();
 + });
 +}
 +
 +/* Шаблон Panorama */
 +function addPanorama() {
 + $.each($('.PanoramaViewer'), function( index, element ) {
 + $(element).append('<iframe width="684px" align="middle" height="380px" frameborder="0" seamless="" scrolling="no" marginheight="0" marginwidth="0" src="//content.wargaming.net/wot/community/panoramas/' + $(element).children('div.Panorama').text() + '"></iframe>');
 + });
 +}
 +
 +/* WoWs: ретагертинг ВК */
 +function add_VK_retag() {
 + if (wgCanonicalNamespace == 'Navy' && wgPageName == 'World_of_Warships') {
 + (window.Image ? (new Image()) : document.createElement('img')).src = location.protocol + '//vk.com/rtrg?r=cj1A6IhaIFpO3BoHvuW7dl*ZerRIlEHZ5JAfF1HBUUc4I9bBUeRNL//Lctmr5tztW0cthhi0Te31*/ORHHyQCnYUe9Rd9mh4rgaATuXFWFCwzMFE8yV58QJWQLWZFRkGr43/fHDJ0o5Q2ZWDnvGdKVlEs2BzVNRnpiCXf7h/SFU-&pixel_id=1000064587';
 + }
 + if (wgCanonicalNamespace == 'Ship') {
 + if (wgPageName == 'Словарь_морских_терминов') {
 + (window.Image ? (new Image()) : document.createElement('img')).src = location.protocol + '//vk.com/rtrg?r=gZ8LfxKUw0k2vFDjCYOMYSi1UXB*Mv1gOh4EmfDT5XYDlkn2KUgr95*JoBadis/76uyAolNvKObpj77BXJO2PDS4T8Gc*WR2RLkvSUV/oMq9wW5m/8nE4L1ACtLDBiRZ0CrS9Mb0X36m8ukZv2mEHAnYoMpvF55gmmKuwZERsdc-&pixel_id=1000064588'; }
 + if (wgPageName == 'Русско-японская_война') {
 + (window.Image ? (new Image()) : document.createElement('img')).src = location.protocol + '//vk.com/rtrg?r=wxub3EROPDo7g/kePWq0NAx4jhXh/ZblYtp1lS*xrUT25mop4YOTg87yanm*Dgbz3wnkGT/z3RiRdJWnk1fTnsfEjALhmaCJM1LunQyb2bVBnROpAccJHIYewTyRXsfl2MIma/QeBsFaF//b3O/Bur6XqhPKEcgQpUJWyCPSGk4-&pixel_id=1000064589'; }
 + }
 } }
  
 /** ready */ /** ready */
?$(document).ready( function(){+$(document).ready( function() {
? modulesBlock();+ //modulesBlock();
  setDefaultjsOptions();  setDefaultjsOptions();
  switcher();  switcher();
? setTimeout(addImagePopups,0);+ setTimeout(addImagePopups, 0);
? + addPopupWindow();
?// setTimeout(hideNoDataInfoInTankPerformance,0);+ addModel3DViewer();
?// setTimeout(getAlias,0);+ addSoundPlayer();
?// Add Hooks+ addPanorama();
 + add_VK_retag();
 + 
 + // setTimeout(hideNoDataInfoInTankPerformance,0);
 + // setTimeout(getAlias,0);
 + // Add Hooks
  
  addPlayButton();  addPlayButton();
Строка 839:Строка 886:
  collapsibleTables();  collapsibleTables();
  gunShellsBlock();  gunShellsBlock();
?}+ }
?/* ready **/+
  
?/* setTimeout(function (){$('.rotator').simpleRotator({width: '100%', textLoad: '<img src="https://wiki.worldoftanks.ru/uploads/2/2d/RotateIcon.png" />'});}); */+ /* setTimeout(function (){$('.rotator').simpleRotator({width: '100%', textLoad: '<img src="https://wiki.worldoftanks.ru/uploads/2/2d/RotateIcon.png" />'});}); */
  
  //----  //----
? setTimeout(function (){+ setTimeout(function () {
? $('.myRotator').click(function(){+ $('.myRotator').click(function() {
? if (isRotate) {return 0;}+ if (isRotate) {return 0;}
? addRotatorPopupWindow();+ addRotatorPopupWindow();
? $('#rotatorTarget').html($(this).children('.rotator').html());+ $('#rotatorTarget').html($(this).children('.rotator').html());
? $('#rotatorTarget').simpleRotator({width: '1024px', textLoading: '<img src="' + imageLoaderUrl + '" />'});+ $('#rotatorTarget').simpleRotator({width: '1024px', textLoading: '<img src="' + imageLoaderUrl + '" alt="Загрузка" />'});
? $('#rotatorTarget').children(".loader").click();+ $('#rotatorTarget').children(".loader").click();
? $('#popupRotatorWindow').find('.closeBtn').click(function(){ + $('#popupRotatorWindow').find('.closeBtn').click(function() {
? $('#popupRotatorWindow').remove(); + $('#popupRotatorWindow').remove();
? isRotate = false;+ isRotate = false;
? });+ });
? $('#popupRotatorWindow').show();+ $('#popupRotatorWindow').show();
? isRotate = true; + isRotate = true;
? });+ });
  });  });
  
Строка 865:Строка 911:
  
  //----  //----
?// setTimeout(addAdditionalEdittools,0);+ // setTimeout(addAdditionalEdittools,0);
?// setTimeout(checkContent,0);+ // setTimeout(checkContent,0);
?// setTimeout(jsOptionsPanel,0);+ // setTimeout(jsOptionsPanel,0);
?// setTimeout(improvedPanelEditTools,0);+ // setTimeout(improvedPanelEditTools,0);
?// setTimeout(profitPanel,0);+ // setTimeout(profitPanel,0);
?// setTimeout(KMVAlert,0);+ // setTimeout(KMVAlert,0);
  
  //----  //----
? setTimeout(function (){+ setTimeout(function () {
? $('.provRef').click(function(){+ $('.provRef').click(function() {
  var ref = '#' + $(this).data('ref');  var ref = '#' + $(this).data('ref');
  var origin = $(this).parents('tr:first').attr('id');  var origin = $(this).parents('tr:first').attr('id');
  $('.provSelect').removeClass('provSelect');  $('.provSelect').removeClass('provSelect');
  $('.provOrigin').removeClass('provOrigin');  $('.provOrigin').removeClass('provOrigin');
? $(ref).addClass('provSelect').find('[data-ref=' + origin + ']').addClass('provOrigin'); + $(ref).addClass('provSelect').find('[data-ref=' + origin + ']').addClass('provOrigin');
  location.href = ref;  location.href = ref;
  });  });
Строка 885:Строка 931:
  
  //----  //----
? setTimeout(function (){+ setTimeout(function () {
? $('#editform').submit(function(){+ $('#editform').submit(function() {
  var result = $('#wpTextbox1').val().indexOf('war' + 'blogs.ru') == -1;  var result = $('#wpTextbox1').val().indexOf('war' + 'blogs.ru') == -1;
  var mb = $('#mw-js-message');  var mb = $('#mw-js-message');
Строка 893:Строка 939:
  mb.show();  mb.show();
  }  }
? return result; + return result;
  });  });
  });  });
 +});
 +/* ready **/
  
? +// CCW loader start
 +(function(w,d,s,p) {
 + var f=d.getElementsByTagName(s)[0],j=d.createElement(s),i;
 + j.async=true;j.src='//'+p['server']+'/compiled/loader.min.js';j.setAttribute('id', 'ccw-loader');
 + for(i in p){if (p.hasOwnProperty(i)) {j.setAttribute('data-'+i,p[i]);}}
 + f.parentNode.insertBefore(j,f);
 +})(window,document,'script',{
 + 'server':'ccw-center.wargaming.net',
 + 'language':'ru',
 + 'service':'wiki'
 }); });
 +// CCW loader end
 +
 +/* SoundPlayer */
 +function addSoundPlayer() {
 + var audio = new Audio();
 + $('.SoundPlayer').click(function(){
 + audio.src = $(this).find('#sound_source').text();
 + if(audio.paused === true) {
 + audio.play();
 + } else {
 + audio.pause();
 + audio.currentTime = 0.0;
 + }
 + });
 +}
 +
 +
 +/* Cookie Banner */
 +(function (w, d, s, p) {
 + var f = d.getElementsByTagName(s)[0], j = d.createElement(s), i;
 + j.src = '//' + p;
 + if (j.readyState) { // only required for IE <9
 + j.onreadystatechange = function () {
 + if (j.readyState === "loaded" || j.readyState === "complete") {
 + j.onreadystatechange = null;
 + CookieBanner.createCookieBanner({openPolicyInNewTab: true});
 + }
 + };
 + } else { //Others
 + j.onload = function () {
 + CookieBanner.createCookieBanner({openPolicyInNewTab: true});
 + };
 + }
 + f.parentNode.insertBefore(j, f);
 + })(window, document, 'script', 'web-static-production.lesta.ru/cookie-banner/1.3.7/cookie-banner.umd.js');

Текущая версия на 12:35, 18 апреля 2024

/* Размещённый здесь JavaScript код будет загружаться всем пользователям при обращении к каждой странице */


/* Добавление кнопки и функционала Викификатора в режиме редактирования */
if ($.inArray( mw.config.get( 'wgAction' ), ['edit', 'submit'] ) !== -1 ) {
  mw.loader.load('//ru.wikipedia.org/w/index.php?title=MediaWiki:Wikificator.js&action=raw&ctype=text/javascript');
}

var customizeToolbar = function() {
  $('#wpTextbox1').wikiEditor('addToToolbar', {
    'section': 'advanced',
    'group': 'format',
    'tools': {
      'wikify': {
        label: 'Викификатор',
        type: 'button',
        icon: '//upload.wikimedia.org/wikipedia/commons/0/06/Wikify-toolbutton.png',
        action: {
          type: 'callback',
          execute: function(context) {
            Wikify();
          }
        }
      }
    }
  });
};

if ($.inArray(mw.config.get('wgAction'), ['edit', 'submit']) !== -1) {
  mw.loader.using('user.options', function () {
    mw.loader.using('ext.wikiEditor.toolbar', function () {
      $(document).ready(customizeToolbar);
    });
  });
}

/* Сокрытие приглашения скачать игру в подвале для залогиненного пользователя (раньше фунция еще добавляла кнопку "Играть") */
function addPlayButton() {
  try {
    var logout = document.getElementById('pt-logout');
    if (logout != null) {
      document.getElementById('footer-wot-link').style.display = 'none';
    }
  } catch(e) {
    return;
  }
}

/* Функционал тактических примеров. См. пример на [[Тактика. Т-54 — создание перевеса на фланге]] */
var tacticCounter = 1;
var mapImages = new Array();

function tacticNext() {
  document.getElementById('step' + tacticCounter).style.display = 'none';

  if (tacticCounter < mapImages.length - 1) {
    tacticCounter++;
    if (tacticCounter == mapImages.length - 1) document.getElementById('nextsteplink').innerHTML = 'В начало';
  } else {
    tacticCounter = 1;
    document.getElementById('nextsteplink').innerHTML = 'Продолжить »';
  }

  document.getElementById('step' + tacticCounter).style.display = 'block';
  document.getElementById('tacticimg').src = mapImages[tacticCounter];
  return false;
}

function tacticSlideShow() {
  try {
    var mapDiv = document.getElementById('tacticmap');
    if (mapDiv == null) {
      return;
    }
    mapImages = mapDiv.innerHTML.split(',');
    mapDiv.innerHTML = '';
    mapDiv.style.background = 'url(' + mapImages[0] + ') top no-repeat';
    var imgNode = document.createElement('img');
    imgNode.id = 'tacticimg';
    imgNode.src = mapImages[1];
    mapDiv.appendChild(imgNode);

    var aNode = document.createElement('a');
    aNode.setAttribute('id', 'nextsteplink');
    aNode.setAttribute('href', '#');
    aNode.setAttribute('onClick', 'return tacticNext();');
    aNode.appendChild(document.createTextNode('Продолжить »'));
    document.getElementById('nextstep').appendChild(aNode);
  } catch(e) {
    return;
  }
}

/* переключение ТТХ топ/сток */
function tthTopStock() {
  $('#toStock').click(function() {
    $('#stockTTH').show();
    $('#topTTH').hide();
  });
  $('#toTop').click(function() {
    $('#stockTTH').hide();
    $('#topTTH').show();
  });
}

function gunShellsBlock() {
  $('.gunTd span').click(function() {
    if ($(this).parent().hasClass("shellsClosed")) {
      $('#block-' + $(this).data("guncode")).show();
    } else {
      $('#block-' + $(this).data("guncode")).hide();
    }
    $(this).parent().toggleClass("shellsClosed shellsOpened");
  });
}

//Messages
var NavigationBarHide = '[скрыть]';
var NavigationBarShow = '[показать]';
var NavigationBarShowDefault = 2;

/* Функционал раскрывающихся блоков (спойлеры) */
//Collapsiblе

var hasClass = (function () {
  var reCache = {}
  return function (element, className) {
    return (reCache[className] ? reCache[className] : (reCache[className] = new RegExp("(?:\\s|^)" + className + "(?:\\s|$)"))).test(element.className)
  }
})();

/*
$(document).ready(function() {
  $("table.collapsible").each(function(idx, table) {
  $(table).attr("id", 'collapsibleTable' + idx);
  });
});
*/

$(document).ready(function() {
  /*Chrome font bug hack*/
  if ($.browser.chrome) {
    var DALEY_FOR_CHROME_FONT_CORRECTION = 2000;
    setTimeout(function () {
      $('body')
        .addClass('temp')
        .removeClass('temp');
    }, DALEY_FOR_CHROME_FONT_CORRECTION);
  }
});

function collapsibleTables() {
  var Table, HRow,  HCell, btn, a, tblIdx = 0, colTables = [];
  var allTables = document.getElementsByTagName('table');
  for (var i=0; Table = allTables[i]; i++) {
    if (!hasClass(Table, 'collapsible')) continue;
    if (!(HRow=Table.rows[0])) continue;
    if (!(HCell=HRow.getElementsByTagName('th')[0])) continue;
    Table.id = 'collapsibleTable' + tblIdx;
    btn = document.createElement('span');
    btn.style.cssText = 'float:right; font-weight:normal; font-size:smaller';
    a = document.createElement('a');
    a.id = 'collapseButton' + tblIdx;
    a.href = 'javascript:collapseTable(' + tblIdx + ');';
    a.style.color = HCell.style.color;
    a.appendChild(document.createTextNode(NavigationBarHide));
    btn.appendChild(a);
    HCell.insertBefore(btn, HCell.childNodes[0]);
    colTables[tblIdx++] = Table;
  }
  for (var i=0; i < tblIdx; i++) {
    if ((tblIdx > NavigationBarShowDefault && hasClass(colTables[i], 'autocollapse')) || hasClass(colTables[i], 'collapsed')) {
      collapseTable(i)
    }
  }
}

function collapseTable(idx) {
  var Table = document.getElementById('collapsibleTable' + idx);
  var btn = document.getElementById('collapseButton' + idx);
  if (!Table || !btn) {return false;}
  var Rows = Table.rows;
  var isShown = (btn.firstChild.data == NavigationBarHide);
  btn.firstChild.data = isShown ?  NavigationBarShow : NavigationBarHide;
  var disp = isShown ? 'none' : Rows[0].style.display;
  for (var i=1; i < Rows.length; i++) {
    Rows[i].style.display = disp
  }
}

function collapsibleDivs() {
  var navIdx = 0, colNavs = [], i, NavFrame;
  var divs = document.getElementById('content').getElementsByTagName('div');
  for (i=0; NavFrame = divs[i]; i++) {
    if (!hasClass(NavFrame, 'NavFrame')) continue;
    NavFrame.id = 'NavFrame' + navIdx;
    var a = document.createElement('a');
    a.className = 'NavToggle';
    a.id = 'NavToggle' + navIdx;
    a.href = 'javascript:collapseDiv(' + navIdx + ');';
    a.appendChild(document.createTextNode(NavigationBarHide));
    for (var j=0; j < NavFrame.childNodes.length; j++) {
      if (hasClass(NavFrame.childNodes[j], 'NavHead')) {
        NavFrame.childNodes[j].appendChild(a);
      }
    }
    colNavs[navIdx++] = NavFrame;
  }
  for (i=0; i < navIdx; i++) {
    if ((navIdx > NavigationBarShowDefault && !hasClass(colNavs[i], 'expanded')) || hasClass(colNavs[i], 'collapsed')) {
      collapseDiv(i);
    }
  }
}

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);
  btn.firstChild.data = isShown ? NavigationBarShow : NavigationBarHide;
  var disp = isShown ? 'none' : 'block';
  for (var child = div.firstChild;  child != null;  child = child.nextSibling) {
    if (hasClass(child, 'NavPic') || hasClass(child, 'NavContent')) {
      child.style.display = disp;
    }
  }
}

/* Функционал всплывающих подсказок с ТТХ модулей */
var isDropDownBox = false;

$('.commentDrop').hover(
  function() {
    if (!isDropDownBox) {
      $('#bodyContent').append('<div id="dropDownBox" style="position:absolute;"></div>');
      isDropDownBox = true;
    }
    var offset = $(this).position();
    var top = offset.top + $(this).height();
    var obj = $.parseJSON($(this).find(".commentData").text());
    var str = '<div style="border:1px dotted;background:#efefef;padding:5px 1em;"><p style="text-align:center;"><b>' + obj.type + ' ' + obj.mark + '</b></p> <dl>';
    var items = [];
    $.each(obj.data, function(key, val) {
      items.push('<dt>' + key + ':</dt><dd>' + val + '</dd>');
    });
    str += items.join('') + ' </dl></div><p>&nbsp;</p>';
    $("#dropDownBox").html(str);
    $("#dropDownBox").css({"top": top + "px", "left":offset.left + "px"})
    $("#dropDownBox").show();
  },
  function() {
    $("#dropDownBox").hide();
  });

/* Функционал всплывающих подсказок с ТТХ модулей для World of Warships */
var isDropDownBox = false;

var moduleImages = {
  'Орудия главного калибра': 'https://wiki.gcdn.co/images/2/24/Module_wows_artillery.png',
  'Корпус': 'https://wiki.gcdn.co/images/1/17/Module_wows_hull.png',
  'Полётный контроль': 'https://wiki.gcdn.co/images/8/8e/Module_wows_flightcontrol.png',
  'Двигатель': 'https://wiki.gcdn.co/images/a/aa/Module_wows_engine.png',
  'Система управления огнём': 'https://wiki.gcdn.co/images/f/f8/Module_wows_suo.png',
  'Торпеды': 'https://wiki.gcdn.co/images/4/47/Module_wows_torpedoes.png',
  'Истребители': 'https://wiki.gcdn.co/images/d/de/Module_wows_fighter.png',
  'Торпедоносцы': 'https://wiki.gcdn.co/images/a/a1/Module_wows_torpedobomber.png',
  'Пикирующие бомбардировщики': 'https://wiki.gcdn.co/images/0/01/Module_wows_divebomber.png'
};

$('.commentDrop_wows').hover(
  function() {
    if (!isDropDownBox) {
      $('#bodyContent').append('<div id="dropDownBox" style="position:absolute;"></div>');
      isDropDownBox = true;
    }
    var offset = $(this).position();
    var top = offset.top + $(this).height();
    var obj = $.parseJSON($(this).find(".commentData_wows").text());
    var str = '<div class="d-comment"><div class="d-comment-head"><div class="d-comment-img">' + '<img width="60" height="60" src="' + moduleImages[obj.type] + '" alt="">' + '</div><div class="d-comment-name"><h3>' + obj.type + '</h3><span>' + obj.mark + '</span></div></div><div class="b-performance_text d-comment-body"><table class="t-performance">';
    var items = [];

    $.each(obj.data, function(key, val) {
      items.push('<tr><td><span class="t-performance_right">' + val + '</span><span class="t-performance_left">' + key + '</span></td></tr>');
    });

    str += items.join('') + '</table></div></div>';

    $("#dropDownBox").html(str);
    $("#dropDownBox").css({"top": top + "px", "left":offset.left + "px"})
    $("#dropDownBox").show();
  },
  function() {
    $("#dropDownBox").hide();
  }
);

/*
 * Плагины
*/
/* simpleRotator - обеспечивает функционал врашения машины вокруг вертикальной оси */
(function(a){a.fn.simpleRotator=function(b){var d={mouseMoveThresholdX:20,RepeatImageX:true,startImage:0,isAnimate:true,animationSpeed:100,animationShowSpeed:200,width:"auto",height:"auto",linkType:"a",textLoad:"Просмотреть",textLoading:"Загрузка",textLoadError:"Произошла ошибка при загрузке, попробуйте обновить страницу."};var c=a.extend(d,b);return this.each(function(){function u(){a(z).html('<div class="loader loadButton" unselectable="on">'+c.textLoad+"</div>");a(z).children(".loader").click(function(){if(j){return 0}a(z).children(".loader").html(c.textLoading);a(z).children(".loader").removeClass("loadButton");m()})}function w(){for(i=0;i<s.length;i++){a(z).append('<div class="subRotator subRotatorId-'+i+'"></div>');a(z).children(".subRotatorId-"+i).css("background-image",'url("'+q[i].src+'")');a(z).children(".subRotatorId-"+i).hide()}}function x(){try{if(c.linkType=="img"){a(z).children("img").each(function(e){s.push(a(this).attr("src"))})}else{if(c.linkType=="a"){a(z).children("a").each(function(e){s.push(a(this).attr("href"))})}}}catch(A){}}function m(){try{for(i=0;i<s.length;i++){pic=new Image();pic.src=s[i];q.push(pic);pic.addEventListener("load",t,false);pic.addEventListener("error",r,false)}}catch(A){}}function t(e){o++;if(o===s.length){n()}}function n(A){try{h(q[0].width);k(q[0].height);w();v();f(c.startImage);a(z).children(".loader").hide()}catch(B){}}function r(e){a(z).children(".loader").html(c.textLoadError);j=true}function v(){try{a(z).mousedown(function(e){l=true;g=e.clientX});a(z).mouseup(function(e){l=false});a(z).mouseleave(function(e){l=false});a(z).mousemove(function(e){if(l){if(Math.max(g,e.clientX)-Math.min(g,e.clientX)>c.mouseMoveThresholdX){if(e.clientX-g<0){f("prev")}else{f("next")}g=e.clientX}}})}catch(A){}}function f(A){try{if(A=="next"){A=p+1}if(A=="prev"){A=p-1}if(A>s.length-1&&c.RepeatImageX==true){A=0}else{if(A>s.length-1){A=s.length-1}}if(A<0&&c.RepeatImageX==true){A=s.length-1}else{if(A<0){A=0}}if(p!=A){if(c.isAnimate){a(z).children(".subRotator").stop(true,true)}a(z).children(".subRotator").css("z-index","");a(z).children(".subRotator.subRotatorId-"+p).css("z-index","14");a(z).children(".subRotator.subRotatorId-"+p).css("opacity","1");if(c.isAnimate){a(z).children(".subRotator.subRotatorId-"+A).css("opacity",0)}a(z).children(".subRotator.subRotatorId-"+A).css("z-index","15");if(c.isAnimate){a(z).children(".subRotator.subRotatorId-"+A).animate({opacity:1},c.animationSpeed,function(){})}p=A}a(z).children(".subRotator.subRotatorId-"+p).show()}catch(B){}}function h(e){if(c.width!="auto"){e=c.width}else{if(e<=0){e=320}}z.css("width",e)}function k(e){if(c.height!="auto"){e=c.height}else{if(e<=0){e=240}}z.animate({height:e},c.animationShowSpeed)}var l=false;var g=0;var p=-1;var s=Array();var q=Array();var o=0;var j=false;var z=a(this);try{z.addClass("plugin_rotator");z.attr("ondrag","return false;");z.attr("ondragdrop","return false;");z.attr("ondragstart","return false;");z.show();x();u()}catch(y){}})}})(jQuery);


/* Добавление комплектации в Edittools */
function addAdditionalEdittools() {
  try{
    if (localStorage['o_additionalEditPanelButtons'] != 1) return 0;
    if (!$('div.mw-editTools').length) return 0;
    var helpIconAddress = 'https://wiki.worldoftanks.ru/uploads/0/05/Question-small.png';
    var iconSize = '20px';
    var resultText = "";
    etElem = new Array();
    /*
      etElem.push({insertLeft:'Вставка слева', insert:'Вставка', insertRight:'Вставка справа', title:'Подсказка при наведении',img:'Ссылка на картинку', text:'Текст надписи', help:'Ссылка на страницу помощи'});
    */
    etElem.push({text: '<p>'});
    etElem.push({text: 'Достоинства', insertLeft:'{{Достоинства| ', insertRight:'}}', help:'/Шаблон:Достоинства'});
    etElem.push({text: 'Недостатки', insertLeft:'{{Недостатки| ', insertRight:'}}', help:'/Шаблон:Недостатки'});
    etElem.push({text: 'Навыки', insertLeft:'{{Навыки|Строка1= ', insertRight:'|Подпись= }}', help:'/Шаблон:Навыки'});
    etElem.push({text: 'Switcher', insertLeft:'{{switcher|height=|width=|Вкладка1# ', insert:'Содержимое', insertRight:' }}', help:'/Шаблон:Switcher'});
    etElem.push({text: 'Дописать', insertLeft:'{{Дописать}}', help:'/Шаблон:Дописать'});
    etElem.push({text: 'Доработать', insertLeft:'{{Доработать|', insertRight:' }}', help:'/Шаблон:Доработать'});
    etElem.push({text: 'Rotator', insertLeft:'{{Rotator|filename=', insertRight:' }}', help:'/Шаблон:Rotator'});
    etElem.push({text: 'НОС', insertLeft:'{{НОС|', insertRight:'}}', help:'/Шаблон:НОС'});
    etElem.push({text: '</p><p>'});
    etElem.push({text: 'Комплектация', insertLeft:'{{Комплектация|Модуль1 = |Модуль2 = |Модуль3 = |Снаряд1 = ББ |БК1 = 0 |Снаряд2 = БП |БК2 = 0 |Снаряд3 = ОФ |БК3 = 0 |Снаряжение1 = |Снаряжение2 = |Снаряжение3 = }}', help:'/Шаблон:Комплектация'});
    etElem.push({text: ': '});
    etElem.push({insertLeft:'Маскировочная сеть ', img:'https://wiki.worldoftanks.ru/uploads/thumb/f/f8/Маскировочная_сеть.png/'+iconSize+'-Маскировочная_сеть.png'});
    etElem.push({insertLeft:'Стереотруба ', img:'https://wiki.worldoftanks.ru/uploads/thumb/3/33/Стереотруба.png/'+iconSize+'-Стереотруба.png'});
    etElem.push({insertLeft:'Ящик с инструментами ', img:'https://wiki.worldoftanks.ru/uploads/thumb/0/06/Ящик_с_инструментами.png/'+iconSize+'-Ящик_с_инструментами.png'});
    etElem.push({insertLeft:'Рессоры ', img:'https://wiki.worldoftanks.ru/uploads/thumb/a/a1/Рессоры.png/'+iconSize+'-Рессоры.png'});
    etElem.push({insertLeft:'Противоосколочный подбой ', img:'https://wiki.worldoftanks.ru/uploads/thumb/c/c1/Противоосколочный_подбой.png/'+iconSize+'-Противоосколочный_подбой.png'});
    etElem.push({insertLeft:'Улучшенная вентиляция ', img:'https://wiki.worldoftanks.ru/uploads/thumb/7/75/Улучшенная_вентиляция.png/'+iconSize+'-Улучшенная_вентиляция.png'});
    etElem.push({insertLeft:'Мокрая боеукладка ', img:'https://wiki.worldoftanks.ru/uploads/thumb/0/07/Мокрая_боеукладка.png/'+iconSize+'-Мокрая_боеукладка.png'});
    etElem.push({insertLeft:'Досылатель ', img:'https://wiki.worldoftanks.ru/uploads/thumb/7/72/Досылатель.png/'+iconSize+'-Досылатель.png'});
    etElem.push({insertLeft:'Дополнительные грунтозацепы ', img:'https://wiki.worldoftanks.ru/uploads/thumb/4/43/Дополнительные_грунтозацепы.png/'+iconSize+'-Дополнительные_грунтозацепы.png'});
    etElem.push({insertLeft:'Заполнение баков CO2 ', img:'https://wiki.worldoftanks.ru/uploads/thumb/3/3c/Заполнение_баков_CO2.png/'+iconSize+'-Заполнение_баков_CO2.png'});
    etElem.push({insertLeft:'Просветленная оптика ', img:'https://wiki.worldoftanks.ru/uploads/thumb/5/59/Просветленная_оптика.png/'+iconSize+'-Просветленная_оптика.png'});
    etElem.push({insertLeft:'Стабилизатор вертикальной наводки ', img:'https://wiki.worldoftanks.ru/uploads/thumb/7/78/Стабилизатор_вертикальной_наводки.png/'+iconSize+'-Стабилизатор_вертикальной_наводки.png'});
    etElem.push({insertLeft:'Усиленные приводы наводки ', img:'https://wiki.worldoftanks.ru/uploads/thumb/5/59/Усиленные_приводы_наводки.png/'+iconSize+'-Усиленные_приводы_наводки.png'});
    etElem.push({insertLeft:'Фильтр Циклон ', img:'https://wiki.worldoftanks.ru/uploads/thumb/f/fc/Фильтр_Циклон.png/'+iconSize+'-Фильтр_Циклон.png'});
    etElem.push({text: '| '});
    etElem.push({insertLeft:'Малый ремкомплект ', img:'https://wiki.worldoftanks.ru/uploads/thumb/f/fe/Малый_ремкомплект.png/'+iconSize+'-Малый_ремкомплект.png'});
    etElem.push({insertLeft:'Малая аптечка ', img:'https://wiki.worldoftanks.ru/uploads/thumb/e/e6/Малая_аптечка.png/'+iconSize+'-Малая_аптечка.png'});
    etElem.push({insertLeft:'Ручной огнетушитель ', img:'https://wiki.worldoftanks.ru/uploads/thumb/c/c8/Ручной_огнетушитель.png/'+iconSize+'-Ручной_огнетушитель.png'});
    etElem.push({insertLeft:'Ленд-лизное масло ', title:'Ленд-лизное масло (советские танки)', img:'https://wiki.worldoftanks.ru/uploads/thumb/4/40/Ленд-лизное_масло.png/'+iconSize+'-Ленд-лизное_масло.png'});
    etElem.push({insertLeft:'Качественное масло ', title:'Качественное масло (китайские танки)', img:'https://wiki.worldoftanks.ru/uploads/thumb/3/3b/Качественное_масло.png/'+iconSize+'-Качественное_масло.png'});
    etElem.push({insertLeft:'100-октановый бензин ', title:'100-октановый бензин (немецкие, французские и американские танки с бензиновыми двигателями)', img:'https://wiki.worldoftanks.ru/uploads/thumb/c/c7/100-октановый_бензин.png/'+iconSize+'-100-октановый_бензин.png'});
    etElem.push({insertLeft:'Подкрученный регулятор оборотов ', img:'https://wiki.worldoftanks.ru/uploads/thumb/2/28/Подкрученный_регулятор_оборотов.png/'+iconSize+'-Подкрученный_регулятор_оборотов.png'});

    etElem.push({text: '| '});
    etElem.push({text: 'Модули:', help:'/WoT:Коды_модулей'});
    etElem.push({insertLeft:'{{CommentGun|tank:', insertRight:'}}', img:'https://wiki.worldoftanks.ru/uploads/thumb/1/1a/Ico_gun_alpha.png/'+iconSize+'-Ico_gun_alpha.png'});
    etElem.push({insertLeft:'{{CommentTurret|tank:', insertRight:'}}', img:'https://wiki.worldoftanks.ru/uploads/thumb/4/47/Ico_turret_alpha.png/'+iconSize+'-Ico_turret_alpha.png'});
    etElem.push({insertLeft:'{{CommentEngine|tank:', insertRight:'}}', img:'https://wiki.worldoftanks.ru/uploads/thumb/7/73/Ico_engine_alpha.png/'+iconSize+'-Ico_engine_alpha.png'});
    etElem.push({insertLeft:'{{CommentChassis|tank:', insertRight:'}}', img:'https://wiki.worldoftanks.ru/uploads/thumb/e/e7/Ico_suspension_alpha.png/'+iconSize+'-Ico_suspension_alpha.png'});
    etElem.push({insertLeft:'{{CommentRadio|tank:', insertRight:'}}', img:'https://wiki.worldoftanks.ru/uploads/thumb/c/ca/Ico_radio_alpha.png/'+iconSize+'-Ico_radio_alpha.png'});

    etElem.push({text: '</p>'});

    for ( key in etElem ) {
      insertLeft = etElem[key].insertLeft!==undefined?etElem[key].insertLeft:'';  insertRight = etElem[key].insertRight!==undefined?etElem[key].insertRight:'';
      insert = etElem[key].insert!==undefined?etElem[key].insert:'';  title = etElem[key].title!==undefined?etElem[key].title:insertLeft+insert+insertRight;

      if ((insertLeft+insert+insertRight)!='') {resultText += '<a onclick="insertTags(\''+insertLeft+'\',\''+insertRight+'\',\''+insert+'\');return false;" title="'+title+'" href="#">';}
      if (etElem[key].img !== undefined) {resultText += '<img src="'+etElem[key].img+'" />';}
      if (etElem[key].text !== undefined) {resultText += etElem[key].text}
      if ((insertLeft+insert+insertRight)!='') {resultText +='</a>';}
      if (etElem[key].help !== undefined) {resultText += '<a href="'+etElem[key].help+'" target="_blank"><img src="'+helpIconAddress+'" /></a>';}
      resultText +=' ';
    }
    resultText += '</p>';
    $('#editpage-specialchars').append(resultText);
  } catch (e) {console.error('Ошибка в addComplectationEdittools');}
}



/*  Проверка контента статьи на наличие разделов с подсказкой под левым главым меню */
function checkContent() {
  if ( $('div.TankPerformance').length ) {
    var problems = new Array(); var problemsText = '';
    if( $('div#stockTTH.TankPerformance h3').text().indexOf("Ошибка: Значение не задано")+1 ){ problems.push('<a href="/WoT:Коды_модулей">Код техники</a>') }
    if( !$('.commentDrop').length ){ problems.push('<a href="/WoT:Коды_модулей">Комментарии модулей</a>') }
    /* if( !$('.skillsPanel').length ){ problems.push('<a href="/Шаблон:Навыки">Панели навыков</a>') } */
    if( !$('.complect').length ){ problems.push('<a href="/WoT:Содержание_статей_о_технике#.D0.9E.D0.B1.D0.BE.D1.80.D1.83.D0.B4.D0.BE.D0.B2.D0.B0.D0.BD.D0.B8.D0.B5.2C_.D1.81.D0.BD.D0.B0.D1.80.D1.8F.D0.B6.D0.B5.D0.BD.D0.B8.D0.B5_.D0.B8_.D0.B1.D0.BE.D0.B5.D0.BA.D0.BE.D0.BC.D0.BF.D0.BB.D0.B5.D0.BA.D1.82">Примеры комплектации</a>') }
    if( $('.mw-headline').text().indexOf("Исследование и прокачка")+1 == 0 && $('.TankPerformance .mw-headline a img').attr("src") != '/uploads/2/2b/Gold_icon.png'){ problems.push('<a href="/WoT:Содержание_статей_о_технике#.D0.98.D1.81.D1.81.D0.BB.D0.B5.D0.B4.D0.BE.D0.B2.D0.B0.D0.BD.D0.B8.D0.B5_.D0.B8_.D0.BF.D1.80.D0.BE.D0.BA.D0.B0.D1.87.D0.BA.D0.B0">Раздел Исследование и прокачка</a>');}
    if( $('.mw-headline').text().indexOf("Боевая эффективность")+1 == 0 ){ problems.push('<a href="/WoT:Содержание_статей_о_технике#.D0.91.D0.BE.D0.B5.D0.B2.D0.B0.D1.8F_.D1.8D.D1.84.D1.84.D0.B5.D0.BA.D1.82.D0.B8.D0.B2.D0.BD.D0.BE.D1.81.D1.82.D1.8C">Раздел Боевая эффективность</a>') }
    if( $('div.wot-panel h3').text().indexOf("Галерея скриншотов")+1 == 0 && $('div.wot-panel h2').text().indexOf("Галерея скриншотов")+1 == 0 && $('.NavHead').text().indexOf("Галерея")+1 == 0 ){ problems.push('<a href="/WoT:Содержание_статей_о_технике#.D0.93.D0.B0.D0.BB.D0.B5.D1.80.D0.B5.D1.8F_.D1.81.D0.BA.D1.80.D0.B8.D0.BD.D1.88.D0.BE.D1.82.D0.BE.D0.B2">Галерея скриншотов</a>') }
    if( $('div.wot-panel h3').text().indexOf("Оценка")+1 == 0 ){ problems.push('<a href="/WoT:Содержание_статей_о_технике#.D0.9E.D1.86.D0.B5.D0.BD.D0.BA.D0.B0_.D0.BC.D0.B0.D1.88.D0.B8.D0.BD.D1.8B">Оценка машины</a>') }
    if( $('.mw-headline').text().indexOf("Историческая справка")+1 == 0 ){ problems.push('<a href="/WoT:Содержание_статей_о_технике#.D0.98.D1.81.D1.82.D0.BE.D1.80.D0.B8.D1.87.D0.B5.D1.81.D0.BA.D0.B0.D1.8F_.D1.81.D0.BF.D1.80.D0.B0.D0.B2.D0.BA.D0.B0">Раздел Историческая справка</a>') }
    if( !$('.navbox').length ){ problems.push('<a href="#">Навигация</a>') }
    if( $('table.improvePlate').length ) { problems.push('Доработать: '+$('table.improvePlate i.reasons').text()); $('table.improvePlate').hide();}
    if( $('table.finishPlate').length ) { problems.push('<a href="/WoT:Содержание_статей_о_технике">Приведение в соответствие требованиям проекта</a>'); $('table.finishPlate').hide(); }

    if (problems != "") {
      for ( key in problems ) {
        problemsText += '<li>'+problems[key]+'</li>';
      }
      $('#mw-panel').append('<div class="portal" style="background:RGBA(255,0,0,0.1); padding: 7px 0px 24px 0px;"><h5>Статье требуется</h5><div class="body"><ul>'+problemsText+'</ul></div></div>');
    }
  }
}

/* Прячет не заданные характеристики в ТТХ */
function hideNoDataInfoInTankPerformance() {
  $('.TankPerformance td span').each(function(key, value) {
    if ($(value).text().indexOf('не задано')+1) $(value).parent().parent().hide();
  });
}

/* добавляет структуру для просмотра увеличенных изображений без перехода на другую страницу */
function addImagePopupWindow() {
  $('body').append(
    '<div id="popupImageWindow"><table><tr><td style="vertical-align: middle;">'+
    '<div id="popupImageOverlay"></div>'+
    '<div id="popupImageWrapper">'+
    '<img id="popupImage" src="" />'+
    '<img src="//wiki.gcdn.co/images/b/bd/Close.png" class="closeBtn">'+
    '<a id="popupImageLeft" href="javascript:;">'+
    '<span id="popupImageIcoLeft" class="popupImageIco"></span>'+
    '</a>'+
    '<a id="popupImageRight" href="javascript:;">'+
    '<span id="popupImageIcoRight" class="popupImageIco"></span>'+
    '</a>'+
    '<div id="popupImageInfo"></div>'+
    '</div>'+
    '</td></tr></table></div>'+
    '<div id="popupImageButtons"><a id="openImageFile" href="javascript:;">Файл</a></div>'
  );
}

var gallersArray = [], // Массив галерей, в которых массив объектов (src, text, href)
  currentGalleryIndex = 0, currentImageIndex = 0;

/* Открывает картинку */
function setImage(indexGallery, indexImage) {
  currentGalleryIndex = indexGallery;
  currentImageIndex = indexImage;
  $('#popupImage').width('1px');
  $('#popupImage').height('1px');
  $('#popupImageOverlay').css('background-image', 'url('+imageLoaderUrl+')');
  $('#popupImage').attr('src', gallersArray[indexGallery][indexImage].src);
  $('#popupImageButtons a#openImageFile').attr('href', gallersArray[indexGallery][indexImage].href);
  $('#popupImageInfo').html(gallersArray[indexGallery][indexImage].text);
  if (gallersArray[indexGallery].length < indexImage + 2) { // Если нет следующей картинки убираем кнопку
    $('#popupImageRight').hide();
  } else {
    $('#popupImageRight').show();
  }
  if (indexImage - 1 < 0) { // Если нет предыдущей картинки убираем кнопку
    $('#popupImageLeft').hide();
  } else {
    $('#popupImageLeft').show();
  }
  $('#popupImageWrapper').hide();
  $('#popupImageWindow').show();
  $('#popupImageButtons').show();
}

/* добавляет функционал просмотра увеличенных изображений без перехода на другую страницу */
function addImagePopups() {
  addImagePopupWindow();

  // Для галерей
  $.each($('ul.gallery'), function(indexGallery, valueGallery) {
    gallersArray[indexGallery] = [];
    $.each($(valueGallery).find('li.gallerybox'), function(indexImage, valueImage) {
      var Image = new Object();
      var srcStr = $(valueImage).find('a.image img').attr('src');
      if (typeof srcStr !== 'undefined') {
        if (srcStr.indexOf('thumb/')+1 > 0) {
          srcStr = srcStr.replace(/thumb\//gi, '');
          srcStr = srcStr.substring(0, srcStr.lastIndexOf("/"));
        }
      }
      Image.src = srcStr;
      Image.text = $(valueImage).find('div.gallerytext').text().trim();
      Image.href = $(valueImage).find('a.image').attr('href');
      if (typeof Image.src !== 'undefined') {
        gallersArray[indexGallery][indexImage] = Image;
        $(valueImage).find('a.image').click(function(index) {
          setImage(indexGallery, indexImage);
          return false;
        });
      }
    });
  });

  // Для одиночных эскизров
  $.each($('a.image').not($('.js-vehicles_by_types a.image')).not($('ul.gallery a.image')), function(index, value) {
    var indexGallery = gallersArray.length;
    gallersArray[indexGallery] = [];
    var Image = new Object();
    var srcStr = $(value).find('img').attr('src');
    if (typeof srcStr !== 'undefined') {
      if (srcStr.indexOf('thumb/')+1 > 0) {
        srcStr = srcStr.replace(/thumb\//gi, '');
        srcStr = srcStr.substring(0, srcStr.lastIndexOf("/"));
      }
    }
    Image.src = srcStr;
    var titleStr = ''; //Подпись
    if ($(this).next('div.thumbcaption').length > 0) {
      titleStr = $(this).next('div.thumbcaption').text().trim();
    } else if($(this).parent().parent().parent().children('div.gallerytext').length > 0) {
      titleStr = $(this).parent().parent().parent().children('div.gallerytext').text().trim();
    }
    Image.text = titleStr;
    Image.href = $(value).attr('href');
    if (typeof Image.src !== 'undefined') {
      gallersArray[indexGallery][0] = Image;
      $(value).click(function(index) {
        setImage(indexGallery, 0);
        return false;
      });
    }
  });

  // После загрузки картинки показываем её
  $('#popupImage').load(function() {
    $('#popupImage').width('').height('');
    $(this).css('max-width', (self.innerWidth-100)+'px');
    $(this).css('max-height',(self.innerHeight-100)+'px');
    $('#popupImageOverlay').css('background-image', '');
    $('#popupImageWrapper').show();
  });

  //Закрыть попап кнопкой
  $('.closeBtn').click(function(index) {
    $('#popupImageWindow').hide();
    $('#popupImageButtons').hide();
    $('#popupImageButtons a').attr('href', '#');
    $('#popupImageInfo').text('');
    $('#popupImage').attr('src', '');
  });

  //Закрыть попап фоном
  $('#popupImageOverlay').click(function(index) {
    $('#popupImageWindow').hide();
    $('#popupImageButtons').hide();
    $('#popupImageButtons a').attr('href', '#');
    $('#popupImageInfo').text('');
    $('#popupImage').attr('src', '');
  });

  // Предыдущую картинку
  $('a#popupImageLeft').click(function(index) {
    setImage(currentGalleryIndex, currentImageIndex - 1);
  });

  // Следующую картинку
  $('a#popupImageRight').click(function(index) {
    setImage(currentGalleryIndex, currentImageIndex + 1);
  });
}

/* Дерево модулей */
function modulesBlock() {
  var currentModulesBlock = 1;
  var modulesBlock = [];
  modulesBlock[1] = $('#modulesBlock').html();
  modulesBlock[2] = false;
  var vehicle = $('#codeValue').text();

  $('#modulesBlockH2').append('<span id="modulesBlockChange"><div class="switcherCtrlBtn active" id="modulesBlockChange_1"><span>список</span></div><div class="switcherCtrlBtn" id="modulesBlockChange_2"><span>дерево развития</span></div></span>');

  $('#modulesBlockChange .switcherCtrlBtn').click(function() {
    if ($(this).hasClass('active')) {return false;}
    currentModulesBlock = $(this).attr("id") == 'modulesBlockChange_1' ? 1 : 2;
    if (modulesBlock[currentModulesBlock] == false ) {
      modulesBlock[currentModulesBlock] = '<iframe frameborder="0" style="border-width: 0; width: 100%; min-width: 780px; height: 620px;" src="https://armor.kiev.ua/wot/tanks/modulestree.php?vehicle=' + vehicle + '"></iframe>';
    }
    $('#modulesBlock').html(modulesBlock[currentModulesBlock]);
    $('#modulesBlockChange .switcherCtrlBtn').removeClass('active');
    $(this).addClass('active');
    return false;
  });

  $('.treeFrame').each(function(indx) {
    $(this).html('<iframe frameborder="0" style="border-width: 0; width: 1645px; min-width: 1010px; height: 750px;" src="' + $(this).html() + '"></iframe>');
  });
  $('.modulesTreeFrame').each(function(indx) {
    $(this).html('<iframe frameborder="0" style="border-width: 0; width: 100%; min-width: 820px; height: 620px;" src="' + $(this).html() + '"></iframe>');
  });
}

/* Переключатель между разными дивами */
function switcher() {
  try{if (localStorage.o_debug_switcher == 1) {return 0;}} catch (e) {} // дебаг
  $('.switcher').each(function () {
    var sWidth = $(this).find('.sw_data-width').text();
    var sHeight = $(this).find('.sw_data-height').text();
    var sMenuposition = $(this).find('.sw_data-menuposition').text();

    if (sWidth != "") {
      $(this).find('.switcherWrap').css('width',sWidth);
      $(this).find('.subSwitcher').css('width',sWidth);
    }
    if (sHeight != "") {
      $(this).find('.switcherFrame').css('height',sHeight);
      $(this).find('.subSwitcher').css('height',sHeight);
    }

    $(this).find('.subSwitcher:first').show();
    $(this).find('.switcherControlButton:first').addClass('active');

    if (sMenuposition != "") {
      if (sMenuposition == 'top') {
        $(this).find('.switcherControl').detach().prependTo($(this).find('.switcherWrap'));
      }
    }

    if ($(this).find('.subSwitcherBackground a img').length) {
      $(this).find('.switcherFrame').css('backgroundImage', 'url('+$(this).find('.subSwitcherBackground a img').attr('src')+')');
    }

    $(this).removeClass('hidden');
  })

  $('.switcherControlButton').click(function () {
    var buttonCkickId=$(this).find('.sw_data-id').text();
    $(this).parent().children('.switcherControlButton').removeClass('active'); //hurr
    $(this).addClass('active');
    $(this).parent().parent().find('.subSwitcher').each(function() { //durr
      if(buttonCkickId == $(this).find('.sw_data-id').text()) $(this).show();
      else $(this).hide();
    });
  });
}

function switcher_original() {
  try{if (localStorage.o_debug_switcher == 1) {return 0;}} catch (e) {} // дебаг
  $('.switcher').each(function () {
    if ($(this).data('width') != undefined && $(this).data('width') != "") {
      $(this).find('.switcherWrap').css('width',$(this).data('width'));
      $(this).find('.subSwitcher').css('width',$(this).data('width'));
    }
    if ($(this).data('height') != undefined && $(this).data('height') != "") {
      $(this).find('.switcherFrame').css('height',$(this).data('height'));
      $(this).find('.subSwitcher').css('height',$(this).data('height'));
    }

    $(this).find('.subSwitcher:first').show();
    $(this).find('.switcherControlButton:first').addClass('active');

    if ($(this).data('menuposition') !== undefined) {
      if ($(this).data('menuposition') == 'top') {
        $(this).find('.switcherControl').detach().prependTo($(this).find('.switcherWrap'));
      }
    }

    console.log($(this).find('.subSwitcherBackground a img').length);
    if ($(this).find('.subSwitcherBackground a img').length) {
      $(this).find('.switcherFrame').css('backgroundImage', 'url('+$(this).find('.subSwitcherBackground a img').attr('src')+')');
    }

    $(this).removeClass('hidden');
  })

  $('.switcherControlButton').click(function () {
    var buttonCkickId=$(this).data('id');
    $(this).parent().children('.switcherControlButton').removeClass('active'); //hurr
    $(this).addClass('active');
    $(this).parent().parent().find('.subSwitcher').each(function() { //durr
      if (buttonCkickId == $(this).data('id')) {
        $(this).show();
      } else {
        $(this).hide();
      }
    });
  });
}

/* Улучшение панели */
function improvedPanelEditTools() {
  try {
    if (localStorage['o_improvedEditPanel'] != 1) return 0;
    if (!$('#wpTextbox1').length) return 0;
    var animateSpeed = 150;
    $('#editform').append('<div id="editPanel"></div>');
    $('#editPanel').addClass('improved'); $('.templatesUsed ul').addClass('improved');

    $('.mw-editTools').appendTo('#editPanel');
    if (localStorage['o_improvedEditPanelDownKey'] != 1) { $('.editOptions').appendTo('#editPanel'); }

    if (localStorage['o_improvedEditPanelShowRight'] != 1) {
      $("#editPanel").mouseenter(function(){ $('#editPanel').stop(true,true); $('#editPanel').animate({bottom: '0px'}, animateSpeed); })
        .mouseleave(function(){ $('#editPanel').stop(true,true); $('#editPanel').animate({bottom: '-'+($('#editPanel').height()-10)+'px'}, animateSpeed); });
      $('#editPanel').animate({bottom: '-'+($('#editPanel').height()-10)+'px'}, animateSpeed);
    } else {
      $("#editPanel").mouseenter(function(){ $('#editPanel').stop(true,true); $('#editPanel').animate({right: '0px'}, animateSpeed); })
        .mouseleave(function(){ $('#editPanel').stop(true,true); $('#editPanel').animate({right: '-'+($('#editPanel').width()-10)+'px'}, animateSpeed); });
      $('#editPanel').animate({right: '-'+($('#editPanel').width()-10)+'px'}, animateSpeed);
    }

    wpTextbox1Resizer();
    $('#wpTextbox1').bind('keydown keypress keyup', wpTextbox1Resizer);
  } catch (e) {console.error('Ошибка в improvedPanelEditTools');}
}

function wpTextbox1Resizer() {
  if ($('#wpTextbox1')[0].scrollHeight > $('#wpTextbox1')[0].offsetHeight) { $('#wpTextbox1').css('height',($('#wpTextbox1')[0].scrollHeight+200)+'px'); }
}

/* Доходность (шаблон) */
function profitPanel() {
  $('.profitMore').toggle(
    function() {$(this).prev().prev().show();$(this).text('&#9650; Подробнее');},
    function() {$(this).prev().prev().hide();$(this).text('&#9660; Подробнее');}
  );
}

/* Прозвища ajax */
function getAlias() {
  try {
    if ( $('div.TankPerformance').length ) {
      var codeValue = $('#codeValue').text();
      var nationValue = $('#nationValue').text();
      $('div.TankPerformance table tbody').eq(1).prepend(''+
        '<tr><th class="center group alias aliasHeader" colspan="2">Прозвища в игре <div class="editLink">[<a href="/WoT:Прозвища">править</a>]</div></th></tr>'+
        '<tr><td class="alias aliasContent" colspan="2"></td></tr>'
      );
      $('div.TankPerformance table tbody').eq(4).prepend(''+
        '<tr><th class="center group alias aliasHeader" colspan="2">Прозвища в игре <div class="editLink">[<a href="/WoT:Прозвища">править</a>]</div></th></tr>'+
        '<tr><td class="alias aliasContent" colspan="2"></td></tr>'
      );
      $.get('/WoT:Прозвища/'+nationValue)
        .done(function(data) {
          var obj = $.parseJSON(jQuery(data).find("div.mw-content-ltr p").text());
          if (obj[codeValue] !== undefined) { $('.aliasContent').text(obj[codeValue]); }
        })
        .always(function() { if ($('.aliasContent').text() != '') {$('.alias').fadeIn();} });
    }
  } catch (e) {
    console.log("Что-то пошло не так. Пичалька, прозвища ниработают");
  }
}

/* Установка дефолтных настроек */
function setDefaultjsOptions() {
  try{
    lsElement = new Array(
      {param:'o_showJsOptionsPanel', value:1},
      {param:'o_additionalEditPanelButtons', value:1},
      {param:'o_improvedEditPanel', value:0}, {param:'o_improvedEditPanelDownKey', value:0}, {param:'o_improvedEditPanelShowRight', value:0},
      {param:'o_spellCheck', value:0}, {param:'o_spellCheckIgnoreUppercase', value:0}
    );
    for (key in lsElement) {if (localStorage[lsElement[key].param]===undefined) {localStorage[lsElement[key].param] = lsElement[key].value;}}
  } catch (e) { console.error('Нет поддержки localStorage? Пришло время обновить браузер.'); }
}

/* Панелька настроек */
function jsOptionsPanel() {
  try {
    if (localStorage['o_showJsOptionsPanel'] != 1) return 0;
    if(!(wgTitle==wgUserName && wgCanonicalNamespace=='User')) return 0;
    $('#bodyContent').append('<fieldset id="js_options" style="font-size: 10px;">'+
      '<legend>Дополнительные настройки скриптов</legend>'+
      '<input type="checkbox" id="o_improvedEditPanel" name="o_improvedEditPanel" /><label for="o_improvedEditPanel"> Улучшеная панель редактирования</label><br>'+
      '&nbsp; <input type="checkbox" id="o_improvedEditPanelDownKey" name="o_improvedEditPanelDownKey" /><label for="o_improvedEditPanelDownKey"> Кнопки управления внизу</label><br>'+
      '&nbsp; <input type="checkbox" id="o_improvedEditPanelShowRight" name="o_improvedEditPanelShowRight" /><label for="o_improvedEditPanelShowRight"> Отображать панель справа</label><br>'+
      '<input type="checkbox" id="o_additionalEditPanelButtons" name="o_additionalEditPanelButtons" /><label for="o_additionalEditPanelButtons"> Дополнительные кнопки редактирования</label><br>'+
      '</fieldset>');

    $('#js_options input[type="checkbox"]').each(function (index) { if (localStorage[$(this).attr('name')]==1) { $(this).attr('checked','checked');} })

    $('#js_options input[type="checkbox"]').bind('change', function() {
      if ($(this).is(':checked')) { localStorage[$(this).attr('name')] = 1; }
      else { localStorage[$(this).attr('name')] = 0; }
    });
  } catch (e) {console.error('Ошибка в jsOptionsPanel');}
}

/* Вводная инструкция по редактированию */
function KMVAlert() {
  try {
    if(!$('#editform').length) {return 0;}
    var oToday = new Date();
    if (localStorage['o_lastShownKMVAlertDate']==undefined) {localStorage['o_lastShownKMVAlertDate'] = 0;}
    var lastShownKMVAlertDate = new Date(); lastShownKMVAlertDate.setTime(localStorage['o_lastShownKMVAlertDate']);
    var nDaysLeft = lastShownKMVAlertDate < oToday ? Math.ceil((oToday-lastShownKMVAlertDate) / (1000 * 60 * 60 * 24)) : 0;
    if (nDaysLeft>30) {
      $('body').append('<div id="alertMessage" style="position:fixed; top:0; left:0; right:0; bottom:0; z-index:9050; background:RGBA(0,0,0,0.4); padding: 50px; overflow:auto;">'+
        '<div class="content" style="padding: 17px; background: white; min-height:300px; font-size: 80%;">'+
        'Загрузка'+
        '</div><div style="text-align:center;padding: 0 0 100px;"><a class="closeBtn" style="padding:12px; background:#FF3333; color:#000000;" onclick="var oToday = new Date(); localStorage[\'o_lastShownKMVAlertDate\'] = oToday.getTime(); $(\'#alertMessage\').hide(); return false;" href="#">Я всё понял</a></div>'+
        '</div>');
      $('#alertMessage .content').load('/WoT:Краткая_вводная div.mw-content-ltr', function() {});
    } else {
      localStorage['o_lastShownKMVAlertDate'] = oToday.getTime();
    }
  } catch (e) {
    console.log("КМВ: Что-то пошло не так");
  }
}

/* Конфиг */
var imageLoaderUrl = '/Loading.gif';
var isRotate = false;

function addRotatorPopupWindow() {
  $('body').append('<div id="popupRotatorWindow"><table><tr><td><div id="popupRotatorWrapper">'+
    '<div id="rotatorTarget"></div><img src="//wiki.gcdn.co/images/b/bd/Close.png" class="closeBtn" alt="Закрыть"></div>'+
    '</td></tr></table></div>'
  );
}

/* Popup */
function addPopupWindow() {
  $('body').append(
    '<div id="popupWindow"><table><tr><td style="vertical-align: middle;">'+
    '<div id="popupOverlay"></div>'+
    '<div id="popupWrapper">'+
    '<div id="popupContent"></div>'+
    '<img src="//wiki.gcdn.co/images/b/bd/Close.png" class="closeBtn" alt="Закрыть">'+
    '</div>'+
    '</td></tr></table></div>'
  );
  //Закрыть попап кнопкой
  $('.closeBtn').click(function(index) {
    $('#popupWindow').hide();
  });

  //Закрыть попап фоном
  $('#popupOverlay').click(function(index) {
    $('#popupWindow').hide();
  });
}

/* Шаблон Model3DViewer */
function addModel3DViewer() {
  $('.Model3DViewer').click(function(){
    document.getElementById("popupContent").innerHTML = '<iframe width="'+(document.documentElement.clientWidth-150)+'px" height="'+(document.documentElement.clientHeight-150)+'px" id="Model3D" src="https://sketchfab.com/models/'+$(this).children('div.Model3D').text()+'/embed?autostart=1&amp;preload=1" frameborder="0" allowfullscreen mozallowfullscreen="true" webkitallowfullscreen="true" onmousewheel=""></iframe>';
    $('#popupWrapper').show();
    $('#popupWindow').show();
  });
}

/* Шаблон Panorama */
function addPanorama() {
  $.each($('.PanoramaViewer'), function( index, element ) {
    $(element).append('<iframe width="684px" align="middle" height="380px" frameborder="0" seamless="" scrolling="no" marginheight="0" marginwidth="0" src="//content.wargaming.net/wot/community/panoramas/' + $(element).children('div.Panorama').text() + '"></iframe>');
  });
}

/* WoWs: ретагертинг ВК */
function add_VK_retag() {
  if (wgCanonicalNamespace == 'Navy' && wgPageName == 'World_of_Warships') {
    (window.Image ? (new Image()) : document.createElement('img')).src = location.protocol + '//vk.com/rtrg?r=cj1A6IhaIFpO3BoHvuW7dl*ZerRIlEHZ5JAfF1HBUUc4I9bBUeRNL//Lctmr5tztW0cthhi0Te31*/ORHHyQCnYUe9Rd9mh4rgaATuXFWFCwzMFE8yV58QJWQLWZFRkGr43/fHDJ0o5Q2ZWDnvGdKVlEs2BzVNRnpiCXf7h/SFU-&pixel_id=1000064587';
  }
  if (wgCanonicalNamespace == 'Ship') {
    if (wgPageName == 'Словарь_морских_терминов') {
      (window.Image ? (new Image()) : document.createElement('img')).src = location.protocol + '//vk.com/rtrg?r=gZ8LfxKUw0k2vFDjCYOMYSi1UXB*Mv1gOh4EmfDT5XYDlkn2KUgr95*JoBadis/76uyAolNvKObpj77BXJO2PDS4T8Gc*WR2RLkvSUV/oMq9wW5m/8nE4L1ACtLDBiRZ0CrS9Mb0X36m8ukZv2mEHAnYoMpvF55gmmKuwZERsdc-&pixel_id=1000064588'; }
    if (wgPageName == 'Русско-японская_война') {
      (window.Image ? (new Image()) : document.createElement('img')).src = location.protocol + '//vk.com/rtrg?r=wxub3EROPDo7g/kePWq0NAx4jhXh/ZblYtp1lS*xrUT25mop4YOTg87yanm*Dgbz3wnkGT/z3RiRdJWnk1fTnsfEjALhmaCJM1LunQyb2bVBnROpAccJHIYewTyRXsfl2MIma/QeBsFaF//b3O/Bur6XqhPKEcgQpUJWyCPSGk4-&pixel_id=1000064589'; }
  }
}

/** ready */
$(document).ready( function() {
  //modulesBlock();
  setDefaultjsOptions();
  switcher();
  setTimeout(addImagePopups, 0);
  addPopupWindow();
  addModel3DViewer();
  addSoundPlayer();
  addPanorama();
  add_VK_retag();

  // setTimeout(hideNoDataInfoInTankPerformance,0);
  // setTimeout(getAlias,0);
  // Add Hooks

  addPlayButton();

  if (wgAction == 'edit' || wgAction == 'submit') {
    // importScriptURI('https://ru.wikipedia.org/w/index.php?title=MediaWiki:Wikificator.js&action=raw&ctype=text/javascript')
    // addWikifButton()
  } else {
    tacticSlideShow();
    tthTopStock();
    collapsibleDivs();
    collapsibleTables();
    gunShellsBlock();
  }

  /* setTimeout(function (){$('.rotator').simpleRotator({width: '100%', textLoad: '<img src="https://wiki.worldoftanks.ru/uploads/2/2d/RotateIcon.png" />'});}); */

  //----
  setTimeout(function () {
    $('.myRotator').click(function() {
      if (isRotate) {return 0;}
      addRotatorPopupWindow();
      $('#rotatorTarget').html($(this).children('.rotator').html());
      $('#rotatorTarget').simpleRotator({width: '1024px', textLoading: '<img src="' + imageLoaderUrl + '" alt="Загрузка" />'});
      $('#rotatorTarget').children(".loader").click();
      $('#popupRotatorWindow').find('.closeBtn').click(function() {
        $('#popupRotatorWindow').remove();
        isRotate = false;
      });
      $('#popupRotatorWindow').show();
      isRotate = true;
    });
  });

  //----
  setTimeout(function (){$('.hangarRotator').simpleRotator({width: '1060px', textLoading: '<img src="' + imageLoaderUrl + '" />'}); $('.hangarRotator').children(".loader").click(); });

  //----
  // setTimeout(addAdditionalEdittools,0);
  // setTimeout(checkContent,0);
  // setTimeout(jsOptionsPanel,0);
  // setTimeout(improvedPanelEditTools,0);
  // setTimeout(profitPanel,0);
  // setTimeout(KMVAlert,0);

  //----
  setTimeout(function () {
    $('.provRef').click(function() {
      var ref = '#' + $(this).data('ref');
      var origin = $(this).parents('tr:first').attr('id');
      $('.provSelect').removeClass('provSelect');
      $('.provOrigin').removeClass('provOrigin');
      $(ref).addClass('provSelect').find('[data-ref=' + origin + ']').addClass('provOrigin');
      location.href = ref;
    });
  });

  //----
  setTimeout(function () {
    $('#editform').submit(function() {
      var result = $('#wpTextbox1').val().indexOf('war' + 'blogs.ru') == -1;
      var mb = $('#mw-js-message');
      if (!result) {
        mb.html('Возникла неизвестная ошибка при сохранении');
        mb.show();
      }
      return result;
    });
  });
});
/* ready **/

// CCW loader start
(function(w,d,s,p) {
  var f=d.getElementsByTagName(s)[0],j=d.createElement(s),i;
  j.async=true;j.src='//'+p['server']+'/compiled/loader.min.js';j.setAttribute('id', 'ccw-loader');
  for(i in p){if (p.hasOwnProperty(i)) {j.setAttribute('data-'+i,p[i]);}}
  f.parentNode.insertBefore(j,f);
})(window,document,'script',{
  'server':'ccw-center.wargaming.net',
  'language':'ru',
  'service':'wiki'
});
// CCW loader end

/* SoundPlayer */
function addSoundPlayer() {
  var audio = new Audio();
  $('.SoundPlayer').click(function(){
    audio.src = $(this).find('#sound_source').text();
    if(audio.paused === true) {
      audio.play();
    } else {
      audio.pause();
      audio.currentTime = 0.0;
    }
  });
}


/* Cookie Banner */
(function (w, d, s, p) {
        var f = d.getElementsByTagName(s)[0], j = d.createElement(s), i;
        j.src = '//' + p;
        if (j.readyState) {  // only required for IE <9
            j.onreadystatechange = function () {
                if (j.readyState === "loaded" || j.readyState === "complete") {
                    j.onreadystatechange = null;
                    CookieBanner.createCookieBanner({openPolicyInNewTab: true});
                }
            };
        } else {  //Others
            j.onload = function () {
                CookieBanner.createCookieBanner({openPolicyInNewTab: true});
            };
        }
        f.parentNode.insertBefore(j, f);
    })(window, document, 'script', 'web-static-production.lesta.ru/cookie-banner/1.3.7/cookie-banner.umd.js');