Update content of files

This commit is contained in:
GitHub Action 2024-09-19 16:52:54 +00:00
parent 720360b177
commit 0ddefe562d

View file

@ -2930,7 +2930,7 @@ var Stars = {
updateOptions: function(html) {
var $form = Aj.state.$starsSearchForm;
var stars = $form.field('stars').value();
$('.js-stars-options').replaceWith(html);
$('.js-premium-options').replaceWith(html);
$form.field('stars').value(stars);
},
eBuyStars: function(e) {
@ -3112,161 +3112,6 @@ var Stars = {
}
};
var Gateway = {
init: function() {
Aj.onLoad(function(state) {
var cont = Aj.ajContainer;
$(cont).on('click.curPage', '.js-howtopay-ton', Ads.eHowToPayTon);
state.$howToPayTonPopup = $('.js-how-to-pay-ton-popup');
$(cont).on('click.curPage', '.js-more-funds-btn', Gateway.eAddMoreFunds);
$(cont).on('click.curPage', '.js-recharge-btn', Gateway.eRechargeAccount);
state.$rechargeForm = $('.js-recharge-form', cont);
Main.initForm(state.$rechargeForm);
state.$rechargeForm.on('submit', Gateway.eAmountChanged);
state.$curPrice = $('.js-cur-price', cont);
state.$amountField = $('.js-credits-quantity-field');
$(cont).on('click.curPage', '.js-quantity-clear', Gateway.eQuantityClear);
state.$rechargeForm.field('credits').on('change', Gateway.eAmountChanged);
state.updLastReq = +Date.now();
if (state.needUpdate) {
state.updStateTo = setTimeout(Gateway.updateState, Main.UPDATE_PERIOD);
}
});
Aj.onUnload(function(state) {
clearTimeout(state.updStateTo);
state.needUpdate = false;
Main.destroyForm(state.$rechargeForm);
state.$rechargeForm.field('credits').off('change', Gateway.eAmountChanged);
});
},
eHowToPayTon: function(e) {
e.preventDefault();
e.stopImmediatePropagation();
Main.openSimplePopup(Aj.state.$howToPayTonPopup);
},
updateState: function(force) {
var now = +Date.now();
if (document.hasFocus() || force ||
Aj.state.updLastReq && (now - Aj.state.updLastReq) > Main.FORCE_UPDATE_PERIOD) {
var $form = Aj.state.$rechargeForm;
var account = $form.field('account').value();
var credits = Main.amountFieldValue($form, 'credits');
Aj.state.updLastReq = now;
Aj.apiRequest('updateGatewayRechargeState', {
mode: Aj.state.mode,
account: account,
credits: credits
}, function(result) {
if (result.mode) {
Aj.state.mode = result.mode;
}
if (result.html) {
Gateway.updateContent(result.html);
}
if (result.cur_price) {
Aj.state.$curPrice.html(result.cur_price);
}
if (Aj.state.needUpdate && result.need_update) {
Aj.state.updStateTo = setTimeout(Gateway.updateState, Main.UPDATE_PERIOD);
}
});
} else {
if (Aj.state.needUpdate) {
Aj.state.updStateTo = setTimeout(Gateway.updateState, Main.CHECK_PERIOD);
}
}
},
eQuantityClear: function() {
Gateway.clearQuantity(true);
},
clearQuantity: function(need_focus) {
var $form = Aj.state.$rechargeForm;
var $field = $form.field('credits');
$field.value('');
if (need_focus) {
$field.focus();
}
Aj.state.$curPrice.html('');
Gateway.updateButton();
},
eAmountChanged: function(e) {
e.stopImmediatePropagation();
e.preventDefault();
var $form = Aj.state.$rechargeForm;
var account = $form.field('account').value();
var credits = +$form.field('credits').value();
Aj.state.$curPrice.html('');
Aj.state.$amountField.addClass('loading').removeClass('play').redraw().addClass('play');
Aj.apiRequest('updateGatewayPrices', {
account: account,
credits: credits
}, function(result) {
Aj.state.$amountField.removeClass('loading');
if (result.error) {
return showAlert(result.error);
}
Aj.state.$curPrice.html(result.cur_price);
Gateway.updateButton();
});
},
updateButton: function() {
},
eRechargeAccount: function(e) {
e.stopImmediatePropagation();
e.preventDefault();
var $form = Aj.state.$rechargeForm;
var account = $form.field('account').value();
var credits = Main.amountFieldValue($form, 'credits');
if (credits === false || credits <= 0) {
$form.field('credits').focus();
return;
}
Aj.apiRequest('initGatewayRechargeRequest', {
account: account,
credits: credits
}, function(result) {
if (result.error) {
return showAlert(result.error);
}
Wallet.sendTransaction({
request: {
method: 'getGatewayRechargeLink',
params: {
id: result.req_id
}
},
title: l('WEB_POPUP_QR_GATEWAY_HEADER'),
description: l('WEB_POPUP_QR_GATEWAY_TEXT', {
amount: '<span class="icon-before icon-ton-text js-amount_fee">' + result.amount + '</span>'
}),
qr_label: result.item_title,
tk_label: l('WEB_POPUP_QR_GATEWAY_TK_BUTTON'),
terms_label: l('WEB_POPUP_QR_PROCEED_TERMS'),
onConfirm: function(by_server) {
Gateway.updateState(true);
}
});
Aj.state.needUpdate = true;
});
},
eAddMoreFunds: function(e) {
e.preventDefault();
e.stopImmediatePropagation();
var href = this.href;
Aj.apiRequest('repeatGatewayAddFunds', {}, function(result) {
if (result.error) {
return showAlert(result.error);
}
Aj.location(href);
});
},
updateContent: function(html) {
$('.js-main-content').html(html);
}
};
var QR = {
showPopup: function(options) {
options = $.extend({