battles/rating/index_files/dynamic.js
2018-01-28 18:40:49 +02:00

759 lines
22 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

var thingWidget;
$(document).ready(function(){
$(document).mousemove(function(e) {
mouseX = e.pageX;
mouseY = e.pageY;
if (thingWidget && thingWidget.is(':visible')) {
var ww = $(window).width();
var indent = 35;
var boxWidth = 300;
if ((mouseX + indent + boxWidth) > ww) {
var posLeft = e.pageX - (indent + boxWidth);
var cssArr = {
top: e.pageY - 150,
left: posLeft
}
}
else {
var cssArr = {
top: (e.pageY - 150),
left: (e.pageX + 35)
}
}
thingWidget.css(cssArr);
}
}).mouseover();
$('.thing-widget').hover(
function() {
var ww = $(window).width();
var indent = 35;
var boxWidth = 300;
if ((mouseX + indent + boxWidth) > ww) {
var posLeft = mouseX - (indent + boxWidth);
var cssArr = {
top: mouseY - 150,
left: posLeft
}
}
else {
var cssArr = {
top: (mouseY - 150),
left: (mouseX + 35)
}
}
var that = $('div.tw[data-id="' + $(this).attr('data-target') +'"]');
thingWidget = that;
that.stop(true).queue('fx', function(){
that.css(cssArr).show('fast').dequeue('fx');
});
},
function() {
var that = $('div.tw[data-id="' + $(this).attr('data-target') +'"]');
that.stop(true).queue('fx', function(e){
that.hide('fast').dequeue('fx');
});
}
);
if ($('body').find('ul.admin-menu').size() > 0)
{
$('ul.admin-menu').children('li').click(function(){
if ($(this).is('.exit'))
{
$('div.admin-data').hide('fast');
$('ul.admin-menu').children('li').removeClass('active');
$('div.admin-panel').removeClass('active');
}
else if (!$(this).is('.active'))
{
$('ul.admin-menu').children('li').removeClass('active');
$(this).addClass('active');
$('div.admin-panel').addClass('active');
if (!$(this).children('a').is('.hierarchy'))
{
$('div.admin-content').addClass('rf');
}
else
{
$('div.admin-content').removeClass('rf');
}
var that = $('div.admin-data[data-id="' + $(this).children('a').attr('data-target') +'"]');
$('div.admin-data').hide('fast');
that.show('fast');
}
});
}
/* GLOBAL DROPPED MENU */
if ($('body').find('ul.dropped-down').size() > 0)
{
$('ul.dropped-down').click(function()
{
if($(this).is('.open'))
{
$(this).children('li').hide('fast', function(){
$('ul.dropped-down').removeClass('open');
});
}
else
{
$(this).children('li').show('fast', function(){
$('ul.dropped-down').addClass('open');
});
}
});
}
/* GLOBAL SUB MENU */
if ($('body').find('li.sub-menu').size() > 0)
{
$('li.sub-menu').hover(
function() {
$(this).children('ul.sub-menu').slideDown(300);
},
function() {
$(this).children('ul.sub-menu').slideUp(300);
}
);
}
/* GLOBAL USER SUB MENU */
if ($('body').find('li.sub-menu-click').size() > 0)
{
$('li.sub-menu-click').click(function(){
if(!$(this).children('ul.sub-menu-click').is(':visible')) {
$(this).children('ul.sub-menu-click').slideDown(300);
}
else {
$(this).children('ul.sub-menu-click').slideUp(300);
}
});
}
/* MAIN AUTH FORM */
if ($('body').find('form.rand-auth').size() > 0)
{
$('div.checkbox').click(function(){
if($(this).is('.active')) {
$(this).removeClass('active');
$(this).children('input').removeAttr('checked');
}
else {
$(this).addClass('active');
$(this).children('input').attr('checked', 'checked');
}
});
}
/*
if ($('body').find('a.subscriber-auth').size() > 0)
{
$('a.subscriber-auth').click(function(e){
$('li.subscriber').children('div.auth').slideDown(100);
rel = $('li.subscriber').children('div.auth').attr('data-rel');
if (rel == 'right') {
$('div.right').css('padding-top', '155px');
}
e.preventDefault();
});
}
*/
$(document).mouseup(function (e) {
var div = $("div.inmain-auth");
if (!div.is(e.target) && div.has(e.target).length === 0) {
div.hide();
if ($('div.inmain-auth').attr('data-rel') == 'right') {
$('div.right').removeAttr('style');
}
}
});
/* ******************* */
/* FAQ QUESTIONS */
if($('body').find('div.bfaq').size() > 0)
{
$('a.question').click(function(e){
if($(this).is('.active')) {
$(this).removeClass('active');
$(this).parent('.each').children('.answer').slideUp(400);
}
else {
$('.question').removeClass('active');
$('.answer').slideUp(400);
$(this).addClass('active');
$(this).parent('.each').children('.answer').slideDown(400);
}
e.preventDefault();
});
}
/* ******************* */
if ($('body').find('textarea#content').size() > 0)
{
$('textarea#content').redactor({
lang: 'ru',
air: false,
autoclear: false,
imageGetJson: false,
imageUpload: '/picture-upload/',
toolbar: 'mini'
});
}
if ($('body').find('textarea#faq-content').size() > 0)
{
$('textarea#faq-content').redactor({
lang: 'ru',
air: false,
autoclear: false,
toolbar: 'faq'
});
}
if ($('body').find('textarea#admin-content-plain').size() > 0)
{
$('textarea#admin-content-plain').redactor({
lang: 'ru',
air: false,
autoclear: false,
imageGetJson: false,
imageUpload: '/picture-upload/',
toolbar: 'admincontent'
});
}
if ($('body').find('textarea#admin-content-plain-added').size() > 0)
{
$('textarea#admin-content-plain-added').redactor({
lang: 'ru',
air: false,
autoclear: false,
imageGetJson: false,
imageUpload: '/picture-upload/',
toolbar: 'admincontent'
});
}
if ($('body').find('div#notice').size() > 0)
{
if ($('div#notice').is('.fly'))
{
setTimeout(function(){
$('div#notice').animate({
opacity: 0,
top: '-=100px'
}, 1000);
}, 3500);
}
}
if ($('body').find('input.clean').size() > 0)
{
$('input.clean').val('');
}
if ($('body').find('.goods').size() > 0) {
$('.goods').children('.item').click(function(){
var item_id = '.item-' + $(this).attr('data-id');
if ($(this).is('.active')) {
$(this).removeClass('active');
$(item_id).slideUp('fast');
}
else {
$('.goods').children('.item').removeClass('active');
$(this).addClass('active');
$('.goods-pay').slideUp('fast', function(){
setTimeout(function(){
$(item_id).slideDown('slow');
}, 400);
});
}
});
}
$('ul#switch').children('li').children('a').click(function(e){
if (!$(this).parent('li').is('active')) {
$('ul#switch').children('li').removeClass('active');
$(this).parent('li').addClass('active');
var dataRel = $(this).attr('data-rel');
if($('.goods-pay').is(':visible')) {
$('.goods').children('.item').removeClass('active');
$('.goods-pay').slideUp('fast');
}
if (dataRel == 0) {
$('.goods').children('.item').show();
}
else if (dataRel == 1) {
$("div.item[data-target='2']").hide();
}
else if (dataRel == 2) {
$("div.item[data-target='1']").hide();
}
$("div.item[data-target='" + dataRel +"']").show();
}
e.preventDefault();
});
$('ul#switch-menu').children('li').children('a').click(function(e){
if(!$(this).parent('li').is('.active')) {
$('ul#switch-menu').children('li').removeClass('active');
$(this).parent('li').addClass('active');
var dataRel = $(this).attr('data-rel');
$('.switch-target').hide();
$("div.switch-target[data-id='" + dataRel +"']").show();
}
e.preventDefault();
});
$('input#shop-val-dimond').bind('keyup', function(){
var value = $(this).val() * 1;
if ($.isNumeric(value) && value >= 1) {
if ($(this).parent('div').is('.invalid')) {
$(this).parent('div').removeClass('invalid');
}
var newPrice = Math.ceil(value / (shop_price_amn * 1));
$('a.shop-money-dimond').text('Купить за ' + newPrice + ' руб').attr('data-price', value);
if($(this).is('.summa-bonus')) {
var actual_summa = 0;
if (value >= 5000) {
actual_summa = 5000;
actual_val = Math.ceil(value * 0.2);
actual_text = '+' + actual_val + ' бесплатно';
}
else if (value >= 3000) {
actual_summa = 3000;
actual_val = Math.ceil(value * 0.17);
actual_text = '+' + actual_val + ' бесплатно';
}
else if (value >= 1500) {
actual_summa = 1500;
actual_val = Math.ceil(value * 0.15);
actual_text = '+' + actual_val + ' бесплатно';
}
else if (value >= 1000) {
actual_summa = 1000;
actual_val = Math.ceil(value * 0.12);
actual_text = '+' + actual_val + ' бесплатно';
}
else if (value >= 500) {
actual_summa = 500;
actual_val = Math.ceil(value * 0.1);
actual_text = '+' + actual_val + ' бесплатно';
}
else if (value >= 150) {
actual_summa = 150;
actual_val = Math.ceil(value * 0.05);
actual_text = '+' + actual_val + ' бесплатно';
}
var summa_bonus_name = 'span.summa-bonus-dimond-' + actual_summa;
if (actual_summa >= 150) {
$(summa_bonus_name).text(actual_text).show();
$(this).width(120);
}
if (actual_summa < 1) {
$('span.summa-bonus').hide();
$(this).width(256);
}
}
}
else {
if (!$.isNumeric(value)) {
$(this).parent('div').addClass('invalid');
}
$('a.shop-money-dimond').text($('a.shop-money-dimond').attr('data-default')).attr('data-price', 0);
}
});
$('input#shop-val-gold').bind('keyup', function(){
var value = $(this).val() * 1;
var amnVal = value / 10;
if ($.isNumeric(value) && value > 1) {
if ($(this).parent('div').is('.invalid')) {
$(this).parent('div').removeClass('invalid');
}
var newPrice = Math.ceil(value / (shop_price_zmn * 1));
$('a.shop-money-gold').text('Купить за ' + newPrice + ' руб').attr('data-price', value / 10);
if($(this).is('.summa-bonus')) {
var actual_summa = 0;
if (amnVal >= 5000) {
actual_summa = 5000;
actual_val = Math.ceil(amnVal * 0.2) * 10;
actual_text = '+' + actual_val + ' бесплатно';
}
else if (amnVal >= 3000) {
actual_summa = 3000;
actual_val = Math.ceil(amnVal * 0.17) * 10;
actual_text = '+' + actual_val + ' бесплатно';
}
else if (amnVal >= 1500) {
actual_summa = 1500;
actual_val = Math.ceil(amnVal * 0.15) * 10;
actual_text = '+' + actual_val + ' бесплатно';
}
else if (amnVal >= 1000) {
actual_summa = 1000;
actual_val = Math.ceil(amnVal * 0.12) * 10;
actual_text = '+' + actual_val + ' бесплатно';
}
else if (amnVal >= 500) {
actual_summa = 500;
actual_val = Math.ceil(amnVal * 0.1) * 10;
actual_text = '+' + actual_val + ' бесплатно';
}
else if (amnVal >= 150) {
actual_summa = 150;
actual_val = Math.ceil(amnVal * 0.05) * 10;
actual_text = '+' + actual_val + ' бесплатно';
}
var summa_bonus_name = 'span.summa-bonus-gold-' + actual_summa;
if (actual_summa >= 150) {
$(summa_bonus_name).text(actual_text).show();
$(this).width(120);
}
if (actual_summa < 1) {
$('span.summa-bonus').hide();
$(this).width(256);
}
}
}
else {
if (!$.isNumeric(value)) {
$(this).parent('div').addClass('invalid');
}
$('a.shop-money-gold').text($('a.shop-money-gold').attr('data-default')).attr('data-price', 0);
}
});
$('a.shop-pay').click(function(e){
if (($(this).attr('data-price') * 1) < 1) {
if ($(this).is('.shop-money-dimond')) {
$('input#shop-val-dimond').parent('div').addClass('invalid');
}
if ($(this).is('.shop-money-gold')) {
$('input#shop-val-dimond').parent('div').addClass('invalid');
}
}
else if (!$(this).is('.shop-pay-block')) {
$(this).addClass('shop-pay-block');
if ($(this).is('.shop-money-gold')) {
var callRequest = {
'amount': $(this).attr('data-price'),
'gold': $('input#shop-val-gold').val()
}
} else {
var callRequest = {
'amount': $(this).attr('data-price')
}
}
system.call(urlShopPay, callRequest, function(data){
if (data.error) {
if (data.error.code == 'INVALID_USER') {
window.location.href = '/sign/';
} else if (data.error.code == 'INVALID_ERROR') {
$('div#fly-fail').fadeIn('fast');
}
} else if (data.success) {
XPSLightBox.open('https://secure.xsolla.com/paystation2/?access_token=' + data.success.token, 750, 620);
}
});
setTimeout(function(button){
$('a.shop-pay').removeClass('shop-pay-block');
}, 3500);
}
e.preventDefault();
});
$('.goods-close').click(function(){
$(this).parent('div.goods-pay').slideUp('fast');
$('.goods').children('.item').removeClass('active');
});
$('#fly-fail').children('.close').click(function(){
$(this).parent('div').fadeOut('fast');
});
$('#fly-result').children('.close').click(function(){
$(this).parent('div').fadeOut('fast');
});
$('.tooltip').tooltip({
show: null,
position: {
my: "center bottom",
at: "center top-20"
},
open: function( event, ui ) {
ui.tooltip.animate({ top: ui.tooltip.position().top + 10 }, "fast" );
}
});
/* IGNORED EVENTS */
$('a.ignore').click(function(e){
e.preventDefault();
});
$('form.ignore').submit(function(e){
e.preventDefault();
});
/* VIP ACCOUNT */
if ($('body').find('div.vip-lib').size() > 0)
{
var cl = account_stat_vip*1;
var cr = account_stat_rub*1;
if (cr >= 1) vipLoad();
$('span.bnext').click(function(){
var cb = $('div.lib-box-vi').attr('data-id');
var cbn = (cb*1) + 1;
if (cbn <= 12) {
var next = 'div.lib-box-' + cbn;
var nextNM = ($(next).attr('data-next')*1) - cr;
var needM = $(next).attr('data-next')*1;
$('div.lib-box-vi').removeClass('lib-box-vi').fadeOut('fast', function(){
$(next).addClass('lib-box-vi').fadeIn('slow');
$('div.vip-line').children('span.prefix').text('VIP ' + cl);
$('div.vip-line').children('span.suffix').text('VIP ' + (cbn + 1));
if (cbn == 12) {
$('span.vip-desc').text('Следующий уровень не доступен');
$('a.vip-pay').addClass('vip-pay-disabled').removeClass('vip-pay');
$('div.line').children('span.need').text('> 22000');
} else if (nextNM < 1) {
$('span.vip-desc').text('Р­СРѕС СѓСЂРѕРІРµРЅСЊ VIP вам доступен');
$('a.vip-pay').addClass('vip-pay-disabled').removeClass('vip-pay');
$('div.line').children('span.need').text(needM);
vipLineLength(cr, needM);
} else {
$('span.vip-desc').text('Купите ' + nextNM + ' алмазных монет');
$('a.vip-pay-disabled').addClass('vip-pay').removeClass('vip-pay-disabled');
$('div.line').children('span.need').text(nextNM);
vipLineLength(cr, needM);
}
});
}
});
$('span.blast').click(function(){
var cb = $('div.lib-box-vi').attr('data-id');
var cbn = (cb*1) - 1;
if (cbn >= 0) {
var last = 'div.lib-box-' + cbn;
var nextNM = ($(last).attr('data-next')*1) - cr;
var needM = $(last).attr('data-next')*1;
$('div.lib-box-vi').removeClass('lib-box-vi').fadeOut('fast', function(){
$(last).addClass('lib-box-vi').fadeIn('slow');
$('div.vip-line').children('span.prefix').text('VIP ' + cl);
$('div.vip-line').children('span.suffix').text('VIP ' + cb);
if (nextNM < 1) {
$('span.vip-desc').text('Р­СРѕС СѓСЂРѕРІРµРЅСЊ VIP вам доступен');
$('a.vip-pay').addClass('vip-pay-disabled').removeClass('vip-pay');
$('div.line').children('span.need').text(needM);
vipLineLength(cr, needM);
} else {
$('span.vip-desc').text('Купите ' + nextNM + ' алмазных монет');
$('a.vip-pay-disabled').addClass('vip-pay').removeClass('vip-pay-disabled');
$('div.line').children('span.need').text(nextNM);
vipLineLength(cr, needM);
}
});
}
});
$('a.vip-pay-disabled').live('click', function(e){
e.preventDefault();
});
}
function vipLineLength (money, needMoney)
{
var min = 30;
if (money >= 10) min = 38;
if (money >= 100) min = 45;
if (money >= 1000) min = 55;
if (money >= 10000) min = 65;
var max = 669;
var len = max * ((money*1) / (needMoney*1));
var cw = $('div.inline').width()*1;
cw = cw < min ? min : cw;
len = len < min ? min : len;
len = len > max ? max : len;
if (len >= cw) {
var w = len - cw;
$('div.inline').animate({
width: '+=' + w + 'px'
}, 500);
} else {
var w = cw - len;
$('div.inline').animate({
width: '-=' + w + 'px'
}, 500);
}
}
function vipLoad (cl, cr)
{
var cl = account_stat_vip*1;
var cr = account_stat_rub*1;
if (cl <= 12) {
var next = 'div.lib-box-' + cl;
var nextNM = ($(next).attr('data-next')*1) - cr;
var needM = $(next).attr('data-next')*1;
$('div.lib-box-vi').removeClass('lib-box-vi').fadeOut('fast', function(){
$(next).addClass('lib-box-vi').fadeIn('slow');
$('div.vip-line').children('span.prefix').text('VIP ' + cl);
$('div.vip-line').children('span.suffix').text('VIP ' + (cl + 1));
if (cl == 12) {
$('span.vip-desc').text('Следующий уровень не доступен');
$('a.vip-pay').addClass('vip-pay-disabled').removeClass('vip-pay');
$('div.line').children('span.need').text('> 22000');
} else if (nextNM < 1) {
$('span.vip-desc').text('Р­СРѕС СѓСЂРѕРІРµРЅСЊ VIP вам доступен');
$('a.vip-pay').addClass('vip-pay-disabled').removeClass('vip-pay');
$('div.line').children('span.need').text(needM);
vipLineLength(cr, needM);
} else {
$('span.vip-desc').text('Купите ' + nextNM + ' алмазных монет');
$('a.vip-pay-disabled').addClass('vip-pay').removeClass('vip-pay-disabled');
$('div.line').children('span.need').text(nextNM);
vipLineLength(cr, needM);
}
});
}
}
if ($('body').find('a.lb1').size() > 0) {
jQuery('a.lb1').lightBox({
overlayBgColor: '#000',
overlayOpacity: 0.8,
imageLoading: '/images/724.gif'
});
}
if ($('body').find('a.lb2').size() > 0) {
jQuery('a.lb2').lightBox({
overlayBgColor: '#1D2F35',
overlayOpacity: 0.6,
imageLoading: '/images/preloader_724_1.gif'
});
}
if ($('body').find('a.lb3').size() > 0) {
jQuery('a.lb3').lightBox({
overlayBgColor: '#1D2F35',
overlayOpacity: 0.6,
imageLoading: '/images/preloader_724_1.gif'
});
}
if ($('body').find('a.lib-image').size() > 0) {
jQuery('a.lib-image').lightBox({
overlayBgColor: '#1D2F35',
overlayOpacity: 0.6,
imageLoading: '/images/preloader_724_1.gif',
imageBtnClose: '/images/lightbox-btn-close.gif',
imageBtnPrev: '/images/lightbox-btn-prev.gif',
imageBtnNext: '/images/lightbox-btn-next.gif',
imageBlank: '/images/lightbox-blank.gif',
txtImage: 'Изображение',
txtOf: 'РёР·'
});
}
if ($('body').find('a.lv1').size() > 0) {
$('a.lv1').click(function(){
$('body').append('<div id="jquery-overlay" style="background-color: rgba(29, 47, 53, 0.6); width: 100%; height: ' + Math.max($(document).height(), $(window).height()) + 'px"></div><div id="jquery-lightbox" style="top: 150px; left: 0px"><div id="lightbox-container-image-box" style="width: 660px; height: 380px;"><div id="lightbox-container-image"><iframe width="640" height="360" src="//www.youtube.com/embed/47vfsoCnS5A?rel=0&amp;showinfo=0" frameborder="0" allowfullscreen></iframe></iframe></div></div><div id="lightbox-container-image-data-box" style="display: block; width: 640px;"><div id="lightbox-container-image-data"><div id="lightbox-image-details"><span id="lightbox-image-details-caption" style="display: none"></span><span id="lightbox-image-details-currentNumber" style="display: none"></span></div><div id="lightbox-secNav"><a href="#" id="lightbox-secNav-btnClose"><img src="/images/lightbox-btn-close.gif" /></a></div></div></div></div>');
});
$('#jquery-overlay').live('click', function(){
$('#jquery-lightbox').remove();
$('#jquery-overlay').fadeOut(function() { $('#jquery-overlay').remove(); });
});
$('#lightbox-secNav-btnClose').live('click', function(e){
$('#jquery-lightbox').remove();
$('#jquery-overlay').fadeOut(function() { $('#jquery-overlay').remove(); });
e.preventDefault();
});
}
$('.invite-select').change(function(){
$(this).addClass('selected');
});
/* FORMS */
$('input.alter').keyup(function()
{
if ($(this).parent('.field').is('.alarm'))
{
$(this).parent('.field').removeClass('alarm');
$(this).parent('.field').parent('fieldset').children('p.note').slideUp(300);
}
});
$('ul.radio').children('li').click(function()
{
var dataTarget = 'input#' + $(this).parent('ul').attr('data-target');
var dataRel = $(this).attr('data-rel');
$(this).parent('ul').parent('div.field').removeClass('alarm success');
$(this).parent('ul').children('li').removeClass('active');
$(this).addClass('active');
$(dataTarget).val(dataRel);
});
});