MediaWiki:Common.js
Версия от 14:12, 30 июля 2013;
Замечание. Возможно, после сохранения вам придётся очистить кэш своего браузера, чтобы увидеть изменения.
- Firefox / Safari: Удерживая клавишу Shift, нажмите на панели инструментов Обновить либо нажмите Ctrl-F5 или Ctrl-R (⌘-R на Mac)
- Google Chrome: Нажмите Ctrl-Shift-R (⌘-Shift-R на Mac)
- Internet Explorer: Удерживая Ctrl, нажмите Обновить либо нажмите Ctrl-F5
- Opera: Выберите очистку кэша в меню Инструменты → Настройки
/* Размещённый здесь JavaScript код будет загружаться всем пользователям при обращении к каждой странице */ /* Добавление кнопки и функционала Викификатора в режиме редактирования */ function addWikifButton() { var toolbar = document.getElementById('toolbar') if (!toolbar) return var i = document.createElement('img') i.src = 'https://upload.wikimedia.org/wikisource/ru/d/d1/Button-wikifikator.png' i.alt = i.title = 'викификатор' i.onclick = Wikify i.style.cursor = 'pointer' toolbar.appendChild(i) } /* Сокрытие приглашения скачать игру в подвале для залогиненного пользователя (раньше фунция еще добавляла кнопку "Играть") */ 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 tthToTop() { document.getElementById('stockTTH').style.display = 'none'; document.getElementById('topTTH').style.display = 'block'; return false; } /* Переключение таблицы ТТХ машины в стоковую конфигурацию */ function tthToStock() { document.getElementById('topTTH').style.display = 'none'; document.getElementById('stockTTH').style.display = 'block'; return false; } /* переключение ТТХ топ/сток */ function tthTopStock() { try { var toStock = document.getElementById('toStock'); var toTop = document.getElementById('toTop'); if (toStock == null || toTop == null) { return; } var aNode = document.createElement( 'a' ); aNode.setAttribute( 'href', '#' ); aNode.setAttribute( 'onClick', 'return tthToTop();' ); aNode.appendChild(document.createTextNode('топ')); toTop.appendChild(aNode); var aNode = document.createElement( 'a' ); aNode.setAttribute( 'href', '#' ); aNode.setAttribute( 'onClick', 'return tthToStock();' ); aNode.appendChild(document.createTextNode('сток')); toStock.appendChild(aNode); } catch(e) { return; } } //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 ); }); }); */ 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 } // Add Hooks addOnloadHook(addPlayButton); if (wgAction == 'edit' || wgAction == 'submit') { importScriptURI('https://ru.wikipedia.org/w/index.php?title=MediaWiki:Wikificator.js&action=raw&ctype=text/javascript') addOnloadHook(addWikifButton) } else { addOnloadHook(tacticSlideShow) addOnloadHook(tthTopStock) addOnloadHook(collapsibleDivs) addOnloadHook(collapsibleTables) } /* Функционал всплывающих подсказок с ТТХ модулей */ 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:#f2f2d2;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> </p>'; $("#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); /* MaSha (https://mashajs.com) плагин */ (function(){function r(a,b,c,d){function e(){if(f)return null;var h=b;b.childNodes&&b.childNodes.length&&!k?b=b[d?"lastChild":"firstChild"]:b[d?"previousSibling":"nextSibling"]?(b=b[d?"previousSibling":"nextSibling"],k=!1):b.parentNode&&(b=b.parentNode,b===a&&(f=!0),k=!0,e());h===c&&(f=!0);return h}d=!!d;b=b||a[d?"lastChild":"firstChild"];var f=!b,k=!1;return e}function t(a){for(var b=1;b<arguments.length;b++)for(key in arguments[b])a[key]=arguments[b][key];return a}function u(a){return(a||"").replace(/^\s+|\s+$/g, "")}function w(a,b){for(;a&&!g(a,b);)a=a.parentNode;return a||null}function z(a,b){for(var c=r(a),d=null;d=c();)if(1===d.nodeType&&g(d,b))return d;return null}function A(a){a=r(a);for(var b=null;(b=a())&&3!==b.nodeType;);return b}function n(a,b){if(a.getElementsByClassName)return a.getElementsByClassName(b);for(var c=[],d,e=r(a);d=e();)1==d.nodeType&&g(d,b)&&c.push(d);return c}function v(a){for(var b=[],c=r(a);a=c();)3===a.nodeType&&b.push(a);return b}function B(a){return RegExp("(^|\\s+)"+a+"(?:$|\\s+)", "g")}function g(a,b){return B(b).test(a.className)}function x(a,b){B(b).test(a.className)||(a.className=a.className+" "+b)}function s(a,b){var c=B(b);c.test(a.className)&&(a.className=u(a.className.replace(c,"$1")))}function E(a,b){for(var c=0,d=b.length;c<d;c++)if(b[c]===a)return c;return-1}function l(a,b,c){a.addEventListener?a.addEventListener(b,c,!1):a.attachEvent&&a.attachEvent("on"+b,c)}function q(a,b,c){a.removeEventListener?a.removeEventListener(b,c,!1):a.detachEvent&&a.detachEvent("on"+b, c)}function C(a){a.preventDefault?a.preventDefault():a.returnValue=!1}var j=function(){};j.prototype={setHash:function(a){window.location.hash=a},getHash:function(){return window.location.hash},addHashchange:function(a){this.callback=a;l(window,"hashchange",a)},destroy:function(){this.callback&&q(window,"hashchange",this.callback)}};var m=function(a){a=a||{};"select_message"in a&&(a.selectMessage=a.select_message);"enable_haschange"in a&&(a.enableHaschange=a.enable_haschange);"is_block"in a&&(a.isBlock= a.is_block);this.options=t({},m.defaultOptions,a);t(this,{counter:0,savedSel:[],ranges:{},childs:[],blocks:{}});this.init()};m.version="25.04.2013-09:55:11";m.LocationHandler=j;m.defaultOptions={regexp:"[^\\s,;:\u2013.!?<>\u2026\\n\u00a0\\*]+",selectable:"selectable-content",marker:"txtselect_marker",ignored:null,selectMessage:null,location:new j,validate:!1,enableHaschange:!0,onMark:null,onUnmark:null,onHashRead:function(){var a=z(this.selectable,"user_selection_true");a&&!this.hashWasRead&&(this.hashWasRead= !0,window.setTimeout(function(){for(var b=0,c=0;a;)b+=a.offsetLeft,c+=a.offsetTop,a=a.offsetParent;window.scrollTo(b,c-150)},1))},isBlock:function(a){var b;if(!(b="BR"==a.nodeName)){b="display";var c="";document.defaultView&&document.defaultView.getComputedStyle?c=document.defaultView.getComputedStyle(a,"").getPropertyValue(b):a.currentStyle&&(b=b.replace(/\-(\w)/g,function(a,b){return b.toUpperCase()}),c=a.currentStyle[b]);b=-1==E(c,["inline","none"])}return b}};m.prototype={init:function(){this.selectable= "string"==typeof this.options.selectable?document.getElementById(this.options.selectable):this.options.selectable;"string"==typeof this.options.marker?(this.marker=document.getElementById(this.options.marker),null===this.marker&&(this.marker=document.createElement("a"),this.marker.setAttribute("id",this.options.marker),this.marker.setAttribute("href","#"),document.body.appendChild(this.marker))):this.marker=this.options.marker;if("string"!=typeof this.options.regexp)throw"regexp is set as string"; this.regexp=RegExp(this.options.regexp,"ig");this.selectable&&(this.isIgnored=this.constructIgnored(this.options.ignored),this.options.selectMessage&&this.initMessage(),this.enumerateElements(),"ontouchstart"in window||window.DocumentTouch&&document instanceof DocumentTouch?(this.touchEnd=p(this.touchEnd,this),l(this.selectable,"touchend",this.touchEnd)):(this.mouseUp=p(this.mouseUp,this),l(this.selectable,"mouseup",this.mouseUp)),this.markerClick=p(this.markerClick,this),l(this.marker,"click",this.markerClick), l(this.marker,"touchend",this.markerClick),this.hideMarker=p(this.hideMarker,this),l(document,"click",this.hideMarker),this.options.enableHaschange&&(this.hashChange=p(this.hashChange,this),this.options.location.addHashchange(this.hashChange)),this.readHash())},destroy:function(){s(this.marker,"show");this.options.selectMessage&&this.hideMessage();q(this.selectable,"mouseup",this.mouseUp);q(this.selectable,"touchEnd",this.touchEnd);q(this.marker,"click",this.markerClick);q(this.marker,"touchend", this.markerClick);q(document,"click",this.hideMarker);this.options.location.destroy();var a=n(this.selectable,"user_selection_true");this.removeTextSelection(a);for(var b=n(this.selectable,"closewrap"),a=b.length;a--;)b[a].parentNode.removeChild(b[a]);b=n(this.selectable,"masha_index");for(a=b.length;a--;)b[a].parentNode.removeChild(b[a])},mouseUp:function(a){var b;if(null==a.pageX){var c=document.documentElement,d=document.body;b={x:a.clientX+(c&&c.scrollLeft||d&&d.scrollLeft||0)-(c.clientLeft|| 0),y:a.clientY+(c&&c.scrollTop||d&&d.scrollTop||0)-(c.clientTop||0)}}else b={x:a.pageX,y:a.pageY};window.setTimeout(p(function(){this.showMarker(b)},this),1)},touchEnd:function(){window.setTimeout(p(function(){var a=window.getSelection();if(a.rangeCount){a=a.getRangeAt(0).getClientRects();if(a=a[a.length-1])var b={x:a.left+a.width+document.body.scrollLeft,y:a.top+a.height/2+document.body.scrollTop};this.showMarker(b)}},this),1)},hashChange:function(){if(this.lastHash!=this.options.location.getHash()){var a= [],b;for(b in this.ranges)a.push(b);this.deleteSelections(a);this.readHash()}},hideMarker:function(a){(a.target||a.srcElement)!=this.marker&&s(this.marker,"show")},markerClick:function(a){C(a);a.stopPropagation?a.stopPropagation():a.cancelBubble=!0;a=a.target||a.srcElement;if(!g(this.marker,"masha-marker-bar")||g(a,"masha-social")||g(a,"masha-marker"))if(s(this.marker,"show"),this.rangeIsSelectable()&&(this.addSelection(),this.updateHash(),this.options.onMark&&this.options.onMark.call(this),this.options.selectMessage&& this._showMessage(),g(a,"masha-social")&&(a=a.getAttribute("data-pattern"))))a=a.replace("{url}",encodeURIComponent(window.location.toString())),this.openShareWindow(a)},openShareWindow:function(a){window.open(a,"","status=no,toolbar=no,menubar=no,width=800,height=400")},getMarkerCoords:function(a,b){return{x:b.x+5,y:b.y-33}},getPositionChecksum:function(a){for(var b="",c=0;3>c;c++){var d=(a()||"").charAt(0);d&&(d=d.charCodeAt(0)%62,d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890".charAt(d)); b+=d}return b},showMarker:function(a){var b=RegExp(this.options.regexp,"g"),c=window.getSelection().toString();""!=c&&b.test(c)&&this.rangeIsSelectable()&&(a=this.getMarkerCoords(this.marker,a),this.marker.style.top=a.y+"px",this.marker.style.left=a.x+"px",x(this.marker,"show"))},deleteSelections:function(a){for(var b=a.length;b--;){var c=a[b],d=n(this.selectable,c),e=z(d[d.length-1],"closewrap");e.parentNode.removeChild(e);this.removeTextSelection(d);delete this.ranges[c]}},removeTextSelection:function(a){for(var b= a.length;b--;){for(var c=a[b],d=0;d<c.childNodes.length;d++)c.parentNode.insertBefore(c.childNodes[d],c);c.parentNode.removeChild(c)}},isInternal:function(a){for(;a.parentNode;){if(a==this.selectable)return!0;a=a.parentNode}return!1},_siblingNode:function(a,b,c,d,e){for(e=e||this.regexp;a.parentNode&&this.isInternal(a);){for(;a[b+"Sibling"];){for(a=a[b+"Sibling"];1==a.nodeType&&a.childNodes.length;)a=a[c+"Child"];if(3==a.nodeType&&null!=a.data.match(e))return{_container:a,_offset:d*a.data.length}}a= a.parentNode}return null},prevNode:function(a,b){return this._siblingNode(a,"previous","last",1,b)},nextNode:function(a,b){return this._siblingNode(a,"next","first",0,b)},wordCount:function(a){var b=0;if(3==a.nodeType)(a=a.nodeValue.match(this.regexp))&&(b+=a.length);else if(a.childNodes&&a.childNodes.length){a=v(a);for(i=a.length;i--;)b+=a[i].nodeValue.match(this.regexp).length}return b},words:function(a,b,c){1==a.nodeType&&(a=A(a));b=a.data.substring(0,b).match(this.regexp);null!=b?("start"==c&& (b=b.length+1),"end"==c&&(b=b.length)):b=1;c=a;a=this.getNum(a);for(var d=this.getFirstTextNode(a);c&&c!=d;)c=this.prevNode(c,/.*/)._container,b+=this.wordCount(c);return a+":"+b},symbols:function(a){var b=0;if(3==a.nodeType)b=a.nodeValue.length;else if(a.childNodes&&a.childNodes.length){a=v(a);for(var c=a.length;c--;)b+=a[c].nodeValue.length}return b},updateHash:function(){var a=[];for(key in this.ranges)a.push(this.ranges[key]);this.lastHash=a="#sel="+a.join(";");this.options.location.setHash(a)}, readHash:function(){var a=this.splittedHash();if(a){for(var b=0;b<a.length;b++)this.deserializeSelection(a[b]);this.updateHash();this.options.onHashRead&&this.options.onHashRead.call(this)}},splittedHash:function(){var a=this.options.location.getHash();if(!a)return null;a=a.replace(/^#/,"").replace(/;+$/,"");if(!/^sel\=(?:\d+\:\d+(?:\:[^:;]*)?\,|%2C\d+\:\d+(?:\:[^:;]*)?;)*\d+\:\d+(?:\:[^:;]*)?\,|%2C\d+\:\d+(?:\:[^:;]*)?$/.test(a))return null;a=a.substring(4,a.length);return a.split(";")},deserializeSelection:function(a){var b= window.getSelection();0<b.rangeCount&&b.removeAllRanges();(a=this.deserializeRange(a))&&this.addSelection(a)},deserializeRange:function(a){var b=/^([0-9A-Za-z:]+)(?:,|%2C)([0-9A-Za-z:]+)$/.exec(a),c=b[1].split(":"),b=b[2].split(":");if(parseInt(c[0],10)<parseInt(b[0],10)||c[0]==b[0]&&parseInt(c[1],10)<=parseInt(b[1],10)){var d=this.deserializePosition(c,"start"),e=this.deserializePosition(b,"end");if(d.node&&e.node){var f=document.createRange();f.setStart(d.node,d.offset);f.setEnd(e.node,e.offset); if(!this.options.validate||this.validateRange(f,c[2],b[2]))return f}}window.console&&"function"==typeof window.console.warn&&window.console.warn("Cannot deserialize range: "+a);return null},validateRange:function(a,b,c){var d=!0,e;b&&(e=this.getPositionChecksum(a.getWordIterator(this.regexp)),d=d&&b==e);c&&(e=this.getPositionChecksum(a.getWordIterator(this.regexp,!0)),d=d&&c==e);return d},getRangeChecksum:function(a){sum1=this.getPositionChecksum(a.getWordIterator(this.regexp));sum2=this.getPositionChecksum(a.getWordIterator(this.regexp, !0));return[sum1,sum2]},deserializePosition:function(a,b){for(var c=this.blocks[parseInt(a[0],10)],d,e=0;c;){for(var f=RegExp(this.options.regexp,"ig");null!=(myArray=f.exec(c.data));)if(e++,e==a[1])return"start"==b&&(d=myArray.index),"end"==b&&(d=f.lastIndex),{node:c,offset:parseInt(d,10)};(c=(c=this.nextNode(c,/.*/))?c._container:null)&&this.isFirstTextNode(c)&&(c=null)}return{node:null,offset:0}},serializeRange:function(a){var b=this.words(a.startContainer,a.startOffset,"start"),c=this.words(a.endContainer, a.endOffset,"end");this.options.validate&&(a=this.getRangeChecksum(a),b+=":"+a[0],c+=":"+a[1]);return b+","+c},checkSelection:function(a){this.checkPosition(a,a.startOffset,a.startContainer,"start");this.checkPosition(a,a.endOffset,a.endContainer,"end");this.checkBrackets(a);this.checkSentence(a);return a},checkPosition:function(a,b,c,d){function e(a){return null!=a.match(j.regexp)}function f(a){return null==a.match(j.regexp)}function k(a,b,c){for(;0<b&&c(a.data.charAt(b-1));)b--;return b}function h(a, b,c){for(;b<a.data.length&&c(a.data.charAt(b));)b++;return b}var j=this;if(1==c.nodeType&&0<b)if(b<c.childNodes.length)c=c.childNodes[b],b=0;else{var g=v(c);g.length&&(c=g[g.length-1],b=c.data.length)}if("start"==d){if(1==c.nodeType&&""!=u(c.textContent||c.innerText))c=A(c),b=0;if(3!=c.nodeType||null==c.data.substring(b).match(this.regexp))b=this.nextNode(c),c=b._container,b=b._offset;b=h(c,b,f);b=k(c,b,e);a.setStart(c,b)}if("end"==d){if(1==c.nodeType&&""!=u(c.textContent||c.innerText)&&0!=b)c=c.childNodes[a.endOffset- 1],g=v(c),c=g[g.length-1],b=c.data.length;if(3!=c.nodeType||null==c.data.substring(0,b).match(this.regexp))b=this.prevNode(c),c=b._container,b=b._offset;b=k(c,b,f);b=h(c,b,e);a.setEnd(c,b)}},checkBrackets:function(a){this._checkBrackets(a,"(",")",/\(|\)/g,/\(x*\)/g);this._checkBrackets(a,"\u00ab","\u00bb",/\\u00ab|\\u00bb/g,/\u00abx*\u00bb/g)},_checkBrackets:function(a,b,c,d,e){var f=a.toString();if(d=f.match(d)){d=d.join("");for(var k=d.length+1;d.length<k;)k=d.length,d=d.replace(e,"x");d.charAt(d.length- 1)==c&&f.charAt(f.length-1)==c&&(1==a.endOffset?(c=this.prevNode(a.endContainer),a.setEnd(c.container,c.offset)):a.setEnd(a.endContainer,a.endOffset-1));d.charAt(0)==b&&f.charAt(0)==b&&(a.startOffset==a.startContainer.data.length?(c=this.nextNode(a.endContainer),a.setStart(c.container,c.offset)):a.setStart(a.startContainer,a.startOffset+1))}},checkSentence:function(a){function b(){a.setEnd(c._container,c._offset+1)}var c,d;if(a.endOffset==a.endContainer.data.length){c=this.nextNode(a.endContainer, /.*/);if(!c)return null;d=c._container.data.charAt(0)}else c={_container:a.endContainer,_offset:a.endOffset},d=a.endContainer.data.charAt(a.endOffset);if(d.match(/\.|\?|\!/)){d=a.toString();if(d.match(/(\.|\?|\!)\s+[A-Z\u0410-\u042f\u0401]/)||0==a.startOffset&&a.startContainer.previousSibling&&1==a.startContainer.previousSibling.nodeType&&g(a.startContainer.previousSibling,"masha_index"))return b();for(var e,f=a.getElementIterator();e=f();)if(1==e.nodeType&&g(e,"masha_index"))return b();return d.charAt(0).match(/[A-Z\u0410-\u042f\u0401]/)&& (d=a.startContainer.data.substring(0,a.startOffset),d.match(/\S/)||(d=this.prevNode(a.startContainer,/\W*/)._container.data),d=u(d),d.charAt(d.length-1).match(/(\.|\?|\!)/))?b():null}},mergeSelections:function(a){var b=[],c=a.getElementIterator(),d=c(),e=d,f=w(d,"user_selection_true");f&&(f=/(num\d+)(?:$| )/.exec(f.className)[1],a.setStart(A(z(this.selectable,f)),0),b.push(f));for(;d;)1==d.nodeType&&g(d,"user_selection_true")&&(e=/(num\d+)(?:$|)/.exec(d.className)[0],-1==E(e,b)&&b.push(e)),e=d,d= c();if(e=w(e,"user_selection_true"))e=/(num\d+)(?:$| )/.exec(e.className)[1],c=(c=n(this.selectable,e))?c[c.length-1]:null,c=v(c),c=c[c.length-1],a.setEnd(c,c.length);b.length&&(c=a.startContainer,d=a.startOffset,e=a.endContainer,f=a.endOffset,this.deleteSelections(b),a.setStart(c,d),a.setEnd(e,f));return a},addSelection:function(a){a=a||this.getFirstRange();a=this.checkSelection(a);a=this.mergeSelections(a);var b="num"+this.counter;this.ranges[b]=this.serializeRange(a);a.wrapSelection(b+" user_selection_true"); this.addSelectionEvents(b)},addSelectionEvents:function(a){for(var b=!1,c=this,d=n(this.selectable,a),e=d.length;e--;)l(d[e],"mouseover",function(){for(var a=d.length;a--;)x(d[a],"hover");window.clearTimeout(b)}),l(d[e],"mouseout",function(a){for(a=a.relatedTarget;a&&a.parentNode&&a.className!=this.className;)a=a.parentNode;if(!a||a.className!=this.className)b=window.setTimeout(function(){for(var a=d.length;a--;)s(d[a],"hover")},2E3)});e=document.createElement("a");e.className="txtsel_close";e.href= "#";var f=document.createElement("span");f.className="closewrap";f.appendChild(e);l(e,"click",function(b){C(b);c.deleteSelections([a]);c.updateHash();c.options.onUnmark&&c.options.onUnmark.call(c)});d[d.length-1].appendChild(f);this.counter++;window.getSelection().removeAllRanges()},getFirstRange:function(){var a=window.getSelection();return a.rangeCount?a.getRangeAt(0):null},enumerateElements:function(){function a(b){b=b.childNodes;for(var e=!1,f=!1,k=0;k<b.length;++k){var h=b.item(k),g=h.nodeType; if(3!=g||h.nodeValue.match(c.regexp))3==g?f||(c.captureCount++,e=document.createElement("span"),e.className="masha_index masha_index"+c.captureCount,e.setAttribute("rel",c.captureCount),h.parentNode.insertBefore(e,h),k++,c.blocks[c.captureCount]=h,e=f=!0):1==g&&!c.isIgnored(h)&&(c.options.isBlock(h)?(h=a(h),e=e||h,f=!1):f||(f=a(h),e=e||f))}return e}var b=this.selectable;this.captureCount=this.captureCount||0;var c=this;a(b)},isFirstTextNode:function(a){a=[a.previousSibling,a.parentNode.previousSibling]; for(var b=a.length;b--;)if(a[b]&&1==a[b].nodeType&&"masha_index"==a[b].className)return!0;return!1},getFirstTextNode:function(a){return!a?null:(a=n(this.selectable,"masha_index"+a)[0])?1==a.nextSibling.nodeType?a.nextSibling.childNodes[0]:a.nextSibling:null},getNum:function(a){for(;a.parentNode;){for(;a.previousSibling;){for(a=a.previousSibling;1==a.nodeType&&a.childNodes.length;)a=a.lastChild;if(1==a.nodeType&&g(a,"masha_index"))return a.getAttribute("rel")}a=a.parentNode}return null},constructIgnored:function(a){if("function"== typeof a)return a;if("string"==typeof a){var b=[],c=[],d=[];a=a.split(",");for(var e=0;e<a.length;e++){var f=u(a[e]);"#"==f.charAt(0)?b.push(f.substr(1)):"."==f.charAt(0)?c.push(f.substr(1)):d.push(f)}return function(a){var e;for(e=b.length;e--;)if(a.id==b[e])return!0;for(e=c.length;e--;)if(g(a,c[e]))return!0;for(e=d.length;e--;)if(a.tagName==d[e].toUpperCase())return!0;return!1}}return function(){return!1}},rangeIsSelectable:function(){var a,b,c,d=!0,e=this.getFirstRange();if(!e)return!1;for(e=e.getElementIterator();a= e();)if(3==a.nodeType&&null!=a.data.match(this.regexp)&&(b=b||a,c=a),a=d&&3==a.nodeType?a.parentNode:a,d=!1,1==a.nodeType){for(;a!=this.selectable&&a.parentNode;){if(this.isIgnored(a))return!1;a=a.parentNode}if(a!=this.selectable)return!1}b=w(b,"user_selection_true");c=w(c,"user_selection_true");return b&&c?(d=/(?:^| )(num\d+)(?:$| )/,d.exec(b.className)[1]!=d.exec(c.className)[1]):!0},initMessage:function(){this.msg="string"==typeof this.options.selectMessage?document.getElementById(this.options.selectMessage): this.options.selectMessage;this.close_button=this.getCloseButton();this.msg_autoclose=null;this.closeMessage=p(this.closeMessage,this);l(this.close_button,"click",this.closeMessage)},closeMessage:function(a){C(a);this.hideMessage();this.saveMessageClosed();clearTimeout(this_.msg_autoclose)},showMessage:function(){x(this.msg,"show")},hideMessage:function(){s(this.msg,"show")},getCloseButton:function(){return this.msg.getElementsByTagName("a")[0]},getMessageClosed:function(){return window.localStorage? !!localStorage.masha_warning:!!document.cookie.match(/(?:^|;)\s*masha-warning=/)},saveMessageClosed:function(){window.localStorage?localStorage.masha_warning="true":this.getMessageClosed()||(document.cookie+="; masha-warning=true")},_showMessage:function(){var a=this;this.getMessageClosed()||(this.showMessage(),clearTimeout(this.msg_autoclose),this.msg_autoclose=setTimeout(function(){a.hideMessage()},1E4))}};j=window.Range||document.createRange().constructor;j.prototype.splitBoundaries=function(){var a= this.startContainer,b=this.startOffset,c=this.endContainer,d=this.endOffset,e=a===c;3==c.nodeType&&d<c.length&&c.splitText(d);3==a.nodeType&&0<b&&(a=a.splitText(b),e&&(d-=b,c=a),b=0);this.setStart(a,b);this.setEnd(c,d)};j.prototype.getTextNodes=function(){for(var a=this.getElementIterator(),b=[],c;c=a();)3==c.nodeType&&b.push(c);return b};j.prototype.getElementIterator=function(a){return a?r(null,this.endContainer,this.startContainer,!0):r(null,this.startContainer,this.endContainer)};j.prototype.getWordIterator= function(a,b){var c=this.getElementIterator(b),d,e=0,f=0,g=!1,h,j=this;return function(){if(e==f&&!g){do{do d=c();while(d&&3!=d.nodeType);g=!d;g||(value=d.nodeValue,d==j.endContainer&&(value=value.substr(0,j.endOffset)),d==j.startContainer&&(value=value.substr(j.startOffset)),h=value.match(a))}while(d&&!h);h&&(e=b?0:h.length-1,f=b?h.length-1:0)}else b?f--:f++;return g?null:h[f]}};j.prototype.wrapSelection=function(a){this.splitBoundaries();for(var b=this.getTextNodes(),c=b.length;c--;){var d=document.createElement("span"); d.className=a;b[c].parentNode.insertBefore(d,b[c]);d.appendChild(b[c])}};var F=function(a){this.prefix=a};F.prototype={setHash:function(a){a=a.replace("sel",this.prefix).replace(/^#/,"");a.length==this.prefix.length+1&&(a="");var b=this.getHashPart();window.location.hash.replace(/^#\|?/,"");a=b?window.location.hash.replace(b,a):window.location.hash+"|"+a;a="#"+a.replace("||","").replace(/^#?\|?|\|$/g,"");window.location.hash=a},addHashchange:m.LocationHandler.prototype.addHashchange,getHashPart:function(){for(var a= window.location.hash.replace(/^#\|?/,"").split(/\||%7C/),b=0;b<a.length;b++)if(a[b].substr(0,this.prefix.length+1)==this.prefix+"=")return a[b];return""},getHash:function(){return this.getHashPart().replace(this.prefix,"sel")}};window.MaSha=m;window.jQuery&&(window.jQuery.fn.masha=function(a){a=a||{};a=t({selectable:this[0]},a);return new m(a)});window.MultiMaSha=function(a,b,c){b=b||function(a){return a.id};for(var d=0;d<a.length;d++){var e=a[d],f=b(e);f&&(e=t({},c||{},{selectable:e,location:new F(f)}), new m(e))}};j=m.$M={};j.extend=t;j.byClassName=n;j.addClass=x;j.removeClass=s;j.addEvent=l;j.removeEvent=q;var D=Function.prototype.bind,y=Array.prototype.slice,p=function(a,b){var c,d;if(a.bind===D&&D)return D.apply(a,y.call(arguments,1));c=y.call(arguments,2);return d=function(){if(!(this instanceof d))return a.apply(b,c.concat(y.call(arguments)));ctor.prototype=a.prototype;var e=new ctor;ctor.prototype=null;var f=a.apply(e,c.concat(y.call(arguments)));return Object(f)===f?f:e}}})(); /* Добавление комплектации в 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><div id="popupImageWrapper">'+ '<img id="popupImage" src="" /><div id="popupImageInfo"></div></div>'+ '</td></tr></table></div>'+ '<div id="popupImageButtons"><a id="openImageFile" href="#">Файл</a></div>'); } /* добавляет функционал просмотра увеличенных изображений без перехода на другую страницу */ function addImagePopups() { if(localStorage.oImagePopupOn==0) return true; // для дебага addImagePopupWindow(); $('a.image').click(function(index) { $('#popupImage').attr('src',''); var srcStr = $(this).children('img').attr('src'); //Адрес картинки if(srcStr.indexOf('thumb')+1>0) { srcStr = srcStr.replace(/thumb\//gi, ''); srcStr = srcStr.substring(0, srcStr.lastIndexOf("/")); } $('#popupImageWindow table').css('background-image', 'url('+imageLoaderUrl+')'); $('#popupImage').width('1px'); $('#popupImage').height('1px'); $('#popupImage').attr('src',srcStr); $('#popupImageButtons a#openImageFile').attr('href', $(this).attr('href')); 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();} //слабоумие и отвага if(titleStr.trim().length > 0) {$('#popupImageInfo').text(titleStr.trim());} else {$('#popupImageInfo').text('');} $('#popupImageWrapper').hide(); $('#popupImageWindow').show(); $('#popupImageButtons').show(); return false; }); // При загрузке картинки $('#popupImage').load(function() { $('#popupImage').width(''); $('#popupImage').height(''); $(this).css('max-width', (self.innerWidth-100)+'px'); $(this).css('max-height',(self.innerHeight-100)+'px'); $('#popupImageWindow table').css('background-image', ''); $('#popupImageWrapper').show(); if($('#popupImageInfo').text().trim().length > 0) {$('#popupImageInfo').show();} else {$('#popupImageInfo').hide();} }); //Закрыть попап $('#popupImageWindow').click(function(index) { $(this).hide(); $('#popupImageButtons').hide(); $('#popupImageButtons a').attr('href', '#'); $('#popupImageInfo').text('');$('#popupImage').attr('src',''); }); }; /* Дерево модулей */ function modulesBlock() { var currentModulesBlock = 1; var modulesShowTxt = []; modulesShowTxt[-1] = 'показать список'; modulesShowTxt[1] = 'показать дерево'; var modulesBlock = []; modulesBlock[-1] = false; modulesBlock[1] = $('#modulesBlock').html(); var vehicle = $('#modulesBlock').attr("class"); $('#modulesBlock').attr("class", ""); $('#modulesBlockH2').html($('#modulesBlockH2').html() + ' <small>[<a id="modulesBlockChange" href="#">' + modulesShowTxt[currentModulesBlock] + '</a>]</small>'); $('#modulesBlockChange').click(function(){ currentModulesBlock = -1 * currentModulesBlock; 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]); $(this).text(modulesShowTxt[currentModulesBlock]); return false; }); $('.treeFrame').each(function(indx){ $(this).html('<iframe frameborder="0" style="border-width: 0; width: 100%; min-width: 1010px; height: 695px;" 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 () { 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('↑ Подробнее');}, function() {$(this).prev().prev().hide();$(this).text('↓ Подробнее');} ); } /* Прозвища 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>'+ ''); $.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>'+ ' <input type="checkbox" id="o_improvedEditPanelDownKey" name="o_improvedEditPanelDownKey" /><label for="o_improvedEditPanelDownKey"> Кнопки управления внизу</label><br>'+ ' <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');} } /* Конфиг */ var imageLoaderUrl = '/uploads/4/42/Loading.gif'; var isRotate = false; function addRotatorPopupWindow() { $('body').append('<div id="popupRotatorWindow"><table><tr><td><div id="popupRotatorWrapper">'+ '<div id="rotatorTarget"></div><img src="/uploads/b/bd/Close.png" class="closeBtn"></div>'+ '</td></tr></table></div>' ); } /* ready */ $(document).ready( function(){ modulesBlock(); setDefaultjsOptions(); switcher(); setTimeout(addImagePopups,0); setTimeout(hideNoDataInfoInTankPerformance,0); setTimeout(getAlias,0); /* 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 + '" />'}); $('#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); // MaSha.instance = new MaSha({'selectable': 'bodyContent', 'validate': true}); //---- 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; }); }); });