911 lines
33 KiB
JavaScript
911 lines
33 KiB
JavaScript
|
//для кнопки наверх
|
|||
|
$(document).ready(function () {
|
|||
|
$('body').append('<a href="#" id="go-top" title="наверх"><br></a>');
|
|||
|
});
|
|||
|
|
|||
|
$(function () {
|
|||
|
$.fn.scrollToTop = function () {
|
|||
|
$(this).hide().removeAttr('href');
|
|||
|
if ($(window).scrollTop() >= '250') $(this).fadeIn('slow');
|
|||
|
var scrollDiv = $(this);
|
|||
|
$(window).scroll(function () {
|
|||
|
if ($(window).scrollTop() <= '250') $(scrollDiv).fadeOut('slow');
|
|||
|
else $(scrollDiv).fadeIn('slow');
|
|||
|
});
|
|||
|
$(this).click(function () {
|
|||
|
$('html, body').animate(
|
|||
|
{
|
|||
|
scrollTop: 0,
|
|||
|
},
|
|||
|
'slow'
|
|||
|
);
|
|||
|
});
|
|||
|
};
|
|||
|
});
|
|||
|
|
|||
|
$(function () {
|
|||
|
$('#go-top').scrollToTop();
|
|||
|
});
|
|||
|
//модальные формы
|
|||
|
$(document).ready(function () {
|
|||
|
const MIN_NUMBER_DIGITS = 6;
|
|||
|
const MAX_CASH = 200000;
|
|||
|
const MIN_CASH = 50;
|
|||
|
|
|||
|
let $order_id = get_current_step_data().paymentStepData?.order_id || 0;
|
|||
|
let $code_currency_crypto = '';
|
|||
|
let $code_cash_carrenct = '';
|
|||
|
let $exchange_crypto = 0;
|
|||
|
let $min_crypto = 0;
|
|||
|
let $max_crypto = 0;
|
|||
|
|
|||
|
let decimalPlaces = 0;
|
|||
|
|
|||
|
let timerUpdateVia = 0;
|
|||
|
let updateDataInterval = null;
|
|||
|
let updateSecondsInterval = null;
|
|||
|
|
|||
|
let isGettingData = false;
|
|||
|
|
|||
|
function get_current_step_data() {
|
|||
|
return {
|
|||
|
currentStep: JSON.parse(localStorage.getItem('paymentStep')),
|
|||
|
paymentStepData: JSON.parse(localStorage.getItem('paymentStepData')),
|
|||
|
};
|
|||
|
}
|
|||
|
|
|||
|
function set_currect_step_data(step, data) {
|
|||
|
localStorage.setItem('paymentStep', `${step}`);
|
|||
|
localStorage.setItem('paymentStepData', JSON.stringify(data));
|
|||
|
}
|
|||
|
|
|||
|
function remove_current_step_data() {
|
|||
|
localStorage.removeItem('paymentStep');
|
|||
|
localStorage.removeItem('paymentStepData');
|
|||
|
}
|
|||
|
|
|||
|
function remove_decimal_places(count, numberOfSings) {
|
|||
|
const receiptAmount = String(count);
|
|||
|
const currentCommaIndex = receiptAmount.indexOf('.');
|
|||
|
|
|||
|
return receiptAmount.substring(0, currentCommaIndex + 1 + numberOfSings);
|
|||
|
}
|
|||
|
|
|||
|
function payment_timer(expirationDate) {
|
|||
|
const $timer = document.getElementsByClassName('timer_pays')[0];
|
|||
|
|
|||
|
const expiresTime = expirationDate
|
|||
|
? luxon.DateTime.fromMillis(expirationDate)
|
|||
|
: luxon.DateTime.now().plus({ minutes: 60, seconds: 1 });
|
|||
|
|
|||
|
const expirationInterval = setInterval(() => {
|
|||
|
if (luxon.DateTime.now().ts > expiresTime?.ts) {
|
|||
|
clearInterval(expirationInterval);
|
|||
|
remove_current_step_data();
|
|||
|
} else {
|
|||
|
const now = luxon.DateTime.now();
|
|||
|
const timeToFinish = luxon.Interval.fromDateTimes(now, expiresTime);
|
|||
|
const millisecondsLeft = timeToFinish.length('milliseconds');
|
|||
|
|
|||
|
$timer.textContent = luxon.Duration.fromMillis(millisecondsLeft).toFormat("mm:ss'");
|
|||
|
}
|
|||
|
}, 1000);
|
|||
|
}
|
|||
|
|
|||
|
function coin_rounding_calculation(coinPrice) {
|
|||
|
const minCount = String(MIN_CASH / coinPrice);
|
|||
|
const maxCount = String(MAX_CASH / coinPrice);
|
|||
|
|
|||
|
const minCommaIndex = minCount.indexOf('.');
|
|||
|
const maxCommaIndex = maxCount.indexOf('.');
|
|||
|
|
|||
|
const isOneNumberBeforeComma = minCommaIndex === 1 && minCount.at(0) > 0;
|
|||
|
const numbersBeforeComma = isOneNumberBeforeComma ? 1 : minCommaIndex > 1 ? minCommaIndex : -1;
|
|||
|
|
|||
|
let numbersAfrerComma = 0;
|
|||
|
let minCrypto = 0;
|
|||
|
let maxCrypto = 0;
|
|||
|
|
|||
|
if (numbersBeforeComma >= MIN_NUMBER_DIGITS) {
|
|||
|
minCrypto = minCount.substring(0, minCommaIndex);
|
|||
|
maxCrypto = maxCount.substring(0, maxCommaIndex);
|
|||
|
numbersAfrerComma = 0;
|
|||
|
} else if (numbersBeforeComma < MIN_NUMBER_DIGITS && numbersBeforeComma >= 1) {
|
|||
|
// 5 === current range (MIN_NUMBER_DIGITS - 1)
|
|||
|
// 2 === means a comma and one number after it
|
|||
|
minCrypto = minCount.substring(0, MIN_NUMBER_DIGITS - 1 + 2);
|
|||
|
numbersAfrerComma = minCrypto.substring(minCommaIndex + 1).length;
|
|||
|
maxCrypto = maxCount.substring(0, maxCommaIndex + 1 + numbersAfrerComma);
|
|||
|
} else {
|
|||
|
const firstNumbIndex = minCount.split('').findIndex((elem) => Number(elem) > 0);
|
|||
|
|
|||
|
minCrypto = minCount.substring(0, firstNumbIndex + MIN_NUMBER_DIGITS);
|
|||
|
numbersAfrerComma = minCrypto.substring(minCommaIndex + 1).length;
|
|||
|
maxCrypto = maxCount.substring(0, maxCommaIndex + 1 + numbersAfrerComma);
|
|||
|
}
|
|||
|
|
|||
|
return { minCrypto, maxCrypto, numbersAfrerComma };
|
|||
|
}
|
|||
|
|
|||
|
function set_value_in_crypto_cash_input(coinPrice, numberOfSings) {
|
|||
|
const [$cashInput] = document.getElementsByClassName('input_import_cash');
|
|||
|
const cashValue = $cashInput.value;
|
|||
|
|
|||
|
return {
|
|||
|
cryptoValue: cashValue ? remove_decimal_places(cashValue / coinPrice, numberOfSings) : 0,
|
|||
|
cashValue: cashValue ?? 0,
|
|||
|
};
|
|||
|
}
|
|||
|
|
|||
|
function in_download_process(isProcess) {
|
|||
|
isGettingData = isProcess;
|
|||
|
document.getElementsByClassName('input_import_cash')[0].disabled = isProcess;
|
|||
|
document.getElementsByClassName('input_export_crypto')[0].disabled = isProcess;
|
|||
|
|
|||
|
const $timer = document.getElementById('timer-auto-update');
|
|||
|
$timer.innerHTML = 'Получение данных о курсе...';
|
|||
|
|
|||
|
if (isProcess) {
|
|||
|
clear_all_timers();
|
|||
|
} else {
|
|||
|
remaining_timer();
|
|||
|
timer_reset_time();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
function clear_all_timers(isError = false) {
|
|||
|
clearInterval(updateDataInterval);
|
|||
|
clearInterval(updateSecondsInterval);
|
|||
|
|
|||
|
if (isError) {
|
|||
|
const $timer = document.getElementById('timer-auto-update');
|
|||
|
$timer.textContent = 'Произошла ошибка в получении данных курса. Попробуйте перезагрузить страницу или зайти чуть позже.';
|
|||
|
$timer.style.color = 'red';
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
function set_current_coin_price() {
|
|||
|
in_download_process(true);
|
|||
|
|
|||
|
get_current_coin_price($code_currency_crypto, $code_cash_carrenct)
|
|||
|
.then((result) => {
|
|||
|
const { minCrypto, maxCrypto, numbersAfrerComma } = coin_rounding_calculation(result);
|
|||
|
const { cashValue, cryptoValue } = set_value_in_crypto_cash_input(result, decimalPlaces);
|
|||
|
|
|||
|
$exchange_crypto = result;
|
|||
|
$min_crypto = minCrypto;
|
|||
|
$max_crypto = maxCrypto;
|
|||
|
decimalPlaces = numbersAfrerComma;
|
|||
|
|
|||
|
$('.current_informer').html($exchange_crypto);
|
|||
|
$('.min-numbers_crypto').html($min_crypto);
|
|||
|
$('.max-numbers_crypto').html($max_crypto);
|
|||
|
|
|||
|
if (cashValue && cryptoValue) {
|
|||
|
$('.input_import_cash').val(cashValue);
|
|||
|
$('.input_export_crypto').val(cryptoValue);
|
|||
|
}
|
|||
|
|
|||
|
in_download_process(false);
|
|||
|
})
|
|||
|
.catch((err) => {
|
|||
|
console.error(err);
|
|||
|
|
|||
|
$('.current_informer').html('ERROR');
|
|||
|
$('.min-numbers_crypto').html('ERROR');
|
|||
|
$('.max-numbers_crypto').html('ERROR');
|
|||
|
|
|||
|
clear_all_timers(true);
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
function remaining_timer(update = false) {
|
|||
|
if (update) {
|
|||
|
set_current_coin_price();
|
|||
|
} else {
|
|||
|
timerUpdateVia = 180;
|
|||
|
updateDataInterval = setInterval(set_current_coin_price, timerUpdateVia * 1000);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
function timer_reset_time() {
|
|||
|
const $timer = document.getElementById('timer-auto-update');
|
|||
|
|
|||
|
updateSecondsInterval = setInterval(() => {
|
|||
|
timerUpdateVia -= 1;
|
|||
|
|
|||
|
const secondsTitle = timerUpdateVia === 1 ? 'секунда' : timerUpdateVia >= 2 && timerUpdateVia <= 4 ? 'секунды' : 'секунд';
|
|||
|
|
|||
|
if (timerUpdateVia < 0) {
|
|||
|
clearInterval(updateDataInterval);
|
|||
|
remaining_timer();
|
|||
|
}
|
|||
|
|
|||
|
$timer.innerHTML = `Автообновление курса через ${timerUpdateVia} ${secondsTitle}`;
|
|||
|
}, 1000);
|
|||
|
}
|
|||
|
|
|||
|
function update_exchange_rate_on_click() {
|
|||
|
clear_all_timers();
|
|||
|
set_current_coin_price();
|
|||
|
}
|
|||
|
|
|||
|
async function get_current_coin_price(giveTicker, getTicker) {
|
|||
|
let giveCoinId = '';
|
|||
|
let getCoinId = '';
|
|||
|
|
|||
|
switch (giveTicker.toLowerCase()) {
|
|||
|
case 'btc':
|
|||
|
giveCoinId = 'bitcoin';
|
|||
|
break;
|
|||
|
case 'eth':
|
|||
|
giveCoinId = 'ethereum';
|
|||
|
break;
|
|||
|
case 'ltc':
|
|||
|
giveCoinId = 'litecoin';
|
|||
|
break;
|
|||
|
case 'ada':
|
|||
|
giveCoinId = 'cardano';
|
|||
|
break;
|
|||
|
case 'doge':
|
|||
|
giveCoinId = 'dogecoin';
|
|||
|
break;
|
|||
|
case 'shib':
|
|||
|
giveCoinId = 'shiba-inu';
|
|||
|
break;
|
|||
|
case 'trx':
|
|||
|
giveCoinId = 'tron';
|
|||
|
break;
|
|||
|
case 'xlm':
|
|||
|
giveCoinId = 'stellar';
|
|||
|
break;
|
|||
|
}
|
|||
|
|
|||
|
switch (getTicker.toLowerCase()) {
|
|||
|
case 'usdt':
|
|||
|
getCoinId = 'tether';
|
|||
|
break;
|
|||
|
case 'busd':
|
|||
|
getCoinId = 'binance-usd';
|
|||
|
break;
|
|||
|
case 'usdc':
|
|||
|
getCoinId = 'usd-coin';
|
|||
|
break;
|
|||
|
}
|
|||
|
|
|||
|
try {
|
|||
|
const [giveDataCoin, getDataCoin] = await Promise.all([
|
|||
|
(await fetch(`https://api.coingecko.com/api/v3/simple/price?ids=${giveCoinId}&vs_currencies=usd`)).json(),
|
|||
|
(await fetch(`https://api.coingecko.com/api/v3/simple/price?ids=${getCoinId}&vs_currencies=usd`)).json(),
|
|||
|
]);
|
|||
|
|
|||
|
const givePriceDollarPrice = giveDataCoin[giveCoinId].usd;
|
|||
|
const getPriceDollarPrice = getDataCoin[getCoinId].usd;
|
|||
|
|
|||
|
const givenTickerPrice = getPriceDollarPrice * givePriceDollarPrice;
|
|||
|
const commissionPrice = givenTickerPrice - givenTickerPrice * 0.03;
|
|||
|
|
|||
|
const priceLength = String(givePriceDollarPrice).length;
|
|||
|
const result = String(commissionPrice).substring(0, priceLength);
|
|||
|
|
|||
|
return result;
|
|||
|
} catch (err) {
|
|||
|
throw new Error(err);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
const { currentStep, paymentStepData: paymentStep } = get_current_step_data();
|
|||
|
|
|||
|
if ((paymentStep?.renderExpirationTime && currentStep === 2) || currentStep === 3) {
|
|||
|
if (luxon.DateTime.now().ts > paymentStep.renderExpirationTime) {
|
|||
|
remove_current_step_data();
|
|||
|
} else {
|
|||
|
switch (currentStep) {
|
|||
|
case 2:
|
|||
|
order_2_step_render();
|
|||
|
break;
|
|||
|
case 3:
|
|||
|
order_verification_3_step_render();
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
$('.close-modal-form, .hover-site').click(function () {
|
|||
|
$('.hover-site').removeClass('display-block');
|
|||
|
$('.modal-form').removeClass('display-block');
|
|||
|
});
|
|||
|
$('.button-modal').click(function () {
|
|||
|
$('.top-modal-form-order-call-back').addClass('display-block');
|
|||
|
$('.hover-site').addClass('display-block');
|
|||
|
});
|
|||
|
|
|||
|
$('.post-answer nav').click(function () {
|
|||
|
if ($(this).hasClass('active-answer')) {
|
|||
|
$('.post-answer nav').parent('.post-answer').children('section').slideUp(300);
|
|||
|
$('.post-answer nav').removeClass('active-answer');
|
|||
|
} else {
|
|||
|
$('.post-answer nav').parent('.post-answer').children('section').slideUp(300);
|
|||
|
$(this).parent('.post-answer').children('section').slideDown(300);
|
|||
|
$('.post-answer nav').removeClass('active-answer');
|
|||
|
$(this).addClass('active-answer');
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
if ($('.box-currencys-for-inputs_crypto').length) {
|
|||
|
//box-currencys-for-inputs crypto
|
|||
|
$('.box-currencys-for-inputs_crypto').children('.post-currency-for-input').first().addClass('activer_crypto_currentcy');
|
|||
|
|
|||
|
$code_currency_crypto = $('.activer_crypto_currentcy').children('.code_currency_crypto').text();
|
|||
|
$('.currency_symbol_crypto').html($code_currency_crypto);
|
|||
|
|
|||
|
$title_crypto = $('.activer_crypto_currentcy').children('.title_crypto').text();
|
|||
|
$('.title-currency-input_crypto').html($title_crypto);
|
|||
|
|
|||
|
$img_crypto = $('.activer_crypto_currentcy').children('.img-currency-box').html();
|
|||
|
$('.img-currency-input_crypto').html($img_crypto);
|
|||
|
|
|||
|
// $min_crypto_text = $('.activer_crypto_currentcy').children('.min_currency_crypto').text();
|
|||
|
// $min_crypto = Number($min_crypto_text);
|
|||
|
// $('.min-numbers_crypto').html($min_crypto);
|
|||
|
|
|||
|
// $max_crypto_text = $('.activer_crypto_currentcy').children('.max_currency_crypto').text();
|
|||
|
|
|||
|
// $max_crypto = Number($max_crypto_text);
|
|||
|
// $('.max-numbers_crypto').html($max_crypto);
|
|||
|
|
|||
|
$('.box-currencys-for-inputs').slideUp(300);
|
|||
|
$('.left-currency-input_crypto').click(function () {
|
|||
|
if (!isGettingData) {
|
|||
|
$(this).parent('.inputs-currency').parent('.box-currency-inputs').children('.box-currencys-for-inputs').slideDown(300);
|
|||
|
$(this).addClass('active-left-currency-input');
|
|||
|
}
|
|||
|
|
|||
|
return;
|
|||
|
});
|
|||
|
|
|||
|
function click_post_currency_crypto() {
|
|||
|
$('.left-currency-input').removeClass('active-left-currency-input');
|
|||
|
$('.box-currencys-for-inputs').slideUp(300);
|
|||
|
$('.post-currency-for-input_crypto').removeClass('activer_crypto_currentcy');
|
|||
|
$(this).addClass('activer_crypto_currentcy');
|
|||
|
|
|||
|
$code_currency_crypto = $(this).children('.code_currency_crypto').text();
|
|||
|
$('.currency_symbol_crypto').html($code_currency_crypto);
|
|||
|
|
|||
|
$title_crypto = $(this).children('.title_crypto').text();
|
|||
|
$('.title-currency-input_crypto').html($title_crypto);
|
|||
|
|
|||
|
$img_crypto = $(this).children('.img-currency-box_crypto').html();
|
|||
|
$('.img-currency-input_crypto').html($img_crypto);
|
|||
|
|
|||
|
// $min_crypto_text = $(this).children('.min_currency_crypto').text();
|
|||
|
// $min_crypto = Number($min_crypto_text);
|
|||
|
// $('.min-numbers_crypto').html($min_crypto);
|
|||
|
|
|||
|
// $max_crypto_text = $(this).children('.max_currency_crypto').text();
|
|||
|
// $max_crypto = Number($max_crypto_text);
|
|||
|
// $('.max-numbers_crypto').html($max_crypto);
|
|||
|
|
|||
|
$code_currency_crypto = $(this).children('.code_currency_crypto').text();
|
|||
|
|
|||
|
update_exchange_rate_on_click();
|
|||
|
|
|||
|
$('.input_export_crypto').val('');
|
|||
|
$('.input_import_cash').val('');
|
|||
|
}
|
|||
|
|
|||
|
//box-currencys-for-inputs cash
|
|||
|
$('.box-currencys-for-inputs_cash').children('.post-currency-for-input').first().addClass('activer_cash_currentcy');
|
|||
|
$code_currency_cash = $('.activer_cash_currentcy').children('.code_currency_cash').text();
|
|||
|
$('.currency_symbol_cash').html($code_currency_cash);
|
|||
|
$title_cash = $('.activer_cash_currentcy').children('.title_cash').text();
|
|||
|
$('.title-currency-input_cash').html($title_cash);
|
|||
|
$img_cash = $('.activer_cash_currentcy').children('.img-currency-box_cash').html();
|
|||
|
$('.img-currency-input_cash').html($img_cash);
|
|||
|
$max_cash = $('.activer_cash_currentcy').children('.max_currency_cash').text();
|
|||
|
$('.max-numbers_cash').html($max_cash);
|
|||
|
$placeholder_crypto_wallet = $('.activer_cash_currentcy').children('.code_currency_placeholder').text();
|
|||
|
$('.input_name_wallet_user').attr('placeholder', $placeholder_crypto_wallet);
|
|||
|
$('.img_input_wallet_user').html($img_cash);
|
|||
|
$code_cash_carrenct = $('.activer_cash_currentcy').children('.code_fact_currency_cash').html();
|
|||
|
|
|||
|
remaining_timer(true);
|
|||
|
|
|||
|
$('.box-currencys-for-inputs').slideUp(300);
|
|||
|
$('.left-currency-input_cash').click(function () {
|
|||
|
if (!isGettingData) {
|
|||
|
$(this).parent('.inputs-currency').parent('.box-currency-inputs').children('.box-currencys-for-inputs').slideDown(300);
|
|||
|
$(this).addClass('active-left-currency-input');
|
|||
|
}
|
|||
|
|
|||
|
return;
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
function click_post_currency_cash() {
|
|||
|
$('.left-currency-input').removeClass('active-left-currency-input');
|
|||
|
$('.box-currencys-for-inputs').slideUp(300);
|
|||
|
$('.post-currency-for-input_cash').removeClass('activer_cash_currentcy');
|
|||
|
$(this).addClass('activer_cash_currentcy');
|
|||
|
|
|||
|
$code_currency_cash = $(this).children('.code_currency_cash').text();
|
|||
|
$('.currency_symbol_cash').html($code_currency_cash);
|
|||
|
|
|||
|
$title_cash = $(this).children('.title_cash').text();
|
|||
|
$('.title-currency-input_cash').html($title_cash);
|
|||
|
|
|||
|
$img_cash = $(this).children('.img-currency-box_cash').html();
|
|||
|
$('.img-currency-input_cash').html($img_cash);
|
|||
|
$('.img_input_wallet_user').html($img_cash);
|
|||
|
|
|||
|
$max_cash = $(this).children('.max_currency_cash').text();
|
|||
|
$('.max-numbers_cash').html($max_cash);
|
|||
|
|
|||
|
$placeholder_crypto_wallet = $(this).children('.code_currency_placeholder').text();
|
|||
|
$('.input_name_wallet_user').attr('placeholder', $placeholder_crypto_wallet);
|
|||
|
|
|||
|
$code_cash_carrenct = $('.activer_cash_currentcy').children('.code_fact_currency_cash').html();
|
|||
|
|
|||
|
update_exchange_rate_on_click();
|
|||
|
|
|||
|
$('.input_export_crypto').val('');
|
|||
|
$('.input_import_cash').val('');
|
|||
|
}
|
|||
|
|
|||
|
function keyup_input_cash() {
|
|||
|
$input_import_cash = parseInt($('.input_import_cash').val());
|
|||
|
$input_export_crypto = $('.input_export_crypto').val();
|
|||
|
|
|||
|
$max_cash_num = Number($max_cash);
|
|||
|
$input_import_cash_num = parseInt($input_import_cash, 2);
|
|||
|
|
|||
|
$code_cash_carrenct = $('.activer_cash_currentcy').children('.code_fact_currency_cash').html();
|
|||
|
|
|||
|
$result_to_export_crypto = remove_decimal_places($input_import_cash / $exchange_crypto, decimalPlaces);
|
|||
|
|
|||
|
$('.input_export_crypto').val($result_to_export_crypto);
|
|||
|
|
|||
|
if ($result_to_export_crypto < $min_crypto) {
|
|||
|
$('.min-numbers').removeClass('display-none');
|
|||
|
} else {
|
|||
|
$('.min-numbers').addClass('display-none');
|
|||
|
}
|
|||
|
|
|||
|
if ($result_to_export_crypto > $max_crypto) {
|
|||
|
$('.max-numbers').removeClass('display-none');
|
|||
|
} else {
|
|||
|
$('.max-numbers').addClass('display-none');
|
|||
|
}
|
|||
|
|
|||
|
if ($input_import_cash > $max_cash) {
|
|||
|
$('.max-numbers_cash_red').removeClass('display-none');
|
|||
|
} else {
|
|||
|
$('.max-numbers_cash_red').addClass('display-none');
|
|||
|
}
|
|||
|
|
|||
|
// if ($input_import_cash > $max_cash || $result_to_export_crypto < $min_crypto) {
|
|||
|
// $('.form-btn').attr('disabled', 'disabled');
|
|||
|
// } else {
|
|||
|
// $('.form-btn').removeAttr('disabled');
|
|||
|
// }
|
|||
|
}
|
|||
|
|
|||
|
$('.input_import_cash')
|
|||
|
.add('.input_export_crypto')
|
|||
|
.change(function () {
|
|||
|
$input_import_cash = parseInt($('.input_import_cash').val());
|
|||
|
$input_export_crypto = $('.input_export_crypto').val();
|
|||
|
$code_cash_carrenct = $('.activer_cash_currentcy').children('.code_fact_currency_cash').html();
|
|||
|
|
|||
|
$result_to_export_cash = ($input_export_crypto * $exchange_crypto).toFixed(2);
|
|||
|
$result_to_export_crypto = remove_decimal_places($input_import_cash / $exchange_crypto, decimalPlaces);
|
|||
|
|
|||
|
if ($('.input_import_cash').val() < MIN_CASH || $result_to_export_cash < MIN_CASH) {
|
|||
|
$('.input_import_cash').val(MIN_CASH);
|
|||
|
$('.input_export_crypto').val(remove_decimal_places(MIN_CASH / $exchange_crypto, decimalPlaces));
|
|||
|
}
|
|||
|
if ($('.input_import_cash').val() > MAX_CASH || $result_to_export_cash > MAX_CASH) {
|
|||
|
$('.input_import_cash').val(MAX_CASH);
|
|||
|
$('.input_export_crypto').val(remove_decimal_places(MAX_CASH / $exchange_crypto, decimalPlaces));
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
function keyup_input_crypto() {
|
|||
|
$input_import_cash = parseInt($('.input_import_cash').val());
|
|||
|
$input_export_crypto = $('.input_export_crypto').val();
|
|||
|
|
|||
|
$max_cash_num = Number($max_cash);
|
|||
|
$input_import_cash_num = parseInt($input_import_cash, 2);
|
|||
|
|
|||
|
$code_cash_carrenct = $('.activer_cash_currentcy').children('.code_fact_currency_cash').html();
|
|||
|
|
|||
|
$result_to_export_cash = $input_export_crypto * $exchange_crypto;
|
|||
|
$result_to_export_cash_fixed = $result_to_export_cash.toFixed(2);
|
|||
|
$('.input_import_cash').val($result_to_export_cash_fixed);
|
|||
|
|
|||
|
if ($input_export_crypto < $min_crypto) {
|
|||
|
$('.min-numbers').removeClass('display-none');
|
|||
|
} else {
|
|||
|
$('.min-numbers').addClass('display-none');
|
|||
|
}
|
|||
|
|
|||
|
if ($input_export_crypto > $max_crypto) {
|
|||
|
$('.max-numbers').removeClass('display-none');
|
|||
|
} else {
|
|||
|
$('.max-numbers').addClass('display-none');
|
|||
|
}
|
|||
|
|
|||
|
if ($result_to_export_cash > $max_cash) {
|
|||
|
$('.max-numbers_cash_red').removeClass('display-none');
|
|||
|
} else {
|
|||
|
$('.max-numbers_cash_red').addClass('display-none');
|
|||
|
}
|
|||
|
|
|||
|
// if ($result_to_export_cash > $max_cash || $input_export_crypto < $min_crypto || $input_export_crypto > $max_crypto) {
|
|||
|
// $('.form-btn').attr('disabled', 'disabled');
|
|||
|
// } else {
|
|||
|
// $('.form-btn').removeAttr('disabled');
|
|||
|
// }
|
|||
|
}
|
|||
|
|
|||
|
function order_2_step_render(isFirstRender = false, input_order_id = '') {
|
|||
|
let orderId = input_order_id;
|
|||
|
|
|||
|
if (!isFirstRender) {
|
|||
|
const {
|
|||
|
paymentStepData: { network, numbersOfCoins, renderExpirationTime, order_id },
|
|||
|
} = get_current_step_data();
|
|||
|
|
|||
|
orderId = order_id;
|
|||
|
|
|||
|
payment_timer(renderExpirationTime);
|
|||
|
|
|||
|
$('.wallet_network').text(network);
|
|||
|
$('.summ_for_crypto_carrency').text(numbersOfCoins);
|
|||
|
} else {
|
|||
|
payment_timer();
|
|||
|
|
|||
|
$network_currency_crypto = $('.activer_crypto_currentcy').children('.network_currency_crypto').text();
|
|||
|
$('.wallet_network').text($network_currency_crypto);
|
|||
|
|
|||
|
$summ_for_crypto_carrency = $('.input_export_crypto').val();
|
|||
|
$('.summ_for_crypto_carrency').text($summ_for_crypto_carrency);
|
|||
|
}
|
|||
|
|
|||
|
$number_wallet_cripto = $('.activer_crypto_currentcy').children('.purse_currency_crypto').text();
|
|||
|
|
|||
|
$('.number_wallet_cripto').text($number_wallet_cripto);
|
|||
|
$('.box-step1').addClass('display-none');
|
|||
|
$('.box-step2').removeClass('display-none');
|
|||
|
|
|||
|
const $number_order = document.getElementById('number_order_step2');
|
|||
|
$number_order.textContent = orderId;
|
|||
|
|
|||
|
$xlm_crypto_simbol = $('.step2-input-text').children('.currency_symbol_crypto').text();
|
|||
|
$('.step2-input-memo').addClass('display-none');
|
|||
|
}
|
|||
|
|
|||
|
function order_verification_3_step_render(isFirstRender = false, order_id = '') {
|
|||
|
const $boxStep3 = document.getElementsByClassName('box-step3')[0];
|
|||
|
const $number_order = document.getElementById('number_order_step3');
|
|||
|
|
|||
|
if (!isFirstRender) {
|
|||
|
const {
|
|||
|
paymentStepData: { order_id },
|
|||
|
} = get_current_step_data();
|
|||
|
|
|||
|
const $boxStep1 = document.getElementsByClassName('box-step1')[0];
|
|||
|
|
|||
|
$boxStep1.classList.toggle('display-none');
|
|||
|
$boxStep3.classList.toggle('display-none');
|
|||
|
|
|||
|
$number_order.textContent = order_id;
|
|||
|
} else {
|
|||
|
const $boxStep2 = document.getElementsByClassName('box-step2')[0];
|
|||
|
|
|||
|
$boxStep2.classList.toggle('display-none');
|
|||
|
$boxStep3.classList.toggle('display-none');
|
|||
|
|
|||
|
$number_order.textContent = order_id;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
function Order() {
|
|||
|
if ($('.custom-checkbox').prop('checked')) {
|
|||
|
const [$cryptoInput] = document.getElementsByClassName('input_export_crypto');
|
|||
|
const [$emailInput] = document.getElementsByClassName('email_user_input');
|
|||
|
const [$nameInput] = document.getElementsByClassName('fio_user');
|
|||
|
const [$mobileInput] = document.getElementsByClassName('phone_input');
|
|||
|
const [$walletInput] = document.getElementsByClassName('input_name_wallet_user');
|
|||
|
|
|||
|
const isAlpha = (locale) => validator.isAlpha($nameInput.value, [locale]);
|
|||
|
|
|||
|
const isCryptoNotEmpty = validator.isNumeric($cryptoInput.value);
|
|||
|
const isEmail = validator.isEmail($emailInput.value);
|
|||
|
const isName = (isAlpha('ru-RU') || isAlpha('en-US') || isAlpha('uk-UA')) && $nameInput.value.length >= 3;
|
|||
|
const isMobilePhone = validator.isMobilePhone($mobileInput.value, ['ru-RU', 'uk-UA']);
|
|||
|
const isWalletNotEmpty = !validator.isEmpty($walletInput.value, { ignore_whitespace: true });
|
|||
|
|
|||
|
if (!isCryptoNotEmpty || !isEmail || !isName || !isMobilePhone || !isWalletNotEmpty || isGettingData) {
|
|||
|
$('.informer-required').addClass('display-block');
|
|||
|
|
|||
|
const hiddenContainer = (name, hidden) => (document.getElementById(`container-error-${name}`).hidden = hidden);
|
|||
|
|
|||
|
isCryptoNotEmpty ? hiddenContainer('crypto', true) : hiddenContainer('crypto', false);
|
|||
|
isEmail ? hiddenContainer('email', true) : hiddenContainer('email', false);
|
|||
|
isName ? hiddenContainer('fio', true) : hiddenContainer('fio', false);
|
|||
|
isMobilePhone ? hiddenContainer('phone', true) : hiddenContainer('phone', false);
|
|||
|
isWalletNotEmpty ? hiddenContainer('wallet-user', true) : hiddenContainer('wallet-user', false);
|
|||
|
|
|||
|
return false;
|
|||
|
}
|
|||
|
|
|||
|
$order_id = $order_id || luxon.DateTime.now().ts;
|
|||
|
|
|||
|
const requestData = {
|
|||
|
name: $('.fio_user').val(),
|
|||
|
phone: $('.phone_input').val(),
|
|||
|
email: $('.email_user_input').val(),
|
|||
|
wallet: $('.input_name_wallet_user').val(),
|
|||
|
order_id: $order_id,
|
|||
|
};
|
|||
|
|
|||
|
$.ajax({
|
|||
|
type: 'POST',
|
|||
|
url: '/send.php',
|
|||
|
data: requestData,
|
|||
|
success: function (data) {
|
|||
|
order_2_step_render(true, $order_id);
|
|||
|
|
|||
|
set_currect_step_data(2, {
|
|||
|
...requestData,
|
|||
|
network: $network_currency_crypto,
|
|||
|
numbersOfCoins: $('.input_export_crypto').val(),
|
|||
|
renderExpirationTime: luxon.DateTime.now().plus({ minutes: 60, seconds: 1 }).ts,
|
|||
|
});
|
|||
|
},
|
|||
|
});
|
|||
|
} else {
|
|||
|
$('.informer-required').addClass('display-block');
|
|||
|
$('.left-chek-for-button').addClass('red_border');
|
|||
|
return false;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
//copy wallet
|
|||
|
$(function () {
|
|||
|
// copy content to clipboard
|
|||
|
function copyToClipboard(element) {
|
|||
|
var $temp = $('<input>');
|
|||
|
$('body').append($temp);
|
|||
|
$temp.val($(element).text()).select();
|
|||
|
document.execCommand('copy');
|
|||
|
$temp.remove();
|
|||
|
}
|
|||
|
|
|||
|
// copy coupone code to clipboard
|
|||
|
$('#copy_summ_for_crypto_carrency').on('click', function () {
|
|||
|
copyToClipboard('#summ_crypto_carrency');
|
|||
|
$('.coupon-alert-crypto').addClass('display-block');
|
|||
|
});
|
|||
|
// copy coupone code to clipboard
|
|||
|
$('#copy_wallet_crypto_carrency').on('click', function () {
|
|||
|
copyToClipboard('#wallet_crypto_carrency');
|
|||
|
$('.coupon-alert-number').addClass('display-block');
|
|||
|
});
|
|||
|
// copy coupone code to clipboard
|
|||
|
$('#copy_summ_memo_number').on('click', function () {
|
|||
|
copyToClipboard('#memo_number');
|
|||
|
$('.coupon-alert-memo_number').addClass('display-block');
|
|||
|
});
|
|||
|
// copy coupone code to clipboard
|
|||
|
$('#copy_network').on('click', function () {
|
|||
|
copyToClipboard('#wallet_network');
|
|||
|
$('.coupon-alert_network_number').addClass('display-block');
|
|||
|
});
|
|||
|
});
|
|||
|
|
|||
|
function toExchange() {
|
|||
|
$('#input_1_1').val($order_id); //id_заявки
|
|||
|
$('#input_1_10').val($order_id); //id_заявки
|
|||
|
|
|||
|
$symbol_crypto_single = $('.title-currency-input_crypto').text(); //валюта_которую_продает
|
|||
|
$('#input_1_11').val($symbol_crypto_single); //валюта_которую_продает
|
|||
|
|
|||
|
$input_crypto_single = $('.input_export_crypto').val(); //количество_продаваемой_валюты
|
|||
|
$('#input_1_12').val($input_crypto_single); //количество_продаваемой_валюты
|
|||
|
|
|||
|
$code_cash_carrenct = $('.activer_cash_currentcy').children('.code_fact_currency_cash').html();
|
|||
|
|
|||
|
$('#input_1_18').val($exchange_crypto); //количество_продаваемой_валюты
|
|||
|
|
|||
|
$title_cash_single = $('.title-currency-input_cash').text(); //валюта_которую_покупает
|
|||
|
$('#input_1_13').val($title_cash_single); //валюта_которую_покупает
|
|||
|
|
|||
|
$import_cash_single = $('.input_import_cash').val(); //количество_покупаемой_валюты
|
|||
|
$('#input_1_14').val($import_cash_single); //количество_покупаемой_валюты
|
|||
|
|
|||
|
$name_wallet_user_single = $('.input_name_wallet_user').val(); //номер_счета_на_который_хочет_получить_перевод
|
|||
|
$('#input_1_15').val($name_wallet_user_single); //номер_счета_на_который_хочет_получить_перевод
|
|||
|
|
|||
|
$email_user_input_single = $('.email_user_input').val(); //email_пользователя
|
|||
|
$('#input_1_16').val($email_user_input_single); //email_пользователя
|
|||
|
$('#input_1_19').val($email_user_input_single); //email_пользователя_для_отправки_уведомлений
|
|||
|
|
|||
|
$fio_user_single = $('.fio_user').val(); //фио_получателя
|
|||
|
$('#input_1_17').val($fio_user_single); //фио_получателя
|
|||
|
|
|||
|
$memo_number_single = $('.memo_number').text(); //number memo
|
|||
|
$('#input_1_20').val($memo_number_single); //number memo
|
|||
|
|
|||
|
Swal.fire({
|
|||
|
title: 'Вы точно перевели?',
|
|||
|
icon: 'question',
|
|||
|
showCancelButton: true,
|
|||
|
confirmButtonColor: '#3085d6',
|
|||
|
cancelButtonColor: '#d33',
|
|||
|
confirmButtonText: 'Да',
|
|||
|
cancelButtonText: 'Нет',
|
|||
|
}).then((result) => {
|
|||
|
if (result.isConfirmed) {
|
|||
|
$('.informer-required2').removeClass('display-block');
|
|||
|
// window.location.href = 'https://cryptofonia.com/block-explorers/';
|
|||
|
order_verification_3_step_render(true, $order_id);
|
|||
|
|
|||
|
remove_current_step_data();
|
|||
|
set_currect_step_data(3, {
|
|||
|
order_id: $order_id,
|
|||
|
renderExpirationTime: luxon.DateTime.now().plus({ minutes: 60 }).ts,
|
|||
|
});
|
|||
|
} else {
|
|||
|
$('.informer-required2').addClass('display-block');
|
|||
|
return false;
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
// $('#gform_submit_button_1').trigger('click');
|
|||
|
}
|
|||
|
|
|||
|
$('#step2-btn').click(toExchange);
|
|||
|
$('#step1-btn').click(Order);
|
|||
|
$('.input_export_crypto').keyup(keyup_input_crypto);
|
|||
|
$('.input_import_cash').keyup(keyup_input_cash);
|
|||
|
$('.post-currency-for-input_cash').click(click_post_currency_cash);
|
|||
|
$('.post-currency-for-input_crypto').click(click_post_currency_crypto);
|
|||
|
|
|||
|
// if ($('.status_order').length) {
|
|||
|
// // делаем здесь что-то
|
|||
|
// $status_order = $('.status_order').text();
|
|||
|
// $status_order_num = Number($status_order);
|
|||
|
|
|||
|
// if ($status_order_num == 1) {
|
|||
|
// $('.step_exchange').removeClass('active_step_exchange');
|
|||
|
// $('.step_exchange').addClass('complite_step_exchange');
|
|||
|
// $('.list_step').removeClass('complite_step_exchange');
|
|||
|
// $('.list_step').addClass('active_step_exchange');
|
|||
|
// $('.step_3').addClass('display-none');
|
|||
|
// $('.step_4').removeClass('display-none');
|
|||
|
// } else {
|
|||
|
// }
|
|||
|
// }
|
|||
|
});
|
|||
|
|
|||
|
$(document).ready(function () {
|
|||
|
$('#feedback-top-modal-form-order-call-back').submit(function (event) {
|
|||
|
event.preventDefault();
|
|||
|
$.ajax({
|
|||
|
url: '/wp-content/themes/burum/order-callback.php',
|
|||
|
beforeSend: function () {
|
|||
|
$('.load').fadeIn(400);
|
|||
|
},
|
|||
|
type: 'post',
|
|||
|
data: $('#feedback-top-modal-form-order-call-back').serialize(),
|
|||
|
success: function (answer) {
|
|||
|
$('#answer-top-modal-form-order-call-back').html(answer);
|
|||
|
},
|
|||
|
}).done(function () {
|
|||
|
$('.load').fadeOut(400);
|
|||
|
$('.reset-input').val('');
|
|||
|
setTimeout(function () {
|
|||
|
$('.modal-form').removeClass('display-block');
|
|||
|
$('#answer-top-modal-form-order-call-back').addClass('display-block');
|
|||
|
}, 1);
|
|||
|
setTimeout(function () {
|
|||
|
$('#answer-top-modal-form-order-call-back, .hover-site').removeClass('display-block');
|
|||
|
}, 3000);
|
|||
|
});
|
|||
|
});
|
|||
|
|
|||
|
$('.order-catalog-name-product').click(function () {
|
|||
|
var nameProduct = $(this).attr('data-name'); //записываем название товара для вывода в форме
|
|||
|
$('input[name=name_product]').val(nameProduct);
|
|||
|
});
|
|||
|
|
|||
|
$('.phone-mask').mask('+999999999999');
|
|||
|
$('.wpcf7-submit').addClass('button-order');
|
|||
|
$('.wpcf7-submit').addClass('button-order-monitor1');
|
|||
|
|
|||
|
document.addEventListener(
|
|||
|
'wpcf7mailsent',
|
|||
|
function (event) {
|
|||
|
if ('189' == event.detail.contactFormId) {
|
|||
|
setTimeout(function () {
|
|||
|
$('.modal-form').removeClass('display-block');
|
|||
|
$('#answer-modal-form-ok, .hover-site').addClass('display-block');
|
|||
|
}, 1);
|
|||
|
setTimeout(function () {
|
|||
|
$('#answer-modal-form-ok, .hover-site').removeClass('display-block');
|
|||
|
}, 3000);
|
|||
|
// Делаем ещё что-нибудь
|
|||
|
}
|
|||
|
},
|
|||
|
false
|
|||
|
);
|
|||
|
});
|
|||
|
|
|||
|
//mobil
|
|||
|
$(document).ready(function () {
|
|||
|
$('.mobile-menu').slideUp(10);
|
|||
|
$('.open-mobile-menu').click(function () {
|
|||
|
$('.mobile-menu').slideDown(300);
|
|||
|
$('.hover-site').addClass('display-block');
|
|||
|
$('.open-mobile-menu').addClass('display-none');
|
|||
|
$('.close-mobile-menu').addClass('display-flex');
|
|||
|
});
|
|||
|
$('.close-mobile-menu, .hover-site').click(function () {
|
|||
|
$('.mobile-menu').slideUp(300);
|
|||
|
$('.hover-site').removeClass('display-block');
|
|||
|
$('.open-mobile-menu').removeClass('display-none');
|
|||
|
$('.close-mobile-menu').removeClass('display-flex');
|
|||
|
});
|
|||
|
});
|
|||
|
//box-before-header
|
|||
|
$(document).ready(function () {
|
|||
|
setTimeout(function () {
|
|||
|
var heightHeder = $('.header').height();
|
|||
|
var heightWindow = $(window).height();
|
|||
|
|
|||
|
$('.box-before-header').css({
|
|||
|
'padding-top': heightHeder + 'px',
|
|||
|
});
|
|||
|
|
|||
|
$('.mobile-menu').css({
|
|||
|
top: heightHeder + 'px',
|
|||
|
'max-height': heightWindow - heightHeder + 'px',
|
|||
|
'overflow-y': 'auto',
|
|||
|
});
|
|||
|
}, 100);
|
|||
|
});
|
|||
|
//menu
|
|||
|
$(document).ready(function () {
|
|||
|
$('li.menu-item-has-children').addClass('arrow-bottom');
|
|||
|
$('li.menu-item-has-children').children('ul').slideUp(0);
|
|||
|
$('li.menu-item-has-children').children('ul').addClass('children-ul');
|
|||
|
$('li.menu-item-has-children').hover(
|
|||
|
function () {
|
|||
|
$(this).removeClass('arrow-bottom');
|
|||
|
$(this).addClass('arrow-top');
|
|||
|
$(this).children('ul').slideDown(250);
|
|||
|
},
|
|||
|
function () {
|
|||
|
$(this).addClass('arrow-bottom');
|
|||
|
$(this).removeClass('arrow-top');
|
|||
|
$(this).children('ul').slideUp(250);
|
|||
|
}
|
|||
|
);
|
|||
|
|
|||
|
//модальное окно всплывающее при прокрутке
|
|||
|
$(window).scroll(function () {
|
|||
|
if ($(window).scrollTop() >= '1500') {
|
|||
|
if ($('.modal-form-popap-avto').hasClass('scroll-tab')) {
|
|||
|
setTimeout(function () {
|
|||
|
$('.modal-form-popap-avto').removeClass('scroll-tab');
|
|||
|
$('.modal-form-popap-avto').addClass('display-block');
|
|||
|
$('.hover-site').addClass('display-block');
|
|||
|
}, 3000);
|
|||
|
}
|
|||
|
}
|
|||
|
});
|
|||
|
});
|