Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- case 'DATA':
- var packet = actions.data;
- if (undefined !== packet[packet.gamerecord.type] &&
- undefined !== packet[packet.gamerecord.type].h &&
- undefined !== packet[packet.gamerecord.type].h[0] &&
- undefined !== packet[packet.gamerecord.type].h[0].t) {
- var boughtTicketsLength = packet[packet.gamerecord.type].h[0].t.length; // bought tickets length
- state.bought_tickets = boughtTicketsLength;
- //if have new tickets in boughtTickets wrapper
- if (state.oldTicketsPacket < boughtTicketsLength) {
- var balance = Number(actions.data.greeno.h[0].balance);
- var price = actions.data.greeno.h[0].template[actions.data.currencyid]
- state.buy_btn_enable = false;
- // ends loading screen
- new Promise(function (resolve, reject) {
- setTimeout(function () {
- state.buy_btn_enable = false;
- $(".btn-buy").addClass("btn-buy--inactive")
- resolve($.unblockUI());
- }, 0);
- }).then(function (value) {
- state.buy_btn_enable = price <= balance && price !== 0;
- });
- if (history2.checkVisability() && state.boughtHistoryTickets) { //used only when tickets are bought in history screen
- hist_helper.closeHistoryModal(); // when in history close it and run the aniamtion
- state.boughtHistoryTickets = false;
- }
- if (state.flyingTicketsCounter === 1) { //if button clicked
- state.boughtHistoryTickets = false;
- if (state.show_15_tickets === 1) {
- // state.ticketsCount = $('#tickets_container_premade .ktbought.ticketsStyle:visible').length;
- state.random_tickets = []; //empty premade tickets screen
- runTicketsAnimation(); // run animation
- update_buy_btn_enable(state);
- // Stays for little because tickets are shown too early
- // $('.kbought_wrapper .ktbought').fadeIn(3200);
- $('.kbought_wrapper').find('.ktbought').fadeIn(3200);
- state.flyingTicketsCounter = 0; // resets counter for flying animation on 15 tickets
- } else {
- // state.ticketsCount = 1;
- runTicketsAnimation(); // run animation for flying tickets
- var num_length = gamesConfig.gameNumbers[gametype]
- var num_cnt = gamesConfig.gameNumbersSelectedConfig[gametype] //check the type of game so the generated nums will match the type of game
- // var cell = actions.data;
- var array = []; //fill this array with the generated numbers
- if (state.show_15_tickets != 1) {
- for (var i = 1; i <= num_length; i++) {
- array.push(i);
- state.manual_ticket.selected[i - 1][0] = false;
- state.manual_ticket.selected[i - 1][1] = 0;
- }
- var shuffled = extra.array_shuffle(array);
- for (var i = 0; i < num_cnt; i++) {
- state.manual_ticket.selected[shuffled[i] - 1][0] = true;
- let incrementBy = (num_cnt - 1 === i) ? 2 : 1;
- state.manual_ticket.selected[shuffled[i] - 1][1] = state.incrementSelected + incrementBy;
- }
- state.manual_ticket.num_selected = num_cnt;
- }
- if (state.manual_ticket.num_selected >= num_cnt) {
- state.buy_btn_enable = true;
- }
- update_buy_btn_enable(state);
- state.flyingTicketsCounter = 0; // resets counter for flying animation on 1 ticket
- }
- }
- }
- state.totalPages_prev_next = Math.ceil(boughtTicketsLength / 5); //show 5 bought tickets on one page
- state.totalPages_up_down = Math.ceil(state.random_tickets.length / 15); //show only 15 generated tickets on one page in BP state
- state.totalPages_up_down_nmb = Math.ceil(boughtTicketsLength / 15); //show only 15 tickets on one page in NMB state
- //set starting index from one for each pagination
- if (state.totalPages_prev_next === 0) {
- state.totalPages_prev_next = 1;
- }
- if (state.totalPages_up_down === 0) {
- state.totalPages_up_down = 1;
- }
- if (state.totalPages_up_down_nmb === 0) {
- state.totalPages_up_down_nmb = 1;
- }
- state.buy_btn_enable = false;
- }
- state.buy_btn_enable = false;
- set_currency(packet.currency); // save it global
- return state;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement