Advertisement
Guest User

Untitled

a guest
Sep 26th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.54 KB | None | 0 0
  1. case 'DATA':
  2. var packet = actions.data;
  3.  
  4. if (undefined !== packet[packet.gamerecord.type] &&
  5. undefined !== packet[packet.gamerecord.type].h &&
  6. undefined !== packet[packet.gamerecord.type].h[0] &&
  7. undefined !== packet[packet.gamerecord.type].h[0].t) {
  8. var boughtTicketsLength = packet[packet.gamerecord.type].h[0].t.length; // bought tickets length
  9. state.bought_tickets = boughtTicketsLength;
  10.  
  11. //if have new tickets in boughtTickets wrapper
  12. if (state.oldTicketsPacket < boughtTicketsLength) {
  13.  
  14. var balance = Number(actions.data.greeno.h[0].balance);
  15. var price = actions.data.greeno.h[0].template[actions.data.currencyid]
  16. state.buy_btn_enable = false;
  17.  
  18. // ends loading screen
  19.  
  20. new Promise(function (resolve, reject) {
  21. setTimeout(function () {
  22. state.buy_btn_enable = false;
  23. $(".btn-buy").addClass("btn-buy--inactive")
  24. resolve($.unblockUI());
  25. }, 0);
  26. }).then(function (value) {
  27. state.buy_btn_enable = price <= balance && price !== 0;
  28. });
  29.  
  30.  
  31. if (history2.checkVisability() && state.boughtHistoryTickets) { //used only when tickets are bought in history screen
  32. hist_helper.closeHistoryModal(); // when in history close it and run the aniamtion
  33. state.boughtHistoryTickets = false;
  34. }
  35.  
  36. if (state.flyingTicketsCounter === 1) { //if button clicked
  37. state.boughtHistoryTickets = false;
  38.  
  39. if (state.show_15_tickets === 1) {
  40.  
  41. // state.ticketsCount = $('#tickets_container_premade .ktbought.ticketsStyle:visible').length;
  42. state.random_tickets = []; //empty premade tickets screen
  43. runTicketsAnimation(); // run animation
  44. update_buy_btn_enable(state);
  45. // Stays for little because tickets are shown too early
  46. // $('.kbought_wrapper .ktbought').fadeIn(3200);
  47. $('.kbought_wrapper').find('.ktbought').fadeIn(3200);
  48.  
  49. state.flyingTicketsCounter = 0; // resets counter for flying animation on 15 tickets
  50.  
  51. } else {
  52. // state.ticketsCount = 1;
  53. runTicketsAnimation(); // run animation for flying tickets
  54. var num_length = gamesConfig.gameNumbers[gametype]
  55. var num_cnt = gamesConfig.gameNumbersSelectedConfig[gametype] //check the type of game so the generated nums will match the type of game
  56.  
  57. // var cell = actions.data;
  58. var array = []; //fill this array with the generated numbers
  59. if (state.show_15_tickets != 1) {
  60. for (var i = 1; i <= num_length; i++) {
  61. array.push(i);
  62. state.manual_ticket.selected[i - 1][0] = false;
  63. state.manual_ticket.selected[i - 1][1] = 0;
  64. }
  65. var shuffled = extra.array_shuffle(array);
  66. for (var i = 0; i < num_cnt; i++) {
  67. state.manual_ticket.selected[shuffled[i] - 1][0] = true;
  68. let incrementBy = (num_cnt - 1 === i) ? 2 : 1;
  69. state.manual_ticket.selected[shuffled[i] - 1][1] = state.incrementSelected + incrementBy;
  70. }
  71. state.manual_ticket.num_selected = num_cnt;
  72. }
  73. if (state.manual_ticket.num_selected >= num_cnt) {
  74. state.buy_btn_enable = true;
  75. }
  76.  
  77. update_buy_btn_enable(state);
  78. state.flyingTicketsCounter = 0; // resets counter for flying animation on 1 ticket
  79. }
  80. }
  81. }
  82.  
  83. state.totalPages_prev_next = Math.ceil(boughtTicketsLength / 5); //show 5 bought tickets on one page
  84. state.totalPages_up_down = Math.ceil(state.random_tickets.length / 15); //show only 15 generated tickets on one page in BP state
  85. state.totalPages_up_down_nmb = Math.ceil(boughtTicketsLength / 15); //show only 15 tickets on one page in NMB state
  86. //set starting index from one for each pagination
  87. if (state.totalPages_prev_next === 0) {
  88. state.totalPages_prev_next = 1;
  89. }
  90. if (state.totalPages_up_down === 0) {
  91. state.totalPages_up_down = 1;
  92. }
  93. if (state.totalPages_up_down_nmb === 0) {
  94. state.totalPages_up_down_nmb = 1;
  95. }
  96.  
  97. state.buy_btn_enable = false;
  98.  
  99. }
  100. state.buy_btn_enable = false;
  101.  
  102. set_currency(packet.currency); // save it global
  103.  
  104. return state;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement