|
|
Строка 1: |
Строка 1: |
− | /* Код открытия внешних ссылок в новой вкладке */
| |
− | function externalLinks() {
| |
− | var links = document.getElementsByTagName('a');
| |
− | for (var i = 0; i < links.length; i++) {
| |
− | var a = new RegExp('/' + window.location.host + '/');
| |
− | if( !a.test(links[i].href) && links[i].href != '' ) {
| |
− | links[i].target = '_blank';
| |
− | }
| |
− | }
| |
− | }
| |
| | | |
− | function addSymbols() {
| |
− | if( $( '#wpTextbox1' )[0] ) {
| |
− | setTimeout(function(){
| |
− | $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
| |
− | 'section': 'characters',
| |
− | 'page': 'symbols',
| |
− | 'characters': [ '▀', '▂', '▅', '▃', '▄', '␠', '', '⋠', '␗' ]
| |
− | });
| |
− | }, 500);
| |
− | }
| |
− | }
| |
− |
| |
− | /* Код получения cookie */
| |
− | function getCookie(name) {
| |
− | var matches = document.cookie.match(new RegExp(
| |
− | "(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)"
| |
− | ));
| |
− | return matches ? decodeURIComponent(matches[1]) : undefined;
| |
− | }
| |
− |
| |
− | function ttxZebra() {
| |
− | $('.ttx-table-line:nth-child(odd)').css('background-color', 'inherit');
| |
− |
| |
− | count = 0;
| |
− |
| |
− | $('.ttx-table-line').each(function(){
| |
− | if (!($(this).hasClass("ttx-collapsed"))){
| |
− | if (count % 2 == 0) {
| |
− | $(this).css('background-color','#DBE0E2');
| |
− | } else {
| |
− | $(this).css('background-color','inherit');
| |
− | }
| |
− | count++;
| |
− | }
| |
− | });
| |
− | }
| |
− |
| |
− | /* Код веток техники */
| |
− | function treeGroup() {
| |
− | document.querySelectorAll('.tree-group-collapse').forEach( function(item, i, arr) {
| |
− | item.style = 'position: absolute; max-height: 0;';
| |
− | });
| |
− | var hideAll = function() {
| |
− | document.querySelectorAll('.tree-group-collapse.open').forEach( function(item, i, arr) {
| |
− | item.classList.remove('open');
| |
− | });
| |
− | }
| |
− | document.querySelectorAll('.tree-group').forEach( function(item, i, arr) {
| |
− | item.onclick = function( e ) {
| |
− | hideAll();
| |
− | e.target.previousElementSibling.classList.add('open');
| |
− | e.stopPropagation();
| |
− | }
| |
− | });
| |
− | document.getElementsByTagName('body')[0].addEventListener('click', function( e ) {
| |
− | if (event.target.className != 'tree-item-js')
| |
− | hideAll();
| |
− | });
| |
− | }
| |
− |
| |
− | function gun_go() {
| |
− | var kfbr = 1900;
| |
− | var caliber = Number( document.getElementById('gun_caliber').value );
| |
− | var mass = Number( document.getElementById('gun_mass').value );
| |
− | var speed = Number( document.getElementById('gun_speed').value );
| |
− | var tnt = Number( document.getElementById('gun_tnt').value );
| |
− | var apcbc = document.getElementById('gun_APCBC').checked;
| |
− |
| |
− | tnt = ( tnt / mass ) * 100;
| |
− |
| |
− | var kf_apcbc = ( apcbc ) ? 1 : 0.9;
| |
− |
| |
− | if ( tnt < 0.65 ) {
| |
− | knap = 1;
| |
− | } else if ( tnt < 1.6 ) {
| |
− | knap = 1 + ( tnt - 0.65 ) * ( 0.93 - 1 ) / ( 1.6 - 0.65 );
| |
− | } else if ( tnt < 2 ) {
| |
− | knap = 0.93 + ( tnt - 1.6 ) * ( 0.9 - 0.93 ) / ( 2 - 1.6 );
| |
− | } else if ( tnt < 3 ) {
| |
− | knap = 0.9 + ( tnt - 2 ) * ( 0.85 - 0.9 ) / ( 3 - 2 );
| |
− | } else if ( tnt < 4 ) {
| |
− | knap = 0.85 + ( tnt - 3 ) * ( 0.75 - 0.85 ) / ( 4 - 3 );
| |
− | } else {
| |
− | knap = 0.75;
| |
− | }
| |
− |
| |
− | document.getElementById('gun_rezult').value = ( ( ( Math.pow( speed , 1.43 ) * Math.pow( mass , 0.71 ) ) / ( Math.pow( kfbr , 1.43 ) * Math.pow( caliber / 100 , 1.07 ) ) ) * 100 * knap * kf_apcbc ).toFixed(2);
| |
− | }
| |
− |
| |
− | function gunHtml() {
| |
− | if(document.getElementById('gun_test')){document.getElementById('gun_test').innerHTML = '<table cellpadding="5" style="border: 1px solid #a2a9b1;margin: 5px;width: 520px;"><tr><td style="width: 180px;">Калибр (мм):</td><td><input id="gun_caliber" type="number" style="width: 100px; height: 30px;" value="57"></td><td style="text-align: center;">Пробитие (мм):</td></tr><tr><td>Масса (кг):</td><td><input id="gun_mass" type="number" style="width: 100px; height: 30px;" value="3.14"></td><td rowspan="3"><input id="gun_rezult" type="text" style="width: 200px;height: 90px;border: 0;background: #f6f6f6;text-align: center;font-size: 40px;" disabled></td></tr><tr><td>Скорость (м/с):</td><td><input id="gun_speed" type="number" style="width: 100px; height: 30px;" value="990"></td></tr><tr><td>Масса ВВ (кг):</td><td><input id="gun_tnt" type="number" style="width: 100px; height: 30px;" value="0.1"></td></tr><tr><td><span title="Остроголовый снаряд с бронебойным наконечником и баллистическим колпачком" style="border-bottom: 1px dotted; cursor: help; white-space: nowrap">APCBC</span>:</td><td><input id="gun_APCBC" type="checkbox"></td><td><input id="gun_but" class="ttx-buy-button" type="button" value="РАССЧИТАТЬ" onclick="gun_go();" style="width: 200px; height: 30px;border:0;" value=""></td></tr></table>';}
| |
− | }
| |
− |
| |
− | function gun2_go() {
| |
− | var caliber = Number( document.getElementById('gun2_caliber').value );
| |
− | var shell_mass = Number( document.getElementById('gun2_shell_mass').value );
| |
− | var core_mass = Number( document.getElementById('gun2_core_mass').value );
| |
− | var speed = Number( document.getElementById('gun2_speed').value );
| |
− |
| |
− | var pallet_mass = shell_mass - core_mass;
| |
− | var kfbr = 3000;
| |
− | var part_pallet_mass = ( core_mass / shell_mass ) * 100;
| |
− | var kf_pallet_mass = ( part_pallet_mass > 36.0 ) ? 0.5 : 0.4;
| |
− | var calculated_mass = core_mass + ( kf_pallet_mass * pallet_mass );
| |
− |
| |
− |
| |
− | document.getElementById('gun2_rezult').value = ( ( Math.pow( speed , 1.43 ) * Math.pow( calculated_mass , 0.71 ) ) / ( Math.pow( kfbr , 1.43 ) * Math.pow( caliber / 10000 , 1.07 ) ) ).toFixed(2);
| |
− | }
| |
− |
| |
− | function gun2Html() {
| |
− | if(document.getElementById('gun2_test')){document.getElementById('gun2_test').innerHTML = '<table cellpadding="5" style="border: 1px solid #a2a9b1;margin: 5px;width: 520px;"><tr><td>Калибр сердечника (мм):</td><td><input id="gun2_caliber" type="number" style="width: 100px; height: 30px;" value="28"></td><td style="text-align: center;">Пробитие (мм):</td></tr><tr><td>Масса снаряда (кг):</td><td><input id="gun2_shell_mass" type="number" style="width: 100px; height: 30px;" value="4.15"></td><td rowspan="2"><input id="gun2_rezult" type="text" style="width: 200px;height: 90px;border: 0;background: #f6f6f6;text-align: center;font-size: 40px;" disabled></td></tr><tr><td>Масса сердечника (кг):</td><td><input id="gun2_core_mass" type="number" style="width: 100px; height: 30px;" value="1.1"></td></tr><tr><td>Скорость (м/с):</td><td><input id="gun2_speed" type="number" style="width: 100px; height: 30px;" value="930"></td><td><input id="gun2_but" class="ttx-buy-button" type="button" value="РАССЧИТАТЬ" onclick="gun2_go();" style="width: 200px; height: 30px;border:0;" value=""></td></tr></table>';}
| |
− | }
| |
− |
| |
− | function gunHtmlEn() {
| |
− | if(document.getElementById('gun_test_en')){document.getElementById('gun_test_en').innerHTML = '<table cellpadding="5" style="border: 1px solid #a2a9b1;margin: 5px;width: 520px;"><tr><td style="width: 180px;">Calibre (mm):</td><td><input id="gun_caliber" type="number" style="width: 100px; height: 30px;" value="57"></td><td style="text-align: center;">Armour piercing (mm):</td></tr><tr><td>Weight (kg):</td><td><input id="gun_mass" type="number" style="width: 100px; height: 30px;" value="3.14"></td><td rowspan="3"><input id="gun_rezult" type="text" style="width: 200px;height: 90px;border: 0;background: #f6f6f6;text-align: center;font-size: 40px;" disabled></td></tr><tr><td>Speed (m/s):</td><td><input id="gun_speed" type="number" style="width: 100px; height: 30px;" value="990"></td></tr><tr><td>Weight of explosive mass (kg):</td><td><input id="gun_tnt" type="number" style="width: 100px; height: 30px;" value="0.1"></td></tr><tr><td>APCBC:</td><td><input id="gun_APCBC" type="checkbox"></td><td><input id="gun_but" class="ttx-buy-button" type="button" value="CALCULATE" onclick="gun_go();" style="width: 200px; height: 30px;border:0;" value=""></td></tr></table>';}
| |
− | }
| |
− |
| |
− | function gun2HtmlEn() {
| |
− | if(document.getElementById('gun2_test_en')){document.getElementById('gun2_test_en').innerHTML = '<table cellpadding="5" style="border: 1px solid #a2a9b1;margin: 5px;width: 520px;"><tr><td style="width: 180px;">Core Calibre (mm):</td><td><input id="gun2_caliber" type="number" style="width: 100px; height: 30px;" value="28"></td><td style="text-align: center;">Armour piercing (mm):</td></tr><tr><td>Shell mass (kg):</td><td><input id="gun2_shell_mass" type="number" style="width: 100px; height: 30px;" value="4.15"></td><td rowspan="2"><input id="gun2_rezult" type="text" style="width: 200px;height: 90px;border: 0;background: #f6f6f6;text-align: center;font-size: 40px;" disabled></td></tr><tr><td>Core weight (kg):</td><td><input id="gun2_core_mass" type="number" style="width: 100px; height: 30px;" value="1.1"></td></tr><tr><td>Speed (m/s):</td><td><input id="gun2_speed" type="number" style="width: 100px; height: 30px;" value="930"></td><td><input id="gun2_but" class="ttx-buy-button" type="button" value="CALCULATE" onclick="gun2_go();" style="width: 200px; height: 30px;border:0;" value=""></td></tr></table>';}
| |
− | }
| |
− |
| |
− | /* Код галереи камуфляжей */
| |
− | function skinGallery() {
| |
− | var el = document.querySelectorAll(".skin_gallery .skin");
| |
− | for (var i = 0; i < el.length; i++) {
| |
− | var type = '';
| |
− | switch ( el[i].getAttribute('data-type') ) {
| |
− | case 'live':
| |
− | type = 'SKIN_LIVE';
| |
− | break;
| |
− | case 'market':
| |
− | type = 'SKIN_MARKET';
| |
− | break;
| |
− | default:
| |
− | continue;
| |
− | }
| |
− | var link = el[i].getAttribute('data-link');
| |
− | el[i].querySelector('.skin_img').setAttribute('onclick', "if(typeof yaCounter48855122 != 'undefined'){yaCounter48855122.reachGoal('" + type + "',{URL:document.location.href});}window.open('" + link + "');return true;");
| |
− | }
| |
− | }
| |
− |
| |
− | function specsSlider() {
| |
− | if( document.querySelector( '.specs_card_main_slider' ) ) {
| |
− | var node = document.querySelector( '.specs_card_main_slider_container' );
| |
− |
| |
− | var imgArr = document.querySelectorAll( '.specs_card_main_slider_system div' );
| |
− |
| |
− | if ( imgArr.length < 1 ) {
| |
− | return;
| |
− | }
| |
− |
| |
− | var labels_container = document.createElement('div');
| |
− | labels_container.className = 'labels_container';
| |
− |
| |
− | var labels = document.createElement('div');
| |
− | labels.className = 'labels';
| |
− |
| |
− | var functionSelect = function(e) {
| |
− | document.querySelector('.specs_card_main_slider .labels label.checked').classList.remove('checked');
| |
− | var checked_id = document.querySelector('.specs_card_main_slider_container input:checked').id;
| |
− | document.querySelector('.specs_card_main_slider label[for=' + checked_id + ']').classList.add('checked');
| |
− | };
| |
− |
| |
− | var addLinkImg = function( elem, node, labelList, index ) {
| |
− | var input = document.createElement('input');
| |
− | input.type = 'radio';
| |
− | input.name = 'slider';
| |
− | input.id = 'slider_input_' + String(index);
| |
− | input.onchange = functionSelect;
| |
− |
| |
− | var img = document.createElement('div');
| |
− | img.className = 'slide';
| |
− | img.appendChild( elem );
| |
− |
| |
− | var label = document.createElement('label');
| |
− | label.htmlFor = 'slider_input_' + String(index);
| |
− | label.id = 'label_' + String(index);
| |
− | if ( labelList.childElementCount === 0 ) {
| |
− | label.className = 'checked';
| |
− | input.checked = true;
| |
− | input.autofocus = true;
| |
− | } else if ( labelList.childElementCount === 1 ) {
| |
− | label.className = 'checked';
| |
− | input.checked = true;
| |
− | input.autofocus = true;
| |
− | labelList.querySelector('#label_0').className = '';
| |
− | }
| |
− |
| |
− |
| |
− | node.appendChild(input);
| |
− | node.appendChild(img);
| |
− |
| |
− | labelList.appendChild(label);
| |
− | };
| |
− |
| |
− | var addImg = function( lnk, node, labelList, index ) {
| |
− | var input = document.createElement('input');
| |
− | input.type = 'radio';
| |
− | input.name = 'slider';
| |
− | input.id = 'slider_input_' + String(index);
| |
− | input.onchange = functionSelect;
| |
− |
| |
− | var img = document.createElement('div');
| |
− | img.style.backgroundImage = 'url(' + String(lnk) + ')';
| |
− | img.className = 'slide';
| |
− |
| |
− | var label = document.createElement('label');
| |
− | label.htmlFor = 'slider_input_' + String(index);
| |
− | label.id = 'label_' + String(index);
| |
− | if ( labelList.childElementCount === 0 ) {
| |
− | label.className = 'checked';
| |
− | input.checked = true;
| |
− | input.autofocus = true;
| |
− | } else if ( labelList.childElementCount === 1 ) {
| |
− | label.className = 'checked';
| |
− | input.checked = true;
| |
− | input.autofocus = true;
| |
− | labelList.querySelector('#label_0').className = '';
| |
− | }
| |
− |
| |
− |
| |
− | node.appendChild(input);
| |
− | node.appendChild(img);
| |
− |
| |
− | labelList.appendChild(label);
| |
− | };
| |
− |
| |
− | var add360 = function( lnk, node, labelList, index ) {
| |
− | function onProgress ( e ) {
| |
− | progress = e.progress.loaded / e.progress.total * 100;
| |
− | e.target.container.parentElement.querySelector('.specs_360_loading_progress_line').style.width = progress + '%';
| |
− | if ( progress == 100 ) {
| |
− | e.target.container.parentElement.querySelector('.specs_360_loading').style.opacity = '0';
| |
− | }
| |
− | }
| |
− |
| |
− | jQuery.getScript( '/index.php?title=MediaWiki:Panorama.js&action=raw&ctype=text/javascript' ).done(function( script, textStatus ) {
| |
− | var input = document.createElement('input');
| |
− | input.type = 'radio';
| |
− | input.name = 'slider';
| |
− | input.id = 'slider_input_' + String(index);
| |
− | if ( labelList.childElementCount === 0 ) {
| |
− | input.checked = true;
| |
− | input.autofocus = true;
| |
− | }
| |
− | input.onchange = functionSelect;
| |
− |
| |
− | var div = document.createElement('div');
| |
− | div.className = 'slide';
| |
− |
| |
− | var container360 = document.createElement('div');
| |
− | container360.style.width = '100%';
| |
− | container360.style.height = '100%';
| |
− | container360.id = 'specs_360_container_' + String(index);
| |
− | container360.allowFullscreen = true;
| |
− | container360.frameBorder = '0';
| |
− | container360.setAttribute('mozallowfullscreen', true);
| |
− | container360.setAttribute('webkitallowfullscreen', true);
| |
− | container360.setAttribute('data-link', lnk);
| |
− |
| |
− | container360Loading = document.createElement('div');
| |
− | container360Loading.className = 'specs_360_loading';
| |
− |
| |
− | container360LoadingText = document.createElement('span');
| |
− | container360LoadingText.className = 'specs_360_loading_text ';
| |
− | container360LoadingText.innerHTML = 'ЗАГРУЗКА...';
| |
− |
| |
− | container360LoadingProgress = document.createElement('div');
| |
− | container360LoadingProgress.className = 'specs_360_loading_progress';
| |
− |
| |
− | container360LoadingProgressLine = document.createElement('div');
| |
− | container360LoadingProgressLine.className = 'specs_360_loading_progress_line';
| |
− |
| |
− | container360LoadingProgress.appendChild(container360LoadingProgressLine);
| |
− | container360Loading.appendChild(container360LoadingText);
| |
− | container360Loading.appendChild(container360LoadingProgress);
| |
− |
| |
− | div.appendChild(container360);
| |
− |
| |
− | div.appendChild(container360Loading);
| |
− |
| |
− | var label = document.createElement('label');
| |
− | label.htmlFor = 'slider_input_' + String(index);
| |
− | label.id = 'label_' + String(index);
| |
− | label.className = 'label360';
| |
− | label.onclick = function( e ) {
| |
− | var elem_id = e.target.id.replace('label_', '');
| |
− | var container_360 = document.getElementById('specs_360_container_' + elem_id);
| |
− | if ( container_360.innerHTML != '' ) {
| |
− | return;
| |
− | }
| |
− |
| |
− | if (typeof yaCounter48855122 != 'undefined') {
| |
− | yaCounter48855122.reachGoal('COCKPIT_BUTTON',{URL:document.location.href});
| |
− | }
| |
− |
| |
− | var panorama, viewer;
| |
− | panorama = new PANOLENS.ImagePanorama( container_360.getAttribute('data-link') );
| |
− | panorama.addEventListener( 'progress', onProgress );
| |
− | viewer = new PANOLENS.Viewer({
| |
− | container: container_360
| |
− | });
| |
− | viewer.add( panorama );
| |
− | viewer.tweenControlCenter( new THREE.Vector3(25000.0, 1000, 0), 0 );
| |
− | };
| |
− |
| |
− | node.appendChild(input);
| |
− | node.appendChild(div);
| |
− |
| |
− | labelList.appendChild(label);
| |
− | });
| |
− | }
| |
− |
| |
− | for ( var i = 0; i < imgArr.length; i++ ) {
| |
− | var item = imgArr[i];
| |
− |
| |
− | if (
| |
− | item.childElementCount == 1
| |
− | ) {
| |
− | if ( item.children[0].tagName == 'IMG' ) {
| |
− | addImg( item.children[0].src, node, labels, i );
| |
− | } else if (
| |
− | item.children[0].tagName == 'A' &&
| |
− | item.children[0].childElementCount == 1 &&
| |
− | item.children[0].children[0].tagName == 'IMG'
| |
− | ) {
| |
− | addLinkImg( item.children[0], node, labels, i );
| |
− | }
| |
− | } else {
| |
− | var match = item.innerText.match(/([a-z0-9]*)\:\/\/(.*)\n?/);
| |
− | var protocol = match[1];
| |
− |
| |
− | switch ( protocol ) {
| |
− | case '360':
| |
− | add360( match[2], node, labels, i );
| |
− | break;
| |
− | }
| |
− | }
| |
− | }
| |
− |
| |
− | labels_container.appendChild( labels );
| |
− |
| |
− | node.appendChild( labels_container );
| |
− | document.querySelector( '.specs_card_main_slider_system' ).remove();
| |
− | }
| |
− | }
| |
− |
| |
− | /* Код кнопки "Купить" ТТХ карточек */
| |
− | function specsBuyButton() {
| |
− | var el = document.getElementsByClassName("general_info_buy_button");
| |
− | for (var i = 0; i < el.length; i++){
| |
− | var link = 'https://store.gaijin.net/story.php?id=' + el[i].getAttribute('data-link') + '&partner=Wiki&partner_val=mufby3bs';
| |
− | el[i].setAttribute('onclick', "if(typeof yaCounter48855122 != 'undefined'){yaCounter48855122.reachGoal('BUY_BUTTON',{URL:document.location.href});}window.open('" + link + "');return true;");
| |
− | }
| |
− | }
| |
− |
| |
− | /* Код кнопки "Найти на бирже" ТТХ карточек */
| |
− | function specsMarketButton() {
| |
− | var el = document.getElementsByClassName("general_info_market_button");
| |
− | for (var i = 0; i < el.length; i++){
| |
− | var link = 'https://trade.gaijin.net/?n=' + el[i].getAttribute('data-link') + '&viewitem=&a=1067';
| |
− | el[i].setAttribute('onclick', "if(typeof yaCounter48855122 != 'undefined'){yaCounter48855122.reachGoal('MARKET_BUTTON',{URL:document.location.href});}window.open('" + link + "');return true;");
| |
− | }
| |
− | }
| |
− |
| |
− | function specsOpenInGame() {
| |
− | var logout = document.getElementById('pt-logout');
| |
− | if ( logout == null ) {
| |
− | var login_link = document.querySelector('#pt-login a').href;
| |
− | var popup_html = '<div class="ogp_popup_container"><div class="ogp_popup_center"><div class="ogp_popup"><div class="ogp_close" onclick="closeOgpPopup();"></div><div class="ogp_logo"><a href="https://warthunder.ru" target="_blank"><img src="https://wiki.warthunder.ru/images/9/9d/Ogp_logo.png"></a></div><div class="ogp_block desc"><img src="https://wiki.warthunder.ru/images/9/91/Msg-info.png"><span>Как посмотреть технику в игре:</span></div><div class="ogp_divider"></div><div class="ogp_block user"><div><b>Уже есть аккаунт Gaijin?</b></div><div><ol><li><a href="' + login_link + '">Авторизуйтесь</a> на Wiki</li><li>Войдите с этим же аккаунтом в War Thunder</li></ol></div></div><div class="ogp_divider"></div><div class="ogp_block"><div><b>Нет War Thunder?</b></div><div>Более 1800 танков, самолётов, вертолётов и кораблей ждут в игре!</div><div class="ogp_button">ЗАРЕГИСТРИРОВАТЬСЯ</div></div></div></div></div><div class="ogp_background" onclick="closeOgpPopup();"></div>';
| |
− | var el = document.querySelectorAll('.general_info_game_button');
| |
− | for (var i = 0; i < el.length; i++){
| |
− | el[i].onclick = function(e) {
| |
− | var divc = document.createElement('div');
| |
− | divc.innerHTML = popup_html;
| |
− | document.querySelector('.content-area').appendChild(divc);
| |
− | document.querySelector('.ogp_button').onclick = function() {
| |
− | if (typeof yaCounter48855122 != 'undefined') {
| |
− | yaCounter48855122.reachGoal('OIG_REG',{URL:document.location.href});
| |
− | }
| |
− | window.open('https://warthunder.ru/ru/play4free?r=wiki');
| |
− | }
| |
− | };
| |
− | }
| |
− | } else {
| |
− | var el = document.querySelectorAll('.general_info_game_button');
| |
− | for (var i = 0; i < el.length; i++){
| |
− | el[i].onclick = function(e) {
| |
− | var xhr = new XMLHttpRequest();
| |
− | var unit_id = document.querySelector('.specs_card_main').getAttribute('data-code');
| |
− | if (typeof yaCounter48855122 != 'undefined') {
| |
− | yaCounter48855122.reachGoal('OIG_SHOW',{URL:document.location.href,CODE:unit_id});
| |
− | }
| |
− | xhr.open('GET', '/Special:GameObjectView?object_id=' + unit_id, false);
| |
− | xhr.send();
| |
− |
| |
− | try {
| |
− | var msg_container = document.querySelector('.general_info_message');
| |
− | if (xhr.status != 200) {
| |
− | msg_container.innerText = 'Ошибка (1): Обновите страницу или повторите попытку позже';
| |
− | msg_container.classList.remove('ok');
| |
− | msg_container.classList.add('error');
| |
− | } else {
| |
− | var response = JSON.parse(xhr.responseText);
| |
− | if (response.status == 200) {
| |
− | if ( response.details.status == 'failed' ) {
| |
− | if ( response.details.error == 'SERVER_ERROR_INTERNAL' ) {
| |
− | msg_container.innerText = 'Ошибка (5): Игра не запущена или запущена не под текущим аккаунтом';
| |
− | msg_container.classList.remove('ok');
| |
− | msg_container.classList.add('error');
| |
− | } else {
| |
− | msg_container.innerText = 'Ошибка (8): Обновите страницу или повторите попытку позже';
| |
− | msg_container.classList.remove('ok');
| |
− | msg_container.classList.add('error');
| |
− | }
| |
− | } else if ( response.details.status == 'ERROR' ) {
| |
− | xhr.open('GET', '/api.php?action=logout', false);
| |
− | xhr.send();
| |
− |
| |
− | msg_container.innerText = 'Ошибка (9): Повторите авторизацию на WIKI (нажмите кнопку "Выйти" и зайдите заново)';
| |
− | msg_container.classList.remove('ok');
| |
− | msg_container.classList.add('error');
| |
− | } else if ( response.details.status == 'ok' ) {
| |
− | if ( response.details.reply.result == 'unit_not_found' ) {
| |
− | msg_container.innerText = 'Ошибка (6): Машина не найдена. Обновите страницу или повторите попытку позже';
| |
− | msg_container.classList.remove('ok');
| |
− | msg_container.classList.add('error');
| |
− | } else if ( response.details.reply.result == 'success' ) {
| |
− | msg_container.innerText = 'Просмотр техники открыт в окне игры!';
| |
− | msg_container.classList.remove('error');
| |
− | msg_container.classList.add('ok');
| |
− | } else {
| |
− | msg_container.innerText = 'Ошибка (7): Обновите страницу или повторите попытку позже';
| |
− | msg_container.classList.remove('ok');
| |
− | msg_container.classList.add('error');
| |
− | }
| |
− | } else {
| |
− | msg_container.innerText = 'Ошибка (5): Обновите страницу или повторите попытку позже';
| |
− | msg_container.classList.remove('ok');
| |
− | msg_container.classList.add('error');
| |
− | }
| |
− | } else if (response.status == 403) {
| |
− | msg_container.innerText = 'Ошибка (4): Повторите авторизацию на WIKI (нажмите кнопку "Выйти" и зайдите заново)';
| |
− | msg_container.classList.remove('ok');
| |
− | msg_container.classList.add('error');
| |
− | } else {
| |
− | msg_container.innerText = 'Ошибка (2): Обновите страницу или повторите попытку позже';
| |
− | msg_container.classList.remove('ok');
| |
− | msg_container.classList.add('error');
| |
− | }
| |
− | }
| |
− | } catch (e) {
| |
− | msg_container.innerText = 'Ошибка (3): Обновите страницу или повторите попытку позже';
| |
− | msg_container.classList.remove('ok');
| |
− | msg_container.classList.add('error');
| |
− | }
| |
− | };
| |
− | }
| |
− | }
| |
− | }
| |
− |
| |
− | function closeOgpPopup() {
| |
− | document.querySelector('.ogp_popup_container').remove();
| |
− | document.querySelector('.ogp_background').remove();
| |
− | }
| |
− |
| |
− | function specsOpenSlider() {
| |
− | var sliderList = document.querySelectorAll('.specs_slider');
| |
− |
| |
− | for ( var i = 0; i < sliderList.length; i++ ) {
| |
− | var title_elem = sliderList[i].querySelector('.specs_slider_title');
| |
− | if ( title_elem ) {
| |
− | title_elem.onclick = function( e ) {
| |
− | e.target.parentElement.classList.toggle('open');
| |
− | }
| |
− | }
| |
− | }
| |
− | }
| |
− |
| |
− | function specsShowMod() {
| |
− | var modsList = document.querySelectorAll('.specs_mod:not(.view)');
| |
− | if ( modsList.length == 0 ) {
| |
− | return;
| |
− | }
| |
− |
| |
− | var hideMods = function() {
| |
− | var modsOpenList = document.querySelector('.specs_mod.view');
| |
− | modsOpenList.classList.add('hide');
| |
− | }
| |
− |
| |
− | document.addEventListener('click', function( e ) {
| |
− | if (
| |
− | e.target.classList.contains('specs_mod') ||
| |
− | e.target.parentElement.classList.contains('specs_mod')
| |
− | ) {
| |
− | return;
| |
− | }
| |
− |
| |
− | hideMods();
| |
− | });
| |
− |
| |
− | document.querySelector('.specs_slider_container').addEventListener('scroll', hideMods);
| |
− |
| |
− | var openMod = function( e ) {
| |
− | var view_container = document.querySelector('.specs_mod.view');
| |
− | var view_pos = document.querySelector('.specs_mods').parentElement.getBoundingClientRect();
| |
− | var pos = e.target.offsetParent.getBoundingClientRect();
| |
− | view_container.style.left = (pos.x - view_pos.x - 26) + "px";
| |
− | view_container.style.top = (pos.y - view_pos.y - 12) + "px";
| |
− | view_container.innerHTML = e.target.innerHTML;
| |
− | view_container.classList.remove('hide');
| |
− | }
| |
− |
| |
− | for ( var i = 0; i < modsList.length; i++ ) {
| |
− | modsList[i].onclick = openMod;
| |
− | }
| |
− | }
| |
− |
| |
− | function wikiSetup() {
| |
− | treeGroup();
| |
− | externalLinks();
| |
− | gunHtml();
| |
− | gun2Html();
| |
− | gunHtmlEn();
| |
− | gun2HtmlEn();
| |
− | addSymbols();
| |
− | skinGallery();
| |
− | specsSlider();
| |
− | specsBuyButton();
| |
− | specsMarketButton();
| |
− | specsOpenInGame();
| |
− | specsShowMod();
| |
− | specsOpenSlider();
| |
− | }
| |
− |
| |
− | if (document.readyState === "complete" || document.readyState === "loaded" || document.readyState === "interactive") {
| |
− | wikiSetup();
| |
− | } else {
| |
− | document.addEventListener('DOMContentLoaded', wikiSetup);
| |
− | }
| |