Guest User

Untitled

a guest
Jul 16th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 34.07 KB | None | 0 0
  1. import * as extra from './extra.js';
  2. import {
  3. gamesConfig
  4. } from './game_config'
  5. import {
  6. resizeConfig
  7. } from './resizeConfig'
  8. import {
  9. store,
  10. state,
  11. keno_games,
  12. gametype,
  13. keno_fill_hits_and_sortorder,
  14. ps,
  15. ticketThings,
  16. render_bh_tickets,
  17. update_buy_btn_enable,
  18. startAnimation,
  19. } from './keno.js';
  20. import {
  21. history2
  22. } from './history_2.js'
  23. // import {
  24. // resizeSplits
  25. // } from './keno_prizes_table.js'
  26. import {
  27. initialize
  28. } from './initialize.js'
  29. import * as keno_slider from './keno_slider_2.js';
  30. import * as bought_tickets from './bought_tickets.js';
  31. import * as theme from "./theme";
  32. import * as b_tickets from "./bought_tickets";
  33. import {
  34. get
  35. } from 'https';
  36.  
  37.  
  38. const sprintf = require('sprintf').sprintf;
  39.  
  40.  
  41. const hist_helper = {
  42. url: {
  43. getAllGames: '',
  44. },
  45.  
  46. gameNumbers: [],
  47. historyData: [],
  48. gameData: [],
  49. allTicketsHistory: [],
  50. historyBalls: [],
  51. firstPageTickets: [],
  52.  
  53. firstPage: '',
  54. shownPage: '',
  55. historyGamesCounter: '',
  56.  
  57. leftArrow: '#previousGame',
  58. rightArrow: '#nextGame',
  59. closeBtn: '#closeButton',
  60. historyBtn: '#repeatButton',
  61. openModal: '.btnRepeat',
  62. history_actions: {
  63. drag_pager: 'HISTORY_DRAG',
  64. up_btn: 'HISTORY_UP',
  65. down_btn: 'HISTORY_DOWN',
  66. up_scroll: 'HISTORY_UP_SCROLL'
  67. },
  68. couterForRecursion: 0,
  69. renderPageCounter: 0,
  70. animationInvoke: false,
  71. /* initialize modal html, start it hidden*/
  72. init() {
  73. this.historyModal();
  74. this.test1(); //FIXME
  75. },
  76. /* Getting proper URL thanks to proper game id and session id we took from getHistPacket function in keno.js*/
  77. concatUrl(gameId, sessionId) {
  78. this.url.getAllGames = 'https://' + window.location.hostname + ':8150/support/allGames/' + gameId + '/' + sessionId;
  79. },
  80. /* Getting game numbers in array for easier search from first page to last page */
  81. getGameNumbers(gameId, sessionId) {
  82. this.concatUrl(gameId, sessionId);
  83. const allGameNumbers = extra.getData(this.url.getAllGames);
  84. const repeatBtn = $('.btnRepeat');
  85. const repeatBtn2 = $('.kbtn_history');
  86.  
  87. allGameNumbers.then((gameNumbers) => {
  88.  
  89. if (gameNumbers.success === undefined) {
  90. console.error('There was an error in the Statistics. the Error was: ');
  91. console.error(gameNumbers.error);
  92. return
  93. }
  94.  
  95. repeatBtn.removeClass('btnRepeat_disabled');
  96. repeatBtn2.removeClass('btnRepeat_disabled2');
  97.  
  98. // console.log(gameNumbers.success[0] === undefined);
  99. // if (!gameNumbers.success) return console.error(gameNumbers.error);
  100. this.gameNumbers = gameNumbers.success.map((number) => number.gamenumber);
  101. this.firstPage = this.gameNumbers[0];
  102.  
  103. if (gameNumbers.success.length === 0) {
  104. repeatBtn.addClass('btnRepeat_disabled');
  105. repeatBtn2.addClass('btnRepeat_disabled2');
  106. return;
  107. }
  108.  
  109. this.renderPage(this.firstPage);
  110. }).always(() => {
  111. $.unblockUI(); // stop loading screen -> packet is here
  112. }).fail(() => { //jqXHR, textStatus, errorThrown
  113. if (this.couterForRecursion < 2) {
  114. this.couterForRecursion++;
  115. setTimeout(() => this.getGameNumbers(gameId, sessionId), 1000);
  116. }
  117.  
  118. repeatBtn.addClass('btnRepeat_disabled');
  119. repeatBtn2.addClass('btnRepeat_disabled2');
  120. console.error('History data error... Please try again later!');
  121. });
  122. },
  123. getFirstPageTickets() {
  124. this.renderPage(this.firstPage);
  125. },
  126. /* Getting the main data for the correct gameNumber */
  127. renderPage(gameNumber) {
  128. const route = this.url.getAllGames + '/' + gameNumber;
  129. const firstPage = extra.getData(route);
  130. const repeatBtn = $('.btnRepeat');
  131. const repeatBtn2 = $('.kbtn_history');
  132. const ls = store.getState().localstate;
  133.  
  134. firstPage.then((gameData) => {
  135. // if (!gameData.success) return console.error(gameData.error);
  136. repeatBtn.removeClass('btnRepeat_disabled');
  137. repeatBtn2.removeClass('btnRepeat_disabled2');
  138. this.gameData = gameData.success[0];
  139.  
  140. /*fill tickets from gameDATA*/
  141. this.allTicketsHistory = this.fillAllTickets(this.gameData).slice();
  142.  
  143. if (gameNumber === this.firstPage) this.firstPageTickets = this.allTicketsHistory; //for repeat one game btn
  144.  
  145. if (history2.checkVisability()) {
  146. ls.random_tickets = this.allTicketsHistory;
  147. ls.totalPages_up_down = Math.ceil(ls.random_tickets.length / 15);
  148. update_buy_btn_enable(ls);
  149. }
  150.  
  151. this.historyBalls = extra.jp(this.gameData.balls);
  152. const ballPositions = (gametype === gamesConfig.keno_games.KENO535) ? 0 : 1; //set 5 or 6 balls depending on gametype (try to unify for as one pram from config);
  153.  
  154. /*Needed for slider and user interaction, when click arrow to give you the right tickets, grey purchase button
  155. if you have sum of over 10,000 tickets (bought + purchased), update of buyBtn and resize html of the tickets*/
  156. store.dispatch({
  157. type: "NEW_HISTORY_GAME"
  158. });
  159.  
  160. this.clearPanelHits();
  161.  
  162. this.renderHits(this.historyBalls); //render hits in panelHitsHistory, (move panelHitsRener function to this file);
  163.  
  164. this.renderPrizesRows(); //render prizes 3-4 rowsdepending on gametype, (try to pass it as parame);
  165.  
  166. this.render_modal_tickets();
  167.  
  168. this.renderBalls(this.gameData.balls, ballPositions); // render balls for displayed game, (ballPositions param is generated above);
  169.  
  170. this.historyTextFill(); // function to fill game info in coresponding panel: win, bet, tickets, ticket price
  171.  
  172. }).always(() => {
  173. $.unblockUI(); // stop loading screen => packet is here
  174. }).fail(() => { //jqXHR, textStatus, errorThrown
  175.  
  176. if (this.renderPageCounter < 2) {
  177. this.renderPageCounter++;
  178. setTimeout(() => this.renderPage(gameNumber), 1000);
  179. }
  180.  
  181. repeatBtn.addClass('btnRepeat_disabled');
  182. repeatBtn2.addClass('btnRepeat_disabled2');
  183. // console.warn("You don't have data, please make a game.");
  184. });
  185. },
  186. /* Fills array with the structure of tickets to help them render when you try to purchase them in premadeTickets Screen*/
  187. fillAllTickets(gameData) {
  188. const allTickets = [];
  189. gameData.playerTickets.map((ticketData) => {
  190. allTickets.push({
  191. data: extra.js(ticketData.ticket),
  192. id: parseInt(ticketData.id),
  193. cnt: ticketData.cnt,
  194. });
  195. });
  196. return allTickets;
  197. },
  198.  
  199. renderHits(balls) {
  200. balls.map((e) => {
  201. const hitCell = $(".panel-hits-hist__cell" + e);
  202.  
  203. if (!hitCell.hasClass("panel-hits__cell-hit")) {
  204. hitCell.addClass("panel-hits__cell-hit");
  205. }
  206. });
  207. },
  208.  
  209. clearPanelHits() {
  210. const panelHitCells = $('#panelHitsHistory').find('.panel-hits__cell');
  211. if (panelHitCells.hasClass('panel-hits__cell-hit')) panelHitCells.removeClass('panel-hits__cell-hit');
  212. },
  213.  
  214. test1() { //FIXME INVOKING SLIDER, RENAME ME
  215. this.historyGamesCounter = this.gameNumbers[0];
  216. const ticketsContainer = $("#ticketsContainer");
  217.  
  218. new keno_slider.KenoSlider(ticketsContainer, 'history');
  219.  
  220. },
  221. /* Create transparent div, behind modal */
  222. creatTransparentDiv() {
  223. const transparentDiv = $('<div class="transparentDiv" ></div>');
  224. $('.game_keno').append(transparentDiv);
  225. },
  226. /* Remove transparent div, behind modal */
  227. removeTransparentDiv() {
  228. $('.transparentDiv').remove();
  229. },
  230.  
  231. changeFontSizeTitle() {
  232. const priceTitle = $('#ticketPriceTitle');
  233. const lang = theme.get();
  234. const priceTitleObj = {
  235. 8: "1.5vw",
  236. 13: "1.5vw",
  237. 15: "1.5vw",
  238. 16: "1.3vw"
  239. }
  240. const priceTitleLang = {
  241. 'bg': '1.35vw',
  242. 'ru': '1vw',
  243. 'ua': '1.2vw'
  244. };
  245.  
  246. extra.changeFontSize(priceTitle, priceTitleObj);
  247.  
  248. if (navigator.userAgent.match(/Android/i) && $(window).width() == 798) {
  249. priceTitle.css('font-size', priceTitleLang[lang]);
  250. }
  251. },
  252.  
  253. /* Fill divs in modal with proper text (data) */
  254. historyTextFill() {
  255. const gameData = this.gameData;
  256. const gameNumbers = this.gameNumbers;
  257. const currencyText = gameData.units[this.gameData.currencyid];
  258. const parsedTickedPrice = extra.jp(gameData.ticketprice);
  259. const ticketPrice = parsedTickedPrice[gameData.currencyid] * gameData.tickets;
  260. const winText = gameData.win / extra.jp(gameData.conv)[gameData.currencyid];
  261.  
  262. // new history modal data fill
  263. /* Win - START */
  264. // const winTitle = $('#winTitle');
  265. // const winTitleObj = {
  266. // 3: "3vw",//win
  267. // 6: "2.4vw",//виграш
  268. // 7: "2.2vw",//печалба, выигрыш
  269. // // 9: "1.9vw"//
  270. // }
  271. // extra.changeFontSize(winTitle, winTitleObj);
  272.  
  273. const win = $('#winValue')
  274. const winObj = {
  275. // length of winValue + currency
  276. 7: "3vw",
  277. 8: "3vw",
  278. 9: "3vw",
  279. 10: "3vw",
  280. 11: "2.6vw",
  281. 12: "2.4vw",
  282. 13: "2.2vw",
  283. 14: "2vw",
  284. 15: "1.8vw",
  285. // 13: "2.7vw",
  286. // 14: "2.6vw"
  287. }
  288. win.text(extra.moneyStyleSmallCurrencyID(winText, win, currencyText));
  289. extra.changeFontSize(win, winObj);
  290. /* Win - END */
  291.  
  292. /* Bet - START */
  293. // const betTitle = $('#betTitle');
  294. // const betTitleObj = {
  295. // 3: "3vw",
  296. // 5:"3vw",
  297. // 6: "2.8vw",
  298. // 7: "2.6vw",
  299. // 8: "2.6vw",
  300. // 14: "2.2vw"
  301. // }
  302. // extra.changeFontSize(betTitle, betTitleObj);
  303.  
  304. const bet = $('#betValue');
  305. const betObj = {
  306. 7: "3vw",
  307. 8: "3vw",
  308. 9: "3vw",
  309. 10: "3vw",
  310. 11: "2.6vw",
  311. 12: "2.4vw",
  312. 13: "2.2vw",
  313. 14: "2vw",
  314. 15: "1.8vw",
  315. }
  316. bet.text(extra.moneyStyleSmallCurrencyID(ticketPrice, $('#betValue'), currencyText));
  317. extra.changeFontSize(bet, betObj);
  318.  
  319. global.change_bet_size = extra.changeFontSize(bet, betObj);
  320. /* Bet - END */
  321.  
  322.  
  323. // Change title font-size on Samsung S8 for BG, RU, UA
  324. this.changeFontSizeTitle();
  325.  
  326.  
  327. $('#ticketsValue').text(gameData.tickets);
  328. $('#ticketPriceValue').text(extra.moneyStyleSmallCurrencyID(parsedTickedPrice[gameData.currencyid], $('#ticketPriceValue'), currencyText));
  329. $('#gameIdValue').text(gameData.id);
  330. $('#dateInfo').text(gameData.gamestart);
  331. $('#pageInfo').text((store.getState().localstate.hisotryPageCounter + 1) + '/' + this.gameNumbers.length);
  332.  
  333. },
  334. sliderShowHide(pager) {
  335. return store.getState().localstate.historyTickets.length >= 15 ? pager.show() : pager.hide();
  336. },
  337. /* Rendering proper balls by getting array from the packet */
  338. renderBalls(balls, ballPositions) {
  339. const parsedBalls = extra.jp(balls);
  340. const ballsHolder = $('#ballsHolderHistory');
  341. ballsHolder.empty();
  342.  
  343. parsedBalls.forEach((ball, index, ) => {
  344. const historyBallDiv = $(`<div class='histball histball${index}_${ballPositions} ball_${ball}'></div>`);
  345. ballsHolder.append(historyBallDiv);
  346. });
  347. },
  348. clearTicketHits() {
  349. const historyTickets = $('#tickets_container_premade');
  350. historyTickets.find('.ticket__num-box').attr("class", "ticket__num-box knum"); // Clear number of hits from tickets in history
  351. historyTickets.find('.ktbought_tickethits').attr("class", "ktbought_tickethits").css('background-image', 'none'); // Clear red circle hits from tickets in history
  352. },
  353. /* Render all tickets, sort order, hits and pagination */
  354. render_modal_tickets() {
  355.  
  356. /** function to fill text information inside history modal */
  357. this.clearTicketHits();
  358.  
  359. /** Render History Tickets */
  360. keno_fill_hits_and_sortorder(this.allTicketsHistory, this.historyBalls); //sorts tickets same same as they on the last stage of the game
  361.  
  362. ticketThings();
  363. render_bh_tickets(true);
  364.  
  365. // let ticket;
  366. // /* b_ticket - boughtTickets */
  367. // for (var index = store.getState().localstate.shownPage_up_down * 15, i = 0; i < 15 && index < this.gameData.tickets; index++, i++) {
  368. // ticket = bought_tickets.fillTicketData(sorted[index], i, bought_tickets.target.BP_SHOW_15_TICKETS);
  369. // if (store.getState().localstate.in_history_modal === 1) {
  370. // bought_tickets.set_hits(ticket, this.historyBalls, sorted[index], true /* in bet please*/ );
  371. // }
  372. // }
  373. // for (; i < 15; index++, i++) bought_tickets.fillTicketData(null, i, bought_tickets.target.BP_SHOW_15_TICKETS);
  374.  
  375. /* Page counter up/down - premade tickets in BP*/
  376. const totalTicketsHist = this.gameData.tickets;
  377. const pager_bp = $('.page_counter_hist');
  378. const history_pager = $('.history_pager');
  379. history_pager.append(pager_bp);
  380. /* For slider pager */
  381. totalTicketsHist === 0 ? pager_bp.hide() : pager_bp.show();
  382. totalTicketsHist <= 15 ? history_pager.hide() : history_pager.show();
  383. },
  384.  
  385. /* Left Arrow render state*/
  386. renderLeftArrow(left, ns) {
  387. if (ns.localstate.hisotryPageCounter === 0) {
  388. return left.removeClass('historyArrowLeftActive modalPulse').addClass('historyArrowLeftInactive');
  389. }
  390. left.removeClass('historyArrowLeftInactive modalPulse').addClass('historyArrowLeftActive modalPulse');
  391. },
  392.  
  393. /* Right Arrow render state */
  394. renderRightArrow(right, ns) {
  395. if (ns.localstate.hisotryPageCounter === this.gameNumbers.length - 1) {
  396. return right.removeClass('historyArrowRightActive modalPulse').addClass('historyArrowRightInactive');
  397. }
  398. right.removeClass('historyArrowRightInactive').addClass('historyArrowRightActive modalPulse');
  399. },
  400. /* Here are rendered left, right arrows, slider, pager*/
  401. renderNavigation() {
  402. const ns = store.getState();
  403. //Render game navigation arrows state
  404. this.renderLeftArrow($(this.leftArrow), ns);
  405. this.renderRightArrow($(this.rightArrow), ns);
  406.  
  407. //call slider functions for history slider
  408. // const total_pages = ns.localstate.historyTotalPages - 1;
  409. // const shown_page = ns.localstate.historyShownPage;
  410.  
  411. // keno_slider.KenoSlider.renderSlider('history', total_pages, shown_page, this.history_actions);
  412. // keno_slider.KenoSlider.sliderAnimation('history', total_pages, shown_page);
  413. // try {
  414. // keno_slider.render(total_pages, 'history_slider', 'history_pager', 'HISTORY_SCROLL');
  415. // keno_slider.update(total_pages, shown_page, 'history_slider', 'history_pager');
  416. // keno_slider.slider_animation(shown_page, total_pages, 'k_up_btn_hist', 'k_down_btn_hist', 'history_pager', total_tickets, 7, 7, 20, 30);
  417. // keno_slider.show_hide_page_num(total_tickets.length - 1, shown_page, 'history_pager', 'bottom_text_hist', 'k_up_btn_hist');
  418. // } catch (e) {
  419. // console.error(e);
  420. // }
  421.  
  422. // const pager_history = $('.page_counter_history');
  423. // ns.localstate.historyTickets.length === 0 ? pager_history.hide() : pager_history.show();
  424. // pager_history.text(sprintf("%d", ns.localstate.historyShownPage + 1));
  425. // hist_helper.sliderShowHide($('.history_pager'));
  426. },
  427.  
  428. /* Structure of the whole Modal, starts hidden */
  429. historyModal() {
  430. $('.btnRepeat').addClass('btnRepeat_disabled');
  431. $('.kbtn_history').addClass('kbtn_history_disabled');
  432.  
  433. $('#historyModal').remove();
  434. const body = `<div id="historyModal" style='display:none'>
  435. <div id="histModalFirstRow" class="histModalRow">
  436. <div class="historyArrow" >
  437. <div class="histCenteredButton" id="leftArrow" ></div>
  438. </div>
  439. <div id="dataContainer">
  440. <div id="drawIdContainer" class="styleContainer">
  441. <div id="gameIdHist" >
  442. <span id="gameIdTextHist"></span> &nbsp&nbsp
  443. <span id="gameIdValueHist"></span>
  444. </div>
  445. <div id="gamePageHist">
  446. <span id="historyPagesText" ></span> &nbsp&nbsp&nbsp
  447. <span id="historyPages" ></span>
  448. </div>
  449. </div>
  450. <div id="dateContainer" class="styleContainer "></div>
  451. </div>
  452. <div class="historyArrow" >
  453. <div class="histCenteredButton" id="rightArrow" ></div>
  454. </div>
  455. </div>
  456. <div id="histModalSecondRow" class="histModalRow">
  457. <div class="buttonContainer">
  458. <div class="histCenteredButton" id="repeatButton" style='display:none'></div>
  459. <div class="histCenteredButton" id="repeatButtonInactive" style='display:none'></div>
  460. </div>
  461. <div id="ticketsBetWinContainer">
  462. <div id="ticketsBetDiv">
  463. <div id="ticketsCount" class="histHalfContainer styleContainer">
  464. <div id="ticketsTextHist"></div>
  465. <div id="ticketsValueHist"></div>
  466. </div>
  467. <div id="betContainer" class="histHalfContainer styleContainer">
  468. <div id="betTextHist"></div>
  469. <div id="betValueHist">
  470. <div class="currencyId"></div>
  471. </div>
  472. </div>
  473. </div>
  474. <div id="winContainer" class="styleContainer ">
  475. <div id="winTextHist" ></div>
  476. <div id="winValueHist">
  477. <div class="currencyId"></div>
  478. </div>
  479. </div>
  480. </div>
  481. <div class="buttonContainer">
  482. <div class="histCenteredButton" id="closeButton" ></div>
  483. </div>
  484. </div>
  485. <div id="histModalThirdRow" class="histModalRow">
  486. <div id="ticketsContainer"></div>
  487. <div id='prizesWrapperHistory'>
  488. <div id='ballsHolderHistory'></div>
  489. <div id='prizesBodyHistory'></div>
  490. </div>
  491. </div>
  492. </div>`;
  493. $('.game_keno').append(body); //appends once for the main layout
  494. },
  495. /* Generating dynamically rows by gameType */
  496. generatePrizesRow(parent, index, prizesArr, prizesArrLength, jpArr, currencyText) {
  497.  
  498. const row = `<div class='prizesRowHist' id="prizesRowHist${index + 1}">
  499. <div class='jpLeftBox' id='jpLeftFive'>
  500. <div class='jpLeftStart'>${index + 3}</div>
  501. </div>
  502. <div class='jpMiddleBoxHist' id='jpMiddle${index + 1}'>
  503. <div id='jackpotStat${index}' class='jpMiddleStartHist numbers_stat'>${jpArr}</div>
  504. <div id='jackpotWin${index}' class='jpMiddleEnd numbers_stat'>
  505. <div id='jackpotWinsCountHist${index}' class='jackpotWinsCountHist'>${prizesArrLength}</div>
  506. <div id='xHist${index}' class='xHist'>&nbspx&nbsp</div>
  507. <div id='jackpotWins${index}' class='jackpotWins'>${prizesArr}</div>
  508. <div id='space${index}'>&nbsp</div>
  509. <div class='jpCenteredCurrencyHist'>${currencyText}</div>
  510. </div>
  511. </div>
  512. <div class='jpRightBox' id='jpRightFive'></div>
  513. </div>`;
  514. parent.append(row);
  515. },
  516. clearZeros(index, prizesCount) {
  517. if (prizesCount === 0) {
  518. $('#jackpotWinsCountHist' + index).hide();
  519. $('#xHist' + index).hide();
  520. $('#jackpotWins' + index).hide();
  521. }
  522. },
  523. /* Render prizes rows dynamically and fill them with calculated data from the packet */
  524. renderPrizesRows() {
  525. this.historyTextFill(); // function to fill text information inside history modal
  526. // this.renderBalls(this.gameData.balls); // display proper balls
  527. //fixme out of here
  528. $('#prizesBodyHistory .prizesRowHist').remove();
  529.  
  530. // checkingtype of game to know how many rows to render
  531. const forLoopStartsFrom = (gametype === gamesConfig.keno_games.KENO535) ? 2 : 3;
  532. const arrWithJpWins = this.gameData.playerProfitByNumbers;
  533. const currencyText = this.gameData.units[this.gameData.currencyid];
  534. const prizesBody = $('#prizesBodyHistory');
  535. const historyData = this.gameData;
  536.  
  537. const jpArr = [];
  538. const prizesArr = [];
  539. const prizesArrLength = [];
  540. let counter = 0;
  541.  
  542. let formatedWin;
  543. let formatedAllWin;
  544. let convertedWin;
  545. let winsPerJp;
  546.  
  547. for (let i = forLoopStartsFrom; i >= 0; i--) {
  548. arrWithJpWins.forEach((wins) => {
  549. winsPerJp = wins[3 + i];
  550. if (winsPerJp === undefined) { //if it's undefined, there's no jp, so setting 0
  551. prizesArrLength[i] += 0;
  552. jpArr[i] += 0;
  553. prizesArr[i] += 0;
  554. return;
  555. }
  556. // calculating value by currency
  557. prizesArr[i] = winsPerJp; //elm[3+i] is the single jp value
  558. counter++; // to find how many wins we have from every jp
  559. });
  560. if (isNaN(prizesArr[i])) prizesArr[i] = 0; // in the begining is NaN see if needed
  561.  
  562. prizesArrLength[i] = counter; // getting how many wins we have from that jp
  563. convertedWin = extra.money_convert(prizesArr[i], historyData.currencyid, extra.jp(historyData.conv)) | 0;
  564. jpArr[i] = convertedWin * prizesArrLength[i]; // getting the whole jp
  565. formatedWin = (convertedWin / 100).toFixed(2);
  566. formatedAllWin = (jpArr[i] / 100).toFixed(2);
  567. // appending results
  568. this.generatePrizesRow(prizesBody, i, formatedWin, prizesArrLength[i], formatedAllWin, currencyText);
  569. this.clearZeros(i, prizesArrLength[i]);
  570. counter = 0; //resetting for the next jp
  571. }
  572.  
  573. $('#historyPagesText').text(theme.get_array('historyPagesText'));
  574. this.resizeHistorySplits();
  575. this.resizeHistorySplits();
  576.  
  577. },
  578.  
  579. resizeHistorySplits() {
  580.  
  581. const jackpotOne = $('#jackpotStat0');
  582. const jackpotTwo = $('#jackpotStat1');
  583. const jackpotThree = $('#jackpotStat2');
  584. const jackpotFour = $('#jackpotStat3');
  585. const splitOne = $('#jackpotWins0');
  586. const splitTwo = $('#jackpotWins1');
  587. const splitThree = $('#jackpotWins2');
  588. const splitFour = $('#jackpotWins3');
  589. if (initialize.device[0] === 'android' && gamesConfig.prizesTable[gametype] === 4) { /* Android */
  590. let androidHistoryRows4 = resizeConfig.historyPrizesPanel.showSplit.androidPrizesTable4;
  591.  
  592. extra.changeFontSize(jackpotOne, androidHistoryRows4.jackpotObj1);
  593. extra.changeFontSize(jackpotTwo, androidHistoryRows4.jackpotObj2);
  594. extra.changeFontSize(jackpotThree, androidHistoryRows4.jackpotObj3);
  595. extra.changeFontSize(jackpotFour, androidHistoryRows4.jackpotObj4);
  596.  
  597. extra.changeFontSize(splitOne, androidHistoryRows4.splitsObj);
  598. extra.changeFontSize(splitTwo, androidHistoryRows4.splitsObj);
  599. extra.changeFontSize(splitThree, androidHistoryRows4.splitsObj);
  600. extra.changeFontSize(splitFour, androidHistoryRows4.splitsObj);
  601.  
  602. } else if (initialize.device[0] === 'android' && gamesConfig.prizesTable[gametype] === 3) {
  603. let androidHistoryRows3 = resizeConfig.historyPrizesPanel.showSplit.androidPrizesTable3;
  604.  
  605.  
  606. extra.changeFontSize(jackpotOne, androidHistoryRows3.jackpotObj1);
  607. extra.changeFontSize(jackpotTwo, androidHistoryRows3.jackpotObj2);
  608. extra.changeFontSize(jackpotThree, androidHistoryRows3.jackpotObj3);
  609. // console.log(androidHistoryRows3.jackpotObj3);
  610.  
  611. extra.changeFontSize(splitOne, androidHistoryRows3.splitsObj);
  612. extra.changeFontSize(splitTwo, androidHistoryRows3.splitsObj);
  613. extra.changeFontSize(splitThree, androidHistoryRows3.splitsObj);
  614.  
  615. } else if (initialize.device[0] === 'iPhone' && gamesConfig.prizesTable[gametype] === 4) { /* Iphone */
  616. let iosHistoryRows4 = resizeConfig.historyPrizesPanel.showSplit.iosPrizesTable4;
  617.  
  618. extra.changeFontSize(jackpotOne, iosHistoryRows4.jackpotObj1);
  619. extra.changeFontSize(jackpotTwo, iosHistoryRows4.jackpotObj2);
  620. extra.changeFontSize(jackpotThree, iosHistoryRows4.jackpotObj3);
  621. extra.changeFontSize(jackpotFour, iosHistoryRows4.jackpotObj4);
  622.  
  623. extra.changeFontSize(splitOne, iosHistoryRows4.splitsObj);
  624. extra.changeFontSize(splitTwo, iosHistoryRows4.splitsObj);
  625. extra.changeFontSize(splitThree, iosHistoryRows4.splitsObj);
  626. extra.changeFontSize(splitFour, iosHistoryRows4.splitsObj);
  627.  
  628. } else if (initialize.device[0] === 'iPhone' && gamesConfig.prizesTable[gametype] === 3) {
  629. let iosHistoryRows3 = resizeConfig.historyPrizesPanel.showSplit.iosPrizesTable3;
  630.  
  631. extra.changeFontSize(jackpotOne, iosHistoryRows3.jackpotObj1);
  632. extra.changeFontSize(jackpotTwo, iosHistoryRows3.jackpotObj2);
  633. extra.changeFontSize(jackpotThree, iosHistoryRows3.jackpotObj3);
  634.  
  635. extra.changeFontSize(splitOne, iosHistoryRows3.splitsObj);
  636. extra.changeFontSize(splitTwo, iosHistoryRows3.splitsObj);
  637. extra.changeFontSize(splitThree, iosHistoryRows3.splitsObj);
  638.  
  639. } else if (initialize.device[0] === 'iPad' && gamesConfig.prizesTable[gametype] === 4) { /* Iphone */
  640. let ipadHistoryRows4 = resizeConfig.historyPrizesPanel.showSplit.ipadPrizesTable4;
  641.  
  642. extra.changeFontSize(jackpotOne, ipadHistoryRows4.jackpotObj1);
  643. extra.changeFontSize(jackpotTwo, ipadHistoryRows4.jackpotObj2);
  644. extra.changeFontSize(jackpotThree, ipadHistoryRows4.jackpotObj3);
  645. extra.changeFontSize(jackpotFour, ipadHistoryRows4.jackpotObj4);
  646.  
  647. extra.changeFontSize(splitOne, ipadHistoryRows4.splitsObj);
  648. extra.changeFontSize(splitTwo, ipadHistoryRows4.splitsObj);
  649. extra.changeFontSize(splitThree, ipadHistoryRows4.splitsObj);
  650. extra.changeFontSize(splitFour, ipadHistoryRows4.splitsObj);
  651.  
  652. } else if (initialize.device[0] === 'iPad' && gamesConfig.prizesTable[gametype] === 3) {
  653. let ipadHistoryRows3 = resizeConfig.historyPrizesPanel.showSplit.ipadPrizesTable3;
  654.  
  655. extra.changeFontSize(jackpotOne, ipadHistoryRows3.jackpotObj1);
  656. extra.changeFontSize(jackpotTwo, ipadHistoryRows3.jackpotObj2);
  657. extra.changeFontSize(jackpotThree, ipadHistoryRows3.jackpotObj3);
  658.  
  659. extra.changeFontSize(splitOne, ipadHistoryRows3.splitsObj);
  660. extra.changeFontSize(splitTwo, ipadHistoryRows3.splitsObj);
  661. extra.changeFontSize(splitThree, ipadHistoryRows3.splitsObj);
  662.  
  663. } else if (!initialize.device[0] && gamesConfig.prizesTable[gametype] === 4) { /* desktop */
  664. let desktopHistoryRows4 = resizeConfig.historyPrizesPanel.showSplit.defaultPrizesTable4;
  665.  
  666. // console.log(desktopHistoryRows4.jackpotObj1);
  667. extra.changeFontSize(jackpotOne, desktopHistoryRows4.jackpotObj1);
  668. extra.changeFontSize(jackpotTwo, desktopHistoryRows4.jackpotObj2);
  669. extra.changeFontSize(jackpotThree, desktopHistoryRows4.jackpotObj3);
  670. extra.changeFontSize(jackpotFour, desktopHistoryRows4.jackpotObj4);
  671.  
  672. extra.changeFontSize(splitOne, desktopHistoryRows4.splitsObj);
  673. extra.changeFontSize(splitTwo, desktopHistoryRows4.splitsObj);
  674. extra.changeFontSize(splitThree, desktopHistoryRows4.splitsObj);
  675. extra.changeFontSize(splitFour, desktopHistoryRows4.splitsObj);
  676.  
  677. } else if (!initialize.device[0] && gamesConfig.prizesTable[gametype] === 3) { /* desktop */
  678. let desktopHistoryRows3 = resizeConfig.historyPrizesPanel.showSplit.defaultPrizesTable3;
  679. // console.log(desktopHistoryRows3);
  680.  
  681. extra.changeFontSize(jackpotOne, desktopHistoryRows3.jackpotObj1);
  682. extra.changeFontSize(jackpotTwo, desktopHistoryRows3.jackpotObj2);
  683. extra.changeFontSize(jackpotThree, desktopHistoryRows3.jackpotObj3);
  684.  
  685. extra.changeFontSize(splitOne, desktopHistoryRows3.splitsObj);
  686. extra.changeFontSize(splitTwo, desktopHistoryRows3.splitsObj);
  687. extra.changeFontSize(splitThree, desktopHistoryRows3.splitsObj);
  688.  
  689. } else if (initialize.device[0] === 'safari-ios' && gamesConfig.prizesTable[gametype] === 4) { /* desktop */
  690. let desktopHistoryRows4 = resizeConfig.historyPrizesPanel.showSplit.defaultPrizesTable4;
  691.  
  692. // console.log(desktopHistoryRows4.jackpotObj1);
  693. extra.changeFontSize(jackpotOne, desktopHistoryRows4.jackpotObj1);
  694. extra.changeFontSize(jackpotTwo, desktopHistoryRows4.jackpotObj2);
  695. extra.changeFontSize(jackpotThree, desktopHistoryRows4.jackpotObj3);
  696. extra.changeFontSize(jackpotFour, desktopHistoryRows4.jackpotObj4);
  697.  
  698. extra.changeFontSize(splitOne, desktopHistoryRows4.splitsObj);
  699. extra.changeFontSize(splitTwo, desktopHistoryRows4.splitsObj);
  700. extra.changeFontSize(splitThree, desktopHistoryRows4.splitsObj);
  701. extra.changeFontSize(splitFour, desktopHistoryRows4.splitsObj);
  702.  
  703. } else if (initialize.device[0] === 'safari-ios' && gamesConfig.prizesTable[gametype] === 3) { /* desktop */
  704. let desktopHistoryRows3 = resizeConfig.historyPrizesPanel.showSplit.defaultPrizesTable3;
  705. // console.log(desktopHistoryRows3);
  706. extra.changeFontSize(jackpotOne, desktopHistoryRows3.jackpotObj1);
  707. extra.changeFontSize(jackpotTwo, desktopHistoryRows3.jackpotObj2);
  708. extra.changeFontSize(jackpotThree, desktopHistoryRows3.jackpotObj3);
  709.  
  710. extra.changeFontSize(splitOne, desktopHistoryRows3.splitsObj);
  711. extra.changeFontSize(splitTwo, desktopHistoryRows3.splitsObj);
  712. extra.changeFontSize(splitThree, desktopHistoryRows3.splitsObj);
  713. }
  714. },
  715.  
  716. /* when close modal null everything used when it was opened */
  717. closeHistoryModal() {
  718. const ns = store.getState();
  719. $('#historyModal2').fadeOut('slow');
  720. history2.closeHistory();
  721.  
  722. ns.localstate.in_history_modal = 0;
  723. ns.localstate.hisotryPageCounter = 0;
  724. // this.removeTransparentDiv();
  725. // bought_tickets.clear_knums();
  726. this.clearTicketHits();
  727. },
  728.  
  729. /* when open modal initialize and set everything needed to work properly */
  730. openHistoryModal() {
  731. this.renderPage(this.firstPage);
  732.  
  733. this.renderNavigation();
  734. store.dispatch({
  735. type: 'REPEAT_BET_MODAL'
  736. });
  737. $('#historyModal2').fadeIn('slow');
  738. history2.openHistory();
  739. this.render_modal_tickets();
  740. extra.resize_text(); // called to resize titles (text divs)
  741.  
  742. /* Making shorter animation for History modal and repeat btn */
  743. startAnimation();
  744. },
  745.  
  746. /* for popUp effect when change the page */
  747. animateChanginPage() {
  748. const drawIdContainer = $('#drawIdContainer, #dateContainer');
  749. drawIdContainer.addClass('scaleStatHistIn').removeClass('scaleStatHistOut');
  750. setTimeout(() => drawIdContainer.addClass('scaleStatHistOut').removeClass('scaleStatHistIn'), 100);
  751. }
  752. };
  753.  
  754.  
  755. global.resizeHistorySplits = hist_helper.resizeHistorySplits;
  756.  
  757.  
  758. /* For Closing modal */
  759. $(document).on('click', '#exitHistoryButton', () => {
  760. store.dispatch({
  761. type: 'LEAVE_HISTORY'
  762. });
  763. hist_helper.closeHistoryModal();
  764. ps('change_denom'); //ps - playSound
  765. });
  766.  
  767. /* When purchase tickets from History modal */
  768. $(document).on('click', hist_helper.historyBtn, () => {
  769. store.dispatch({
  770. type: 'REPEAT_BET_MODAL'
  771. });
  772. hist_helper.closeHistoryModal();
  773. ps('repeat');
  774. });
  775.  
  776. // Left Arrow dispatch action to localState
  777. $(document).on('click', hist_helper.leftArrow, () => {
  778. if (store.getState().localstate.hisotryPageCounter !== 0) store.dispatch({
  779. type: 'DECREMENT_HISTORY'
  780. });
  781.  
  782. hist_helper.renderNavigation(); //recalculate navigation state
  783. hist_helper.animateChanginPage();
  784. ps('bet3');
  785. });
  786.  
  787. // Right Arrow dispatch action to localState
  788. $(document).on('click', hist_helper.rightArrow, () => {
  789. if (store.getState().localstate.hisotryPageCounter !== hist_helper.gameNumbers.length - 1) {
  790. store.dispatch({
  791. type: 'INCREMENT_HISTORY'
  792. });
  793. }
  794.  
  795. hist_helper.renderNavigation(); //recalculate navigation state
  796. hist_helper.animateChanginPage();
  797. ps('bet3');
  798. });
  799.  
  800.  
  801.  
  802. export {
  803. hist_helper,
  804. }
Add Comment
Please, Sign In to add comment