From 6efa7ae5ae6229cb2fcba52ee051a36ec60a98bb Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Fri, 20 Sep 2024 04:13:12 +0000 Subject: [PATCH] Update content of files --- data/web/fragment.com/js/auction.js | 157 +++++++++++++++++++++++++++- 1 file changed, 156 insertions(+), 1 deletion(-) diff --git a/data/web/fragment.com/js/auction.js b/data/web/fragment.com/js/auction.js index dd5664eda0..5498409e47 100644 --- a/data/web/fragment.com/js/auction.js +++ b/data/web/fragment.com/js/auction.js @@ -2930,7 +2930,7 @@ var Stars = { updateOptions: function(html) { var $form = Aj.state.$starsSearchForm; var stars = $form.field('stars').value(); - $('.js-premium-options').replaceWith(html); + $('.js-stars-options').replaceWith(html); $form.field('stars').value(stars); }, eBuyStars: function(e) { @@ -3112,6 +3112,161 @@ 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: '' + result.amount + '' + }), + 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({