Guest User

Untitled

a guest
Mar 15th, 2017
414
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 259.78 KB | None | 0 0
  1. Array.prototype.insert = function(index, item) {
  2. this.splice(index, 0, item);
  3. };
  4.  
  5. function pad(str, max) {
  6. str = str.toString();
  7. return str.length < max ? pad("0" + str, max) : str;
  8. }
  9.  
  10. function phraser(phrase) {
  11. if (lang[phrase] == null || lang[phrase] == undefined) {
  12. return phrase;
  13. }
  14. return lang[phrase];
  15. }
  16.  
  17. function copyToClipboard(text) {
  18. var $temp = $("<input>");
  19. $("body").append($temp);
  20. $temp.val(text).select();
  21. document.execCommand("copy");
  22. $temp.remove();
  23. }
  24.  
  25. function getRotationDegrees(obj) {
  26. var matrix = obj.css("-webkit-transform") || obj.css("-moz-transform") || obj.css("-ms-transform") || obj.css("-o-transform") || obj.css("transform");
  27. if (matrix !== 'none') {
  28. var values = matrix.split('(')[1].split(')')[0].split(',');
  29. var a = values[0];
  30. var b = values[1];
  31. var angle = Math.round(Math.atan2(b, a) * (180 / Math.PI));
  32. } else {
  33. var angle = 0;
  34. }
  35. return (angle < 0) ? angle + 360 : angle;
  36. }
  37.  
  38. function needCredits() {
  39. $.ajax({
  40. type: "GET",
  41. url: "/user_credits.php",
  42. success: function(text) {
  43. swal({
  44. title: phraser('ERROR'),
  45. html: phraser('NOT_ENOUGH_CREDITS') + text + " Credits.</b>",
  46. type: 'error',
  47. confirmButtonText: phraser('OKAY')
  48. });
  49. $("#credits").html(parseFloat(text).toFixed(2));
  50. }
  51. });
  52. }
  53.  
  54. function updateCredits(value) {
  55. var newCredits = (parseFloat($("#credits").html()) + parseFloat(value)).toFixed(3);
  56. if (newCredits < 0) {
  57. newCredits = 0;
  58. }
  59. $("#credits").html(newCredits);
  60. }
  61.  
  62. function addCredits(data) {
  63. if (data.user_id == userID) {
  64. $.growl.notice({
  65. title: phraser('SUCCESS'),
  66. message: phraser('CREDITS_ADDED') + " <b>" + data['value'] + "</b> Credits"
  67. });
  68. updateCredits(data.value);
  69. }
  70. }
  71.  
  72. function removeCredits(data) {
  73. if (data.user_id == userID) {
  74. $.growl.notice({
  75. title: phraser('SUCCESS'),
  76. message: phraser('CREDITS_REMOVE') + " <b>" + data['value'] + "</b> Credits"
  77. });
  78. updateCredits(-1 * data.value);
  79. }
  80. }
  81.  
  82. function moveElement(e, target) {
  83. var moveX = e.pageX;
  84. var moveY = e.pageY;
  85. if (typeof e.originalEvent.touches !== 'undefined') {
  86. moveX = e.originalEvent.touches[0].pageX;
  87. moveY = e.originalEvent.touches[0].pageY;
  88. }
  89. window.my_dragging = {};
  90. my_dragging.pageX0 = moveX;
  91. my_dragging.pageY0 = moveY;
  92. my_dragging.elem = $(target);
  93. my_dragging.offset0 = $(target).offset();
  94.  
  95. function handle_dragging(e) {
  96. var dragX = e.pageX;
  97. var dragY = e.pageY;
  98. if (typeof e.originalEvent.touches !== 'undefined') {
  99. dragX = e.originalEvent.touches[0].pageX;
  100. dragY = e.originalEvent.touches[0].pageY;
  101. }
  102. var left = my_dragging.offset0.left + (dragX - my_dragging.pageX0);
  103. var top = my_dragging.offset0.top + (dragY - my_dragging.pageY0);
  104. $(my_dragging.elem).offset({
  105. top: top,
  106. left: left
  107. });
  108. }
  109.  
  110. function handle_mouseup(e) {
  111. $('body').off('mousemove touchmove', handle_dragging).off('mouseup touchend touchcancel', handle_mouseup);
  112. }
  113. $('body').on('mouseup touchend touchcancel', handle_mouseup).on('mousemove touchmove', handle_dragging);
  114. }
  115.  
  116. function adminCredits(data) {
  117. if (data.value > 0) {
  118. $.growl.notice({
  119. title: "Admin",
  120. message: phraser('YOU_HAVE_RECEIVED') + " <b>" + data.value + "</b> Credits"
  121. });
  122. } else {
  123. $.growl.error({
  124. title: "Admin",
  125. message: phraser('YOU_HAVE_RECEIVED') + " <b>" + data.value + "</b> Credits"
  126. });
  127. }
  128. updateCredits(data.value);
  129. }
  130.  
  131. function sendCreditsNotification(data) {
  132. $.growl.notice({
  133. title: phraser('USER_SENT'),
  134. message: phraser('YOU_HAVE_RECEIVED') + " <b>" + data.value + "</b> Credits " + phraser('FROM') + " <b>" + data.fromUser + "</b>"
  135. });
  136. updateCredits(data.value);
  137. }
  138.  
  139. function validateTradeURL(tradeURL) {
  140. if (!tradeURL.match(/steamcommunity\.com\/tradeoffer\/new\/\?partner=[0-9]*&token=[a-zA-Z0-9_-]*/i)) {
  141. return false;
  142. }
  143. return true;
  144. }
  145.  
  146. function changeText(Otext, cont, speed) {
  147. var Ocontent = Otext.split("");
  148. var i = 0;
  149.  
  150. function show() {
  151. if (i < Ocontent.length) {
  152. cont.append(Ocontent[i]);
  153. i = i + 1;
  154. }
  155. }
  156. var Otimer = setInterval(show, speed);
  157. }
  158.  
  159.  
  160. var navbarGiveawayCounter;
  161. var navbarCount;
  162. var navbarStartSeconds;
  163. var navbarStartTime;
  164.  
  165. function navbarStartTimer() {
  166. navbarGiveawayCounter = setInterval(navbarGiveawayTimer, 100);
  167. navbarCount = $("#navbar_giveaway_timer").html().replace("d", "").replace("h", "").replace("m", "").replace("s", "").split(" ");
  168. navbarStartSeconds = parseInt(navbarCount[0]) * 24 * 60 * 60 + parseInt(navbarCount[1]) * 60 * 60 + parseInt(navbarCount[2]) * 60 + parseInt(navbarCount[3]);
  169. navbarStartTime = new Date().getTime();
  170. }
  171.  
  172. function navbarGiveawayTimer() {
  173. var timeElapse = Math.floor((new Date().getTime() - navbarStartTime) / 1000);
  174. var totalSeconds = navbarStartSeconds - timeElapse;
  175. var days = Math.floor(totalSeconds / 60 / 60 / 24);
  176. var seconds = totalSeconds - days * 24 * 60 * 60;
  177. var hours = Math.floor(seconds / 60 / 60);
  178. seconds = seconds - hours * 60 * 60;
  179. var minutes = Math.floor(seconds / 60);
  180. seconds = seconds - minutes * 60;
  181. days = pad(days, 2);
  182. hours = pad(hours, 2);
  183. minutes = pad(minutes, 2);
  184. seconds = pad(seconds, 2);
  185. $("#navbar_giveaway_timer").html(days + "d " + hours + "h " + minutes + "m " + seconds + "s");
  186. if (totalSeconds <= 0) {
  187. $("#navbar_giveaway_timer").html(days + "d " + hours + "h " + minutes + "m " + seconds + "s");
  188. $("#navbar_giveaway").fadeOut();
  189. clearInterval(navbarGiveawayCounter);
  190. }
  191. }
  192.  
  193. function handleSkinGiveaway(data) {
  194. $(".giveaway_small_image_navbar").attr('src', data.item_image);
  195. $("#navbar_giveaway_timer").html(data.d + "d " + data.h + "h " + data.m + "m " + data.s + "s ");
  196. $("#navbar_giveaway").show();
  197. navbarStartTimer();
  198. }
  199. var boxGiveawayCounter;
  200. var boxCount;
  201. var boxStartSeconds;
  202. var boxStartTime;
  203.  
  204. function boxStartTimer() {
  205. boxGiveawayCounter = setInterval(boxGiveawayTimer, 100);
  206. boxCount = $(".chat_giveaway_box_timer").html().replace("m", "").replace("s", "").split(" ");
  207. boxStartSeconds = parseInt(parseInt(boxCount[0]) * 60 + parseInt(boxCount[1]));
  208. boxStartTime = new Date().getTime();
  209. }
  210.  
  211. function boxGiveawayTimer() {
  212. var timeElapse = Math.floor((new Date().getTime() - boxStartTime) / 1000);
  213. var totalSeconds = boxStartSeconds - timeElapse;
  214. var minutes = Math.floor(totalSeconds / 60);
  215. var seconds = totalSeconds - minutes * 60;
  216. minutes = pad(minutes, 2);
  217. seconds = pad(seconds, 2);
  218. $(".chat_giveaway_box_timer").html(minutes + "m " + seconds + "s");
  219. if (totalSeconds <= 0) {
  220. $(".chat_giveaway_box_timer").html(minutes + "m " + seconds + "s");
  221. clearInterval(boxGiveawayCounter);
  222. }
  223. }
  224.  
  225. function handleGiveaway(data) {
  226. if (data.start == 1) {
  227. $("#chat_giveaway_box").addClass("chat_giveaway_box_live");
  228. $(".chat_giveaway_box_timer").hide();
  229. $(".chat_giveaway_box_info").show();
  230. $("#chat_giveaway_box_type").html(data.type);
  231. $("#chat_giveaway_box_hint").html(data.hint);
  232. $("#chat_giveaway_box_value").html(data.value);
  233. if (data.system == 1) {
  234. $(".chat_giveaway_box_timer").html("15m 00s");
  235. boxStartTimer();
  236. }
  237. }
  238. if (data.stop == 1) {
  239. if (data.winner_user_id == userID) {
  240. updateCredits(data.value);
  241. }
  242. $(".chat_giveaway_box_timer").show();
  243. $("#chat_giveaway_box").removeClass();
  244. $(".chat_giveaway_box_info").hide();
  245. }
  246. }
  247.  
  248. function jukeBoxToken(data) {
  249. if (userID == data.user_id) {
  250. $("#jukebox_tokens b").html((parseInt($("#jukebox_tokens b").html()) + 1));
  251. $.growl.notice({
  252. title: 'Jukebox',
  253. message: phraser('YOU_RECEIVED_JUKEBOX_TOKEN')
  254. });
  255. }
  256. }
  257. var jukeboxTimer;
  258.  
  259. function jukeBoxLoad() {
  260. $.ajax({
  261. type: "GET",
  262. url: "/jukebox.php",
  263. data: {
  264. load: true
  265. },
  266. success: function(text) {
  267. if (text != 'none') {
  268. var trackInfo = text.split(";");
  269. jukeBoxPlay(trackInfo[0], trackInfo[1], trackInfo[2], trackInfo[3], trackInfo[4], trackInfo[5], trackInfo[6], trackInfo[7]);
  270. }
  271. }
  272. });
  273. }
  274.  
  275. function jukeBoxStop() {
  276. $("#jukebox_current").hide();
  277. $("#jukebox_form").show();
  278. $("#jukebox_title").hide();
  279. $("#jukebox_volume").hide();
  280. $("#jukebox_available").show();
  281. youtubePlayer.stopVideo()
  282. clearTimeout(jukeboxTimer);
  283. }
  284.  
  285. function jukeBoxPlay(track_id, title, artwork, duration, remaining, url, user, avatar) {
  286. youtubePlayer.loadVideoById(track_id, Math.floor(duration - remaining)).playVideo();
  287. $(".now_playing").html('<img src="' + artwork + '"> ' + title);
  288. $("#jukebox_title").show();
  289. $("#jukebox_volume").show();
  290. $("#jukebox_available").hide();
  291. $("#jukebox_current").css('background-image', 'url(' + artwork + ')').html('<img class="tool" src="' + avatar + '" title="' + user + '"><span class="jukebox_current_blur" style="background-image: url(' + artwork + ')"></span><span class="jukebox_current_content"><i>Current Track:</i><br><a href="' + url + '" target="_blank">' + title + '</a></span>').show();
  292. $("#jukebox_form").hide();
  293. jukeboxTimer = setTimeout(function() {
  294. $("#jukebox_current").hide();
  295. $("#jukebox_form").show();
  296. $("#jukebox_title").hide();
  297. $("#jukebox_volume").hide();
  298. $("#jukebox_available").show();
  299. youtubePlayer.stopVideo()
  300. }, remaining * 1000);
  301. }
  302.  
  303. function saveJukeboxVolume(vol) {
  304. setTimeout(function() {
  305. if (youtubePlayer.getVolume() == vol) {
  306. $.ajax({
  307. type: "GET",
  308. url: "/jukebox.php",
  309. data: {
  310. volume: vol
  311. },
  312. success: function(text) {}
  313. });
  314. }
  315. }, 3000);
  316. }
  317.  
  318. function barrelRoll() {
  319. $("body").addClass('barrel_roller');
  320. setTimeout(function() {
  321. $("body").removeClass('barrel_roller');
  322. }, 4100);
  323. }
  324.  
  325. function recruitsNew(data) {
  326. $.growl.notice({
  327. title: 'Recruits',
  328. message: phraser("YOU_JUST_RECRUITED") + " <b>" + data.persona + "</b>"
  329. });
  330. updateCredits(0.05);
  331. }
  332. var revolverCountdownTimer;
  333.  
  334. function revolverCountdown() {
  335. var startVal = $("#revolver_countdown span").html().replace("s", "").replace(" ", "").split("m");
  336. var startSec = parseInt(startVal[0]) * 60 + parseInt(startVal[1]);
  337. var startTime = new Date().getTime();
  338. clearInterval(revolverCountdownTimer);
  339. timeouts.push(revolverCountdownTimer = setInterval(function() {
  340. var timeElapse = Math.floor((new Date().getTime() - startTime) / 1000);
  341. var seconds = startSec - timeElapse;
  342. var minutes = 0;
  343. if (seconds <= 0) {
  344. seconds = 0;
  345. clearInterval(revolverCountdownTimer);
  346. }
  347. minutes = Math.floor(seconds / 60);
  348. seconds = seconds - minutes * 60;
  349. minutes = pad(minutes, 2);
  350. seconds = pad(seconds, 2);
  351. $("#revolver_countdown span").html(minutes + "m " + seconds + "s");
  352. }, 1000));
  353. }
  354.  
  355. function revolverBet(data) {
  356. if ($("#revolver_background").length == 0 || $(".revolver_player[data-id='" + data.bet.revolver_bet_id + "']").length > 0) {
  357. return;
  358. }
  359. $(".blop").trigger('play');
  360. $("#revolver_players").append('<div class="revolver_player" data-id="' + data.bet.revolver_bet_id + '" data-time="' + data.bet.microtime + '"><span><b>' + data.bet.value + '</b> Credits</span><a show-profile="' + data.user.user_id + '"><img src="' + data.user.avatar + '"></a></div>');
  361. if (data.bet.king == 1) {
  362. revolverKing(data.bet.revolver_bet_id, data.user.avatar, 0);
  363. }
  364. $('#revolver_players').find('.revolver_player').sort(function(a, b) {
  365. return parseInt($(a).attr('data-time')) - parseInt($(b).attr('data-time'));
  366. }).prependTo('#revolver_players');
  367. }
  368.  
  369. function revolverKing(revolver_bet_id, avatar, profit) {
  370. var kingBet = $("#revolver_user_king").attr('data-id');
  371. if (kingBet != undefined) {
  372. $("#revolver_players div[data-id='" + kingBet + "']").remove();
  373. }
  374. $("#revolver_user_king").attr('src', avatar).attr('data-id', revolver_bet_id).show();
  375. $("#revolver_hat_king").show();
  376. $("#revolver_king_profit").show();
  377. $("#revolver_king_profit b").html(profit);
  378. }
  379.  
  380. function revolverPlayer(user) {
  381. $("#revolver_list").hide();
  382. $("#revolver_blood_player, #revolver_blood_king").hide();
  383. $("#revolver_hat_player").show();
  384. $("#revolver_user_player").attr('src', user.avatar).show();
  385. }
  386.  
  387. function revolverLoad(chamber) {
  388. $(".revolver_load").trigger('play');
  389. timeouts.push(setTimeout(function() {
  390. $("#cylinder").css('transform', 'rotate(0deg)');
  391. $("#cylinder").stop(true, true).addClass('cylinder_spin');
  392. $(".revolver_spin").trigger('play');
  393. timeouts.push(setTimeout(function() {
  394. $("#cylinder").removeClass('cylinder_spin');
  395. $(".revolver_spin").trigger('pause');
  396. $(".revolver_spin").prop("currentTime", 0);
  397. }, 2000));
  398. }, 500));
  399. }
  400.  
  401. function revolverNewRound(data) {
  402. if (typeof data.king !== 'undefined' && typeof data.king.user !== 'undefined' && data.king.user.user_id == userID) {
  403. updateCredits(data.king.bet.value);
  404. $.growl.notice({
  405. title: 'Revolver',
  406. message: phraser('YOU_JUST_WON') + " <b>" + data.king.bet.value + "</b> Credits!"
  407. });
  408. }
  409. if ($("#revolver_background").length == 0) {
  410. return;
  411. }
  412. $("#revolver_blood_player, #revolver_blood_king").hide();
  413. $("#revolver_hat_player").hide();
  414. $("#revolver_user_player").attr('src', '').hide();
  415. $("#revolver_king_profit b").html('0');
  416. $("#revolver_players .revolver_player").first().remove();
  417. $("#revolver_countdown span").html("3m 00s");
  418. revolverCountdown();
  419. if (data.player != null) {
  420. revolverKing(data.player.bet.revolver_bet_id, data.player.user.avatar, 0);
  421. } else {
  422. $("#revolver_user_king").hide();
  423. $("#revolver_king_profit").hide();
  424. $("#revolver_hat_king").hide();
  425. }
  426. $("#revolver_list_player_bet").html(data.wanted.bet.value);
  427. $("#revolver_list_player_profit").html(parseFloat(data.wanted.bet.profit).toFixed(3));
  428. $("#revolver_list_player_kills").html(data.wanted.bet.wins);
  429. $("#revolver_list_player_survived").html(data.wanted.bet.survived);
  430. $(".revolver_list_player a").attr('show-profile', data.wanted.user.user_id);
  431. $(".revolver_list_player a img").attr('src', data.wanted.user.avatar);
  432. $("#revolver_list").show();
  433. timeouts.push(setTimeout(function() {
  434. $("#revolver_list").hide();
  435. }, 30000));
  436. $(".revolver_theme").trigger('play');
  437. setTimeout(function() {
  438. $(".revolver_theme").trigger('pause');
  439. $(".revolver_theme").prop("currentTime", 0);
  440. }, 18 * 1000);
  441. }
  442.  
  443. function revolverDuelHandle(data) {
  444. timeouts.push(setTimeout(function() {
  445. if (data.winner.user_id == userID) {
  446. updateCredits(data.winner.won);
  447. $.growl.notice({
  448. title: 'Revolver',
  449. message: phraser('YOU_JUST_WON') + " <b>" + data.winner.won + "</b> Credits!"
  450. });
  451. }
  452. }, 1200 * (data.chamber.number) + 3000));
  453. if ($("#revolver_background").length == 0) {
  454. return;
  455. }
  456. revolverPlayer(data.player.user);
  457. revolverLoad(data.chamber.number);
  458. var kingChance = parseFloat(data.king.bet.value) / (parseFloat(data.player.bet.value) + parseFloat(data.king.bet.value)) * 100;
  459. $("#revolver_king_chance b").html((kingChance).toFixed(2) + '%');
  460. $("#revolver_player_chance b").html((100 - kingChance).toFixed(2) + '%');
  461. $("#revolver_king_chance, #revolver_player_chance").show();
  462. $("#revolver_hash b").html(data.hash);
  463. $("#revolver_hash").show();
  464. timeouts.push(setTimeout(function() {
  465. revolverDuel(data.chamber.number, 1);
  466. }, 2000));
  467. timeouts.push(setTimeout(function() {
  468. if (data.chamber.number % 2 != 0) {
  469. $("#revolver_king_profit b").html(data.winner.profit);
  470. $("#revolver_players div[data-id='" + data.player.bet.revolver_bet_id + "']").remove();
  471. } else {
  472. revolverKing(data.player.bet.revolver_bet_id, data.player.user.avatar, data.winner.profit);
  473. }
  474. var effectText = '';
  475. if (data.chamber.number == 1) {
  476. effectText = '<i class="fa fa-crosshairs"></i> ONE TAP';
  477. } else if (data.king.bet.wins >= 1 && data.chamber.number % 2 != 0) {
  478. effectText = '<i class="fa fa-link"></i> COMBO X' + (parseInt(data.king.bet.wins) + 1);
  479. } else if (data.king.bet.wins > 1 && data.chamber.number % 2 == 0) {
  480. effectText = '<i class="fa fa-chain-broken"></i> COMBOBREAKER';
  481. } else if (data.chamber.number == 6) {
  482. effectText = '<i class="fa fa-bullseye"></i> LAST BULLET';
  483. }
  484. if (effectText != '') {
  485. $("#revolver_duel_holder").prepend('<div class="revolver_shot_effect">' + effectText + '</div>');
  486. setTimeout(function() {
  487. $(".revolver_shot_effect").remove();
  488. }, 2000);
  489. }
  490. $("#revolver_blood_player, #revolver_blood_king").hide();
  491. $("#revolver_hat_player").hide();
  492. $("#revolver_user_player").hide();
  493. $("#revolver_king_chance, #revolver_player_chance, #revolver_hash").hide();
  494. $("#revolver_king_chance b, #revolver_player_chance b").html('0%');
  495. $("#revolver_hash b").html('');
  496. }, 1200 * (data.chamber.number) + 3000));
  497. timeouts.push(setTimeout(function() {
  498. $("#cylinder_chambers div:nth-of-type(" + data.chamber.number + ")").append('<span class="bullet"></span>');
  499. }, (data.chamber.number) * 1200 + 2100));
  500. }
  501.  
  502. function revolverDuel(chamber, shots) {
  503. if (chamber >= 1) {
  504. timeouts.push(setTimeout(function() {
  505. revolverShoot(chamber, 1);
  506. }, 1 * 1200));
  507. }
  508. if (chamber >= 2) {
  509. timeouts.push(setTimeout(function() {
  510. revolverShoot(chamber, 2);
  511. }, 2 * 1200));
  512. }
  513. if (chamber >= 3) {
  514. timeouts.push(setTimeout(function() {
  515. revolverShoot(chamber, 3);
  516. }, 3 * 1200));
  517. }
  518. if (chamber >= 4) {
  519. timeouts.push(setTimeout(function() {
  520. revolverShoot(chamber, 4);
  521. }, 4 * 1200));
  522. }
  523. if (chamber >= 5) {
  524. timeouts.push(setTimeout(function() {
  525. revolverShoot(chamber, 5);
  526. }, 5 * 1200));
  527. }
  528. if (chamber >= 6) {
  529. timeouts.push(setTimeout(function() {
  530. revolverShoot(chamber, 6);
  531. }, 6 * 1200));
  532. }
  533. }
  534.  
  535. function revolverShoot(chamber, shot) {
  536. if (shot % 2 != 0) {
  537. $("#revolver_pistol_king").show();
  538. timeouts.push(setTimeout(function() {
  539. $("#revolver_pistol_king").stop(true, true).addClass('revolver_recoil_king');
  540. }, 500));
  541. } else {
  542. $("#revolver_pistol_player").show();
  543. timeouts.push(setTimeout(function() {
  544. $("#revolver_pistol_player").stop(true, true).addClass('revolver_recoil_player');
  545. }, 500));
  546. }
  547. timeouts.push(setTimeout(function() {
  548. $("#revolver_pistol_king, #revolver_pistol_player").removeClass('revolver_recoil_king').removeClass('revolver_recoil_player').hide();
  549. }, 900));
  550. timeouts.push(setTimeout(function() {
  551. if (chamber == shot) {
  552. $("span.bullet").fadeOut(200);
  553. $(".revolver_shot").trigger('play');
  554. setTimeout(function() {
  555. $(".revolver_shot").trigger('play');
  556. }, 600);
  557. if (shot % 2 != 0 && $("#revolver_user_player").is(':visible')) {
  558. $("#revolver_blood_player").show();
  559. } else if ($("#revolver_user_player").is(':visible')) {
  560. $("#revolver_blood_king").show();
  561. }
  562. } else {
  563. $(".revolver_dry").trigger('play');
  564. setTimeout(function() {
  565. $(".revolver_dry").trigger('play');
  566. }, 400);
  567. }
  568. $("#cylinder").css('transform', 'rotate(' + (getRotationDegrees($("#cylinder")) + 60) + 'deg)');
  569. }, 450));
  570. }
  571.  
  572. function casesNew(data) {
  573. var testSpin = '';
  574. if (data.item.test == 1) {
  575. testSpin = ' (Test)';
  576. }
  577. $("#cases_latest_title").after('<div class="cases_list_item tool" title="<b>' + data.item.name + '</b><br>' + data.item.value + ' Credits' + testSpin + '"><div class="item_color" style="background: ' + data.item.color + ';"></div><a show-profile="' + data.user.user_id + '"><img src="' + data.user.avatar + '" class="cases_list_item_user"></a><img src="' + data.case.image + '" class="cases_list_item_case_image"><img src="' + data.item.image + '" class="cases_list_item_image"></div>');
  578. $('.cases_list_item').not('.cases_list_item:lt(24)').remove();
  579. }
  580.  
  581. function casesOpen(case_id, case_price, testSpin, button, buttonHTML) {
  582. $.ajax({
  583. type: "GET",
  584. url: "/cases_bet.php",
  585. data: {
  586. case_id: case_id,
  587. user_token: $("#user_token").val(),
  588. test: testSpin
  589. },
  590. success: function(text) {
  591. if (text == 'errorCredits') {
  592. needCredits();
  593. button.prop('disabled', false).html(buttonHTML);
  594. } else if (text == 'errorAction') {
  595. swal({
  596. title: phraser('ERROR'),
  597. html: phraser('ACTION_NOT_AVAILABLE'),
  598. type: 'error',
  599. confirmButtonText: phraser('OKAY')
  600. });
  601. button.prop('disabled', false).html(buttonHTML);
  602. } else {
  603. if (parseInt($("#case_tokens span").html()) == 0 && !testSpin) {
  604. updateCredits(-1 * case_price);
  605. } else if (!testSpin) {
  606. $("#case_tokens span").html(parseInt($("#case_tokens span").html()) - 1);
  607. }
  608. text = text.split(";");
  609. $.ajax({
  610. type: "GET",
  611. url: "/cases_load.php",
  612. data: {
  613. spinner: true,
  614. case_id: case_id,
  615. case_item_id: text[0]
  616. },
  617. success: function(resp) {
  618. $(".case_buttons").hide();
  619. $("#round_draw_pointer").show();
  620. $(".case_spinner").removeClass('case_spinner_filter').html(resp).css('padding-left', ($(".case_spinner_holder").width() / 2 + 20 - (Math.floor(Math.random() * 110) + 10)) + 'px').addClass('case_spinner_animate');
  621. $(".case_open_sound").trigger('play');
  622. timeouts.push(setTimeout(function() {
  623. $(".case_open_sound").trigger('pause');
  624. $(".case_open_sound").prop("currentTime", 0);
  625. }, 8000));
  626. timeouts.push(setTimeout(function() {
  627. $("#round_draw_pointer").hide();
  628. $("#case_item_win").removeClass('background_flow').addClass('background_master').css('border', '2px solid #fad733');
  629. }, 7100));
  630. timeouts.push(setTimeout(function() {
  631. $("#case_item_win .case_item_wear").show();
  632. $("#case_item_win .case_item_price").show();
  633. $(".woosh").trigger('play');
  634. setTimeout(function() {
  635. $(".woosh").trigger('pause');
  636. $(".woosh").prop("currentTime", 0);
  637. }, 300);
  638. }, 7800));
  639. timeouts.push(setTimeout(function() {
  640. $("#case_item_win .case_item_wear").html(text[1]);
  641. $("#case_item_win .case_item_price").html(text[2]);
  642. $(".woosh").trigger('play');
  643. setTimeout(function() {
  644. $(".woosh").trigger('pause');
  645. $(".woosh").prop("currentTime", 0);
  646. }, 300);
  647. }, 8300));
  648. timeouts.push(setTimeout(function() {
  649. button.prop('disabled', false).html(buttonHTML);
  650. $(".case_buttons").show();
  651. $(".case_spinner").css('padding-left', '0').removeClass('case_spinner_animate').addClass('case_spinner_filter');
  652. }, 10000));
  653. if (!testSpin) {
  654. setTimeout(function() {
  655. $.growl.notice({
  656. title: 'Cases',
  657. message: phraser("YOUR_CASE_CONTAINED") + " <b>" + text[3] + "</b>. " + phraser("YOUR_ITEM_IS_WORTH") + " <b>" + text[2] + "</b> Credits!"
  658. });
  659. updateCredits(text[2]);
  660. $(".cases_hash span").html(text[4]);
  661. }, 10000);
  662. } else {
  663. setTimeout(function() {
  664. $(".cases_hash span").html(text[4]);
  665. }, 10000);
  666. }
  667. }
  668. });
  669. }
  670. }
  671. });
  672. }
  673.  
  674. function BezierCubicXY(p0, p1, p2, p3, t) {
  675. var ret = {};
  676. var coords = ['x', 'y'];
  677. var i, k;
  678. for (i in coords) {
  679. k = coords[i];
  680. ret[k] = Math.pow(1 - t, 3) * p0[k] + 3 * Math.pow(1 - t, 2) * t * p1[k] + 3 * (1 - t) * Math.pow(t, 2) * p2[k] + Math.pow(t, 3) * p3[k];
  681. }
  682. return ret;
  683. }
  684.  
  685. function getMultiplierFromBezier(bezierCurve, durationPercent, maxMultiplier) {
  686. var p1 = {
  687. x: 0,
  688. y: 0
  689. };
  690. var p2 = {
  691. x: bezierCurve[0],
  692. y: bezierCurve[1]
  693. };
  694. var p3 = {
  695. x: bezierCurve[2],
  696. y: bezierCurve[3]
  697. };
  698. var p4 = {
  699. x: 1,
  700. y: 1
  701. };
  702. var val = BezierCubicXY(p1, p2, p3, p4, durationPercent);
  703. return val.y * maxMultiplier + 1;
  704. }
  705.  
  706. function getWidthFromMultiplier(bezierCurve, durationPercent, maxMultiplier) {
  707. var p1 = {
  708. x: 0,
  709. y: 0
  710. };
  711. var p2 = {
  712. x: bezierCurve[0],
  713. y: bezierCurve[1]
  714. };
  715. var p3 = {
  716. x: bezierCurve[2],
  717. y: bezierCurve[3]
  718. };
  719. var p4 = {
  720. x: 1,
  721. y: 1
  722. };
  723. var val = BezierCubicXY(p1, p2, p3, p4, durationPercent);
  724. return val.x * maxMultiplier + 1;
  725. }
  726.  
  727. function crashBetAdd(data) {
  728. if ($("#crash_graph_holder").length == 0) {
  729. return;
  730. }
  731. $("#crash_list").append('<tr data-id="' + data.bet.crash_bet_id + '" data-handled="false"><td class="crash_list_user"><a show-profile="' + data.player.user_id + '"><img src="' + data.player.avatar + '" class="crash_list_img"></a>' + data.player.persona + '</td><td></td><td>' + data.bet.value + '</td><td class="crash_list_profit">---</td></tr>');
  732. $(".blop").trigger('play');
  733. }
  734.  
  735. function crashBetRemove(data) {
  736. if ($("#crash_graph_holder").length == 0) {
  737. return;
  738. }
  739. var listItem = $("#crash_list tr[data-id='" + data.bet.crash_bet_id + "']");
  740. $("#crash_list tr[data-id='" + data.bet.crash_bet_id + "']").remove();
  741. listItem.insertAfter('#crash_list .crash_list_titles').css('color', '#27c24c').attr('data-handled', 'true');
  742. $("#crash_list tr[data-id='" + data.bet.crash_bet_id + "'] td.crash_list_profit").html(parseFloat(data.bet.profit).toFixed(2));
  743. if (data.player.user_id == userID) {
  744. $("#crash_form_cashout").fadeOut();
  745. updateCredits(data.bet.credits);
  746. $.growl.notice({
  747. title: 'Crash',
  748. message: phraser('WON_A_TOTAL_OF') + " <b>" + parseFloat(data.bet.credits).toFixed(2) + "</b>" + phraser('CREDITS_ON') + " Crash."
  749. });
  750. }
  751. }
  752. var crashCountdownTimer;
  753.  
  754. function crashCountdown(text) {
  755. if ($("#crash_graph_holder").length == 0) {
  756. return;
  757. }
  758. $("#crash_graph_y_holder").html('');
  759. for (y = 11; y >= 1; y--) {
  760. $("#crash_graph_y_holder").prepend('<div class="crash_graph_y" data-value="' + y + '" style="bottom:' + ((y - 1) * 10) + '%;"><span>' + y + '</span><i></i></div>');
  761. }
  762. $("#crash_overlay").height('100%');
  763. $("#triangle_gradient_color").attr('stop-color', '#0cb6e7');
  764. $("#crash_amount").fadeOut(100);
  765. $("#crash_countdown").html(text).fadeIn(100);
  766. var startSec = parseInt(text);
  767. var startTime = new Date().getTime();
  768. timeouts.push(crashCountdownTimer = setInterval(function() {
  769. var timeElapse = Math.floor((new Date().getTime() - startTime) / 1000);
  770. var sec = startSec - timeElapse;
  771. if (sec <= 0) {
  772. sec = 0;
  773. clearInterval(crashCountdownTimer);
  774. }
  775. $("#crash_countdown").html(sec);
  776. }, 1000));
  777. }
  778.  
  779. function crashStart(instant_crash, durationPercent) {
  780. if ($("#crash_graph_holder").length == 0) {
  781. return;
  782. }
  783. clearInterval(crashCountdownTimer);
  784. $("#crash_countdown").fadeOut(100);
  785. $("#crash_form_cashout button").prop('disabled', false)
  786. if (instant_crash == 0) {
  787. $("#crash_amount").css('color', '#fff').fadeIn(100);
  788. crashAnimationStart(durationPercent);
  789. } else {
  790. $("#crash_amount").css('color', '#b75552').fadeIn(100);
  791. crashAnimationStop(0.01);
  792. }
  793. }
  794.  
  795. function crashStop(data) {
  796. if ($("#crash_graph_holder").length == 0) {
  797. return;
  798. }
  799. if (data.old_round.instant_crash == 0) {
  800. crashAnimationStop(data.old_round.multiplier);
  801. }
  802. $("#crash_hash").html(phraser('HASH') + ': ' + data.new_round.hash);
  803. $("#crash_round").html(phraser('ROUND_L') + ': ' + data.new_round.crash_id);
  804. $("#crash_list tr[data-id]").remove();
  805. $("#crash_latest_list").prepend('<span class="tool-top" title="<b>' + phraser('ROUND_L') + ':</b><br>' + data.old_round.crash_id + '<br><br><b>' + phraser('WIN_PERCENTAGE') + ':</b><br>' + data.old_round.percentage + '<br><br><b>' + phraser('HASH') + ':</b><br>' + data.old_round.hash + '">' + data.old_round.multiplier + '<i class="fa fa-times"></i></span>');
  806. timeouts.push(setTimeout(function() {
  807. if (crashAutoBet) {
  808. $("#crash_form").submit();
  809. }
  810. }, 3000));
  811. }
  812. var crashAutoBet = false;
  813. var crash_percentage = "";
  814. var crashAnimation;
  815.  
  816. function crashAnimationStart(durationPercent) {
  817. if ($("#crash_graph_holder").length == 0) {
  818. return;
  819. }
  820. if (durationPercent == 0) {
  821. $(".load").trigger('play');
  822. setTimeout(function() {
  823. $(".load").trigger('pause');
  824. $(".load").prop("currentTime", 0);
  825. }, 1000);
  826. }
  827. var durationFull = 60 * 8;
  828. var maxMultiplier = 1000;
  829. var curve = [.35, .01, .37, .1];
  830. var startTime = new Date().getTime();
  831. crashAnimation = $({
  832. value: 0
  833. }).animate({
  834. value: maxMultiplier
  835. }, {
  836. duration: durationFull * 1000,
  837. easing: 'linear',
  838. step: function(now, fx) {
  839. var multiplier = getMultiplierFromBezier(curve, fx.pos + durationPercent, maxMultiplier).toFixed(2);
  840. if (multiplier > 11) {
  841. $("#crash_overlay").css('height', '0%');
  842. if ($(".crash_graph_y").length < 11) {
  843. var y = parseInt($(".crash_graph_y").first().attr('data-value')) + 1;
  844. $("#crash_graph_y_holder").prepend('<div class="crash_graph_y" data-value="' + y + '" style="bottom:150%;"><span>' + y + '</span><i></i></div>');
  845. }
  846. $(".crash_graph_y").each(function() {
  847. var y = $(this).attr('data-value');
  848. if (y < multiplier - 10) {
  849. $(this).remove();
  850. } else {
  851. $(this).css('bottom', (y - multiplier + 10) * 10 + '%');
  852. }
  853. });
  854. } else {
  855. $("#crash_overlay").css('height', (100 - (multiplier - 1) * 10) + '%');
  856. }
  857. var r = 12 + Math.round(multiplier * 7.5 * 9);
  858. var g = 182 - Math.round(multiplier * 1.2 * 9);
  859. var b = 231 - Math.round(multiplier * 2.4 * 9);
  860. $("#triangle_gradient_color").attr('stop-color', 'rgb(' + r + ', ' + g + ', ' + b + ')');
  861. $('#crash_amount').text(multiplier + 'x');
  862. $(".crash_profit_label b").html((parseFloat($(".crash_profit_label").attr('data-value')) * multiplier - parseFloat($(".crash_profit_label").attr('data-value'))).toFixed(2));
  863. if (multiplier % 5 == 0 || multiplier == 1) {
  864. crashParticles();
  865. }
  866. }
  867. });
  868. }
  869.  
  870. function crashAnimationStop(endMultiplier) {
  871. $(".cork").trigger('play');
  872. timeouts.push(setTimeout(function() {
  873. $(".cork").trigger('pause');
  874. $(".cork").prop("currentTime", 0);
  875. }, 2000));
  876. $(crashAnimation).stop(true, false);
  877. $(crashParticleAnimation).stop(true, false);
  878. $("#crash_form_cashout button").prop('disabled', true);
  879. $("#crash_form_cashout").fadeOut();
  880. timeouts.push(setTimeout(function() {
  881. var stopHeight = 100 - (endMultiplier - 1) * 10;
  882. if (endMultiplier < 1 || stopHeight > 100) {
  883. stopHeight = 100;
  884. }
  885. $("#crash_amount").stop(true, false).css('color', '#b75552').text(phraser('CRASHED_AT') + ' ' + endMultiplier + 'x');
  886. $("#crash_overlay").css('height', stopHeight + '%');
  887. if (endMultiplier > 11) {
  888. $("#crash_overlay").css('height', '0%');
  889. $("#crash_graph_y_holder").html('');
  890. for (y = Math.floor(endMultiplier); y >= Math.floor(endMultiplier) - 10; y--) {
  891. $("#crash_graph_y_holder").prepend('<div class="crash_graph_y" data-value="' + y + '" style="bottom:' + ((y - endMultiplier + 10) * 10) + '%;"><span>' + y + '</span><i></i></div>');
  892. }
  893. } else {
  894. $("#crash_overlay").css('height', stopHeight + '%');
  895. $("#crash_graph_y_holder").html('');
  896. for (y = 11; y >= 1; y--) {
  897. $("#crash_graph_y_holder").prepend('<div class="crash_graph_y" data-value="' + y + '" style="bottom:' + ((y - 1) * 10) + '%;"><span>' + y + '</span><i></i></div>');
  898. }
  899. }
  900. }, 100));
  901. timeouts.push(setTimeout(function() {
  902. crashCountdown(10);
  903. }, 3000));
  904. }
  905. var crashParticleAnimation;
  906.  
  907. function crashParticles() {
  908. if ($("#crash_graph_holder").length == 0) {
  909. return;
  910. }
  911. $(crashParticleAnimation).stop(true);
  912. $("#crash_amount").css('color', 'rgb(255, 215, 0)');
  913. crashParticleAnimation = $({
  914. someValue: 0
  915. }).animate({
  916. someValue: 255
  917. }, {
  918. duration: 1000,
  919. easing: 'linear',
  920. step: function() {
  921. var g = 215 + Math.round((this.someValue / 255) * (255 - 215));
  922. var b = 0 + Math.round(this.someValue);
  923. $("#crash_amount").css('color', 'rgb(255, ' + g + ', ' + b + ')');
  924. },
  925. complete: function() {
  926. $("#crash_amount").css('color', 'rgb(255, 255, 255)');
  927. }
  928. });
  929. $("#graph_particles").explosion({
  930. origin: {
  931. x: $("#graph_particles").width() / 2,
  932. y: $("#graph_particles").height() / 2
  933. }
  934. });
  935. }
  936.  
  937. function safeboxBet(data) {
  938. if (data.answer == 'correct') {
  939. $("#safe_box_log .round_bet").remove();
  940. $(".safe_box_empty").show();
  941. $("#safe_box_pot span").text("1000");
  942. return;
  943. }
  944. var oldValue = $("#safe_box_pot span").text();
  945. var newValue = parseFloat(oldValue) + 0.25;
  946. $("#safe_box_pot span").text(newValue);
  947. $("#safe_box_pot").prepend('<div class="safe_box_add"><i class="fa fa-plus"></i></div>');
  948. $(".safe_box_add").fadeOut(2000);
  949. $('<div class="round_bet"><span class="safe_box_tries">' + data.number + '</span><a show-profile="' + data.player.user_id + '"><img src="' + data.player.avatar + '"></a> <b>' + data.player.persona + '</b></div>').hide().prependTo("#safe_box_log").fadeIn(1000);
  950. $(".safe_box_empty").hide();
  951. }
  952. var scratchy_finished = false;
  953.  
  954. function scratchyEnd(arg) {
  955. scratchy_finished = true;
  956. document.getSelection().removeAllRanges();
  957. $('#scratchy_pad').wScratchPad('enable', false).wScratchPad('clear');
  958. arg = arg.split(";");
  959. result = arg[0];
  960. $("#scratchy_hash").html("<b>" + phraser('HASH') + ":</b> " + arg[1]);
  961. if (result > 3) {
  962. var chestWinnings = [0, 0, 0, 0, 5, 10, 50, 100, 300, 1000];
  963. updateCredits(chestWinnings[result]);
  964. $.growl.notice({
  965. title: 'Scratchy',
  966. message: phraser("TICKET_RESULTED_IN") + result + " " + phraser("CHESTS") + phraser("SCRATCHY_YOU_WON") + chestWinnings[result] + " Credits."
  967. });
  968. } else {
  969. $.growl.error({
  970. title: 'Scratchy',
  971. message: phraser("TICKET_RESULTED_IN") + result + " " + phraser("CHESTS") + phraser("SCRATCHY_YOU_DIDNT_WIN")
  972. });
  973. }
  974. timeouts.push(setTimeout(function() {
  975. $('#scratchy_pad').wScratchPad('reset').wScratchPad('destroy').remove();
  976. $("#scratchy_holder").prepend('<div id="scratchy_pad"></div>');
  977. $("#scratchy_form").show();
  978. scratchyStart();
  979. }, 5000));
  980. }
  981.  
  982. function scratchyStart() {
  983. scratchy_finished = false;
  984. $("#scratchy_pad").wScratchPad({
  985. size: 30,
  986. bg: site + '/images/scratchy_1_1.png?load',
  987. fg: site + '/images/scratchy_clear.png?load',
  988. cursor: 'url("' + site + '/images/scratch-coin-small.png") 10 10, default',
  989. realtime: true,
  990. scratchDown: null,
  991. scratchUp: null,
  992. scratchMove: function(e, percent) {
  993. if (percent > 50 && !scratchy_finished) {
  994. scratchy_finished = true;
  995. scratchyEnd($("#scratchy_result").html());
  996. }
  997. }
  998. }).wScratchPad('enable', false);
  999. }
  1000.  
  1001. function raceSort() {
  1002. $('#dragrace_listings').find('.dragrace_list').sort(function(a, b) {
  1003. if ($(b).attr('data-status') == $(a).attr('data-status')) {
  1004. return parseInt($(b).attr('data-sort')) - parseInt($(a).attr('data-sort'));
  1005. }
  1006. return parseInt($(a).attr('data-status')) - parseInt($(b).attr('data-status'));
  1007. }).prependTo('#dragrace_listings');
  1008. }
  1009.  
  1010. function raceAdd(data) {
  1011. if ($("#race_" + data.game.dragrace_id).length == 0) {
  1012. $("#dragrace_listings").append('<div class="dragrace_list" id="coin_' + data.game.dragrace_id + '" data-sort="' + data.game.value + '" data-status="0"><span class="dragrace_list_status_join" data-id="' + data.game.dragrace_id + '" data-value="' + data.game.value + '"><i class="fa fa-play-circle"></i> ' + phraser('CHALLENGE') + '</span><span class="dragrace_list_status_view" data-id="' + data.game.dragrace_id + '"><i class="fa fa-eye"></i></span><span class="dragrace_list_value">' + data.game.value + '<br>Credits</span><a show-profile="' + data.player.user_id + '"><img src="' + data.player.avatar + '" class="dragrace_list_avatar"></a></div>');
  1013. raceSort();
  1014. }
  1015. }
  1016.  
  1017. function raceJoin(data) {
  1018. $("#race_" + data.game.dragrace_id).append('<a show-profile="' + data.player.user_id + '"><img src="' + data.player.avatar + '" class="dragrace_list_avatar"></a>');
  1019. if ($("#dragrace_game_" + data.game.dragrace_id).length > 0) {
  1020. $("#race_track_cars").append('<img data-player="' + data.player.position + '" src="' + site + '/images/race_smoke_v2.gif" class="race_track_smoke race_track_car_' + data.player.position + '"><img data-player="' + data.player.position + '" src="' + site + '/images/race_car' + data.player.car_image + '.png" class="race_track_car race_track_car_' + data.player.position + '">');
  1021. $(".race_player[data-player='" + data.player.position + "'").html('<img src="' + site + '/images/race_car' + data.player.car_image + '.png" class="race_player_car"><img src="' + data.player.avatar + '" class="race_player_avatar" data-player="' + data.player.position + '">');
  1022. if (data.game.finish == '1') {
  1023. raceStart(data.game.winner_position);
  1024. }
  1025. }
  1026. if (data.game.finish == '1') {
  1027. raceEnd(data);
  1028. }
  1029. }
  1030.  
  1031. function raceEnd(data) {
  1032. $("#race_" + data.game.dragrace_id).attr('data-status', '1');
  1033. $("#race_" + data.game.dragrace_id + " .dragrace_list_status_join").removeClass('dragrace_list_status_join dragrace_list_status_join_final').addClass('dragrace_list_status_finished').html(phraser('FINISHED'));
  1034. raceSort();
  1035. if (data.top.user_id == userID || data.mid.user_id == userID || data.player.user_id == userID) {
  1036. setTimeout(function() {
  1037. if (data.game.winner_user_id == userID) {
  1038. $.growl.notice({
  1039. title: 'Drag Race',
  1040. message: phraser('THE_GAME_OF') + " <b>" + data.game.value + "</b> Credits" + phraser('ENDED_AS') + "<b>" + phraser('WIN') + "</b>."
  1041. });
  1042. updateCredits(2.95 * data.game.value);
  1043. } else {
  1044. $.growl.error({
  1045. title: 'Drag Race',
  1046. message: phraser('THE_GAME_OF') + " <b>" + data.game.value + "</b> Credits" + phraser('ENDED_AS') + "<b>" + phraser('LOSS') + "</b>."
  1047. });
  1048. }
  1049. }, 9200);
  1050. }
  1051. if ($("#dragrace_game_" + data.game.dragrace_id).length > 0) {
  1052. raceStart(data.game.winner_position);
  1053. }
  1054. }
  1055.  
  1056. function raceLoad(type, dragrace_id) {
  1057. $("#race_res").hide();
  1058. $("#race_loader").show();
  1059. $.ajax({
  1060. type: "GET",
  1061. url: "/dragrace_load.php",
  1062. data: {
  1063. type: type,
  1064. dragrace_id: dragrace_id
  1065. },
  1066. success: function(text) {
  1067. $("#race_loader").hide();
  1068. $("#race_res").html(text).show();
  1069. }
  1070. });
  1071. }
  1072.  
  1073. function raceStart(winner_position) {
  1074. var winner = 1;
  1075. if (winner_position == 'mid') {
  1076. winner = 2;
  1077. }
  1078. if (winner_position == 'bot') {
  1079. winner = 3;
  1080. }
  1081. var animation = [0, Math.floor(Math.random() * 3) + 1, Math.floor(Math.random() * 3) + 1, Math.floor(Math.random() * 3) + 1];
  1082. animation[winner] = Math.floor(Math.random() * 3) + 4;
  1083. timeouts.push(setTimeout(function() {
  1084. $("[data-light='1']").attr('src', site + '/images/race_light_orange.png');
  1085. $(".race_count").trigger('play');
  1086. timeouts.push(setTimeout(function() {
  1087. $(".race_count").trigger('pause');
  1088. $(".race_count").prop("currentTime", 0);
  1089. }, 4000));
  1090. }, 1000));
  1091. timeouts.push(setTimeout(function() {
  1092. $("[data-light='2']").attr('src', site + '/images/race_light_orange.png');
  1093. }, 2000));
  1094. timeouts.push(setTimeout(function() {
  1095. $("[data-light='3']").attr('src', site + '/images/race_light_orange.png');
  1096. $(".race_track_smoke").fadeIn(1000);
  1097. }, 3000));
  1098. timeouts.push(setTimeout(function() {
  1099. $(".race_crowd, .race_crowd2").removeClass('race_crowd_bg').addClass('race_crowd_move_bg');
  1100. $("[data-light='4']").attr('src', site + '/images/race_light_green.png');
  1101. $(".race_track_car[data-player='top'], .race_track_smoke[data-player='top']").addClass('car_animate_' + animation[1]);
  1102. $(".race_track_car[data-player='mid'], .race_track_smoke[data-player='mid']").addClass('car_animate_' + animation[2]);
  1103. $(".race_track_car[data-player='bot'], .race_track_smoke[data-player='bot']").addClass('car_animate_' + animation[3]);
  1104. $(".race_sound_fx").trigger('play');
  1105. timeouts.push(setTimeout(function() {
  1106. $(".race_sound_fx").trigger('pause');
  1107. $(".race_sound_fx").prop("currentTime", 0);
  1108. }, 8000));
  1109. }, 4000));
  1110. timeouts.push(setTimeout(function() {
  1111. $(".race_crowd, .race_crowd2").removeClass('race_crowd_move_bg').addClass('race_crowd_bg');
  1112. $(".race_track_smoke").fadeOut(1000);
  1113. $(".race_player[data-player='" + winner_position + "']").append('<img src="' + site + '/images/race_winner.png" class="race_player_winner">');
  1114. $(".race_player_avatar[data-player='" + winner_position + "']").css('border', '1px solid #FAD733').css('box-shadow', '0px 0px 5px #FAD733');
  1115. }, 9500));
  1116. }
  1117.  
  1118. function bettingEnd(data) {
  1119. if (data.game.result == 'draw') {
  1120. $.growl.warning({
  1121. title: 'Match Betting',
  1122. message: phraser('THE_GAME_OF') + " <b>" + data.bet.value + "</b> Credits" + phraser('ENDED_AS') + "<b>" + phraser('DRAW') + "</b>."
  1123. });
  1124. updateCredits(data.bet.result);
  1125. } else if (data.game.result == 'loss') {
  1126. $.growl.error({
  1127. title: 'Match Betting',
  1128. message: phraser('THE_GAME_OF') + " <b>" + data.bet.value + "</b> Credits" + phraser('ENDED_AS') + "<b>" + phraser('LOSS') + "</b>."
  1129. });
  1130. } else {
  1131. $.growl.notice({
  1132. title: 'Match Betting',
  1133. message: phraser('THE_GAME_OF') + " <b>" + data.bet.value + "</b> Credits" + phraser('ENDED_AS') + "<b>" + phraser('WIN') + "</b>."
  1134. });
  1135. updateCredits(data.bet.result);
  1136. }
  1137. }
  1138.  
  1139. function coinSort() {
  1140. $('#coinflip_listings').find('.coinflip_list').sort(function(a, b) {
  1141. if ($(b).attr('data-status') == $(a).attr('data-status')) {
  1142. return parseInt($(b).attr('data-sort')) - parseInt($(a).attr('data-sort'));
  1143. }
  1144. return parseInt($(a).attr('data-status')) - parseInt($(b).attr('data-status'));
  1145. }).prependTo('#coinflip_listings');
  1146. }
  1147.  
  1148. function coinAdd(data) {
  1149. if ($("#coin_" + data.game.coinflip_id).length == 0) {
  1150. $("#coinflip_listings").append('<div class="coinflip_list" id="coin_' + data.game.coinflip_id + '" data-sort="' + data.game.value + '" data-status="0"><span class="coinflip_list_status_join" data-id="' + data.game.coinflip_id + '" data-value="' + data.game.value + '"><i class="fa fa-play-circle"></i> ' + phraser('CHALLENGE') + '</span><span class="coinflip_list_status_view" data-id="' + data.game.coinflip_id + '"><i class="fa fa-eye"></i></span><img src="' + site + '/images/' + data.creator.side + '.png" class="coinflip_list_side"><span class="coinflip_list_value">' + data.game.value + '<br>Credits</span><a show-profile="' + data.creator.user_id + '"><img src="' + data.creator.avatar + '" class="coinflip_list_avatar"></a><div class="coinflip_list_avatar_vs">VS</div><div class="coinflip_list_avatar_empty">X</div></div>');
  1151. coinSort();
  1152. }
  1153. }
  1154.  
  1155. function coinEnd(data) {
  1156. $("#coin_" + data.game.coinflip_id).attr('data-status', '1');
  1157. $("#coin_" + data.game.coinflip_id + " .coinflip_list_status_join").removeClass('coinflip_list_status_join coinflip_list_status_join_final').addClass('coinflip_list_status_finished').html(phraser('FINISHED'));
  1158. $("#coin_" + data.game.coinflip_id + " .coinflip_list_avatar_empty").remove();
  1159. $("#coin_" + data.game.coinflip_id).append('<a show-profile="' + data.challenger.user_id + '"><img src="' + data.challenger.avatar + '" class="coinflip_list_avatar"></a>');
  1160. coinSort();
  1161. if (data.creator.user_id == userID || data.challenger.user_id == userID) {
  1162. setTimeout(function() {
  1163. if (data.winner.user_id == userID) {
  1164. $.growl.notice({
  1165. title: 'Coin Flip',
  1166. message: phraser('THE_GAME_OF') + " <b>" + data.game.value + "</b> Credits" + phraser('ENDED_AS') + "<b>" + phraser('WIN') + "</b>."
  1167. });
  1168. updateCredits(1.95 * data.game.value);
  1169. } else {
  1170. $.growl.error({
  1171. title: 'Coin Flip',
  1172. message: phraser('THE_GAME_OF') + " <b>" + data.game.value + "</b> Credits" + phraser('ENDED_AS') + "<b>" + phraser('LOSS') + "</b>."
  1173. });
  1174. }
  1175. }, 8500);
  1176. }
  1177. $("#coinflip_amount_" + data.game.side).html(parseInt($("#coinflip_amount_" + data.game.side).html()) + 1);
  1178. if ($("#coinflip_game_" + data.game.coinflip_id).length > 0) {
  1179. $("#coinflip_secret").html(data.game.secret);
  1180. $("#coinflip_percent").html(data.game.percent);
  1181. $("#coinflip_winner_persona").html(data.winner.persona);
  1182. $("#coinflip_waiting").remove();
  1183. $("#coinflip_hidden_user").prepend('<a class="coinflip_player" show-profile="' + data.challenger.user_id + '" data-side="' + data.challenger.side + '"><img src="' + site + '/images/' + data.challenger.side_pic + '.png" class="coinflip_player_side"><img src="' + data.challenger.avatar + '" class="coinflip_player_avatar"></a>');
  1184. coinFlip(data.game.side);
  1185. }
  1186. }
  1187.  
  1188. function coinLoad(type, coinflip_id) {
  1189. $("#coinflip_content").html('<div id="coinflip_loader" class="loader_small"></div>');
  1190. $.ajax({
  1191. type: "GET",
  1192. url: "/coinflip_load.php",
  1193. data: {
  1194. type: type,
  1195. coinflip_id: coinflip_id
  1196. },
  1197. success: function(text) {
  1198. $("#coinflip_content").html(text);
  1199. }
  1200. });
  1201. }
  1202.  
  1203. function coinFlip(side) {
  1204. clearTimeouts();
  1205. $("#coin .both-text").html('5');
  1206. var seconds = 0;
  1207. var timer = setInterval(function() {
  1208. seconds++;
  1209. $("#coin .both-text").html(function(i, html) {
  1210. if ($("#coinflip_table_holder").length == 0 || (parseInt(html) == 0 && seconds == 10)) {
  1211. clearTimeout(timer);
  1212. return "";
  1213. } else if (seconds == 10) {
  1214. seconds = 0;
  1215. return parseInt(html) - 1;
  1216. }
  1217. });
  1218. }, 100);
  1219. $("#coin .both-timer").stop(true).animate({
  1220. 'top': '0px',
  1221. 'opacity': '1',
  1222. }, 6000, "easeInQuad");
  1223. timeouts.push(setTimeout(function() {
  1224. $(".flip").trigger('play');
  1225. setTimeout(function() {
  1226. $(".flip").trigger('pause');
  1227. $(".flip").prop("currentTime", 0);
  1228. }, 2300);
  1229. $('#coin .both').remove();
  1230. $('#coin').addClass('animate' + side);
  1231. $(".coinflip_player, .coinflip_winner").not("#coinflip_winner, #coinflip_info").css('opacity', '0.5');
  1232. }, 6000));
  1233. timeouts.push(setTimeout(function() {
  1234. var borderColor = "#ffd700";
  1235. if (side == 'CT') {
  1236. borderColor = "#0cb6e7";
  1237. }
  1238. $("#coinflip_winner b").css('border-color', borderColor);
  1239. $("[data-side='" + side + "']").css('opacity', '1');
  1240. $("[data-side='" + side + "'] .coinflip_player_side, [data-side='" + side + "'] .coinflip_player_avatar, #coin .front, #coin .back").css('border', '1px solid ' + borderColor).css('box-shadow', '0px 0px 5px ' + borderColor);
  1241. $("#coinflip_winner").css('opacity', '1');
  1242. $("#coinflip_info div").show();
  1243. }, 8000));
  1244. }
  1245.  
  1246. function slotSpin(that, i) {
  1247. var step = 85;
  1248. that.css('margin-top', '0px');
  1249. that.animate({
  1250. marginTop: (-39 * 85) + 'px',
  1251. }, i * 600 + 1000, "easeOutQuad");
  1252. }
  1253.  
  1254. function slotSpinAll() {
  1255. var i = 0;
  1256. $(".slot_child_content").each(function() {
  1257. slotSpin($(this), i);
  1258. i++;
  1259. });
  1260. }
  1261.  
  1262. function slotFill() {
  1263. var fruits = ['apple', 'banana', 'blueberry', 'cherry', 'pear', 'treasure'];
  1264. $(".slot_child_content").each(function() {
  1265. $(this).html('')
  1266. for (var i = 0; i < 40; i++) {
  1267. var fruit = fruits[Math.floor(Math.random() * fruits.length)];
  1268. $(this).append('<img src="' + site + '/images/' + fruit + '.png">');
  1269. }
  1270. });
  1271. }
  1272.  
  1273. function blackJackEnd(data) {
  1274. if (data.player.user_id == userID) {
  1275. var value = data.game.value;
  1276. var credits = data.game.credits;
  1277. var choiceText = data.player.total;
  1278. var oppText = data.dealer.total;
  1279. setTimeout(function() {
  1280. if (data.player.busted) {
  1281. $.growl.error({
  1282. title: 'Blackjack',
  1283. message: phraser('THE_GAME_OF') + " <b>" + parseFloat(value).toFixed(2) + "</b> Credits" + phraser('ENDED_AS') + "<b>" + phraser('LOSS') + "</b>. " + phraser('YOU_GOT_BUSTED')
  1284. });
  1285. } else if (data.winner.state == 'draw') {
  1286. $.growl.warning({
  1287. title: 'Blackjack',
  1288. message: phraser('THE_GAME_OF') + " <b>" + parseFloat(value).toFixed(2) + "</b> Credits" + phraser('ENDED_AS') + "<b>" + phraser('DRAW') + "</b>. " + phraser('YOU_GOT') + choiceText + phraser('DEALER_GOT') + oppText + "."
  1289. });
  1290. updateCredits(credits);
  1291. } else if (data.winner.state == 'win') {
  1292. $.growl.notice({
  1293. title: 'Blackjack',
  1294. message: phraser('THE_GAME_OF') + " <b>" + parseFloat(value).toFixed(2) + "</b> Credits" + phraser('ENDED_AS') + "<b>" + phraser('WIN') + "</b>. " + phraser('YOU_GOT') + choiceText + phraser('DEALER_GOT') + oppText + "."
  1295. });
  1296. updateCredits(credits);
  1297. } else {
  1298. $.growl.error({
  1299. title: 'Blackjack',
  1300. message: phraser('THE_GAME_OF') + " <b>" + parseFloat(value).toFixed(2) + "</b> Credits" + phraser('ENDED_AS') + "<b>" + phraser('LOSS') + "</b>. " + phraser('YOU_GOT') + choiceText + phraser('DEALER_GOT') + oppText + "."
  1301. });
  1302. }
  1303. }, data.dealer.cards * 1000 - 1000);
  1304. }
  1305. }
  1306.  
  1307. function blackJackDeal(cards) {
  1308. var cardArr = cards.split(";");
  1309. var cardOne = cardArr[0].split(",");
  1310. var cardTwo = cardArr[1].split(",");
  1311. var cardThree = cardArr[2].split(",");
  1312. $("#deal_shuffle").hide();
  1313. $("#hit_double_stand").show();
  1314. blackJackAddCard(cardOne[0], 1, cardOne[1], false);
  1315. setTimeout(function() {
  1316. blackJackAddCard(cardThree[0], 1, cardThree[1], true);
  1317. }, 1000);
  1318. setTimeout(function() {
  1319. blackJackAddCard(cardTwo[0], 2, cardTwo[1], false);
  1320. }, 2000);
  1321. setTimeout(function() {
  1322. if (parseInt(cardTwo[1]) != 21) {
  1323. $(".blackjack_double").removeClass('disabled');
  1324. $(".blackjack_hit").removeClass('disabled');
  1325. $(".blackjack_stand").removeClass('disabled');
  1326. } else {
  1327. blackJackStand();
  1328. }
  1329. }, 3000);
  1330. }
  1331.  
  1332. function blackJackHit(card, doubled) {
  1333. card = card.split(",");
  1334. blackJackAddCard(card[0], card[1], card[2], false);
  1335. if (card[3] == 'bust' || doubled) {
  1336. setTimeout(function() {
  1337. $(".blackjack_hit").addClass('disabled');
  1338. blackJackStand();
  1339. }, 1000);
  1340. } else {
  1341. setTimeout(function() {
  1342. $(".blackjack_hit").removeClass('disabled');
  1343. }, 1000);
  1344. }
  1345. if (parseInt(card[2]) == 21 && !doubled) {
  1346. setTimeout(function() {
  1347. blackJackStand();
  1348. }, 1000);
  1349. }
  1350. }
  1351.  
  1352. function blackJackAddCard(card, card_number, sum, dealer) {
  1353. var card_id = "card_p" + card_number;
  1354. var card_color = "card_black";
  1355. var card_icon = "&clubs;";
  1356. var card_value = card.substring(1)
  1357. if (card.charAt(0) == "H") {
  1358. card_color = "card_red";
  1359. card_icon = "&hearts;";
  1360. } else if (card.charAt(0) == "D") {
  1361. card_color = "card_red";
  1362. card_icon = "&diams;";
  1363. } else if (card.charAt(0) == "S") {
  1364. card_icon = "&spades;";
  1365. }
  1366. var degVal, topVal, leftVal, topAlign, playerType, valueType, cardsType;
  1367. degVal = topVal = leftVal = 0;
  1368. if (dealer) {
  1369. topAlign = -1;
  1370. playerType = "#blackjack_dealer";
  1371. valueType = "#blackjack_value_number_dealer";
  1372. cardsType = "#blackjack_dealer";
  1373. } else {
  1374. topAlign = 1;
  1375. playerType = "#blackjack_player";
  1376. valueType = "#blackjack_value_number_player";
  1377. cardsType = "#blackjack_player";
  1378. }
  1379. var leftMargin = $("#blackjack_table").width() / -5 + 30 * (card_number - 1);
  1380. var topMargin = 127 - 5 * card_number;
  1381. topAlign = topMargin * topAlign;
  1382. $("#blackjack_deck").prepend('<div class="card card_90 card_back" id="card_spinning_' + card_id + '" style="z-index:20"></div>');
  1383. $({
  1384. deg: 90,
  1385. top: 0,
  1386. left: 0
  1387. }).animate({
  1388. deg: 360,
  1389. top: topAlign,
  1390. left: leftMargin
  1391. }, {
  1392. duration: 300,
  1393. step: function(now, fx) {
  1394. if (fx.prop == "deg") {
  1395. degVal = now;
  1396. } else if (fx.prop == "top") {
  1397. topVal = now;
  1398. } else if (fx.prop == "left") {
  1399. leftVal = now;
  1400. }
  1401. $("#card_spinning_" + card_id).css({
  1402. top: topVal + 'px',
  1403. left: leftVal + 'px',
  1404. transform: 'rotate(' + degVal + 'deg) scaleX(-1)'
  1405. });
  1406. },
  1407. complete: function() {
  1408. $("#card_spinning_" + card_id).css({
  1409. top: topAlign + 'px',
  1410. left: leftMargin + 'px',
  1411. transform: 'rotate(0deg) scaleX(-1)'
  1412. });
  1413. }
  1414. });
  1415. $(".deal").prop("currentTime", 0.1).trigger('play');
  1416. setTimeout(function() {
  1417. $(".deal").trigger('pause');
  1418. $(".deal").prop("currentTime", 0);
  1419. }, 900);
  1420. setTimeout(function() {
  1421. $("#card_spinning_" + card_id).remove();
  1422. $(playerType).append('<div id="' + card_id + '" class="card_flipper"><div class="card card_back"></div><div class="card ' + card_color + '"><div class="card_top">' + card_icon + ' ' + card_value + '</div><div class="card_mid">' + card_icon + '</div><div class="card_bot">' + card_icon + ' ' + card_value + '</div></div></div>');
  1423. setTimeout(function() {
  1424. $("#" + card_id).addClass('card_flip');
  1425. }, 100);
  1426. setTimeout(function() {
  1427. $(valueType).html(sum);
  1428. }, 300);
  1429. }, 300);
  1430. }
  1431.  
  1432. function blackJackStand() {
  1433. $("#hit_double_stand button").addClass('disabled');
  1434. $(".blackjack_stand").prop('disabled', true).html('<div class="loader_small" style="width: 18px;height: 18px;margin: 0 auto;"></div>');
  1435. $.ajax({
  1436. type: "GET",
  1437. url: "/blackjack_bet.php",
  1438. data: {
  1439. stand: true,
  1440. user_token: $("#user_token").val()
  1441. },
  1442. success: function(text) {
  1443. $(".blackjack_stand").prop('disabled', false).html(phraser('STAND'));
  1444. if (text == 'errorCards' || text == 'errorGameID' || text == 'errorFinished') {
  1445. swal({
  1446. title: phraser('ERROR'),
  1447. html: phraser('ACTION_NOT_AVAILABLE'),
  1448. type: 'error',
  1449. confirmButtonText: phraser('OKAY')
  1450. });
  1451. } else if (text == 'errorAction') {
  1452. swal({
  1453. title: phraser('ERROR'),
  1454. html: phraser('ACTION_NOT_AVAILABLE'),
  1455. type: 'error',
  1456. confirmButtonText: phraser('OKAY')
  1457. });
  1458. } else {
  1459. var cardArr = text.split(";");
  1460. if (cardArr[0] != "bust" && cardArr[0] != "blackjack") {
  1461. var i = 0;
  1462. var card = cardArr[i].split(",");
  1463. blackJackAddCard(card[0], (i + 2), card[1], true);
  1464. i++;
  1465. var cardInterval = setInterval(function() {
  1466. if (i == cardArr.length - 1 || i > cardArr.length - 1) {
  1467. clearInterval(cardInterval);
  1468. } else {
  1469. var card = cardArr[i].split(",");
  1470. blackJackAddCard(card[0], (i + 2), card[1], true);
  1471. i++;
  1472. }
  1473. }, 1000);
  1474. timeouts.push(setTimeout(function() {
  1475. $("#blackjack_player").html('').hide();
  1476. $("#blackjack_dealer").html('');
  1477. $("#blackjack_better").show();
  1478. $(".blackjack_block").hide();
  1479. $(".blackjack_controls").hide();
  1480. $(".blackjack_game_value").html('0 Credits').hide();
  1481. }, (i + 4) * 1000));
  1482. } else {
  1483. timeouts.push(setTimeout(function() {
  1484. $("#blackjack_player").html('').hide();
  1485. $("#blackjack_dealer").html('');
  1486. $("#blackjack_better").show();
  1487. $(".blackjack_block").hide();
  1488. $(".blackjack_controls").hide();
  1489. $(".blackjack_game_value").html('0 Credits').hide();
  1490. }, 1500));
  1491. }
  1492. }
  1493. }
  1494. });
  1495. }
  1496.  
  1497. function addRouletteBet(data) {
  1498. var betHTML = '<div class="roulette_bets" id="r' + data.bet.roulette_bet_id + '" data-user="' + data.player.user_id + '" data-choice="' + data.bet.choice + '"><div class="roulette_bets_value">' + data.bet.value + ' Credits</div><div class="roulette_bets_user"><a show-profile="' + data.player.user_id + '"><img src="' + data.player.avatar + '"></a> ' + data.player.persona + '</div></div>';
  1499. if ($(".roulette_table").length > 0 && !$(".roulette_bets_holder #r" + data.bet.roulette_bet_id).length) {
  1500. if (data.bet.timer_start == 1) {
  1501. startTimer('roulette');
  1502. }
  1503. var betContainer = '#roulette_green';
  1504. if (data.bet.choice == 2) {
  1505. betContainer = '#roulette_red';
  1506. } else if (data.bet.choice == 3) {
  1507. betContainer = '#roulette_black';
  1508. }
  1509. $(betContainer).prepend(betHTML);
  1510. var old_val = parseFloat($("#value").html());
  1511. var new_val = (old_val + parseFloat(data.bet.value));
  1512. $("#value").html(new_val.toFixed(2));
  1513. $('.progress_value').stop(true);
  1514. $({
  1515. someValue: old_val
  1516. }).animate({
  1517. someValue: new_val.toFixed(2)
  1518. }, {
  1519. duration: 200,
  1520. easing: 'swing',
  1521. step: function() {
  1522. $('.progress_value').text(this.someValue.toFixed(2));
  1523. },
  1524. complete: function() {
  1525. $('.progress_value').text(new_val.toFixed(2));
  1526. }
  1527. });
  1528. setTimeout(function() {
  1529. $('.progress_value').stop(true).text(new_val.toFixed(2));
  1530. }, 250);
  1531. var newColorVal = Math.round((parseFloat($(betContainer + "_total").html().replace(" Credits")) + parseFloat(data.bet.value)) * 100) / 100;
  1532. $(betContainer + "_total").html(newColorVal + " Credits");
  1533. document.title = new_val.toFixed(2) + ' - Roulette | CSGOSpeed';
  1534. $(".blop").trigger('play');
  1535. }
  1536. if (data.player.user_id == userID && !$("#global_roulette_bets #r" + data.bet.roulette_bet_id).length) {
  1537. $("#global_roulette_bets").append(betHTML);
  1538. }
  1539. }
  1540.  
  1541. function startRouletteAnimation(data) {
  1542. if ($(".roulette_table").length > 0) {
  1543. var number = data.roulette.winner_number;
  1544. var targetColor = '';
  1545. if (number == 0) {
  1546. targetColor = 'green';
  1547. numberCalc = 0;
  1548. } else if (number > 10) {
  1549. targetColor = 'black';
  1550. numberCalc = 2 * (number - 10);
  1551. } else {
  1552. targetColor = 'red';
  1553. numberCalc = 2 * (number) - 1;
  1554. }
  1555. var numberMargin = 60 * numberCalc;
  1556. var randPos = Math.floor(Math.random() * 52) + 6
  1557. var centerMargin = -21 * 60 + 60 * 7 + $("#page_content").width() / 2;
  1558. var startMargin = centerMargin - numberMargin - randPos;
  1559. $("#round_draw_pointer").show();
  1560. $(".roulette_table").css('left', startMargin + 'px').addClass('roulette_animate');
  1561. $(".click").trigger('play');
  1562. timeouts.push(setTimeout(function() {
  1563. $(".click").trigger('pause');
  1564. $(".click").prop("currentTime", 0);
  1565. }, 5200));
  1566. timeouts.push(setTimeout(function() {
  1567. endRouletteAnimation(data);
  1568. }, 11000));
  1569. timeouts.push(setTimeout(function() {
  1570. calcRouletteBets(targetColor);
  1571. $(".roulette_table").css({
  1572. transform: 'translate(-1680px, 0)'
  1573. });
  1574. }, 8000));
  1575. }
  1576. setTimeout(function() {
  1577. checkRouletteWin(data);
  1578. }, 8000);
  1579. }
  1580.  
  1581. function calcRouletteBets(color) {
  1582. $(".roulette_choice_bets").each(function() {
  1583. var that = $(this);
  1584. var thatTotal = 0;
  1585. var thatSign = '-';
  1586. var thatClass = 'losses';
  1587. var thatColor = that.attr("id").replace('roulette_', '');
  1588. that.find(".roulette_bets .roulette_bets_value").each(function() {
  1589. thatTotal += parseFloat($(this).text());
  1590. });
  1591. thatTotal = (Math.round(thatTotal * 100) / 100)
  1592. if (thatColor == color) {
  1593. thatSign = '+';
  1594. thatClass = 'winnings';
  1595. if (color == 'green') {
  1596. thatTotal = thatTotal * 15;
  1597. } else {
  1598. thatTotal = thatTotal * 2;
  1599. }
  1600. }
  1601. $('#roulette_' + thatColor + '_total').addClass(thatClass);
  1602. $({
  1603. someValue: 0
  1604. }).animate({
  1605. someValue: thatTotal.toFixed(2)
  1606. }, {
  1607. duration: 300,
  1608. easing: 'swing',
  1609. step: function() {
  1610. $('#roulette_' + thatColor + '_total').text(thatSign + " " + this.someValue.toFixed(2) + " Credits");
  1611. },
  1612. complete: function() {
  1613. $('#roulette_' + thatColor + '_total').text(thatSign + " " + thatTotal.toFixed(2) + " Credits");
  1614. }
  1615. });
  1616. });
  1617. }
  1618.  
  1619. function endRouletteAnimation(data) {
  1620. $(".roulette_bets_total span").html('0 Credits').removeClass('winnings').removeClass('losses');
  1621. $("#round_draw_pointer").hide();
  1622. $(".roulette_table").css('left', '0').removeClass('roulette_animate').css({
  1623. transform: 'translate(0, 0)'
  1624. });
  1625. $(".roulette_choice_bets").html('');
  1626. document.title = '0 - Roulette | CSGOSpeed';
  1627. $(".progress_value").html('0');
  1628. $("#value").html('0');
  1629. $("#progress_load_holder_roulette").stop(true).animate({
  1630. width: "0%"
  1631. }, 1000);
  1632. $("#timer_seconds_roulette").html('30');
  1633. $("#timer_minutes_roulette").html('0');
  1634. $(".load").trigger('play');
  1635. setTimeout(function() {
  1636. $(".load").trigger('pause');
  1637. $(".load").prop("currentTime", 0);
  1638. }, 1000);
  1639. $(".roulette_id").html(data.roulette.new_roulette_id);
  1640. var bgColor = '';
  1641. if (data.roulette.winner_number == 0) {
  1642. bgColor = '#5FAE63';
  1643. } else if (data.roulette.winner_number >= 11) {
  1644. bgColor = '#1b1e27';
  1645. } else {
  1646. bgColor = '#bc5652';
  1647. }
  1648. if ($("#rr" + data.roulette.roulette_id).length == 0) {
  1649. $(".roulette_results_holder").prepend('<div class="roulette_result" id="rr' + data.roulette.roulette_id + '" style="background: ' + bgColor + '">' + data.roulette.winner_number + '</div>');
  1650. }
  1651. }
  1652. var checkingRouletteWin = false;
  1653.  
  1654. function checkRouletteWin(data) {
  1655. if (!checkingRouletteWin) {
  1656. checkingRouletteWin = true;
  1657. var total = 0;
  1658. $("#global_roulette_bets .roulette_bets[data-user='" + userID + "']").each(function() {
  1659. var betChoice = $(this).attr("data-choice");
  1660. if ((betChoice - 1) * 10 >= data.roulette.winner_number && (betChoice - 1) * 10 - 9 <= data.roulette.winner_number) {
  1661. var times = 2;
  1662. if (betChoice == 1) {
  1663. times = 15;
  1664. }
  1665. total += parseFloat($(this).find('.roulette_bets_value').html()) * times;
  1666. }
  1667. });
  1668. if (total > 0) {
  1669. updateCredits(total);
  1670. $.growl.notice({
  1671. title: 'Roulette',
  1672. message: phraser('WON_A_TOTAL_OF') + " <b>" + parseFloat(total).toFixed(2) + "</b>" + phraser('CREDITS_ON') + " Roulette."
  1673. });
  1674. }
  1675. setTimeout(function() {
  1676. checkingRouletteWin = false;
  1677. }, 5000);
  1678. }
  1679. $("#global_roulette_bets").html('');
  1680. }
  1681.  
  1682. function sortHeadsup() {
  1683. $('#headsup_bets').find('.headsup_thumb').sort(function(a, b) {
  1684. return parseInt($(b).attr('data-sort')) - parseInt($(a).attr('data-sort'));
  1685. }).prependTo('#headsup_bets');
  1686. }
  1687.  
  1688. function addHeadsup(data) {
  1689. if ($("#h" + data.game.headsup_id).length == 0) {
  1690. $("#headsup_bets").append('<div class="headsup_thumb" id="h' + data.game.headsup_id + '" data-sort="' + data.game.value + '"><div class="headsup_thumb_info"><span>' + data.game.value + '</span> Credits<a class="headsup_go"><i class="fa fa-play-circle"></i></a></div><img src="' + data.creator.avatar + '"></div>');
  1691. sortHeadsup();
  1692. }
  1693. }
  1694.  
  1695. function endHeadsup(data) {
  1696. $("#h" + data.game.headsup_id).remove();
  1697. if (data.creator.user_id == userID) {
  1698. var credits = data.game.value;
  1699. var choiceText = '';
  1700. var oppText = '';
  1701. if (data.creator.choice == 1) {
  1702. choiceText = phraser('ROCK');
  1703. } else if (data.creator.choice == 2) {
  1704. choiceText = phraser('PAPER');
  1705. } else if (data.creator.choice == 3) {
  1706. choiceText = phraser('SCISSOR');
  1707. }
  1708. if (data.challenger.choice == 1) {
  1709. oppText = phraser('ROCK');
  1710. } else if (data.challenger.choice == 2) {
  1711. oppText = phraser('PAPER');
  1712. } else if (data.challenger.choice == 3) {
  1713. oppText = phraser('SCISSOR');
  1714. }
  1715. if (data.game.result == '0') {
  1716. $.growl.warning({
  1717. title: 'Heads Up',
  1718. message: phraser('THE_GAME_OF') + " <b>" + parseFloat(credits).toFixed(2) + "</b> Credits" + phraser('ENDED_AS') + "<b>" + phraser('DRAW') + "</b>. " + phraser('YOU_CHOSE') + choiceText + phraser('OPPONENT_CHOSE') + oppText + "."
  1719. });
  1720. updateCredits(0.95 * credits);
  1721. } else if (data.game.result == '2') {
  1722. $.growl.notice({
  1723. title: 'Heads Up',
  1724. message: phraser('THE_GAME_OF') + " <b>" + parseFloat(credits).toFixed(2) + "</b> Credits" + phraser('ENDED_AS') + "<b>" + phraser('WIN') + "</b>. " + phraser('YOU_CHOSE') + choiceText + phraser('OPPONENT_CHOSE') + oppText + "."
  1725. });
  1726. updateCredits(1.95 * credits);
  1727. } else if (data.game.result == '1') {
  1728. $.growl.error({
  1729. title: 'Heads Up',
  1730. message: phraser('THE_GAME_OF') + " <b>" + parseFloat(credits).toFixed(2) + "</b> Credits" + phraser('ENDED_AS') + "<b>" + phraser('LOSS') + "</b>. " + phraser('YOU_CHOSE') + choiceText + phraser('OPPONENT_CHOSE') + oppText + "."
  1731. });
  1732. }
  1733. }
  1734. }
  1735.  
  1736. function sortUsers() {
  1737. $('.round_players_holder').find('.round_player').sort(function(a, b) {
  1738. return $(b).attr('data-sort') - $(a).attr('data-sort');
  1739. }).prependTo('.round_players_holder');
  1740. }
  1741.  
  1742. function sortDeposits() {
  1743. $('.round_bets_holder').find('.round_bet').sort(function(a, b) {
  1744. return parseInt($(b).attr('data-sort')) - parseInt($(a).attr('data-sort'));
  1745. }).prependTo('.round_bets_holder');
  1746. }
  1747.  
  1748. function addBet(data) {
  1749. if (!$("#r" + data.deposit.deposit_id).length && $("#round_draw_spinner").length) {
  1750. if (data.deposit.timer_start == 1) {
  1751. startTimer('jackpot');
  1752. }
  1753. $("#round_items_empty").hide();
  1754. $("#round_players_empty").hide();
  1755. $("#round_deposits_empty").hide();
  1756. if (!$("#round_player_" + data.player.user_id).length) {
  1757. $(".round_players_holder").prepend('<a show-profile="' + data.player.user_id + '" class="round_player tool" data-sort="' + data.deposit.value + '" id="round_player_' + data.player.user_id + '" title="' + data.player.persona + '"><span class="round_player_chance" id="val_' + data.deposit.value + '">' + data.deposit.chance + '%</span><img src="' + data.player.avatar + '"></a>');
  1758. } else {
  1759. var new_player_value = parseFloat($("#round_player_" + data.player.user_id).attr('data-sort')) + parseFloat(data.deposit.value);
  1760. var new_player_chance = parseFloat($("#round_player_" + data.player.user_id).find('.round_player_chance')) + parseFloat(data.deposit.chance);
  1761. $("#round_player_" + data.player.user_id).attr('data-sort', new_player_value);
  1762. $("#round_player_" + data.player.user_id).find('.round_player_chance').attr('id', 'val_' + new_player_value).html(new_player_chance + '%');
  1763. }
  1764. $(".round_bets_holder").prepend('<div class="round_bet" id="r' + data.deposit.deposit_id + '" data-sort="' + data.deposit.date + '"><a show-profile="' + data.player.user_id + '"><img src="' + data.player.avatar + '"></a> <b>' + data.player.persona + '</b> ' + phraser('DEPOSITED') + ' ' + data.deposit.value + ' Credits</div>');
  1765. sortUsers();
  1766. sortDeposits();
  1767. var old_val = parseFloat($("#value").html());
  1768. var new_val = (old_val + parseFloat(data.deposit.value));
  1769. $("#value").html(new_val.toFixed(2));
  1770. $('.progress_value').stop(true);
  1771. $({
  1772. someValue: old_val
  1773. }).animate({
  1774. someValue: new_val.toFixed(2)
  1775. }, {
  1776. duration: 200,
  1777. easing: 'swing',
  1778. step: function() {
  1779. $('.progress_value').text(this.someValue.toFixed(2));
  1780. },
  1781. complete: function() {
  1782. $('.progress_value').text(new_val.toFixed(2));
  1783. }
  1784. });
  1785. setTimeout(function() {
  1786. $('.progress_value').stop(true).text(new_val.toFixed(2));
  1787. }, 250);
  1788. document.title = new_val.toFixed(2) + ' - Jackpot | CSGOSpeed';
  1789. $(".round_player_chance").each(function() {
  1790. var new_chance = $(this).attr('id');
  1791. var total_val = $("#value").html();
  1792. if (new_chance != undefined) {
  1793. new_chance = new_chance.replace('val_', '');
  1794. new_chance = (parseFloat(new_chance) / total_val) * 100;
  1795. $(this).text(new_chance.toFixed(2) + "%");
  1796. }
  1797. });
  1798. $(".blop").trigger('play');
  1799. }
  1800. }
  1801.  
  1802. function drawWinner(data) {
  1803. if ($("#round_draw_spinner").length) {
  1804. $(".tipsy").remove();
  1805. var randPos = ($("#page_content").width() / 2) + Math.floor(Math.random() * 112) + 6;
  1806. $("#round_draw_players").css('margin-left', (randPos - 840) + 'px').html(data.spinner.html);
  1807. $("#round_draw_players").addClass('jackpot_animate');
  1808. $("#round_draw_pointer").fadeIn();
  1809. $("#round_holder").fadeOut(300);
  1810. $("#round_draw_holder").fadeIn(300);
  1811. timeouts.push(setTimeout(function() {
  1812. $(".click").trigger('play');
  1813. timeouts.push(setTimeout(function() {
  1814. $(".click").trigger('pause');
  1815. $(".click").prop("currentTime", 0);
  1816. }, 5200));
  1817. }, 500));
  1818. timeouts.push(setTimeout(function() {
  1819. $("#round_draw_players").css({
  1820. transform: 'translate(-2280px, 0)'
  1821. });
  1822. $("#round_draw_pointer").fadeOut();
  1823. $(".win_pic").addClass('winning_picture');
  1824. $("#round_draw_winner").html("<span id='type_winner_persona'><i class='fa fa-user'></i> </span><div class='round_info_title'><i class='fa fa-info-circle'></i> " + phraser('DETAILS') + "</div><table class='round_draw_winner_table waiting_table' style='margin:20px auto 0;'><tr><td>" + phraser("ROUND_L") + "</td><td>#" + data.round.round_id + "</td></tr><tr><td>" + phraser("VALUE") + "</td><td><b class='navi-color-yellow'>" + parseFloat(data.round.value).toFixed(2) + " Credits</b></td></tr><tr><td>" + phraser("CHANCE") + "</td><td><b>" + parseFloat(data.round.winner_chance).toFixed(2) + "%</b></td></tr><tr><td>" + phraser("WINNER_PERCENTAGE") + "</td><td>" + data.round.winner_percentage + "%</td></tr></table>").fadeIn('slow');
  1825. changeText(data.round.winner_persona, $("#type_winner_persona"), (data.round.winner_persona.length - 10) * -5 + 120);
  1826. }, 7300));
  1827. timeouts.push(setTimeout(function() {
  1828. newRound(data);
  1829. }, 11 * 1000));
  1830. }
  1831. setTimeout(function() {
  1832. if (data.round.winner_user_id == userID) {
  1833. updateCredits(data.round.value * data.round.winner_take);
  1834. $.growl.notice({
  1835. title: 'Jackpot',
  1836. message: phraser('WON_A_TOTAL_OF') + " <b>" + parseFloat(data.round.value * data.round.winner_take).toFixed(2) + "</b>" + phraser('CREDITS_ON') + " Jackpot."
  1837. });
  1838. }
  1839. }, 7000);
  1840. }
  1841.  
  1842. function newRound(data) {
  1843. $(".tipsy").remove();
  1844. timerStarted = false;
  1845. $(".round_players_holder").html('');
  1846. $(".round_items_holder").html('');
  1847. $(".round_bets_holder").html('');
  1848. $("#round_items_empty").show();
  1849. $("#round_players_empty").show();
  1850. $("#round_deposits_empty").show();
  1851. $(".round_info_extra").find('.round_old_player:first').remove();
  1852. $(".round_info_extra").prepend('<a show-profile="' + data.round.winner_user_id + '" class="round_old_player tool-top" title="<b>' + phraser('ROUND_L') + ':</b><br>' + data.round.round_id + '<br><br><b>' + phraser('WIN_PERCENTAGE') + ':</b><br>' + data.round.winner_percentage + '<br><br><b>' + phraser('HASH') + ':</b><br>' + data.round.hash + '"><span class="round_old_chance"><b>' + data.round.value + '</b> Credits<br>@ <b>' + data.round.winner_chance.toFixed(2) + '%</b></span><img src="' + data.round.winner_avatar + '"></a>');
  1853. $(".round_info_extra").prepend('<a class="round_old_player tool-top" title="<b>' + phraser('ROUND_L') + '</b>:<br>' + data.new_round.round_id + '<br><br><b>' + phraser('HASH') + ':</b><br>' + data.new_round.hash + '"><span class="round_old_chance"><b>TBD</b><br>TBD</span><img src="' + site + '/images/no_user.jpg"></a>');
  1854. $("#round_draw_holder").hide(500);
  1855. $("#round_holder").show(500);
  1856. $("#round_draw_players").html('').removeClass('spinner_animate').css({
  1857. transform: 'translate(0, 0)'
  1858. });
  1859. $("#round_draw_winner").html('').hide();
  1860. $("#progress_load_holder_jackpot").animate({
  1861. width: "0%"
  1862. }, 1000);
  1863. $("#value").html('0');
  1864. $(".progress_value").text("0");
  1865. document.title = '0 - Jackpot | CSGOSpeed';
  1866. $("#timer_seconds_jackpot").html('30');
  1867. $("#timer_minutes_jackpot").html('0');
  1868. $(".load").trigger('play');
  1869. setTimeout(function() {
  1870. $(".load").trigger('pause');
  1871. $(".load").prop("currentTime", 0);
  1872. }, 1000);
  1873. }
  1874. var ongoingTimerInterval;
  1875.  
  1876. function ongoingTimer() {
  1877. clearInterval(ongoingTimerInterval);
  1878. var counter = parseInt($(".round_draw_ongoing_timer").html());
  1879. ongoingTimerInterval = setInterval(function() {
  1880. counter--;
  1881. if (counter < 0) {
  1882. $(".round_draw_ongoing").fadeOut();
  1883. clearInterval(ongoingTimerInterval);
  1884. } else {
  1885. $(".round_draw_ongoing_timer").html(counter);
  1886. }
  1887. }, 1000);
  1888. }
  1889. timerStarted = false;
  1890. timerFinishedPage = false;
  1891.  
  1892. function startTimerTick(type, text) {
  1893. var tMin = Math.floor(parseInt(text) / 60);
  1894. var tSec = parseInt(text) - tMin * 60;
  1895. var progTime = text * 1000;
  1896. var progWidth = 100 * ((30 - text) / 30);
  1897. if (tSec < 10) {
  1898. tSec = "0" + tSec;
  1899. }
  1900. if (text < -20) {
  1901. tSec = "30";
  1902. tMin = "0";
  1903. } else if (text <= 0) {
  1904. tSec = "00";
  1905. tMin = "0";
  1906. }
  1907. var startTime = new Date().getTime();
  1908. var startSec = parseInt(text);
  1909. $("#timer_seconds_" + type).html(tSec);
  1910. $("#timer_minutes_" + type).html(tMin);
  1911. $("#timer_counter_" + type).show();
  1912. $("#timer_loader_" + type).hide();
  1913. if (text > -20) {
  1914. $("#progress_load_holder_" + type).animate({
  1915. width: progWidth + '%'
  1916. }, 500, 'linear');
  1917. setTimeout(function() {
  1918. $("#progress_load_holder_" + type).animate({
  1919. width: '100%'
  1920. }, progTime, 'linear');
  1921. }, 500);
  1922. }
  1923. if (!timerStarted && text > 0) {
  1924. timerStarted = true;
  1925. var countTimer = setInterval(function() {
  1926. var timeElapse = Math.floor((new Date().getTime() - startTime) / 1000);
  1927. var timerNow = startSec - timeElapse;
  1928. var min = Math.floor(timerNow / 60);
  1929. var sec = timerNow - min * 60;
  1930. if (min < 0) {
  1931. timerStarted = false;
  1932. sec = 0;
  1933. min = 0;
  1934. clearInterval(countTimer);
  1935. } else if (sec == 0 && min > 0) {
  1936. sec = 59;
  1937. min = min - 1;
  1938. } else if (sec > 0) {
  1939. sec = sec - 1;
  1940. } else if (sec == 0 && min == 0) {
  1941. timerStarted = false;
  1942. clearInterval(countTimer);
  1943. }
  1944. if (sec < 10) {
  1945. sec = "0" + sec;
  1946. }
  1947. $("#timer_seconds_" + type).html(sec);
  1948. $("#timer_minutes_" + type).html(min);
  1949. if (timerFinishedPage) {
  1950. $("#progress_load_holder_" + type).stop(true).width('0%')
  1951. $("#timer_seconds_" + type).html('30');
  1952. $("#timer_minutes_" + type).html('0');
  1953. timerStarted = false;
  1954. timerFinishedPage = false;
  1955. clearInterval(countTimer);
  1956. }
  1957. }, 1000);
  1958. }
  1959. }
  1960.  
  1961. function startTimer(type, attempt) {
  1962. setTimeout(function() {
  1963. $("#timer_loader_" + type).show();
  1964. $("#timer_counter_" + type).hide();
  1965. attempt = attempt || 0;
  1966. finishRoundExec = false;
  1967. $.ajax({
  1968. type: "GET",
  1969. url: "/" + type + "_timer.php",
  1970. success: function(text) {
  1971. if ($("." + type + "_hidden_value").length) {
  1972. timerFinishedPage = false;
  1973. startTimerTick(type, text);
  1974. }
  1975. },
  1976. error: function() {
  1977. if (attempt <= 1) {
  1978. startTimer(type, attempt + 1);
  1979. } else {
  1980. swal({
  1981. title: phraser('ERROR'),
  1982. html: phraser('PLEASE_TRY_AGAIN'),
  1983. type: 'error',
  1984. confirmButtonText: phraser('OKAY')
  1985. });
  1986. }
  1987. }
  1988. });
  1989. }, Math.floor(Math.random() * 400) + 1);
  1990. }
  1991.  
  1992. function docTitle(string) {
  1993. return (string.charAt(0).toUpperCase() + string.slice(1)).replace(".php", "");
  1994. }
  1995. var timeouts = [];
  1996.  
  1997. function clearTimeouts() {
  1998. for (var i = 0; i < timeouts.length; i++) {
  1999. clearTimeout(timeouts[i]);
  2000. clearInterval(timeouts[i]);
  2001. }
  2002. timeouts = [];
  2003. timerFinishedPage = true;
  2004. }
  2005.  
  2006. function stopAnimations() {
  2007. $(".audio_file").each(function() {
  2008. $(this).trigger('pause').prop("currentTime", 0);
  2009. });
  2010. $(".roulette_table, .progress_load_holder").stop(true);
  2011. $("#crash_overlay").css('height', '100%');
  2012. $(crashAnimation).stop(true, false);
  2013. $(crashParticleAnimation).stop(true);
  2014. clearTimeouts();
  2015. crashAutoBet = false;
  2016. }
  2017. freeToLoad = true;
  2018.  
  2019. function loadPage(page, type) {
  2020. var extrasGET = '';
  2021. var extrasURL = '';
  2022. if (typeof type !== 'undefined') {
  2023. extrasGET = '?type=' + type;
  2024. extrasURL = '/' + type;
  2025. }
  2026. var thisPage = document.location.pathname.replace("/", "");
  2027. $("#page_content").html('<div class="loader"></div>');
  2028. stopAnimations();
  2029. $.ajax({
  2030. type: "GET",
  2031. url: "/" + page + extrasGET,
  2032. success: function(resp) {
  2033. document.title = docTitle(page) + ' | CSGOSpeed';
  2034. $("#page_content").html(resp);
  2035. if (thisPage != page.replace(".php", "")) {
  2036. window.history.pushState("", "", '/' + page.replace(".php", "") + extrasURL);
  2037. }
  2038. setTimeout(function() {
  2039. freeToLoad = true;
  2040. }, 100);
  2041. },
  2042. error: function(xhr, ajaxOptions, thrownError) {
  2043. setTimeout(function() {
  2044. freeToLoad = true;
  2045. }, 100);
  2046. swal({
  2047. title: phraser('ERROR'),
  2048. html: phraser('PLEASE_TRY_AGAIN'),
  2049. type: 'error',
  2050. confirmButtonText: phraser('OKAY')
  2051. });
  2052. }
  2053. });
  2054. }
  2055.  
  2056. function loadSupport(statsType, ticketID) {
  2057. ticketID = ticketID || '';
  2058. $("#user_stats_response").hide();
  2059. $("#user_stats_loader").show();
  2060. $.ajax({
  2061. type: "GET",
  2062. url: "/support_stats.php",
  2063. data: {
  2064. stats: statsType,
  2065. ticket_id: ticketID
  2066. },
  2067. success: function(text) {
  2068. $("#user_stats_response").html(text);
  2069. $("#user_stats_loader").hide();
  2070. $("#user_stats_response").show();
  2071. }
  2072. });
  2073. }
  2074.  
  2075. function loadUserStats(statsType) {
  2076. $("#user_stats_response").hide();
  2077. $("#user_stats_loader").show();
  2078. var user_id = 0;
  2079. if ($("#stats_user_id").length > 0) {
  2080. user_id = $("#stats_user_id").html();
  2081. }
  2082. $.ajax({
  2083. type: "GET",
  2084. url: "/user_stats.php",
  2085. data: {
  2086. stats: statsType,
  2087. user_id: user_id
  2088. },
  2089. success: function(text) {
  2090. $("#user_stats_loader").hide();
  2091. $("#user_stats_response").html(text).show();
  2092. }
  2093. });
  2094. }
  2095.  
  2096. function loadTopList(chosenDate, chosenType) {
  2097. $("#players_result").hide().html('');
  2098. $("#players_load").show();
  2099. $.ajax({
  2100. type: "GET",
  2101. url: "/players_stats.php",
  2102. data: {
  2103. date: chosenDate,
  2104. type: chosenType
  2105. },
  2106. success: function(text) {
  2107. $("#players_load").hide();
  2108. $("#players_result").html(text).show();
  2109. }
  2110. });
  2111. }
  2112.  
  2113. function addNotice(data) {
  2114. $(".admin_notice_message").html(data.message);
  2115. $(".admin_notice").fadeIn(300);
  2116. }
  2117.  
  2118. function removeNotice(data) {
  2119. $(".admin_notice").hide();
  2120. }
  2121.  
  2122. function ticketResponse(data) {
  2123. $.growl.warning({
  2124. title: phraser('SUPPORT'),
  2125. message: phraser('TICKET_ANSWERED')
  2126. });
  2127. }
  2128.  
  2129.  
  2130. function removeChatMessage(data) {
  2131. $(".tipsy").remove();
  2132. $('.chat_message[data-user="' + data.user_id + '"]').remove();
  2133. }
  2134.  
  2135. function addChatMessage(data) {
  2136. var muted_users = $("#chat_mutes").html().split(";");
  2137. if (muted_users.indexOf(data.user_id) > -1) {
  2138. return;
  2139. }
  2140. var scrolled = false;
  2141. var elem = $("#chat_cell");
  2142. if (elem[0].scrollHeight - elem.scrollTop() > elem.outerHeight() + 50) {
  2143. scrolled = true;
  2144. }
  2145. var usrMod = [];
  2146. if (data.level == 3) {
  2147. usrMod[data.user_id] = 'chat_message_admin';
  2148. } else if (data.level == 2) {
  2149. usrMod[data.user_id] = 'chat_message_mod';
  2150. } else if (data.bot == 1) {
  2151. usrMod[data.user_id] = 'chat_message_bot';
  2152. } else {
  2153. usrMod[data.user_id] = '';
  2154. }
  2155. var mute = [];
  2156. if (userID != 0 && usrMod[data.user_id] == '') {
  2157. mute[data.user_id] = '<a class="mute_user tool-left" data-id="' + data.user_id + '" title="Mute"><i class="fa fa-user-times"></i></a>';
  2158. } else {
  2159. mute[data.user_id] = '';
  2160. }
  2161. var chatModLink = [];
  2162. if (chatMod && usrMod[data.user_id] == '') {
  2163. chatModLink[data.user_id] = '<a sID="' + data.steamID + '" class="chat_ban" data-title="' + data.persona + '"><i class="fa fa-ban"></i></a>';
  2164. } else {
  2165. chatModLink[data.user_id] = '';
  2166. }
  2167. var level = [];
  2168. if (data.bot == 1) {
  2169. level[data.user_id] = '<span class="chat_user_level">999</span>';
  2170. } else {
  2171. level[data.user_id] = '<span class="chat_user_level">' + data.user_level + '</span>';
  2172. }
  2173. $("#chat_cell").append('<div class="chat_message" data-user="' + data.user_id + '"><div class="chat_message_title ' + usrMod[data.user_id] + '">' + chatModLink[data.user_id] + mute[data.user_id] + level[data.user_id] + '<a show-profile="' + data.user_id + '"><img src="' + data.steamPic + '"></a>' + data.steamName + '</div><div class="chat_message_text">' + data.message + '</div></div>');
  2174. if (!scrolled) {
  2175. elem.stop(true).animate({
  2176. scrollTop: elem[0].scrollHeight
  2177. }, 100);
  2178. }
  2179. if ($('#chat_cell').find('.chat_message').length > 30 && !scrolled) {
  2180. $('#chat_cell').find('.chat_message:lt(' + ($('#chat_cell').find('.chat_message').length - 30) + ')').remove();
  2181. }
  2182. }
  2183.  
  2184. function postChatMessage(e) {
  2185. var isTrusted = false;
  2186. if (e.screenX && e.screenX != 0 && e.screenY && e.screenY != 0) {
  2187. isTrusted = true;
  2188. }
  2189. if (e.keyCode == 13 || e.which == 13) {
  2190. isTrusted = true;
  2191. }
  2192. if (!isTrusted) {
  2193. $.ajax({
  2194. type: "POST",
  2195. url: "/chat_message.php",
  2196. data: {
  2197. illegal: true
  2198. },
  2199. success: function(text) {}
  2200. });
  2201. return;
  2202. }
  2203. if ($("#chat_message_textarea").val().length == 0) {
  2204. return;
  2205. }
  2206. var messageVal = $("#chat_message_textarea").val();
  2207. $("#chat_message_textarea").val('');
  2208. $("#chat_message_send").prop('disabled', true).css("background-color", "#2d2d2d");
  2209. var cmdTitle = "";
  2210. var cmdText = "";
  2211. if (messageVal.replace(/^(?=\n)$|^\s*|\s*$|\n\n+/gm, "") == '/help') {
  2212. cmdTitle = "COMMANDS";
  2213. cmdText = '/help to show all commands<br>/rules to show chat rules<br>/recruits to get link to enter code<br>/hint to see the current chat giveaway hint';
  2214. } else if (messageVal.replace(/^(?=\n)$|^\s*|\s*$|\n\n+/gm, "") == '/rules') {
  2215. cmdTitle = "CHAT RULES";
  2216. cmdText = 'Do not beg.<br>Do not post links.<br>Do not advertise.<br>Speaking english is preferred.<br>Treat people how you want to be treated yourself.';
  2217. } else if (messageVal.replace(/^(?=\n)$|^\s*|\s*$|\n\n+/gm, "") == '/recruits') {
  2218. cmdTitle = "RECRUITS";
  2219. cmdText = 'Go to <a class="menu_item" data-page="recruits.php">Recruits</a>';
  2220. }
  2221. if (cmdText != "" && cmdTitle != "") {
  2222. $("#chat_cell").append('<div class="chat_message" data-user="21"><div class="chat_message_title chat_message_bot"><span class="chat_user_level">999</span><a show-profile="21"><img src="https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/4c/4cdc67b6ef726812b43e7af7c2f66648f7ebc661.jpg"></a>Chat BOT</div><div class="chat_message_text"><center><b>[' + cmdTitle + ']</b></center>' + cmdText + '</div></div>');
  2223. $("#chat_cell").stop(true).animate({
  2224. scrollTop: $("#chat_cell")[0].scrollHeight
  2225. }, 100);
  2226. $("#chat_message_send").prop('disabled', false).css("background-color", "#e69b23");
  2227. return;
  2228. }
  2229. $.ajax({
  2230. type: "POST",
  2231. url: "/chat_message.php",
  2232. data: {
  2233. message: messageVal
  2234. },
  2235. success: function(text) {
  2236. if (text == "errorSpam") {
  2237. swal({
  2238. title: phraser('ERROR'),
  2239. html: phraser('SPAMMING_CHAT'),
  2240. type: 'error',
  2241. confirmButtonText: phraser('OKAY')
  2242. });
  2243. } else if (text == "errorSlowMode") {
  2244. swal({
  2245. title: phraser('ERROR'),
  2246. html: phraser('SLOW_MODE'),
  2247. type: 'error',
  2248. confirmButtonText: phraser('OKAY')
  2249. });
  2250. } else if (text == "errorModMode") {
  2251. swal({
  2252. title: phraser('ERROR'),
  2253. html: phraser('MOD_MODE'),
  2254. type: 'error',
  2255. confirmButtonText: phraser('OKAY')
  2256. });
  2257. } else if (text.indexOf("errorBanned") > -1) {
  2258. swal({
  2259. title: phraser('ERROR'),
  2260. html: text.replace("errorBanned", ""),
  2261. type: 'error',
  2262. confirmButtonText: phraser('OKAY')
  2263. });
  2264. } else if (text == 'errorAction') {
  2265. swal({
  2266. title: phraser('ERROR'),
  2267. html: phraser('ACTION_NOT_AVAILABLE'),
  2268. type: 'error',
  2269. confirmButtonText: phraser('OKAY')
  2270. });
  2271. }
  2272. $("#chat_message_send").prop('disabled', false).css("background-color", "#e69b23");
  2273. },
  2274. error: function(xhr, ajaxOptions, thrownError) {
  2275. swal({
  2276. title: phraser('ERROR'),
  2277. html: phraser('PLEASE_TRY_AGAIN'),
  2278. type: 'error',
  2279. confirmButtonText: phraser('OKAY')
  2280. });
  2281. $("#chat_message_send").prop('disabled', false).css("background-color", "#e69b23");
  2282. }
  2283. });
  2284. }
  2285.  
  2286. function loadSteamStatus() {
  2287. $("#steam_status_text").hide();
  2288. $("#steam_status_progress").hide();
  2289. $("#steam_status_loader").show();
  2290. $.ajax({
  2291. type: "GET",
  2292. url: "/steamstatus.php",
  2293. success: function(text) {
  2294. var statusPercent = 0;
  2295. var statusClass = '';
  2296. switch (text) {
  2297. case 'Normal':
  2298. statusPercent = 100;
  2299. statusClass = 'progress-bar-success';
  2300. break;
  2301. case 'Inventory Delayed':
  2302. statusPercent = 60;
  2303. statusClass = 'progress-bar-warning';
  2304. break;
  2305. case 'Sessions Delayed':
  2306. statusPercent = 50;
  2307. statusClass = 'progress-bar-warning';
  2308. break;
  2309. case 'Inventory Critical':
  2310. statusPercent = 35;
  2311. statusClass = 'progress-bar-warning';
  2312. break;
  2313. case 'Going Down':
  2314. statusPercent = 20;
  2315. statusClass = 'progress-bar-danger';
  2316. break;
  2317. case 'Session Surge':
  2318. statusPercent = 15;
  2319. statusClass = 'progress-bar-danger';
  2320. break;
  2321. case 'Sessions Surge':
  2322. statusPercent = 15;
  2323. statusClass = 'progress-bar-danger';
  2324. break;
  2325. case 'No Session':
  2326. statusPercent = 10;
  2327. statusClass = 'progress-bar-danger';
  2328. break;
  2329. case 'WebAPI Offline':
  2330. statusPercent = 5;
  2331. statusClass = 'progress-bar-danger';
  2332. break;
  2333. default:
  2334. statusPercent = 90;
  2335. statusClass = 'progress-bar-success';
  2336. break;
  2337. }
  2338. $("#steam_status_text").show();
  2339. $("#steam_status_progress").show();
  2340. $("#steam_status_loader").hide();
  2341. $("#steam_status").html(text);
  2342. $("#steam_status_percentage").html(statusPercent + "%");
  2343. $("#steam_status_bar").removeClass().addClass('progress-bar ' + statusClass).width(statusPercent + '%');
  2344. }
  2345. });
  2346. }
  2347. deals_bot_loading = false;
  2348. botDealsPage = 1;
  2349.  
  2350. function loadBotDeals(more, min, max) {
  2351. if (!more) {
  2352. $('#withdraw_result').html('<div class="loader_small"></div>');
  2353. $("#withdraw_empty").show();
  2354. $("#withdraw_choose").html('').hide();
  2355. $('#withdraw_bot_chosen').html('');
  2356. $('#item_pot_value_bot').html('0 Credits');
  2357. } else {
  2358. $('#withdraw_result').append('<div class="withdraw_clear" style="clear: both;"></div><div class="loader_small"></div>');
  2359. }
  2360. if (!deals_bot_loading) {
  2361. deals_bot_loading = true;
  2362. $.ajax({
  2363. type: "GET",
  2364. url: "/withdraw_deals.php?min=" + min + "&max=" + max + "&page=" + botDealsPage,
  2365. success: function(text) {
  2366. deals_bot_loading = false;
  2367. if (!more) {
  2368. $('#withdraw_result').html(text);
  2369. } else {
  2370. $('#withdraw_result .loader_small, #withdraw_result .withdraw_clear').remove();
  2371. $('#withdraw_result').append(text);
  2372. $("#withdraw_choose .inventory_item").each(function() {
  2373. var itemID = $(this).attr('id');
  2374. $("#withdraw_result #" + itemID).remove();
  2375. });
  2376. }
  2377. }
  2378. });
  2379. }
  2380. }
  2381. inventory_bot_loading = false;
  2382. botInventoryPage = 1;
  2383.  
  2384. function loadBotInventory(more, search) {
  2385. var order = $("#withdraw_order").val();
  2386. var name = $("#withdraw_search").val();
  2387. var min = $("#withdraw_min").val();
  2388. var max = $("#withdraw_max").val();
  2389. if (!more && !search) {
  2390. $('#withdraw_result').html('<div class="loader_small"></div>');
  2391. $("#withdraw_empty").show();
  2392. $("#withdraw_choose").html('').hide();
  2393. $('#withdraw_bot_chosen').html('');
  2394. $('#item_pot_value_bot').html('0 Credits');
  2395. } else if (search) {
  2396. $('#withdraw_result').html('<div class="loader_small"></div>');
  2397. } else {
  2398. $('#withdraw_result').append('<div class="withdraw_clear" style="clear: both;"></div><div class="loader_small"></div>');
  2399. }
  2400. if (!inventory_bot_loading) {
  2401. inventory_bot_loading = true;
  2402. $.ajax({
  2403. type: "GET",
  2404. url: "/withdraw_load.php?order=" + order + "&name=" + name + "&min=" + min + "&max=" + max + "&page=" + botInventoryPage,
  2405. success: function(text) {
  2406. inventory_bot_loading = false;
  2407. if (!more && !search) {
  2408. $('#withdraw_result').html(text);
  2409. } else {
  2410. $('#withdraw_result .loader_small, #withdraw_result .withdraw_clear').remove();
  2411. $('#withdraw_result').append(text);
  2412. $("#withdraw_choose .inventory_item").each(function() {
  2413. var itemID = $(this).attr('id');
  2414. $("#withdraw_result #" + itemID).remove();
  2415. });
  2416. }
  2417. }
  2418. });
  2419. }
  2420. }
  2421.  
  2422. inventory_loading = false;
  2423.  
  2424. function loadInventory() {
  2425. $('#inventory_result').html('');
  2426. $("#inventory_load").show();
  2427. if (!inventory_loading) {
  2428. inventory_loading = true;
  2429. $.ajax({
  2430. type: "GET",
  2431. url: "/deposit_load.php?load",
  2432. success: function(text) {
  2433. inventory_loading = false;
  2434. $('#inventory_result').html(text);
  2435. $("#inventory_load").hide();
  2436. $('#inventory_result').find('.inventory_item').sort(function(a, b) {
  2437. return $(b).attr('data-sort') - $(a).attr('data-sort');
  2438. }).prependTo('#inventory_result');
  2439. }
  2440. });
  2441. }
  2442. }
  2443. inventory_refresh = false;
  2444.  
  2445. function refreshInventory(attempt) {
  2446. if (!inventory_refresh && !inventory_loading) {
  2447. inventory_refresh = true;
  2448. $('#inventory_attempt').html(phraser('ATTEMPT') + ' #' + (attempt + 1));
  2449. $('#inventory_attempt').show();
  2450. $("#inventory_load").show();
  2451. $('#inventory_result').html('');
  2452. $('#pot_result').html('');
  2453. $("#item_pot_value_user").text("0 Credits");
  2454. $("#pot_empty").show();
  2455. $("#pot_result").hide();
  2456. $.ajax({
  2457. type: "GET",
  2458. url: "/deposit_load.php?refresh",
  2459. success: function(text) {
  2460. if (text == 'success') {
  2461. $('#inventory_attempt').hide();
  2462. inventory_refresh = false;
  2463. loadInventory();
  2464. } else {
  2465. if (attempt >= 49) {
  2466. inventory_refresh = false;
  2467. $('#inventory_attempt').hide();
  2468. $("#inventory_load").hide();
  2469. $('#inventory_result').html('<div id="inventory_empty" style="display: block;padding-top: 35px;">' + phraser('COULDNT_GET_INVENTORY') + '</div>');
  2470. } else {
  2471. inventory_refresh = false;
  2472. refreshInventory(attempt + 1);
  2473. }
  2474. }
  2475. }
  2476. });
  2477. }
  2478. }
  2479.  
  2480. function tradeOfferStatus(type, attempt) {
  2481. attempt = attempt || 0;
  2482. $.ajax({
  2483. type: "GET",
  2484. url: "/" + type + "_response.php",
  2485. data: {
  2486. trade_offer_id: $("#waiting_deposit_id").attr('data-id')
  2487. },
  2488. success: function(text) {
  2489. var response = text.split(";");
  2490. if (response[0] == 'success') {
  2491. $("#waiting_deposit_id").hide();
  2492. $("#accept_link_browser").prop('href', 'https://steamcommunity.com/tradeoffer/' + response[1] + '/');
  2493. $("#accept_link_steam").prop('href', 'steam://url/ShowTradeOffer/' + response[1] + '/');
  2494. $(".accept_link").show();
  2495. } else if (response[0] == 'error' || attempt >= 60 * 5) {
  2496. if (response[1] == 'not_found' || response[1] == 'inventory') {
  2497. swal({
  2498. title: phraser('ERROR'),
  2499. html: phraser('COULDNT_FIND_ALL_ITEMS_' + type.toUpperCase()),
  2500. type: 'error',
  2501. confirmButtonText: phraser('OKAY')
  2502. });
  2503. } else if (response[1] == 'inventory') {
  2504. swal({
  2505. title: phraser('ERROR'),
  2506. html: phraser('COULDNT_SEND_OFFER_INVENTORY'),
  2507. type: 'error',
  2508. confirmButtonText: phraser('OKAY')
  2509. });
  2510. } else if (response[1] == 'trade_url') {
  2511. swal({
  2512. title: phraser('ERROR'),
  2513. html: phraser('COULDNT_SEND_OFFER_URL'),
  2514. type: 'error',
  2515. confirmButtonText: phraser('OKAY')
  2516. });
  2517. } else if (response[1] == 'escrow') {
  2518. swal({
  2519. title: phraser('ERROR'),
  2520. html: phraser('COULDNT_SEND_OFFER_ESCROW'),
  2521. type: 'error',
  2522. confirmButtonText: phraser('OKAY')
  2523. });
  2524. } else if (response[1] == 'no_slots') {
  2525. swal({
  2526. title: phraser('ERROR'),
  2527. html: phraser('COULDNT_SEND_OFFER_SLOTS'),
  2528. type: 'error',
  2529. confirmButtonText: phraser('OKAY')
  2530. });
  2531. } else if (response[1] == 'steam_error' || attempt >= 60 * 5) {
  2532. swal({
  2533. title: phraser('ERROR'),
  2534. html: phraser('COULDNT_SEND_OFFER'),
  2535. type: 'error',
  2536. confirmButtonText: phraser('OKAY')
  2537. });
  2538. }
  2539. loadPage(type + '.php');
  2540. } else {
  2541. timeouts.push(setTimeout(function() {
  2542. tradeOfferStatus(type, attempt + 1);
  2543. }, 1500));
  2544. }
  2545. },
  2546. error: function() {
  2547. timeouts.push(setTimeout(function() {
  2548. tradeOfferStatus(type, attempt + 1);
  2549. }, 1000));
  2550. }
  2551. });
  2552. }
  2553. $(function() {
  2554. $(window).bind('popstate', function(e) {
  2555. var newPage = document.location.pathname.replace("/", "");
  2556. if (newPage.length > 1) {
  2557. loadPage(newPage + '.php');
  2558. }
  2559. });
  2560. if (isMobile) {
  2561. $("#chat_cell").height($('body').height() - 75 - 125 - 50);
  2562. }
  2563. $("#chat_cell").scrollTop(999999999, 0);
  2564. $('.tool').tipsy();
  2565. $('.tool-top').tipsy({
  2566. html: true,
  2567. gravity: 's'
  2568. });
  2569. $('.tool-left').tipsy({
  2570. html: true,
  2571. gravity: 'e'
  2572. });
  2573. $('body').on('keyup', '#send_steam_credits, #crash_bet, #crash_cashout, #deposit_value, .roulette_form_value, #headsup_value, #blender_value, #taxi_value, #slot_bet_credits, .betting_value, #send_credits_amount', function(e) {
  2574. if (this.value.charAt(0) == "." || this.value.charAt(0) == ",") {
  2575. this.value = "0" + this.value;
  2576. }
  2577. this.value = this.value.replace(",", ".");
  2578. if ($.isNumeric(this.value) === false) {
  2579. this.value = this.value.slice(0, -1);
  2580. }
  2581. });
  2582. $('body').on('click', '#sign_in_steam', function() {
  2583. $(this).css('opacity', '0.5');
  2584. window.location = site + "/login_request.php?steam";
  2585. });
  2586. $('body').on('click', '.sign_in_new', function() {
  2587. loadPage("login.php");
  2588. });
  2589. $('body').on('click', '.sign_up_new', function() {
  2590. loadPage("register.php");
  2591. });
  2592. $('body').on('mousedown', '.menu_item', function(e) {
  2593. if (freeToLoad) {
  2594. if (e.which == 2) {
  2595. window.open(site + '/' + $(this).attr('data-page').replace(".php", ""), '_blank');
  2596. self.blur();
  2597. } else if (e.which == 1) {
  2598. loadPage($(this).attr('data-page'));
  2599. freeToLoad = false;
  2600. }
  2601. }
  2602. });
  2603. $('body').on('click', '.chat_username_respond', function() {
  2604. var uName = $(this).text();
  2605. if ($('#chat_message_textarea').val().length + uName.length <= 200) {
  2606. $('#chat_message_textarea').val(function(i, text) {
  2607. return text + " [" + uName.replace(/\]/g, "").replace(/\[/g, "") + "] ";
  2608. });
  2609. $('#chat_message_textarea').focus();
  2610. }
  2611. });
  2612. $('#chat_message_textarea').keypress(function(e) {
  2613. var keycode = (e.keyCode ? e.keyCode : e.which);
  2614. if (keycode == 13 && !e.shiftKey) {
  2615. e.preventDefault();
  2616. postChatMessage(e);
  2617. }
  2618. });
  2619. $("#chat_message_send").click(function(e) {
  2620. e.preventDefault();
  2621. postChatMessage(e);
  2622. });
  2623. $(".chat_form").submit(function(e) {
  2624. e.preventDefault();
  2625. });
  2626. $('body').on('click', '.chat_icons', function() {
  2627. var target = $(this).attr('data-target');
  2628. $(".chat_icon_preview img").attr('data-target', target);
  2629. swal({
  2630. title: phraser('CHAT_ICONS'),
  2631. html: $("#chat_icons_html").html(),
  2632. confirmButtonText: phraser('OKAY')
  2633. });
  2634. });
  2635. $('body').on('click', '.chat_icon_preview img', function() {
  2636. var dataShort = $(this).attr('data-keyword');
  2637. var target = $(this).attr('data-target');
  2638. $('#' + target + '_message_textarea').val(function(i, text) {
  2639. return text + " " + dataShort;
  2640. });
  2641. });
  2642.  
  2643. $('body').on('click', '.volume', function() {
  2644. var volumeOn;
  2645. if ($(this).hasClass('on')) {
  2646. $(this).removeClass('on').addClass('off').html('<i class="fa fa-volume-off"></i>');
  2647. volumeOn = 'off';
  2648. $(".audio_file").each(function() {
  2649. $(this).prop("volume", 0);
  2650. });
  2651. } else {
  2652. $(this).removeClass('off').addClass('on').html('<i class="fa fa-volume-up"></i>');
  2653. volumeOn = 'on';
  2654. $(".audio_file").each(function() {
  2655. var volume = $(this).attr("data-volume");
  2656. $(this).prop("volume", volume);
  2657. });
  2658. }
  2659. $.ajax({
  2660. type: "GET",
  2661. url: "/save_volume.php",
  2662. data: {
  2663. volume: volumeOn
  2664. }
  2665. });
  2666. });
  2667. $('#steam_status_holder').click(function() {
  2668. if ($(this).width() > 100) {
  2669. loadSteamStatus();
  2670. }
  2671. });
  2672. $('body').on('click', '#inventory_result .inventory_item', function(e) {
  2673. if ($(this).hasClass('inventory_item_untradable')) {
  2674. swal({
  2675. title: phraser('ERROR'),
  2676. html: phraser('ITEM_IS_NOT_TRADABLE'),
  2677. type: 'error',
  2678. confirmButtonText: phraser('OKAY')
  2679. });
  2680. return;
  2681. }
  2682. if ($("#pot_result .inventory_item").length >= 50) {
  2683. swal({
  2684. title: phraser('ERROR'),
  2685. html: phraser('MAXIMUM_ITEMS_PER_TRADE'),
  2686. type: 'error',
  2687. confirmButtonText: phraser('OKAY')
  2688. });
  2689. return;
  2690. }
  2691. var old_pot = $(".item_pot_value").text().replace(" Credits", "");
  2692. var new_val = $(this).find(".round_item_price span").text();
  2693. var new_pot = parseFloat(old_pot) + parseFloat(new_val);
  2694. $(".item_pot_value").text(new_pot.toFixed(2) + " Credits");
  2695. if (new_pot >= 1) {
  2696. $(".pot_deposit").removeClass("pot_deposit_disabled");
  2697. }
  2698. $("#pot_empty").hide();
  2699. $("#pot_result").show();
  2700. $(this).appendTo("#pot_result");
  2701. });
  2702. $('body').on('click', '#pot_result .inventory_item', function(e) {
  2703. var old_pot = $(".item_pot_value").text().replace(" Credits", "");
  2704. var new_val = $(this).find(".round_item_price span").text();
  2705. var new_pot = parseFloat(old_pot) - parseFloat(new_val);
  2706. $(".item_pot_value").text(new_pot.toFixed(2) + " Credits");
  2707. if ($("#pot_result .inventory_item").length == 1) {
  2708. $("#pot_empty").show();
  2709. $("#pot_result").hide();
  2710. }
  2711. if (new_pot < 1) {
  2712. $(".pot_deposit").addClass("pot_deposit_disabled");
  2713. }
  2714. $(this).appendTo("#inventory_result");
  2715. $('#inventory_result').find('.inventory_item').sort(function(a, b) {
  2716. return $(b).attr('data-sort') - $(a).attr('data-sort');
  2717. }).prependTo('#inventory_result');
  2718. });
  2719. $('body').on('click', '.inventory_refresh', function() {
  2720. refreshInventory(0);
  2721. });
  2722. $('body').on('click', '#deposit_deposit', function() {
  2723. var numberOfItems = 0;
  2724. var arr = [];
  2725. $('#pot_result').children('.inventory_item').each(function() {
  2726. var itemID = $(this).attr('id').replace("ih", "");
  2727. if (!arr.indexOf(itemID) != -1) {
  2728. arr.push(itemID);
  2729. $("#items").val($("#items").val() + itemID + ';');
  2730. numberOfItems += 1;
  2731. }
  2732. });
  2733. if (numberOfItems > 0 && numberOfItems <= 50 && parseFloat($(".item_pot_value").html().replace(" Credits", "")) >= 1) {
  2734. $(".accept_link").hide();
  2735. $("#user_inventory_holder").slideUp();
  2736. $("#user_deposit").slideDown();
  2737. $("#waiting_pot_value").text($(".item_pot_value").text());
  2738. $.ajax({
  2739. type: "GET",
  2740. url: "/deposit_save.php",
  2741. data: {
  2742. items: $("#items").val()
  2743. },
  2744. success: function(text) {
  2745. if (text == 'error amount' || text == 'error access' || text == 'error item' || text == 'error value' || text == 'error bot') {
  2746. setTimeout(function() {
  2747. $(".accept_link").hide();
  2748. $("#user_inventory_holder").slideDown();
  2749. $("#user_deposit").slideUp();
  2750. swal({
  2751. title: phraser('ERROR'),
  2752. text: text.replace(" ", "_").toUpperCase(),
  2753. type: 'error',
  2754. confirmButtonText: phraser('OKAY')
  2755. });
  2756. }, 500);
  2757. } else {
  2758. var response = text.split(";");
  2759. $("#waiting_pot_value").text($(".item_pot_value").text());
  2760. $("#waiting_code").text(response[0]);
  2761. $("#waiting_deposit_id").attr('data-id', response[1]);
  2762. $("#waiting_bot").text(response[2]);
  2763. timeouts.push(setTimeout(function() {
  2764. tradeOfferStatus('deposit');
  2765. }, 1000));
  2766. }
  2767. }
  2768. });
  2769. } else {
  2770. swal({
  2771. title: phraser('ERROR'),
  2772. html: phraser('MAXIMUM_ITEMS_PER_TRADE'),
  2773. type: 'error',
  2774. confirmButtonText: phraser('OKAY')
  2775. });
  2776. }
  2777. });
  2778. var stopScrollTick = false;
  2779. $('body').on('mousedown touchstart', '.scroller', function(e) {
  2780. e.stopPropagation();
  2781. stopScrollTick = false;
  2782. var sender = $(this);
  2783. var target = $(sender.attr('data-target'));
  2784. var child = sender.attr('data-child');
  2785. var pos = target.scrollLeft();
  2786. var scrollSpeed = 2;
  2787. var scrollTime = 0;
  2788. var scrollTick = setInterval(function() {
  2789. var max = target.find(child).length * target.find(child).outerWidth() - $("#page_content").width();
  2790. if (!sender.hasClass('left')) {
  2791. pos = pos + 10 + scrollSpeed;
  2792. } else {
  2793. pos = pos - 10 - scrollSpeed;
  2794. }
  2795. if (pos > max && max < 0) {
  2796. pos = 0;
  2797. } else if (pos > max) {
  2798. pos = max
  2799. }
  2800. target.scrollLeft(pos);
  2801. if (scrollTime % 50 == 0) {
  2802. scrollSpeed = Math.pow(scrollSpeed, 2);
  2803. }
  2804. scrollTime++;
  2805. if (stopScrollTick || pos == max) {
  2806. clearInterval(scrollTick);
  2807. }
  2808. }, 10);
  2809. }).on('mouseup touchend', '.scroller', function() {
  2810. stopScrollTick = true;
  2811. }).on('mouseleave touchmove', '.scroller', function() {
  2812. stopScrollTick = true;
  2813. });
  2814. $('body').on('click', '.accept_link', function() {
  2815. var page = $(this).attr('data-page');
  2816. loadPage(page);
  2817. });
  2818. $('body').on('click', '#user_stats_menu li a', function() {
  2819. var clickedThis = $(this);
  2820. $("#user_stats_menu li").each(function() {
  2821. $(this).removeClass('active');
  2822. });
  2823. clickedThis.parent('li').addClass('active');
  2824. loadUserStats($(this).attr('data-stats'));
  2825. });
  2826. $('body').on('click', '#players_menu li a', function() {
  2827. $("#players_menu li").each(function() {
  2828. $(this).removeClass('active');
  2829. });
  2830. $(this).parent('li').addClass('active');
  2831. loadTopList($(this).attr('data-stats'), $("#players_game_select").val());
  2832. });
  2833. $('body').on('change', '#players_game_select', function() {
  2834. loadTopList($("#players_menu li.active a").attr('data-stats'), $("#players_game_select").val());
  2835. });
  2836. $('body').on('click', '#recruits_menu li a', function() {
  2837. var clickedThis = $(this);
  2838. $("#recruits_menu li").each(function() {
  2839. $(this).removeClass('active');
  2840. });
  2841. clickedThis.parent('li').addClass('active');
  2842. loadRecruits($(this).attr('data-stats'));
  2843. });
  2844. $('body').on('submit', '#settings_form', function(e) {
  2845. e.preventDefault();
  2846. $("#settings_form button").prop('disabled', true).html('<div class="loader_small" style="width: 18px;height: 18px;margin: 0 auto;"></div>');
  2847. if (!validateTradeURL($("#trade_url").val()) && $("#trade_url").val() != "") {
  2848. swal({
  2849. title: phraser('ERROR'),
  2850. html: phraser('PLEASE_ENTER_A_VALID_TRADE_URL'),
  2851. type: 'error',
  2852. confirmButtonText: phraser('OKAY')
  2853. });
  2854. $("#settings_form button").prop('disabled', false).html(phraser('SAVE'));
  2855. return;
  2856. }
  2857. $.ajax({
  2858. type: "GET",
  2859. url: "/settings_save.php",
  2860. data: {
  2861. trade_url: $("#trade_url").val(),
  2862. stream_link: $("#stream_link").val(),
  2863. status_message: $("#status_message").val(),
  2864. hide_steam: $("#hide_steam").prop('checked'),
  2865. timezone: $("#timezone").val(),
  2866. language: $("#language").val()
  2867. },
  2868. success: function(text) {
  2869. $("#settings_form button").prop('disabled', false).html(phraser('SAVE'));
  2870. if (text == 'errorTradeURL') {
  2871. swal({
  2872. title: phraser('ERROR'),
  2873. html: 'bruh... stahp! you aint the first one to try this bruh',
  2874. type: 'error',
  2875. confirmButtonText: phraser('OKAY')
  2876. });
  2877. return;
  2878. } else if (text == 'errorTimeZone') {
  2879. swal({
  2880. title: phraser('ERROR'),
  2881. html: 'bruh... stahp! you aint the first one to try this bruh',
  2882. type: 'error',
  2883. confirmButtonText: phraser('OKAY')
  2884. });
  2885. return;
  2886. }
  2887. swal({
  2888. title: phraser('SUCCESS'),
  2889. html: phraser('SETTINGS_SUCCESSFULLY_SAVED'),
  2890. type: 'success',
  2891. confirmButtonText: phraser('OKAY'),
  2892. allowOutsideClick: false,
  2893. allowEscapeKey: false
  2894. }, function() {
  2895. window.location.reload();
  2896. });
  2897. }
  2898. });
  2899. });
  2900. $('body').on('click', '.jackpot_deposit_button', function() {
  2901. $("#deposit_value").val('');
  2902. $(".jackpot_deposit_button").fadeOut(250);
  2903. $(".jackpot_deposit_value").fadeIn(250);
  2904. $("#deposit_value").focus();
  2905. });
  2906. $('body').on('mousedown', '#deposit_value_submit', function(e) {
  2907. e.preventDefault();
  2908. $('.jackpot_deposit_value').submit();
  2909. });
  2910. $('body').on('submit', '.jackpot_deposit_value', function(e) {
  2911. e.preventDefault();
  2912. $("#jackpot_form").hide();
  2913. $("#jackpot_loader").show();
  2914. var deposit_value = $("#deposit_value").val();
  2915. $.ajax({
  2916. type: "POST",
  2917. url: "/jackpot_bet.php",
  2918. data: {
  2919. deposit_value: deposit_value,
  2920. user_token: $("#user_token").val()
  2921. },
  2922. success: function(text) {
  2923. $("#jackpot_form").show();
  2924. $("#jackpot_loader").hide();
  2925. if (text == 'success') {
  2926. $("#deposit_value").val('');
  2927. $(".jackpot_deposit_value").hide();
  2928. $(".jackpot_deposit_button").show();
  2929. updateCredits(-1 * deposit_value);
  2930. } else if (text == 'errorValue') {
  2931. needCredits();
  2932. } else if (text == 'errorMin') {
  2933. swal({
  2934. title: phraser('ERROR'),
  2935. html: phraser('MINIMUM_BET'),
  2936. type: 'error',
  2937. confirmButtonText: phraser('OKAY')
  2938. });
  2939. } else if (text == 'errorAction') {
  2940. swal({
  2941. title: phraser('ERROR'),
  2942. html: phraser('ACTION_NOT_AVAILABLE'),
  2943. type: 'error',
  2944. confirmButtonText: phraser('OKAY')
  2945. });
  2946. } else if (text == 'errorBets') {
  2947. swal({
  2948. title: phraser('ERROR'),
  2949. html: phraser('TOO_MANY_BETS'),
  2950. type: 'error',
  2951. confirmButtonText: phraser('OKAY')
  2952. });
  2953. } else if (text == 'errorTimer') {
  2954. swal({
  2955. title: phraser('ERROR'),
  2956. html: phraser('TIMER_IS_CLOSING'),
  2957. type: 'error',
  2958. confirmButtonText: phraser('OKAY')
  2959. });
  2960. } else if (text == 'errorLastRound') {
  2961. swal({
  2962. title: phraser('ERROR'),
  2963. html: phraser('LAST_ROUND_NOT_FINISHED'),
  2964. type: 'error',
  2965. confirmButtonText: phraser('OKAY')
  2966. });
  2967. }
  2968. }
  2969. });
  2970. });
  2971. var blenderColorAvailable = true;
  2972. $('body').on('click', '.blender_ingredient', function(e) {
  2973. var flaskHeight = $("#flask_fill").height();
  2974. var fruit = $(this).attr('data-fruit');
  2975. var fruitColor = $(this).attr('data-color');
  2976. var fruitColors = $(this).attr('data-color').split(",");
  2977. var blenderColors = $("#blender_potion_content").html().split(";").length;
  2978. if (blenderAvailable) {
  2979. $("#blender_form").show();
  2980. }
  2981. if (flaskHeight < 400 && blenderColorAvailable) {
  2982. blenderColorAvailable = false;
  2983. $(".woosh").trigger('play');
  2984. setTimeout(function() {
  2985. $(".woosh").trigger('pause');
  2986. $(".woosh").prop("currentTime", 0);
  2987. }, 300);
  2988. var imageOffset = $(this).find('img').offset();
  2989. var potionOffset = $("#flask_fill").offset();
  2990. var newFruit = $(this).find('img').clone();
  2991. newFruit.appendTo("body").css({
  2992. 'height': '80px',
  2993. 'position': 'absolute',
  2994. 'top': imageOffset.top + 'px',
  2995. 'left': imageOffset.left + 'px',
  2996. 'z-index': '20'
  2997. }).addClass('fruit_rotate').animate({
  2998. top: potionOffset.top - 40,
  2999. left: potionOffset.left + 90,
  3000. height: '40px'
  3001. }, 400).fadeOut(200, function() {
  3002. $(this).remove();
  3003. });
  3004. setTimeout(function() {
  3005. $(".fill").trigger('play');
  3006. setTimeout(function() {
  3007. $(".fill").trigger('pause');
  3008. $(".fill").prop("currentTime", 0);
  3009. }, 300);
  3010. if (flaskHeight == 0) {
  3011. $('#flask_wave').css('fill', 'rgb(' + fruitColor + ')');
  3012. } else {
  3013. var potionColor = $('#flask_wave').css('fill').replace("rgb(", "").replace(/\ /g, "").replace(")", "").split(",");
  3014. var newColorR = (potionColor[0] * fruitColors[0]) / 255 + 30;
  3015. var newColorG = (potionColor[1] * fruitColors[1]) / 255 + 30;
  3016. var newColorB = (potionColor[2] * fruitColors[2]) / 255 + 30;
  3017. $('#flask_wave').css('fill', 'rgb(' + Math.round(newColorR) + ',' + Math.round(newColorG) + ',' + Math.round(newColorB) + ')');
  3018. }
  3019. $('#flask_fill').animate({
  3020. height: (blenderColors * 40) + 'px'
  3021. }, 300, 'easeOutBack');
  3022. $("#blender_potion_content").append(fruit + ';');
  3023. }, 200);
  3024. setTimeout(function() {
  3025. blenderColorAvailable = true;
  3026. }, 300);
  3027. } else if (blenderColorAvailable) {
  3028. swal({
  3029. title: phraser('FULL_BOTTLE'),
  3030. html: phraser('FULL_BOTTLE_TEXT'),
  3031. type: 'warning',
  3032. confirmButtonText: phraser('OKAY')
  3033. });
  3034. }
  3035. });
  3036. var blenderAvailable = true;
  3037. $('body').on('submit', '#blender_form', function(e) {
  3038. e.preventDefault();
  3039. var bet_value = $("#blender_value").val();
  3040. if (blenderAvailable) {
  3041. blenderColorAvailable = false;
  3042. blenderAvailable = false;
  3043. $("#blender_submit").hide();
  3044. $.ajax({
  3045. type: "POST",
  3046. url: "/blender_blend.php",
  3047. data: {
  3048. credits: bet_value,
  3049. color_order: $("#blender_potion_content").html(),
  3050. user_token: $("#user_token").val()
  3051. },
  3052. success: function(text) {
  3053. if (text == 'errorCredits') {
  3054. needCredits();
  3055. blenderAvailable = true;
  3056. blenderColorAvailable = true;
  3057. $("#blender_submit").show();
  3058. } else if (text == 'errorMin') {
  3059. swal({
  3060. title: phraser('ERROR'),
  3061. html: phraser('MINIMUM_MAXIMUM_BET'),
  3062. type: 'error',
  3063. confirmButtonText: phraser('OKAY')
  3064. });
  3065. blenderAvailable = true;
  3066. blenderColorAvailable = true;
  3067. $("#blender_submit").show();
  3068. } else if (text == 'errorAction') {
  3069. swal({
  3070. title: phraser('ERROR'),
  3071. html: phraser('ACTION_NOT_AVAILABLE'),
  3072. type: 'error',
  3073. confirmButtonText: phraser('OKAY')
  3074. });
  3075. blenderAvailable = true;
  3076. blenderColorAvailable = true;
  3077. $("#blender_submit").show();
  3078. } else {
  3079. $("#blender_form").hide();
  3080. updateCredits(-1 * bet_value);
  3081. $(".shake").trigger('play');
  3082. setTimeout(function() {
  3083. $(".shake").trigger('pause');
  3084. $(".shake").prop("currentTime", 0);
  3085. }, 1500);
  3086. $("#blender_holder").effect("shake", {
  3087. direction: "up",
  3088. times: 6,
  3089. distance: 15
  3090. }, 1300);
  3091. setTimeout(function() {
  3092. $("#blender_holder").animate({
  3093. borderSpacing: -360
  3094. }, {
  3095. step: function(now, fx) {
  3096. $("#blender_holder").css({
  3097. '-webkit-transform': 'rotate(' + now + 'deg)',
  3098. '-moz-transform': 'rotate(' + now + 'deg)',
  3099. '-ms-transform': 'rotate(' + now + 'deg)',
  3100. 'transform': 'rotate(' + now + 'deg)'
  3101. });
  3102. },
  3103. duration: 'slow'
  3104. }, 1000);
  3105. }, 1000);
  3106. setTimeout(function() {
  3107. if (text == 'won') {
  3108. updateCredits(bet_value * 1.95);
  3109. $.growl.notice({
  3110. title: 'Blender',
  3111. message: phraser('POTION_APPROVED') + "<b>" + parseFloat(bet_value * 1.95).toFixed(2) + "</b> Credits."
  3112. });
  3113. } else {
  3114. $.growl.error({
  3115. title: 'Blender',
  3116. message: phraser('BAD_POTION')
  3117. });
  3118. }
  3119. $("#blender_form").hide();
  3120. $("#blender_submit").show();
  3121. $("#blender_potion_content").html('');
  3122. $("#flask_fill").height('0px');
  3123. $('#flask_wave').css('fill', 'rgb(255,255,255)');
  3124. blenderAvailable = true;
  3125. blenderColorAvailable = true;
  3126. }, 2000);
  3127. }
  3128. }
  3129. });
  3130. }
  3131. });
  3132. $('body').on('click', '.headsup_new', function(e) {
  3133. $("#headsup_create").toggle(250);
  3134. $("#headsup_challenge").hide(250);
  3135. $("#headsup_create").find(".headsup_form_choices a").removeClass('chosen');
  3136. $("#headsup_value").val('');
  3137. $("#headsup_value").focus();
  3138. });
  3139. $('body').on('click', '.headsup_form_choices a', function(e) {
  3140. $(this).parent().parent().find(".headsup_form_choices a").removeClass('chosen');
  3141. $(this).addClass('chosen');
  3142. $("#headsup_value").focus();
  3143. });
  3144. var headsupAvailable = true;
  3145. $('body').on('submit', '#headsup_form', function(e) {
  3146. e.preventDefault();
  3147. var choice = $("#headsup_form").find("a.chosen").attr('data-choice');
  3148. var credits = $("#headsup_value").val();
  3149. if (headsupAvailable) {
  3150. headsupAvailable = false;
  3151. $("#headsup_form").hide();
  3152. $("#headsup_create_loader").show();
  3153. if (choice == undefined) {
  3154. swal({
  3155. title: phraser('ERROR'),
  3156. html: phraser('NEED_TO_CHOOSE_OPTION'),
  3157. type: 'error',
  3158. confirmButtonText: phraser('OKAY')
  3159. });
  3160. headsupAvailable = true;
  3161. $("#headsup_form").show();
  3162. $("#headsup_create_loader").hide();
  3163. } else {
  3164. if (credits >= 0.001) {
  3165. $.ajax({
  3166. type: "GET",
  3167. url: "/headsup_bet.php",
  3168. data: {
  3169. choice: choice,
  3170. credits: credits,
  3171. create: true,
  3172. user_token: $("#user_token").val()
  3173. },
  3174. success: function(text) {
  3175. text = text.split(";");
  3176. if (text[0] == 'success') {
  3177. $(".woosh").trigger('pause').prop("currentTime", 0).trigger('play');
  3178. $("#headsup_create").toggle(250);
  3179. updateCredits(-1 * text[1]);
  3180. } else if (text[0] == 'errorCredits') {
  3181. needCredits();
  3182. } else if (text[0] == 'errorAction') {
  3183. swal({
  3184. title: phraser('ERROR'),
  3185. html: phraser('ACTION_NOT_AVAILABLE'),
  3186. type: 'error',
  3187. confirmButtonText: phraser('OKAY')
  3188. });
  3189. }
  3190. headsupAvailable = true;
  3191. $("#headsup_form").show();
  3192. $("#headsup_create_loader").hide();
  3193. }
  3194. });
  3195. } else {
  3196. swal({
  3197. title: phraser('ERROR'),
  3198. html: phraser('MINIMUM_BET_SMALL'),
  3199. type: 'error',
  3200. confirmButtonText: phraser('ERROR')
  3201. });
  3202. headsupAvailable = true;
  3203. $("#headsup_form").show();
  3204. $("#headsup_create_loader").hide();
  3205. }
  3206. }
  3207. }
  3208. });
  3209. $('body').on('click', '.headsup_thumb', function(e) {
  3210. var newID = $(this).attr('id').replace("h", "");
  3211. var newVal = $(this).attr('data-sort');
  3212. $("#headsup_challenge").find(".headsup_form_choices a").removeClass('chosen');
  3213. $("#headsup_challenge").find('#headsup_challenge_value').html(newVal + " Credits");
  3214. $("#headsup_challenge").attr('data-id', newID).show(250);
  3215. $("#headsup_create").hide(250);
  3216. });
  3217. var headsupChallengeAvailable = true;
  3218. $('body').on('click', '#headsup_challenge_button', function(e) {
  3219. e.preventDefault();
  3220. var choice = $("#headsup_challenge").find("a.chosen").attr('data-choice');
  3221. var gameID = $("#headsup_challenge").attr('data-id');
  3222. var credits = $("#headsup_challenge").find('#headsup_challenge_value').html().replace(" Credits", "");
  3223. var choiceText = '';
  3224. if (choice == 1) {
  3225. choiceText = phraser('ROCK');
  3226. } else if (choice == 2) {
  3227. choiceText = phraser('PAPER');
  3228. } else if (choice == 3) {
  3229. choiceText = phraser('SCISSOR');
  3230. }
  3231. if (headsupChallengeAvailable) {
  3232. $("#headsup_challenge_loader").show();
  3233. $("#headsup_challenge_button").hide();
  3234. headsupChallengeAvailable = false;
  3235. if (choice == undefined) {
  3236. swal({
  3237. title: phraser('ERROR'),
  3238. html: phraser('NEED_TO_CHOOSE_OPTION'),
  3239. type: 'error',
  3240. confirmButtonText: phraser('OKAY')
  3241. });
  3242. headsupChallengeAvailable = true;
  3243. $("#headsup_challenge_loader").hide();
  3244. $("#headsup_challenge_button").show();
  3245. } else {
  3246. $.ajax({
  3247. type: "GET",
  3248. url: "/headsup_bet.php",
  3249. data: {
  3250. choice: choice,
  3251. headsup_id: gameID,
  3252. challenge: true,
  3253. user_token: $("#user_token").val()
  3254. },
  3255. success: function(text) {
  3256. text = text.split(";");
  3257. if (text[0] == 'success') {
  3258. $(".woosh").trigger('pause').prop("currentTime", 0).trigger('play');
  3259. updateCredits(-1 * credits);
  3260. var oppText = '';
  3261. if (text[2] == 1) {
  3262. oppText = phraser('ROCK');
  3263. } else if (text[2] == 2) {
  3264. oppText = phraser('PAPER');
  3265. } else if (text[2] == 3) {
  3266. oppText = phraser('SCISSOR');
  3267. }
  3268. if (text[1] == '0') {
  3269. $.growl.warning({
  3270. title: 'Heads Up',
  3271. message: phraser('THE_GAME_OF') + " <b>" + parseFloat(credits).toFixed(2) + "</b> Credits" + phraser('ENDED_AS') + "<b>" + phraser('DRAW') + "</b>. " + phraser('YOU_CHOSE') + choiceText + phraser('OPPONENT_CHOSE') + oppText + "."
  3272. });
  3273. updateCredits(0.95 * credits);
  3274. } else if (text[1] == '1') {
  3275. $.growl.notice({
  3276. title: 'Heads Up',
  3277. message: phraser('THE_GAME_OF') + " <b>" + parseFloat(credits).toFixed(2) + "</b> Credits" + phraser('ENDED_AS') + "<b>" + phraser('WIN') + "</b>. " + phraser('YOU_CHOSE') + choiceText + phraser('OPPONENT_CHOSE') + oppText + "."
  3278. });
  3279. updateCredits(1.95 * credits);
  3280. } else if (text[1] == '2') {
  3281. $.growl.error({
  3282. title: 'Heads Up',
  3283. message: phraser('THE_GAME_OF') + " <b>" + parseFloat(credits).toFixed(2) + "</b> Credits" + phraser('ENDED_AS') + "<b>" + phraser('LOSS') + "</b>. " + phraser('YOU_CHOSE') + choiceText + phraser('OPPONENT_CHOSE') + oppText + "."
  3284. });
  3285. }
  3286. } else if (text[0] == 'errorCredits') {
  3287. needCredits();
  3288. } else if (text[0] == 'errorUser') {
  3289. swal({
  3290. title: phraser('ERROR'),
  3291. html: phraser('CANNOT_PLAY_YOURSELF'),
  3292. type: 'error',
  3293. confirmButtonText: phraser('OKAY')
  3294. });
  3295. } else if (text[0] == 'errorGameID') {
  3296. swal({
  3297. title: phraser('ERROR'),
  3298. html: phraser('GAME_SNATCHED'),
  3299. type: 'error',
  3300. confirmButtonText: phraser('OKAY')
  3301. });
  3302. } else if (text[0] == 'errorAction') {
  3303. swal({
  3304. title: phraser('ERROR'),
  3305. html: phraser('ACTION_NOT_AVAILABLE'),
  3306. type: 'error',
  3307. confirmButtonText: phraser('OKAY')
  3308. });
  3309. }
  3310. $("#headsup_challenge_loader").hide();
  3311. $("#headsup_challenge_button").show();
  3312. headsupChallengeAvailable = true;
  3313. $("#headsup_challenge").hide(250);
  3314. }
  3315. });
  3316. }
  3317. }
  3318. });
  3319. $('body').on('click', '#support_menu li a', function() {
  3320. var clickedThis = $(this);
  3321. $("#support_menu li").each(function() {
  3322. $(this).removeClass('active');
  3323. });
  3324. clickedThis.parent('li').addClass('active');
  3325. loadSupport($(this).attr('data-page'));
  3326. });
  3327. $('body').on('click', '.support_open_ticket', function() {
  3328. loadSupport('user_ticket', $(this).attr('data-id'));
  3329. });
  3330. $('body').on('click', '.support_mark[data-type]', function() {
  3331. var mark = $(this).attr('data-type');
  3332. var ticketID = $(".support_replies").attr('data-id');
  3333. if (mark == 'solved') {
  3334. mark = 1;
  3335. $(this).attr('data-type', 'unsolved').html('<i class="fa fa-thumbs-down"></i> ' + phraser('MARK_AS_UNSOLVED'));
  3336. } else {
  3337. mark = 0;
  3338. $(this).attr('data-type', 'solved').html('<i class="fa fa-thumbs-up"></i> ' + phraser('MARK_AS_SOLVED'));
  3339. }
  3340. $.ajax({
  3341. type: "GET",
  3342. url: "/support_save.php",
  3343. data: {
  3344. mark: mark,
  3345. ticket_id: ticketID
  3346. },
  3347. success: function(text) {
  3348. loadSupport('user_ticket', ticketID);
  3349. }
  3350. });
  3351. });
  3352. $('body').on('submit', '.support_write', function(e) {
  3353. e.preventDefault();
  3354. if ($("#support_answer").val().length > 5) {
  3355. var reply = $("#support_answer").val();
  3356. var ticketID = $(".support_replies").attr('data-id');
  3357. $("#support_answer").val('');
  3358. $.ajax({
  3359. type: "POST",
  3360. url: "/support_save.php",
  3361. data: {
  3362. reply: reply,
  3363. ticket_id: ticketID
  3364. },
  3365. success: function(text) {
  3366. if ($("#admin_loader").length == 0) {
  3367. loadSupport('user_ticket', ticketID);
  3368. } else {
  3369. $("#admin_response").hide();
  3370. $("#admin_loader").show();
  3371. $.ajax({
  3372. type: "GET",
  3373. url: "/admin_pages.php",
  3374. data: {
  3375. page: 'tickets',
  3376. ticket_id: ticketID
  3377. },
  3378. success: function(text) {
  3379. $("#admin_loader").hide();
  3380. $("#admin_response").html(text).show();
  3381. }
  3382. });
  3383. }
  3384. }
  3385. });
  3386. } else {
  3387. swal({
  3388. title: phraser('ERROR'),
  3389. html: phraser('TEXT_TOO_SHORT'),
  3390. type: 'error',
  3391. confirmButtonText: phraser('OKAY')
  3392. });
  3393. }
  3394. });
  3395. $('body').on('submit', '#support_new', function(e) {
  3396. e.preventDefault();
  3397. var text = $("#support_new_textarea").val();
  3398. var subject = $("#support_new_subject").val();
  3399. $("#support_new").hide();
  3400. $("#support_new_loader").show();
  3401. $.ajax({
  3402. type: "POST",
  3403. url: "/support_save.php",
  3404. data: {
  3405. text: text,
  3406. subject: subject
  3407. },
  3408. success: function(text) {
  3409. console.log(text);
  3410. $("#support_new").show();
  3411. $("#support_new_loader").hide();
  3412. if (text == 'errorLength') {
  3413. swal({
  3414. title: phraser('ERROR'),
  3415. html: phraser('TEXT_TOO_SHORT'),
  3416. type: 'error',
  3417. confirmButtonText: phraser('OKAY')
  3418. });
  3419. } else {
  3420. $("#support_menu li").each(function() {
  3421. $(this).removeClass('active');
  3422. });
  3423. $("#support_menu li").first().addClass('active');
  3424. loadSupport('user_ticket', text);
  3425. }
  3426. }
  3427. });
  3428. });
  3429. $('body').on('click', '.taxi_level', function() {
  3430. $(".taxi_level").removeClass('selected');
  3431. $(this).addClass('selected');
  3432. $("#taxi_chance b").html($(this).attr('data-chance') + "%");
  3433. $("#taxi_multiplier b").html("~" + $(this).attr('data-multiplier') + "x");
  3434. });
  3435. $('body').on('submit', '#taxi_create', function(e) {
  3436. e.preventDefault();
  3437. $("#taxi_create button").prop('disabled', true).html('<div class="loader_small" style="width: 18px;height: 18px;margin: 2px auto;"></div>');
  3438. var credits = parseFloat($("#taxi_value").val());
  3439. var level = $(".taxi_level.selected").attr('data-level');
  3440. $.ajax({
  3441. type: "GET",
  3442. url: "/taxi_bet.php",
  3443. data: {
  3444. value: credits,
  3445. create: true,
  3446. level: level,
  3447. user_token: $("#user_token").val()
  3448. },
  3449. success: function(text) {
  3450. $("#taxi_create button").prop('disabled', false).html(phraser('CREATE'));
  3451. if (text == 'errorCredits') {
  3452. needCredits();
  3453. } else if (text == 'errorAmount') {
  3454. swal({
  3455. title: phraser('ERROR'),
  3456. html: phraser('MINIMUM_MAXIMUM_BET'),
  3457. type: 'error',
  3458. confirmButtonText: phraser('OKAY')
  3459. });
  3460. } else if (text == 'errorAction') {
  3461. swal({
  3462. title: phraser('ERROR'),
  3463. html: phraser('ACTION_NOT_AVAILABLE'),
  3464. type: 'error',
  3465. confirmButtonText: phraser('OKAY')
  3466. });
  3467. } else {
  3468. $(".taxi-start").trigger('play');
  3469. setTimeout(function() {
  3470. $(".taxi-start").trigger('pause');
  3471. $(".taxi-start").prop("currentTime", 0);
  3472. }, 4000);
  3473. updateCredits(-1 * credits);
  3474. $(".taximeter_big span").html('0');
  3475. $(".taximeter_big b").html(credits);
  3476. $("#taxi_hash").html('<b>' + phraser('HASH') + ':</b> ' + text);
  3477. $("#taxi_fuel, #taxi_fuel_bg").toggle(250);
  3478. }
  3479. }
  3480. });
  3481. });
  3482. var taxiChoiceAvailable = true;
  3483. $('body').on('click', '.route-enabled', function(e) {
  3484. var that = $(this);
  3485. var choice = that.attr('data-choice');
  3486. if (!taxiChoiceAvailable) {
  3487. return;
  3488. }
  3489. taxiChoiceAvailable = false;
  3490. $('.route-enabled').each(function() {
  3491. $(this).removeClass('route-enabled').addClass('route-disabled');
  3492. });
  3493. var newTaxi = $("<div>", {
  3494. class: "taxi_car"
  3495. });
  3496. newTaxi.html('<img src="' + site + '/images/taxi.png">').appendTo("body").css({
  3497. 'top': that.offset().top - 10 + 'px',
  3498. }).animate({
  3499. left: that.offset().left + 25
  3500. }, 400, 'easeOutQuad').fadeOut(700, function() {
  3501. $(this).remove();
  3502. });
  3503. $.ajax({
  3504. type: "GET",
  3505. url: "/taxi_bet.php",
  3506. data: {
  3507. choice: choice,
  3508. bet: true,
  3509. user_token: $("#user_token").val()
  3510. },
  3511. success: function(text) {
  3512. taxiChoiceAvailable = true;
  3513. text = text.split(";");
  3514. var value = parseFloat(text[0]);
  3515. var row = text[1];
  3516. var options = text[2].split(",");
  3517. var robbed = text[3];
  3518. $(".route[data-row='" + row + "']").each(function() {
  3519. var content = options[$(this).attr("data-choice") - 1];
  3520. if (content == "R") {
  3521. content = '<img src="' + site + '/images/customer6.png" style="opacity: 1;">';
  3522. }
  3523. $(this).html(content);
  3524. });
  3525. if (robbed == 1) {
  3526. $(".taxi-crash").trigger('play');
  3527. setTimeout(function() {
  3528. $(".taxi-crash").trigger('pause');
  3529. $(".taxi-crash").prop("currentTime", 0);
  3530. }, 2000);
  3531. $.growl.error({
  3532. title: 'Taxi',
  3533. message: phraser('PICKED_UP_CRIMINAL')
  3534. });
  3535. timeouts.push(setTimeout(function() {
  3536. $(".route[data-row='1']").removeClass('route-disabled').addClass('route-enabled');
  3537. $(".route").each(function() {
  3538. $(this).css('color', '').html('<img src="' + site + '/images/customer' + (Math.floor(Math.random() * 5) + 1) + '.png">');
  3539. });
  3540. $(".taximeter_big span, .taximeter_big b").html('0');
  3541. $("#taxi_fuel, #taxi_fuel_bg").toggle(250);
  3542. }, 3000));
  3543. } else {
  3544. $(".taxi-horn").trigger('play');
  3545. setTimeout(function() {
  3546. $(".taxi-horn").trigger('pause');
  3547. $(".taxi-horn").prop("currentTime", 0);
  3548. }, 500);
  3549. $({
  3550. someValue: parseFloat($(".taximeter_big span").html())
  3551. }).animate({
  3552. someValue: value
  3553. }, {
  3554. duration: 400,
  3555. easing: 'swing',
  3556. step: function() {
  3557. $('.taximeter_big span').text(this.someValue.toFixed(1));
  3558. },
  3559. complete: function() {
  3560. $('.taximeter_big span').text(value.toFixed(2));
  3561. }
  3562. });
  3563. setTimeout(function() {
  3564. $(".taximeter_big span").html(value)
  3565. }, 450);
  3566. that.css('color', 'gold');
  3567. if (row < 5) {
  3568. $(".route[data-row='" + (parseInt(row) + 1) + "']").each(function() {
  3569. $(this).removeClass('route-disabled').addClass('route-enabled');
  3570. });
  3571. } else {
  3572. updateCredits(value);
  3573. $.growl.notice({
  3574. title: 'Taxi',
  3575. message: phraser('SUCCESSFULLY_DROVE') + " <b>" + value.toFixed(2) + "</b> Credits"
  3576. });
  3577. timeouts.push(setTimeout(function() {
  3578. $(".route[data-row='1']").removeClass('route-disabled').addClass('route-enabled');
  3579. $(".route").each(function() {
  3580. $(this).css('color', '').html('<img src="' + site + '/images/customer' + (Math.floor(Math.random() * 5) + 1) + '.png">');
  3581. });
  3582. $(".taximeter_big span, .taximeter_big b").html('0');
  3583. $("#taxi_fuel, #taxi_fuel_bg").toggle(250);
  3584. }, 3000));
  3585. }
  3586. }
  3587. }
  3588. });
  3589. });
  3590.  
  3591. $('body').on('click', '.mute_user', function(e) {
  3592. var mThis = $(this);
  3593. swal({
  3594. title: phraser('ARE_YOU_SURE'),
  3595. text: phraser('RECOVER_IN_SETTINGS'),
  3596. type: 'warning',
  3597. showCancelButton: true,
  3598. confirmButtonText: phraser('YES'),
  3599. cancelButtonText: phraser('CANCEL')
  3600. }, function() {
  3601. $.ajax({
  3602. type: "GET",
  3603. url: "/chat_mute.php",
  3604. data: {
  3605. muted_user_id: mThis.attr('data-id'),
  3606. add: true
  3607. },
  3608. success: function(text) {
  3609. $(".tipsy").remove();
  3610. $('.chat_message[data-user="' + mThis.attr('data-id') + '"]').remove();
  3611. $("#chat_mutes").html(text);
  3612. }
  3613. });
  3614. });
  3615. });
  3616. $('body').on('click', '.unmute_user', function(e) {
  3617. var mThis = $(this);
  3618. $.ajax({
  3619. type: "GET",
  3620. url: "/chat_mute.php",
  3621. data: {
  3622. muted_user_id: mThis.attr('data-id'),
  3623. remove: true
  3624. },
  3625. success: function(text) {
  3626. mThis.parent().parent().remove();
  3627. $("#chat_mutes").html(text);
  3628. }
  3629. });
  3630. });
  3631.  
  3632. $('body').on('submit', '#withdraw_form', function(e) {
  3633. e.preventDefault();
  3634. botInventoryPage = 1;
  3635. loadBotInventory(false, true);
  3636. });
  3637. $('body').on('contextmenu', '#withdraw_result .inventory_item', function(e) {
  3638. if (parseInt(userID) > 2) {
  3639. return;
  3640. }
  3641. if ($(this).find('.withdraw_giveaway_item').length == 0) {
  3642. e.preventDefault();
  3643. }
  3644. $(".withdraw_giveaway_item").remove();
  3645. var item_id = $(this).attr('data-id');
  3646. var item_price = $(this).find('.round_item_price span').text();
  3647. $(this).prepend('<a class="withdraw_giveaway_item">GIVEAWAY</a>');
  3648. });
  3649. $('body').on('click', '#withdraw_result .inventory_item', function(e) {
  3650. if ($(this).find('.withdraw_giveaway_item').length) {
  3651. return;
  3652. }
  3653. var old_pot = $(".item_pot_value").text().replace(" Credits", "");
  3654. var new_val = $(this).find(".round_item_price span").text();
  3655. var new_pot = parseFloat(old_pot) + parseFloat(new_val);
  3656. if ($("#withdraw_choose .inventory_item").length >= 10) {
  3657. swal({
  3658. title: phraser('ERROR'),
  3659. html: phraser('MAXIMUM_ITEMS_PER_TRADE_WITHDRAW'),
  3660. type: 'error',
  3661. confirmButtonText: phraser('OKAY')
  3662. });
  3663. return;
  3664. }
  3665. if (new_pot > parseFloat($("#credits").html())) {
  3666. swal({
  3667. title: phraser('ERROR'),
  3668. html: phraser('WALLET_EXCEEDED'),
  3669. type: 'error',
  3670. confirmButtonText: phraser('OKAY')
  3671. });
  3672. return;
  3673. }
  3674. $(".item_pot_value").text(new_pot.toFixed(2) + " Credits");
  3675. if (new_pot >= 1) {
  3676. $(".pot_deposit").removeClass("pot_deposit_disabled");
  3677. }
  3678. $("#withdraw_empty").hide();
  3679. $("#withdraw_choose").show();
  3680. $(this).appendTo("#withdraw_choose");
  3681. });
  3682. $('body').on('click', '#withdraw_choose .inventory_item', function() {
  3683. var old_pot = $(".item_pot_value").text().replace(" Credits", "");
  3684. var new_val = $(this).find(".round_item_price span").text();
  3685. var new_pot = parseFloat(old_pot) - parseFloat(new_val);
  3686. $(".item_pot_value").text(new_pot.toFixed(2) + " Credits");
  3687. if ($("#withdraw_choose .inventory_item").length == 1) {
  3688. $("#withdraw_empty").show();
  3689. $("#withdraw_choose").hide();
  3690. $("#withdraw_bot_chosen").html('');
  3691. $("#withdraw_result .inventory_item").each(function() {
  3692. $(this).fadeTo(100, 1);
  3693. });
  3694. }
  3695. if (new_pot < 1) {
  3696. $(".pot_deposit").addClass("pot_deposit_disabled");
  3697. }
  3698. $(this).insertBefore("#withdraw_result .withdraw_clear");
  3699. });
  3700. $('body').on('click', '.item_inspect, .item_inspect_instant', function(e) {
  3701. e.stopPropagation();
  3702. });
  3703. $('body').on('click', '.item_inspect_instant', function() {
  3704. var url = $(this).attr('data-link');
  3705. swal({
  3706. title: phraser('INSTANT_INSPECT'),
  3707. html: '<video width="100%" height="100%" controls autoplay loop><source src="' + url + '" type="video/mp4">Video not found</video>',
  3708. confirmButtonText: phraser('OKAY')
  3709. });
  3710. });
  3711. $('body').on('click', '.item_search', function(e) {
  3712. e.stopPropagation();
  3713. $("#withdraw_search").val($(this).attr('data-name'));
  3714. $("#withdraw_min, #withdraw_max").val('');
  3715. $("#withdraw_order").val('price_desc');
  3716. $("#withdraw_form").submit();
  3717. $(".tipsy").remove();
  3718. });
  3719. $('body').on('click', '#withdraw_deposit', function() {
  3720. var withdrawItems = '';
  3721. var withdrawPrices = '';
  3722. var numberOfItems = 0;
  3723. var arr = [];
  3724. $('#withdraw_choose').children('.inventory_item').each(function() {
  3725. var itemID = $(this).attr('data-id');
  3726. if (!arr.indexOf(itemID) != -1) {
  3727. arr.push(itemID);
  3728. withdrawItems = withdrawItems + itemID + ',';
  3729. withdrawPrices = withdrawPrices + $(this).attr('data-price') + ',';
  3730. numberOfItems += 1;
  3731. }
  3732. });
  3733. if (numberOfItems > 0 && numberOfItems <= 50 && parseFloat($(".item_pot_value").html().replace(" Credits", "")) >= 1) {
  3734. $(".accept_link").hide();
  3735. $("#bot_inventory_holder").slideUp();
  3736. $("#user_withdraw").slideDown();
  3737. $("#waiting_pot_value").text($(".item_pot_value").text());
  3738. $.ajax({
  3739. type: "GET",
  3740. url: "/withdraw_save.php",
  3741. data: {
  3742. items: withdrawItems,
  3743. prices: withdrawPrices
  3744. },
  3745. success: function(text) {
  3746. if (text == 'errorCredits') {
  3747. needCredits();
  3748. } else if (text == 'errorLevel') {
  3749. setTimeout(function() {
  3750. swal({
  3751. title: phraser('ERROR'),
  3752. html: phraser('ERROR_LEVEL_TOO_LOW'),
  3753. type: 'error',
  3754. confirmButtonText: phraser('OKAY')
  3755. });
  3756. }, 500);
  3757. } else if (text == 'errorValue') {
  3758. setTimeout(function() {
  3759. swal({
  3760. title: phraser('ERROR'),
  3761. html: phraser('MAXIMUM_ITEMS_PER_TRADE_WITHDRAW'),
  3762. type: 'error',
  3763. confirmButtonText: phraser('OKAY')
  3764. });
  3765. }, 500);
  3766. } else if (text == 'errorCreditsPlayed') {
  3767. setTimeout(function() {
  3768. swal({
  3769. title: phraser('ERROR'),
  3770. html: phraser('PLAYED_FOR_EXCEEDED'),
  3771. type: 'error',
  3772. confirmButtonText: phraser('OKAY')
  3773. });
  3774. }, 500);
  3775. } else if (text == 'errorToken') {
  3776. setTimeout(function() {
  3777. swal({
  3778. title: phraser('ERROR'),
  3779. html: phraser('COULDNT_SEND_OFFER_URL'),
  3780. type: 'error',
  3781. confirmButtonText: phraser('OKAY')
  3782. });
  3783. }, 500);
  3784. } else if (text.indexOf('success') !== -1) {
  3785. var response = text.split(";");
  3786. $("#waiting_pot_value").text($(".item_pot_value").text());
  3787. $("#waiting_code").text(response[1]);
  3788. $("#waiting_deposit_id").attr('data-id', response[2]);
  3789. $("#waiting_bot").text(response[3]);
  3790. updateCredits(-1 * parseFloat($(".item_pot_value").text()));
  3791. timeouts.push(setTimeout(function() {
  3792. tradeOfferStatus('withdraw');
  3793. }, 1000));
  3794. } else {
  3795. swal({
  3796. title: phraser('ERROR'),
  3797. html: phraser('UNKNOWN_ERROR') + "<br><br>#" + text,
  3798. type: 'error',
  3799. confirmButtonText: phraser('OKAY')
  3800. });
  3801. }
  3802. if (text.indexOf('success') == -1) {
  3803. $("#bot_inventory_holder").slideDown();
  3804. $("#user_withdraw").slideUp();
  3805. }
  3806. }
  3807. });
  3808. } else {
  3809. swal({
  3810. title: phraser('ERROR'),
  3811. html: phraser('MAXIMUM_ITEMS_PER_TRADE'),
  3812. type: 'error',
  3813. confirmButtonText: phraser('OKAY')
  3814. });
  3815. }
  3816. });
  3817.  
  3818. $('body').on('click', '.items_information_withdraw', function() {
  3819. $("#withdraw_played").fadeOut(100);
  3820. $("#withdraw_played_bg").fadeOut(100);
  3821. $(".background_blaze").css('overflow-y', 'auto');
  3822. if ($("#first_time").length > 0) {
  3823. swal({
  3824. title: "Trade URL",
  3825. html: $("#first_time").html(),
  3826. confirmButtonText: phraser('OKAY')
  3827. }, function() {
  3828. loadPage("settings.php");
  3829. });
  3830. }
  3831. });
  3832. $('body').on('submit', '#recruit_code_form', function(e) {
  3833. e.preventDefault();
  3834. var code = $("#recruit_code").val();
  3835. $("#recruit_code_form").html('<div class="loader_small"></div>');
  3836. $.ajax({
  3837. type: "GET",
  3838. url: "/recruits_save.php",
  3839. data: {
  3840. code: code
  3841. },
  3842. success: function(text) {
  3843. if (text == 'success') {
  3844. updateCredits(0.05);
  3845. loadPage("recruits.php");
  3846. } else {
  3847. loadPage("recruits.php");
  3848. swal({
  3849. title: phraser('ERROR'),
  3850. html: phraser('RECRUIT_' + text.toUpperCase()),
  3851. type: 'error',
  3852. confirmButtonText: phraser('OKAY')
  3853. });
  3854. }
  3855. }
  3856. });
  3857. });
  3858. $('body').on('click', '.withdraw_view_more', function() {
  3859. var type = $(this).attr('data-type');
  3860. $(".withdraw_view_more").remove();
  3861. $(".withdraw_clear").remove();
  3862. if (type == 'withdraw') {
  3863. botInventoryPage = botInventoryPage + 2;
  3864. loadBotInventory(true, false);
  3865. }
  3866. if (type == 'deals') {
  3867. botDealsPage = botDealsPage + 2;
  3868. loadBotDeals(true, $(".withdraw_deal.selected").attr('data-min'), $(".withdraw_deal.selected").attr('data-max'));
  3869. }
  3870. });
  3871.  
  3872. $('body').on('submit', '#search_round_form', function(e) {
  3873. e.preventDefault();
  3874. var round_type = $(this).attr('data-type');
  3875. var round_id = $("#search_round_text").val();
  3876. $("#search_round_result").show();
  3877. $("#search_round_result").html('<div class="loader_small"></div>');
  3878. $.ajax({
  3879. type: "GET",
  3880. url: "/" + round_type + "s_search.php",
  3881. data: {
  3882. round_id: round_id
  3883. },
  3884. success: function(text) {
  3885. $("#search_round_result").html(text);
  3886. }
  3887. });
  3888. });
  3889.  
  3890. $('body').on('submit', '#blackjack_create_form', function(e) {
  3891. e.preventDefault();
  3892. var credits = parseFloat($("#blackjack_bet_value").html());
  3893. credits = Math.round(credits * 100.0) / 100.0;
  3894. $("#blackjack_create_form button").prop('disabled', true).html('<div class="loader_small" style="width: 18px;height: 18px;margin: 0 auto;"></div>');
  3895. var chips = '';
  3896. $("#blackjack_chips_container div").each(function() {
  3897. chips = chips + $(this).attr('data-val') + ";";
  3898. });
  3899. $.ajax({
  3900. type: "POST",
  3901. url: "/blackjack_bet.php",
  3902. data: {
  3903. create: true,
  3904. credits: credits,
  3905. chips: chips,
  3906. user_token: $("#user_token").val()
  3907. },
  3908. success: function(text) {
  3909. $("#blackjack_create_form button").prop('disabled', false).html(phraser("CREATE"));
  3910. if (text == 'errorCredits') {
  3911. needCredits();
  3912. } else if (text == 'errorMin' || text == 'errorMax') {
  3913. swal({
  3914. title: phraser('ERROR'),
  3915. html: phraser('MINIMUM_MAXIMUM_BET'),
  3916. type: 'error',
  3917. confirmButtonText: phraser('OKAY')
  3918. });
  3919. } else if (text == 'errorAction') {
  3920. swal({
  3921. title: phraser('ERROR'),
  3922. html: phraser('ACTION_NOT_AVAILABLE'),
  3923. type: 'error',
  3924. confirmButtonText: phraser('OKAY')
  3925. });
  3926. } else {
  3927. updateCredits(-1 * credits);
  3928. $(".blackjack_hash").html("<b>" + phraser("HASH") + ":</b> " + text);
  3929. $(".blackjack_block").show();
  3930. $("#blackjack_player").show();
  3931. $("#blackjack_better").hide();
  3932. $("#deal_shuffle").show();
  3933. $("#blackjack_value_number_player").html('0');
  3934. $("#blackjack_value_number_dealer").html('0');
  3935. $(".blackjack_game_value").html(credits + ' Credits').show();
  3936. $("#blackjack_chips_container_ongoing").html($("#blackjack_chips_container").html());
  3937. $(".stand").trigger('play');
  3938. setTimeout(function() {
  3939. $(".stand").trigger('pause');
  3940. $(".stand").prop("currentTime", 0);
  3941. }, 900);
  3942. }
  3943. }
  3944. });
  3945. });
  3946. $('body').on('click', '.blackjack_deal', function(e) {
  3947. var button = $(this);
  3948. button.prop('disabled', true).html('<div class="loader_small" style="width: 18px;height: 18px;margin: 0 auto;"></div>');
  3949. $.ajax({
  3950. type: "GET",
  3951. url: "/blackjack_bet.php",
  3952. data: {
  3953. deal: true,
  3954. user_token: $("#user_token").val()
  3955. },
  3956. success: function(text) {
  3957. if (text == 'errorCards' || text == 'errorGameID' || text == 'errorAction') {
  3958. swal({
  3959. title: phraser('ERROR'),
  3960. html: phraser('ACTION_NOT_AVAILABLE'),
  3961. type: 'error',
  3962. confirmButtonText: phraser('OKAY')
  3963. });
  3964. } else {
  3965. blackJackDeal(text);
  3966. }
  3967. button.prop('disabled', false).html(phraser('DEAL'));
  3968. }
  3969. });
  3970. });
  3971. $('body').on('click', '.blackjack_shuffle', function(e) {
  3972. var button = $(this);
  3973. button.prop('disabled', true).html('<div class="loader_small" style="width: 18px;height: 18px;margin: 0 auto;"></div>');
  3974. $.ajax({
  3975. type: "GET",
  3976. url: "/blackjack_bet.php",
  3977. data: {
  3978. shuffle: true,
  3979. user_token: $("#user_token").val()
  3980. },
  3981. success: function(text) {
  3982. if (text == 'errorAction' || text == 'errorGameID') {
  3983. swal({
  3984. title: phraser('ERROR'),
  3985. html: phraser('ACTION_NOT_AVAILABLE'),
  3986. type: 'error',
  3987. confirmButtonText: phraser('OKAY')
  3988. });
  3989. } else {
  3990. $(".blackjack_hash").html("<b>" + phraser("HASH") + ":</b> " + text);
  3991. $(".stand").trigger('play');
  3992. setTimeout(function() {
  3993. $(".stand").trigger('pause');
  3994. $(".stand").prop("currentTime", 0);
  3995. }, 900);
  3996. }
  3997. button.prop('disabled', false).html(phraser('SHUFFLE'));
  3998. }
  3999. });
  4000. });
  4001. $('body').on('click', '.blackjack_hit, .blackjack_double', function(e) {
  4002. if (!$(this).hasClass('disabled')) {
  4003. var button = $(this);
  4004. button.prop('disabled', true).html('<div class="loader_small" style="width: 18px;height: 18px;margin: 0 auto;"></div>');
  4005. $(".blackjack_hit").addClass('disabled');
  4006. $(".blackjack_double").addClass('disabled');
  4007. var doubled = false;
  4008. var buttonString = phraser('HIT');
  4009. if ($(this).hasClass('blackjack_double')) {
  4010. doubled = true;
  4011. updateCredits(-1 * parseFloat($(".blackjack_game_value").html().replace(' Credits', '')));
  4012. buttonString = phraser('DOUBLE');
  4013. }
  4014. $.ajax({
  4015. type: "GET",
  4016. url: "/blackjack_bet.php",
  4017. data: {
  4018. hit: true,
  4019. doubled: doubled,
  4020. user_token: $("#user_token").val()
  4021. },
  4022. success: function(text) {
  4023. if (text == 'errorCards' || text == 'errorGameID' || text == 'errorTotal') {
  4024. swal({
  4025. title: phraser('ERROR'),
  4026. html: phraser('ACTION_NOT_AVAILABLE'),
  4027. type: 'error',
  4028. confirmButtonText: phraser('OKAY')
  4029. });
  4030. } else if (text == 'errorAction') {
  4031. swal({
  4032. title: phraser('ERROR'),
  4033. html: phraser('ACTION_NOT_AVAILABLE'),
  4034. type: 'error',
  4035. confirmButtonText: phraser('OKAY')
  4036. });
  4037. } else if (text == 'errorCredits') {
  4038. $(".blackjack_hit").removeClass('disabled');
  4039. needCredits();
  4040. } else {
  4041. blackJackHit(text, doubled);
  4042. if (doubled) {
  4043. $("#blackjack_chips_container_ongoing").html($("#blackjack_chips_container_ongoing").html() + ' ' + $("#blackjack_chips_container_ongoing").html());
  4044. }
  4045. }
  4046. button.prop('disabled', false).html(buttonString);
  4047. }
  4048. });
  4049. }
  4050. });
  4051. $('body').on('click', '.blackjack_stand', function(e) {
  4052. if (!$(this).hasClass('disabled')) {
  4053. blackJackStand();
  4054. }
  4055. });
  4056. $('body').on('click', '#refresh_steam_info', function(e) {
  4057. $("#refresh_steam_info").prop('disabled', true).html('<div class="loader_small" style="width: 18px;height: 18px;margin: 0 auto;"></div>');
  4058. $.ajax({
  4059. type: "POST",
  4060. url: "/settings_save.php",
  4061. data: {
  4062. refresh_steam: true
  4063. },
  4064. success: function(text) {
  4065. $("#refresh_steam_info").prop('disabled', false).html(phraser('REFRESH'));
  4066. swal({
  4067. title: phraser('SUCCESS'),
  4068. html: phraser('SETTINGS_SUCCESSFULLY_SAVED'),
  4069. type: 'success',
  4070. confirmButtonText: phraser('OKAY'),
  4071. allowOutsideClick: false,
  4072. allowEscapeKey: false
  4073. }, function() {
  4074. window.location.reload();
  4075. });
  4076. }
  4077. });
  4078. });
  4079. $('body').on('click', '#blackjack_better .chip', function(e) {
  4080. var chip = $(this).clone();
  4081. var bet_val = parseFloat($("#blackjack_bet_value").html());
  4082. if ($(this).parent().attr('id') == 'blackjack_chips') {
  4083. $("#blackjack_chips_container").prepend(chip);
  4084. bet_val += parseFloat(chip.attr('data-val'));
  4085. } else {
  4086. $(this).remove();
  4087. bet_val -= parseFloat(chip.attr('data-val'));
  4088. }
  4089. bet_val = Math.round(bet_val * 100) / 100;
  4090. $("#blackjack_bet_value").html(bet_val)
  4091. $(".blackjack_bet_value").html(bet_val + ' Credits');
  4092. });
  4093. var slot_available = true;
  4094. $('body').on('click submit', '#slot_spin, #slot_bet', function(e) {
  4095. e.preventDefault();
  4096. if ($(this).attr('id') == "slot_bet" && e.type == 'click') {
  4097. return;
  4098. }
  4099. if (slot_available) {
  4100. slot_available = false;
  4101. var credits = parseFloat($("#slot_bet_credits").val());
  4102. $("#slot_spin").addClass('slot_spin_disabled');
  4103. $("#slot_winner").removeClass('slot_winner_highlight');
  4104. $(".slot_legend_result").removeClass('slot_legend_highlight');
  4105. $.ajax({
  4106. type: "GET",
  4107. url: "/slot_bet.php",
  4108. data: {
  4109. credits: credits,
  4110. user_token: $("#user_token").val()
  4111. },
  4112. success: function(text) {
  4113. if (text == 'errorCredits') {
  4114. needCredits();
  4115. $("#slot_spin").removeClass('slot_spin_disabled');
  4116. slot_available = true;
  4117. } else if (text == 'errorMin' || text == 'errorMax') {
  4118. swal({
  4119. title: phraser('ERROR'),
  4120. html: phraser('MINIMUM_MAXIMUM_BET_10'),
  4121. type: 'error',
  4122. confirmButtonText: phraser('OKAY')
  4123. });
  4124. $("#slot_spin").removeClass('slot_spin_disabled');
  4125. slot_available = true;
  4126. } else if (text == 'errorAction') {
  4127. swal({
  4128. title: phraser('ERROR'),
  4129. html: phraser('ACTION_NOT_AVAILABLE'),
  4130. type: 'error',
  4131. confirmButtonText: phraser('OKAY')
  4132. });
  4133. } else {
  4134. $(".spin").trigger('play');
  4135. setTimeout(function() {
  4136. $(".spin").trigger('pause');
  4137. $(".spin").prop("currentTime", 0);
  4138. }, 900);
  4139. updateCredits(-1 * credits);
  4140. var fruits = text.split(";");
  4141. var i = 0;
  4142. slotFill();
  4143. $(".slot_child_content").each(function() {
  4144. $(this).append('<img src="' + site + '/images/' + fruits[i] + '.png">');
  4145. $(this).append('<img src="' + site + '/images/' + fruits[(i + 1)] + '.png">');
  4146. i += 2;
  4147. });
  4148. slotSpinAll();
  4149. setTimeout(function() {
  4150. $("#slot_spin").removeClass('slot_spin_disabled');
  4151. slot_available = true;
  4152. if (fruits[7] == 'win') {
  4153. if (fruits[0] == 'treasure' || fruits[0] == 'blueberry') {
  4154. $(".win_big").trigger('play');
  4155. setTimeout(function() {
  4156. $(".win_big").trigger('pause');
  4157. $(".win_big").prop("currentTime", 0);
  4158. }, 1500);
  4159. } else {
  4160. $(".win_normal").trigger('play');
  4161. setTimeout(function() {
  4162. $(".win_normal").trigger('pause');
  4163. $(".win_normal").prop("currentTime", 0);
  4164. }, 1500);
  4165. }
  4166. updateCredits(fruits[6]);
  4167. $("#slot_winner").addClass('slot_winner_highlight');
  4168. $("#" + fruits[0]).addClass('slot_legend_highlight');
  4169. setTimeout(function() {
  4170. $("#slot_winner").removeClass('slot_winner_highlight');
  4171. $("#" + fruits[0]).removeClass('slot_legend_highlight');
  4172. }, 2000);
  4173. }
  4174. }, 2500);
  4175. }
  4176. }
  4177. });
  4178. }
  4179. });
  4180. $('body').on('submit', '#jukebox_form', function(e) {
  4181. e.preventDefault();
  4182. $("#jukebox_form").hide();
  4183. $("#jukebox_loader").show();
  4184. $.ajax({
  4185. type: "GET",
  4186. url: "/jukebox.php",
  4187. data: {
  4188. create: true,
  4189. track_url: $("#track_url").val()
  4190. },
  4191. success: function(text) {
  4192. if (text == 'errorCredits') {
  4193. needCredits();
  4194. } else if (text == 'errorURL') {
  4195. swal({
  4196. title: phraser('ERROR'),
  4197. html: phraser('JUKEBOX_URL_ERROR'),
  4198. type: 'error',
  4199. confirmButtonText: phraser('OKAY')
  4200. });
  4201. } else if (text == 'errorAction') {
  4202. swal({
  4203. title: phraser('ERROR'),
  4204. html: phraser('ACTION_NOT_AVAILABLE'),
  4205. type: 'error',
  4206. confirmButtonText: phraser('OKAY')
  4207. });
  4208. } else if (text == 'errorAvailable') {
  4209. swal({
  4210. title: phraser('ERROR'),
  4211. html: phraser('JUKEBOX_AVAILABLE_ERROR'),
  4212. type: 'error',
  4213. confirmButtonText: phraser('OKAY')
  4214. });
  4215. } else {
  4216. $("#track_url").val('');
  4217. var jukeboxTokens = parseInt($("#jukebox_tokens b").html());
  4218. if (jukeboxTokens == 0 && !chatMod && !userVIP) {
  4219. updateCredits(-1);
  4220. } else if (jukeboxTokens > 0) {
  4221. $("#jukebox_tokens b").html((jukeboxTokens - 1));
  4222. }
  4223. }
  4224. $("#jukebox_form").show();
  4225. $("#jukebox_loader").hide();
  4226. }
  4227. });
  4228. });
  4229. $("#jukebox_slider").bind("slider:changed", function(event, data) {
  4230. var newVolume = Math.round((data.ratio) * 100);
  4231. youtubePlayer.setVolume(newVolume);
  4232. saveJukeboxVolume(newVolume);
  4233. $("#jukebox_volume_holder").val(data.ratio);
  4234. });
  4235. $('body').on('click', '#jukebox_toggle', function(e) {
  4236. var newVolume = 0.75;
  4237. if ($("#jukebox_volume_holder").val() > 0) {
  4238. newVolume = 0;
  4239. }
  4240. $("#jukebox_slider").simpleSlider("setValue", newVolume);
  4241. $("#jukebox_volume_holder").val(newVolume);
  4242. });
  4243. $('body').on('click', '#mini_guide_terms', function(e) {
  4244. loadPage('terms.php');
  4245. });
  4246. $('body').on('click', '[show-profile]', function(e) {
  4247. var isVisible = $("#user_profile").is(':visible');
  4248. var user_id = $(this).attr('show-profile');
  4249. $("#user_profile_links").show();
  4250. $("#send_credits").hide();
  4251. $("#user_profile").html('<div class="loader_small_darker" style="margin-top: 60px;"></div>').fadeIn(100);
  4252. $.ajax({
  4253. type: "GET",
  4254. url: "/user_info.php",
  4255. data: {
  4256. user_id: user_id
  4257. },
  4258. success: function(text) {
  4259. $("#user_profile").attr("data-user", user_id);
  4260. $("#user_profile").html(text);
  4261. }
  4262. });
  4263. if (!isVisible) {
  4264. var posTop = e.pageY - 40;
  4265. var posLeft = e.pageX - 30;
  4266. if (isMobile) {
  4267. posLeft += 30;
  4268. }
  4269. if (posLeft + $("#user_profile").width() > $('body').width()) {
  4270. posLeft -= posLeft + $("#user_profile").width() - $('body').width() + 10;
  4271. }
  4272. if (posTop + $("#user_profile").height() > $('body').height()) {
  4273. posTop -= posTop + $("#user_profile").height() - $('body').height() + 10;
  4274. }
  4275. $("#user_profile").html('<div class="loader_small_darker" style="margin-top: 60px;"></div>').css({
  4276. top: posTop,
  4277. left: posLeft
  4278. }).fadeIn(100);
  4279. }
  4280. });
  4281. $('body').on('click', '#user_profile_close', function(e) {
  4282. $(this).parent().hide();
  4283. });
  4284. var chatOriginalWidth, chatOriginalHeight;
  4285. $('body').on('click', '#chat_hide', function(e) {
  4286. chatOriginalWidth = $(".chat").width();
  4287. chatOriginalHeight = $(".chat").height();
  4288. $("#chat_show").show();
  4289. $(".chat").animate({
  4290. 'width': '0',
  4291. 'height': '0'
  4292. }, 300, function() {
  4293. $(".chat").css({
  4294. 'display': 'none',
  4295. 'width': '',
  4296. 'height': ''
  4297. });
  4298. });
  4299. pusherChat.unsubscribe("chat_channel");
  4300. });
  4301. $('body').on('click', '#chat_show', function(e) {
  4302. $(".chat").css('display', 'table-cell');
  4303. $("#chat_show").hide();
  4304. $(".chat").animate({
  4305. 'width': chatOriginalWidth + 'px',
  4306. 'height': chatOriginalHeight + 'px'
  4307. }, 300, function() {
  4308. $(".chat").css({
  4309. 'width': '',
  4310. 'height': ''
  4311. });
  4312. });
  4313. var cChannel = pusherChat.subscribe('chat_channel');
  4314. cChannel.bind('chat_message_new', function(data) {
  4315. addChatMessage(data);
  4316. });
  4317. cChannel.bind('chat_message_remove', function(data) {
  4318. removeChatMessage(data);
  4319. });
  4320. cChannel.bind('chat_giveaway_new', function(data) {
  4321. handleGiveaway(data);
  4322. });
  4323. });
  4324. $('body').on('change', '#giveaway_random', function(e) {
  4325. if (!$("#giveaway_random").is(':checked')) {
  4326. $("#giveaway_answer").attr('disabled', 'disabled');
  4327. $("#giveaway_hint").attr('disabled', 'disabled');
  4328. } else {
  4329. $("#giveaway_answer").removeAttr('disabled');
  4330. $("#giveaway_hint").removeAttr('disabled');
  4331. }
  4332. });
  4333.  
  4334. $('body').on('click', '.betting_game_minimize', function(e) {
  4335. $(this).hide();
  4336. $(this).parent().find('.betting_game_loader, .betting_game_result').hide();
  4337. $(this).parent().addClass('betting_game_small').css('height', '100px');
  4338. $(this).parent().find('.betting_game_bg').css('height', '100px');
  4339. });
  4340. $('body').on('click', '.betting_game_small', function(e) {
  4341. $(".betting_game").each(function() {
  4342. $(this).find('.betting_game_minimize, .betting_game_loader, .betting_game_result').hide();
  4343. $(this).addClass('betting_game_small').css('height', '100px');
  4344. $(this).find('.betting_game_bg').css('height', '100px');
  4345. });
  4346. var game_id = $(this).attr('show-game');
  4347. var content_height = 120 + $(this).find('.betting_game_result').height();
  4348. $(this).find('.betting_game_minimize').show();
  4349. $(this).removeClass('betting_game_small').css('height', content_height + 'px');
  4350. $(this).find('.betting_game_bg').css('height', content_height + 'px');
  4351. $(this).find('.betting_game_result').fadeIn(500);
  4352. });
  4353. $('body').on('click', '.betting_create_team', function(e) {
  4354. $(".betting_create_team").removeClass('betting_selected');
  4355. $(this).addClass('betting_selected');
  4356. });
  4357. var betting_bet_available = true;
  4358. $('body').on('submit', '.betting_create', function(e) {
  4359. e.preventDefault();
  4360. var that = $(this);
  4361. if (betting_bet_available) {
  4362. betting_bet_available = false;
  4363. var credits = that.find(".betting_value").val();
  4364. var team_id = that.find(".betting_selected").attr('data-id');
  4365. var game_id = that.attr('data-id');
  4366. $("#betting_create_loader").show();
  4367. $("#betting_create_info").hide();
  4368. $.ajax({
  4369. type: "GET",
  4370. url: "/betting_bet.php",
  4371. data: {
  4372. game_id: game_id,
  4373. team_id: team_id,
  4374. credits: credits,
  4375. user_token: $("#user_token").val()
  4376. },
  4377. success: function(text) {
  4378. betting_bet_available = true;
  4379. $("#betting_create_loader").hide();
  4380. $("#betting_create_info").show();
  4381. if (text == 'errorCredits') {
  4382. needCredits();
  4383. } else if (text == 'errorMin' || text == 'errorMax') {
  4384. swal({
  4385. title: phraser('ERROR'),
  4386. html: phraser('MINIMUM_MAXIMUM_BET'),
  4387. type: 'error',
  4388. confirmButtonText: phraser('ERROR')
  4389. });
  4390. } else if (text == 'errorStarted') {
  4391. swal({
  4392. title: phraser('ERROR'),
  4393. html: phraser('MATCH_IS_LIVE'),
  4394. type: 'error',
  4395. confirmButtonText: phraser('OKAY')
  4396. });
  4397. } else if (text == 'errorAction') {
  4398. swal({
  4399. title: phraser('ERROR'),
  4400. html: phraser('ACTION_NOT_AVAILABLE'),
  4401. type: 'error',
  4402. confirmButtonText: phraser('OKAY')
  4403. });
  4404. } else {
  4405. updateCredits(-1 * credits);
  4406. loadPage('betting.php');
  4407. }
  4408. }
  4409. });
  4410. }
  4411. });
  4412. var betting_swap_available = true;
  4413. $('body').on('click', '.betting_swap', function(e) {
  4414. if (betting_swap_available) {
  4415. betting_swap_available = false;
  4416. var bet_id = $(this).attr('data-id');
  4417. $("#betting_swap_loader").show();
  4418. $.ajax({
  4419. type: "GET",
  4420. url: "/betting_bet.php",
  4421. data: {
  4422. bet_id: bet_id,
  4423. user_token: $("#user_token").val()
  4424. },
  4425. success: function(text) {
  4426. $("#betting_swap_loader").hide();
  4427. betting_swap_available = true;
  4428. if (text == 'errorStarted') {
  4429. swal({
  4430. title: phraser('ERROR'),
  4431. html: phraser('MATCH_IS_LIVE'),
  4432. type: 'error',
  4433. confirmButtonText: phraser('OKAY')
  4434. });
  4435. } else if (text == 'errorAction') {
  4436. swal({
  4437. title: phraser('ERROR'),
  4438. html: phraser('ACTION_NOT_AVAILABLE'),
  4439. type: 'error',
  4440. confirmButtonText: phraser('OKAY')
  4441. });
  4442. } else {
  4443. loadPage('betting.php');
  4444. }
  4445. }
  4446. });
  4447. }
  4448. });
  4449. $('body').on('keyup', '.betting_value', function(e) {
  4450. var value = $(this).val();
  4451. var home_multiplier = parseFloat($('.betting_home_multiplier').html());
  4452. var away_multiplier = parseFloat($('.betting_away_multiplier').html());
  4453. if (value.length == 0) {
  4454. value = 0;
  4455. }
  4456. $(".betting_both_value").html(value);
  4457. $(".betting_home_reward").html(Math.round(value * home_multiplier * 100.0) / 100.0);
  4458. $(".betting_away_reward").html(Math.round(value * away_multiplier * 100.0) / 100.0);
  4459. });
  4460. $('body').on('change', '#home_team_id, #away_team_id', function() {
  4461. if ($("#home_team_id").val() == $("#away_team_id").val()) {
  4462. alert("You can't choose same team for both home and away!");
  4463. if ($("#home_team_id").val() == "16") {
  4464. $(this).val("3");
  4465. } else {
  4466. $(this).val("16");
  4467. }
  4468. }
  4469. });
  4470.  
  4471. $('body').on('click', '.coinflip_list_status_join', function(e) {
  4472. $(".coinflip_list_status_join").removeClass('coinflip_list_status_join_final').html('<i class="fa fa-play-circle"></i> ' + phraser("CHALLENGE"));
  4473. $(this).addClass('coinflip_list_status_join_final').html('<i class="fa fa-arrow-right"></i> ' + phraser("CONTINUE"));
  4474. });
  4475. var coinflip_challenge_available = true;
  4476. $('body').on('click', '.coinflip_list_status_join_final', function(e) {
  4477. var coinflip_id = $(this).attr('data-id');
  4478. var value = $(this).attr('data-value');
  4479. var buttonHTML = $(this).html();
  4480. var button = $(this);
  4481. if (coinflip_challenge_available) {
  4482. coinflip_challenge_available = false;
  4483. button.html('<div class="loader_small" style="width: 18px;height: 18px;margin: 15px auto;"></div>');
  4484. $.ajax({
  4485. type: "GET",
  4486. url: "/coinflip_bet.php",
  4487. data: {
  4488. challenge: true,
  4489. coinflip_id: coinflip_id,
  4490. user_token: $("#user_token").val()
  4491. },
  4492. success: function(text) {
  4493. coinflip_challenge_available = true;
  4494. button.html(buttonHTML);
  4495. if (text == 'errorCredits') {
  4496. needCredits();
  4497. } else if (text == 'errorGameID') {
  4498. swal({
  4499. title: phraser('ERROR'),
  4500. html: phraser('GAME_SNATCHED'),
  4501. type: 'error',
  4502. confirmButtonText: phraser('OKAY')
  4503. });
  4504. } else if (text == 'errorUser') {
  4505. swal({
  4506. title: phraser('ERROR'),
  4507. html: phraser('CANNOT_PLAY_YOURSELF'),
  4508. type: 'error',
  4509. confirmButtonText: phraser('OKAY')
  4510. });
  4511. } else if (text == 'errorAvailable') {
  4512. swal({
  4513. title: phraser('ERROR'),
  4514. html: phraser('JUKEBOX_AVAILABLE_ERROR'),
  4515. type: 'error',
  4516. confirmButtonText: phraser('OKAY')
  4517. });
  4518. } else if (text == 'errorAction') {
  4519. swal({
  4520. title: phraser('ERROR'),
  4521. html: phraser('ACTION_NOT_AVAILABLE'),
  4522. type: 'error',
  4523. confirmButtonText: phraser('OKAY')
  4524. });
  4525. } else {
  4526. updateCredits(-1 * value);
  4527. coinLoad("game", coinflip_id);
  4528. }
  4529. }
  4530. });
  4531. }
  4532. });
  4533. $('body').on('click', '.coinflip_list_status_view', function(e) {
  4534. var coinflip_id = $(this).attr('data-id');
  4535. coinLoad("game", coinflip_id);
  4536. });
  4537. $('body').on('click', '.coinflip_view_all', function(e) {
  4538. loadPage("coinflip.php");
  4539. });
  4540. $('body').on('click', '#coinflip_create img', function(e) {
  4541. $("#coinflip_create img").removeClass('coinflip_selected');
  4542. $(this).addClass('coinflip_selected');
  4543. });
  4544. $('body').on('submit', '#coinflip_create', function(e) {
  4545. e.preventDefault();
  4546. $("#coinflip_create button").prop('disabled', true).html('<div class="loader_small" style="width: 18px;height: 18px;margin: 2px auto;"></div>');
  4547. var value = $("#coinflip_value").val();
  4548. var choice = $(".coinflip_selected").attr('data-side');
  4549. $.ajax({
  4550. type: "GET",
  4551. url: "/coinflip_bet.php",
  4552. data: {
  4553. create: true,
  4554. credits: value,
  4555. choice: choice,
  4556. user_token: $("#user_token").val()
  4557. },
  4558. success: function(text) {
  4559. $("#coinflip_create button").prop('disabled', false).html(phraser('CREATE'));
  4560. if (text == 'errorCredits') {
  4561. needCredits();
  4562. } else if (text == 'errorMin') {
  4563. swal({
  4564. title: phraser('ERROR'),
  4565. html: phraser('MINIMUM_BET_SMALL'),
  4566. type: 'error',
  4567. confirmButtonText: phraser('ERROR')
  4568. });
  4569. } else if (text == 'errorAction') {
  4570. swal({
  4571. title: phraser('ERROR'),
  4572. html: phraser('ACTION_NOT_AVAILABLE'),
  4573. type: 'error',
  4574. confirmButtonText: phraser('OKAY')
  4575. });
  4576. } else if (text == 'errorChoice') {
  4577. swal({
  4578. title: phraser('ERROR'),
  4579. html: phraser('ACTION_NOT_AVAILABLE'),
  4580. type: 'error',
  4581. confirmButtonText: phraser('OKAY')
  4582. });
  4583. } else if (text == 'errorBets') {
  4584. swal({
  4585. title: phraser('ERROR'),
  4586. html: phraser('TOO_MANY_BETS'),
  4587. type: 'error',
  4588. confirmButtonText: phraser('OKAY')
  4589. });
  4590. } else {
  4591. updateCredits(-1 * value);
  4592. }
  4593. }
  4594. });
  4595. });
  4596. $('body').on('click', '.dragrace_list_status_join', function(e) {
  4597. $(".dragrace_list_status_join").removeClass('dragrace_list_status_join_final').html('<i class="fa fa-play-circle"></i> ' + phraser("CHALLENGE"));
  4598. $(this).addClass('dragrace_list_status_join_final').html('<img src="' + site + '/images/race_car1.png" data-choice="1"> <img src="' + site + '/images/race_car2.png" data-choice="2"> <img src="' + site + '/images/race_car3.png" data-choice="3"> <img src="' + site + '/images/race_car4.png" data-choice="4">');
  4599. });
  4600. var dragrace_challenge_available = true;
  4601. $('body').on('click', '.dragrace_list_status_join img', function(e) {
  4602. var dragrace_id = $(this).parent().attr('data-id');
  4603. var value = $(this).parent().attr('data-value');
  4604. var choice = $(this).attr('data-choice');
  4605. if (dragrace_challenge_available) {
  4606. dragrace_challenge_available = false;
  4607. $("#dragrace_challenge_loader").show();
  4608. $.ajax({
  4609. type: "GET",
  4610. url: "/dragrace_bet.php",
  4611. data: {
  4612. challenge: true,
  4613. dragrace_id: dragrace_id,
  4614. choice: choice,
  4615. user_token: $("#user_token").val()
  4616. },
  4617. success: function(text) {
  4618. dragrace_challenge_available = true;
  4619. $("#dragrace_challenge_loader").hide();
  4620. if (text == 'errorCredits') {
  4621. needCredits();
  4622. } else if (text == 'errorGameID') {
  4623. swal({
  4624. title: phraser('ERROR'),
  4625. html: phraser('GAME_SNATCHED'),
  4626. type: 'error',
  4627. confirmButtonText: phraser('OKAY')
  4628. });
  4629. } else if (text == 'errorUser') {
  4630. swal({
  4631. title: phraser('ERROR'),
  4632. html: phraser('CANNOT_PLAY_YOURSELF'),
  4633. type: 'error',
  4634. confirmButtonText: phraser('OKAY')
  4635. });
  4636. } else if (text == 'errorAvailable') {
  4637. swal({
  4638. title: phraser('ERROR'),
  4639. html: phraser('JUKEBOX_AVAILABLE_ERROR'),
  4640. type: 'error',
  4641. confirmButtonText: phraser('OKAY')
  4642. });
  4643. } else if (text == 'errorAction') {
  4644. swal({
  4645. title: phraser('ERROR'),
  4646. html: phraser('ACTION_NOT_AVAILABLE'),
  4647. type: 'error',
  4648. confirmButtonText: phraser('OKAY')
  4649. });
  4650. } else {
  4651. updateCredits(-1 * value);
  4652. raceLoad("game", dragrace_id);
  4653. }
  4654. }
  4655. });
  4656. }
  4657. });
  4658. $('body').on('click', '.dragrace_list_status_view', function(e) {
  4659. var dragrace_id = $(this).attr('data-id');
  4660. raceLoad("game", dragrace_id);
  4661. });
  4662. $('body').on('click', '.race_view_all', function(e) {
  4663. loadPage("dragrace.php");
  4664. });
  4665. $('body').on('click', '#dragrace_create img', function(e) {
  4666. $("#dragrace_create img").removeClass('dragrace_selected');
  4667. $(this).addClass('dragrace_selected');
  4668. });
  4669. var dragrace_create_available = true;
  4670. $('body').on('submit', '#dragrace_create', function(e) {
  4671. e.preventDefault();
  4672. if (dragrace_create_available) {
  4673. dragrace_create_available = false;
  4674. var value = $("#dragrace_value").val();
  4675. var choice = $(".dragrace_selected").attr('data-choice');
  4676. $("#dragrace_create_loader").show();
  4677. $("#dragrace_create").hide();
  4678. $.ajax({
  4679. type: "GET",
  4680. url: "/dragrace_bet.php",
  4681. data: {
  4682. create: true,
  4683. credits: value,
  4684. choice: choice,
  4685. user_token: $("#user_token").val()
  4686. },
  4687. success: function(text) {
  4688. dragrace_create_available = true;
  4689. $("#dragrace_create_loader").hide();
  4690. $("#dragrace_create").show();
  4691. if (text == 'errorCredits') {
  4692. needCredits();
  4693. } else if (text == 'errorMin') {
  4694. swal({
  4695. title: phraser('ERROR'),
  4696. html: phraser('MINIMUM_BET_SMALL'),
  4697. type: 'error',
  4698. confirmButtonText: phraser('ERROR')
  4699. });
  4700. } else if (text == 'errorAction') {
  4701. swal({
  4702. title: phraser('ERROR'),
  4703. html: phraser('ACTION_NOT_AVAILABLE'),
  4704. type: 'error',
  4705. confirmButtonText: phraser('OKAY')
  4706. });
  4707. } else if (text == 'errorBets') {
  4708. swal({
  4709. title: phraser('ERROR'),
  4710. html: phraser('TOO_MANY_BETS'),
  4711. type: 'error',
  4712. confirmButtonText: phraser('OKAY')
  4713. });
  4714. } else {
  4715. updateCredits(-1 * value);
  4716. }
  4717. }
  4718. });
  4719. }
  4720. });
  4721. $('body').on('click', '.giveaway_win', function(e) {
  4722. $(this).html('<div class="loader_small" style="margin-top: 0;"></div>');
  4723. $.ajax({
  4724. type: "GET",
  4725. url: "/giveaway_bet.php",
  4726. data: {
  4727. winner: true
  4728. },
  4729. success: function(text) {
  4730. if (text == 'errorNotFound') {
  4731. swal({
  4732. title: phraser('ERROR'),
  4733. html: phraser('PLEASE_TRY_AGAIN'),
  4734. type: 'error',
  4735. confirmButtonText: phraser('OKAY')
  4736. });
  4737. } else if (text == 'errorName') {
  4738. swal({
  4739. title: phraser('ERROR'),
  4740. html: phraser('GIVEAWAY_NEED_NAME'),
  4741. type: 'error',
  4742. confirmButtonText: phraser('OKAY')
  4743. });
  4744. } else {
  4745. updateCredits(text);
  4746. loadPage("giveaway.php");
  4747. }
  4748. }
  4749. });
  4750. });
  4751.  
  4752. $('body').on('change', '#answer_select', function(e) {
  4753. var new_text = $("#answer_" + $(this).val()).text();
  4754. $("#support_answer").val(new_text);
  4755. });
  4756. $('body').on('click', '#go_to_settings', function(e) {
  4757. loadPage("settings.php");
  4758. $(".sweet-alert").removeClass('visible').hide();
  4759. $(".sweet-overlay").hide();
  4760. });
  4761. $('body').on('click', '.send_credits_button', function(e) {
  4762. $("#user_profile_links").hide();
  4763. $("#send_credits").show();
  4764. });
  4765. $('body').on('click', '.send_credits_back', function(e) {
  4766. $("#user_profile_links").show();
  4767. $("#send_credits").hide();
  4768. });
  4769. $('body').on('submit', '#send_credits form', function(e) {
  4770. e.preventDefault();
  4771. $(".loader_small_dark").show();
  4772. $("#send_credits_form").hide();
  4773. var credits = $("#send_credits_amount").val();
  4774. var user_id = $("#user_profile").attr('data-user');
  4775. $.ajax({
  4776. type: "GET",
  4777. url: "/send_credits.php",
  4778. data: {
  4779. user_id: user_id,
  4780. credits: credits,
  4781. user_token: $("#user_token").val()
  4782. },
  4783. success: function(text) {
  4784. $(".loader_small_dark").hide();
  4785. $("#send_credits_form").show();
  4786. if (text == 'errorValue') {
  4787. swal({
  4788. title: phraser('ERROR'),
  4789. html: phraser('DAILY_SEND_LIMIT_NEW'),
  4790. type: 'error',
  4791. confirmButtonText: phraser('OKAY')
  4792. });
  4793. } else if (text == 'errorCredits') {
  4794. needCredits();
  4795. } else if (text == 'errorAction') {
  4796. swal({
  4797. title: phraser('ERROR'),
  4798. html: phraser('ACTION_NOT_AVAILABLE'),
  4799. type: 'error',
  4800. confirmButtonText: phraser('OKAY')
  4801. });
  4802. } else if (text == 'errorLevel') {
  4803. swal({
  4804. title: phraser('ERROR'),
  4805. html: phraser('ERROR_LEVEL_TOO_LOW'),
  4806. type: 'error',
  4807. confirmButtonText: phraser('OKAY')
  4808. });
  4809. } else if (text == 'errorAmount') {
  4810. swal({
  4811. title: phraser('ERROR'),
  4812. html: phraser('SEND_ERROR_AMOUNT'),
  4813. type: 'error',
  4814. confirmButtonText: phraser('OKAY')
  4815. });
  4816. } else if (text == 'errorUser') {
  4817. swal({
  4818. title: phraser('ERROR'),
  4819. html: phraser('COULD_NOT_FIND_USER'),
  4820. type: 'error',
  4821. confirmButtonText: phraser('OKAY')
  4822. });
  4823. } else if (text == 'errorDeposit') {
  4824. swal({
  4825. title: phraser('ERROR'),
  4826. html: phraser('SEND_NEED_DEPOSIT'),
  4827. type: 'error',
  4828. confirmButtonText: phraser('OKAY')
  4829. });
  4830. } else {
  4831. updateCredits(-1 * credits);
  4832. $("#user_profile_links").show();
  4833. $("#send_credits").hide();
  4834. swal({
  4835. title: phraser('SUCCESS'),
  4836. html: phraser('CREDITS_SUCCESSFULLY_SENT'),
  4837. type: 'success',
  4838. confirmButtonText: phraser('OKAY')
  4839. });
  4840. }
  4841. }
  4842. });
  4843. });
  4844. $('body').on('mousedown touchstart', '#user_profile_background_holder', function(e) {
  4845. e.preventDefault();
  4846. moveElement(e, "#user_profile");
  4847. });
  4848. $('body').on('submit', '#scratchy_form', function(e) {
  4849. e.preventDefault();
  4850. $("#scratchy_loader").show();
  4851. $("#scratchy_form").hide();
  4852. var oldTokens = parseInt($(".amount_tokens b").html());
  4853. var newTokens = oldTokens - 1;
  4854. if (newTokens < 0) {
  4855. newTokens = 0;
  4856. }
  4857. $.ajax({
  4858. type: "GET",
  4859. url: "/scratchy_bet.php",
  4860. data: {
  4861. user_token: $("#user_token").val()
  4862. },
  4863. success: function(text) {
  4864. $("#scratchy_loader").hide();
  4865. $("#scratchy_form").show();
  4866. $(".amount_tokens b").html(newTokens);
  4867. if (text == 'errorCredits') {
  4868. needCredits();
  4869. } else if (text == 'errorAction') {
  4870. swal({
  4871. title: phraser('ERROR'),
  4872. html: phraser('ACTION_NOT_AVAILABLE'),
  4873. type: 'error',
  4874. confirmButtonText: phraser('OKAY')
  4875. });
  4876. } else if (text == 'errorUser') {
  4877. swal({
  4878. title: phraser('ERROR'),
  4879. html: phraser('CANNOT_SEND_YOURSELF'),
  4880. type: 'error',
  4881. confirmButtonText: phraser('OKAY')
  4882. });
  4883. } else {
  4884. $("#scratchy_form").hide();
  4885. $('#scratchy_pad').wScratchPad('enable', true);
  4886. var result = text.split(";");
  4887. var chestResult = result[0].split("_");
  4888. $('#scratchy_pad img').attr('src', site + '/images/scratchy_' + result[0] + '.png');
  4889. $("#scratchy_result").html(chestResult[0] + ";" + result[1]);
  4890. if (oldTokens == 0) {
  4891. updateCredits(-3);
  4892. }
  4893. }
  4894. }
  4895. });
  4896. });
  4897.  
  4898. var safebox_available = true;
  4899. $('body').on('click', '#safe_box_pad div', function(e) {
  4900. var code = $("#safe_box_pin_code").text();
  4901. var button = $(this).attr('data-pad');
  4902. var newCode = '';
  4903. $(".beep").trigger('play');
  4904. setTimeout(function() {
  4905. $(".beep").trigger('pause');
  4906. $(".beep").prop("currentTime", 0);
  4907. }, 100);
  4908. if (button == 'BACK' && code != 'CODE') {
  4909. if (code.length == 1) {
  4910. newCode = 'CODE';
  4911. } else {
  4912. newCode = code.substring(0, code.length - 1);
  4913. }
  4914. $("#safe_box_pin_code").text(newCode);
  4915. }
  4916. if (button != 'BACK' && button != 'GO') {
  4917. if (code == 'CODE') {
  4918. newCode = button;
  4919. } else if (code.length < 4) {
  4920. newCode = code + '' + button;
  4921. } else {
  4922. newCode = code;
  4923. }
  4924. $("#safe_box_pin_code").text(newCode);
  4925. }
  4926. if (button == 'GO' && safebox_available) {
  4927. if (code.length == 4 && code != 'CODE') {
  4928. var oldTokens = parseInt($(".amount_tokens b").html());
  4929. var newTokens = oldTokens - 1;
  4930. if (newTokens < 0) {
  4931. newTokens = 0;
  4932. }
  4933. safebox_available = false;
  4934. $.ajax({
  4935. type: "GET",
  4936. url: "/safebox_bet.php",
  4937. data: {
  4938. code: code,
  4939. user_token: $("#user_token").val()
  4940. },
  4941. success: function(text) {
  4942. $(".amount_tokens b").html(newTokens);
  4943. safebox_available = true;
  4944. text = text.split(";");
  4945. if (oldTokens == 0) {
  4946. updateCredits(-0.5);
  4947. }
  4948. if (text[0] == 'errorCredits') {
  4949. setTimeout(function() {
  4950. needCredits();
  4951. }, 100);
  4952. } else if (text[0] == 'errorAction') {
  4953. setTimeout(function() {
  4954. swal({
  4955. title: phraser('ERROR'),
  4956. html: phraser('ACTION_NOT_AVAILABLE'),
  4957. type: 'error',
  4958. confirmButtonText: phraser('OKAY')
  4959. });
  4960. }, 100);
  4961. } else if (text[0] == 'success') {
  4962. if (text[1] == 'correct') {
  4963. updateCredits(parseFloat(text[2]));
  4964. $("#safe_box_circle").addClass('safe_circle_green');
  4965. $(".win_big").trigger('play');
  4966. setTimeout(function() {
  4967. $(".win_big").trigger('pause');
  4968. $(".win_big").prop("currentTime", 0);
  4969. }, 1500);
  4970. } else {
  4971. $("#safe_box_circle").addClass('safe_circle_red');
  4972. $(".error").trigger('play');
  4973. setTimeout(function() {
  4974. $(".error").trigger('pause');
  4975. $(".error").prop("currentTime", 0);
  4976. }, 1500);
  4977. }
  4978. }
  4979. timeouts.push(setTimeout(function() {
  4980. $('#safe_box_pin_code').text('CODE');
  4981. $("#safe_box_circle").removeClass();
  4982. }, 500));
  4983. }
  4984. });
  4985. }
  4986. }
  4987. });
  4988.  
  4989. $("body").on('click', '.perks_claim', function() {
  4990. var that = $(this);
  4991. var perk_id = that.attr('data-id');
  4992. $("#chat_giveaway_ineligible").remove();
  4993. $.ajax({
  4994. type: "GET",
  4995. url: "/perks_claim.php",
  4996. data: {
  4997. perk_id: perk_id
  4998. },
  4999. success: function(text) {
  5000. that.replaceWith(phraser("CLAIMED"));
  5001. }
  5002. });
  5003. });
  5004.  
  5005. $("body").on('click', '.bet_edit', function() {
  5006. var that = $(this);
  5007. var id = that.attr('id');
  5008. var input = $(that.attr('data-input'));
  5009. var value = parseFloat(input.val());
  5010. var max = that.attr('data-max');
  5011. var newValue;
  5012. if (isNaN(value)) {
  5013. value = 0;
  5014. }
  5015. if (id == "bet_clear") {
  5016. newValue = '';
  5017. } else if (id == "bet_one") {
  5018. newValue = value + 1;
  5019. } else if (id == "bet_ten") {
  5020. newValue = value + 10;
  5021. } else if (id == "bet_half") {
  5022. newValue = value / 2;
  5023. } else if (id == "bet_double") {
  5024. newValue = value * 2;
  5025. } else if (id == "bet_max") {
  5026. newValue = parseFloat($("#credits").html());
  5027. }
  5028. if (newValue > max) {
  5029. newValue = max;
  5030. }
  5031. if (newValue > parseFloat($("#credits").html())) {
  5032. newValue = parseFloat($("#credits").html());
  5033. }
  5034. input.val(newValue);
  5035. });
  5036. $("body").on('click', '.copy', function() {
  5037. var text = $(this).attr('original-title');
  5038. copyToClipboard(text);
  5039. $(this).html(phraser('COPIED'));
  5040. });
  5041. $('body').on('keyup', '#credits_amount', function(e) {
  5042. if (this.value.charAt(0) == "." || this.value.charAt(0) == ",") {
  5043. this.value = "0" + this.value;
  5044. }
  5045. this.value = this.value.replace(",", ".");
  5046. if ($.isNumeric(this.value) === false) {
  5047. this.value = this.value.slice(0, -1);
  5048. }
  5049. var newValue = $(this).val();
  5050. var maxValue = parseFloat($("#credits").html());
  5051. if (newValue > maxValue) {
  5052. newValue = maxValue;
  5053. }
  5054. this.value = newValue;
  5055. var newBitcoins = newValue * 1 / $("#bitcoins_rate").html() - 0.00060;
  5056. if (newBitcoins < 0) {
  5057. newBitcoins = 0;
  5058. }
  5059. $("#bitcoins_amount").html(newBitcoins.toFixed(6));
  5060. });
  5061. $('body').on('submit', '#withdraw', function(e) {
  5062. e.preventDefault();
  5063. $("#withdraw button").prop('disabled', true).html('<div class="loader_small" style="width: 18px;height: 18px;margin: 0 auto;"></div>');
  5064. var credits = $("#credits_amount").val();
  5065. $.ajax({
  5066. type: "GET",
  5067. url: "/withdraw_request.php",
  5068. data: {
  5069. address: $("#address").val(),
  5070. credits: $("#credits_amount").val(),
  5071. save_address: $("#save_address").prop('checked'),
  5072. user_token: $("#user_token").val()
  5073. },
  5074. success: function(text) {
  5075. if (text == 'errorCredits') {
  5076. needCredits();
  5077. } else if (text == 'errorBlocked') {
  5078. swal({
  5079. title: phraser('ERROR'),
  5080. html: phraser('WITHDRAW_ADDRESS_BLOCKED'),
  5081. type: 'error',
  5082. confirmButtonText: phraser('OKAY')
  5083. });
  5084. } else if (text == 'errorBitcoin') {
  5085. swal({
  5086. title: phraser('ERROR'),
  5087. html: phraser('BITCOIN_VALUE_NOT_AVAILABLE'),
  5088. type: 'error',
  5089. confirmButtonText: phraser('OKAY')
  5090. });
  5091. } else if (text == 'errorCreditsPlayed') {
  5092. swal({
  5093. title: phraser('ERROR'),
  5094. html: phraser('PLAYED_FOR_EXCEEDED'),
  5095. type: 'error',
  5096. confirmButtonText: phraser('OKAY')
  5097. });
  5098. } else if (text == 'errorMin') {
  5099. swal({
  5100. title: phraser('ERROR'),
  5101. html: phraser('MINIMUM_WITHDRAW'),
  5102. type: 'error',
  5103. confirmButtonText: phraser('OKAY')
  5104. });
  5105. } else if (text == 'errorAction') {
  5106. swal({
  5107. title: phraser('ERROR'),
  5108. html: phraser('ACTION_NOT_AVAILABLE'),
  5109. type: 'error',
  5110. confirmButtonText: phraser('OKAY')
  5111. });
  5112. } else if (text == 'errorPerform') {
  5113. swal({
  5114. title: phraser('ERROR'),
  5115. html: phraser('WITHDRAW_ACTION_ERROR'),
  5116. type: 'error',
  5117. confirmButtonText: phraser('OKAY')
  5118. });
  5119. } else if (text == 'success') {
  5120. updateCredits(-1 * credits);
  5121. $("#user_profile_links").show();
  5122. $("#send_credits").hide();
  5123. swal({
  5124. title: phraser('SUCCESS'),
  5125. html: phraser('CREDITS_SUCCESSFULLY_SENT'),
  5126. type: 'success',
  5127. confirmButtonText: phraser('OKAY'),
  5128. allowOutsideClick: false,
  5129. allowEscapeKey: false
  5130. }, function() {
  5131. loadPage('withdraw.php');
  5132. });
  5133. } else {
  5134. swal({
  5135. title: phraser('ERROR'),
  5136. html: text,
  5137. type: 'error',
  5138. confirmButtonText: phraser('OKAY')
  5139. });
  5140. }
  5141. $("#withdraw button").prop('disabled', false).html(phraser('WITHDRAW_TITLE'));
  5142. }
  5143. });
  5144. });
  5145. $('body').on('submit', '#login_form', function(e) {
  5146. e.preventDefault();
  5147. $("#login_form button").prop('disabled', true).html('<div class="loader_small" style="width: 18px;height: 18px;margin: 0 auto;"></div>');
  5148. $.ajax({
  5149. type: "POST",
  5150. url: "/login_request.php",
  5151. data: {
  5152. email: $("#email").val(),
  5153. password: $("#password").val()
  5154. },
  5155. success: function(text) {
  5156. $("#login_form button").prop('disabled', false).html(phraser('LOG_IN'));
  5157. if (text == 'errorCredentials') {
  5158. swal({
  5159. title: phraser('ERROR'),
  5160. html: phraser('LOGIN_ERROR'),
  5161. type: 'error',
  5162. confirmButtonText: phraser('OKAY')
  5163. });
  5164. } else if (text == 'errorLoginSpam') {
  5165. swal({
  5166. title: phraser('ERROR'),
  5167. html: phraser('LOGIN_ERROR_SPAM'),
  5168. type: 'error',
  5169. confirmButtonText: phraser('OKAY')
  5170. });
  5171. } else {
  5172. $(".user_form_holder").fadeOut(100);
  5173. window.location = site + "/home";
  5174. }
  5175. }
  5176. });
  5177. });
  5178. $('body').on('submit', '#forgot_form', function(e) {
  5179. e.preventDefault();
  5180. $("#forgot_form button").prop('disabled', true).html('<div class="loader_small" style="width: 18px;height: 18px;margin: 0 auto;"></div>');
  5181. $.ajax({
  5182. type: "POST",
  5183. url: "/forgot_request.php",
  5184. data: {
  5185. email: $("#email").val()
  5186. },
  5187. success: function(text) {
  5188. $("#forgot_form button").prop('disabled', false).html(phraser('LOG_IN'));
  5189. if (text == 'errorCredentials') {
  5190. swal({
  5191. title: phraser('ERROR'),
  5192. html: phraser('FORGOT_ERROR_EMAIL'),
  5193. type: 'error',
  5194. confirmButtonText: phraser('OKAY')
  5195. });
  5196. } else if (text == 'errorSending') {
  5197. swal({
  5198. title: phraser('ERROR'),
  5199. html: phraser('FORGOT_ERROR'),
  5200. type: 'error',
  5201. confirmButtonText: phraser('OKAY')
  5202. });
  5203. } else if (text == 'errorTooSoon') {
  5204. swal({
  5205. title: phraser('ERROR'),
  5206. html: phraser('FORGOT_ERROR_TOO_SOON'),
  5207. type: 'error',
  5208. confirmButtonText: phraser('OKAY')
  5209. });
  5210. } else {
  5211. swal({
  5212. title: phraser('SUCCESS'),
  5213. html: phraser('FORGOT_SUCCESS'),
  5214. type: 'success',
  5215. confirmButtonText: phraser('OKAY')
  5216. });
  5217. }
  5218. }
  5219. });
  5220. });
  5221. $('body').on('submit', '#reset_form', function(e) {
  5222. e.preventDefault();
  5223. $("#reset_form button").prop('disabled', true).html('<div class="loader_small" style="width: 18px;height: 18px;margin: 0 auto;"></div>');
  5224. $.ajax({
  5225. type: "POST",
  5226. url: "/reset_request.php",
  5227. data: {
  5228. password: $("#password").val(),
  5229. password_again: $("#password_again").val()
  5230. },
  5231. success: function(text) {
  5232. $("#reset_form button").prop('disabled', false).html(phraser('SAVE'));
  5233. if (text == 'errorPasswordStrength') {
  5234. swal({
  5235. title: phraser('ERROR'),
  5236. html: phraser('REGISTER_ERROR_PASSWORD_STRENGTH'),
  5237. type: 'error',
  5238. confirmButtonText: phraser('OKAY')
  5239. });
  5240. } else if (text == 'errorPasswordAgain') {
  5241. swal({
  5242. title: phraser('ERROR'),
  5243. html: phraser('REGISTER_ERROR_PASSWORD_AGAIN'),
  5244. type: 'error',
  5245. confirmButtonText: phraser('OKAY')
  5246. });
  5247. } else if (text == 'success') {
  5248. swal({
  5249. title: phraser('SUCCESS'),
  5250. html: phraser('RESET_SUCCESS'),
  5251. type: 'success',
  5252. confirmButtonText: phraser('OKAY'),
  5253. allowOutsideClick: false,
  5254. allowEscapeKey: false
  5255. }, function() {
  5256. $(".user_form_holder").fadeOut(100);
  5257. window.location = site + "/login";
  5258. });
  5259. } else {
  5260. swal({
  5261. title: phraser('ERROR'),
  5262. html: phraser('ACTION_NOT_AVAILABLE'),
  5263. type: 'error',
  5264. confirmButtonText: phraser('OKAY')
  5265. });
  5266. }
  5267. }
  5268. });
  5269. });
  5270. $('body').on('submit', '#add_login_form', function(e) {
  5271. e.preventDefault();
  5272. $("#add_login_form button").prop('disabled', true).html('<div class="loader_small" style="width: 18px;height: 18px;margin: 0 auto;"></div>');
  5273. $.ajax({
  5274. type: "POST",
  5275. url: "/settings_save.php",
  5276. data: {
  5277. register: true,
  5278. email: $("#email").val(),
  5279. password: $("#password").val(),
  5280. password_again: $("#password_again").val()
  5281. },
  5282. success: function(text) {
  5283. $("#add_login_form button").prop('disabled', false).html(phraser('SAVE'));
  5284. if (text == 'errorEmail') {
  5285. swal({
  5286. title: phraser('ERROR'),
  5287. html: phraser('REGISTER_ERROR_EMAIL'),
  5288. type: 'error',
  5289. confirmButtonText: phraser('OKAY')
  5290. });
  5291. } else if (text == 'errorEmailTaken') {
  5292. swal({
  5293. title: phraser('ERROR'),
  5294. html: phraser('REGISTER_ERROR_EMAIL_TAKEN'),
  5295. type: 'error',
  5296. confirmButtonText: phraser('OKAY')
  5297. });
  5298. } else if (text == 'errorPasswordStrength') {
  5299. swal({
  5300. title: phraser('ERROR'),
  5301. html: phraser('REGISTER_ERROR_PASSWORD_STRENGTH'),
  5302. type: 'error',
  5303. confirmButtonText: phraser('OKAY')
  5304. });
  5305. } else if (text == 'errorPasswordAgain') {
  5306. swal({
  5307. title: phraser('ERROR'),
  5308. html: phraser('REGISTER_ERROR_PASSWORD_AGAIN'),
  5309. type: 'error',
  5310. confirmButtonText: phraser('OKAY')
  5311. });
  5312. } else if (text == 'success') {
  5313. swal({
  5314. title: phraser('SUCCESS'),
  5315. html: phraser('SETTINGS_SUCCESSFULLY_SAVED'),
  5316. type: 'success',
  5317. confirmButtonText: phraser('OKAY'),
  5318. allowOutsideClick: false,
  5319. allowEscapeKey: false
  5320. }, function() {
  5321. window.location.reload();
  5322. });
  5323. } else {
  5324. swal({
  5325. title: phraser('ERROR'),
  5326. html: phraser('ACTION_NOT_AVAILABLE'),
  5327. type: 'error',
  5328. confirmButtonText: phraser('OKAY')
  5329. });
  5330. }
  5331. }
  5332. });
  5333. });
  5334. $('body').on('submit', '#change_password_form', function(e) {
  5335. e.preventDefault();
  5336. $("#change_password_form button").prop('disabled', true).html('<div class="loader_small" style="width: 18px;height: 18px;margin: 0 auto;"></div>');
  5337. $.ajax({
  5338. type: "POST",
  5339. url: "/settings_save.php",
  5340. data: {
  5341. change_password: true,
  5342. password_old: $("#password_old").val(),
  5343. password: $("#password").val(),
  5344. password_again: $("#password_again").val()
  5345. },
  5346. success: function(text) {
  5347. $("#change_password_form button").prop('disabled', false).html(phraser('SAVE'));
  5348. if (text == 'errorPasswordOld') {
  5349. swal({
  5350. title: phraser('ERROR'),
  5351. html: phraser('CHANGE_PASSWORD_ERROR'),
  5352. type: 'error',
  5353. confirmButtonText: phraser('OKAY')
  5354. });
  5355. } else if (text == 'errorPasswordStrength') {
  5356. swal({
  5357. title: phraser('ERROR'),
  5358. html: phraser('REGISTER_ERROR_PASSWORD_STRENGTH'),
  5359. type: 'error',
  5360. confirmButtonText: phraser('OKAY')
  5361. });
  5362. } else if (text == 'errorPasswordAgain') {
  5363. swal({
  5364. title: phraser('ERROR'),
  5365. html: phraser('REGISTER_ERROR_PASSWORD_AGAIN'),
  5366. type: 'error',
  5367. confirmButtonText: phraser('OKAY')
  5368. });
  5369. } else if (text == 'success') {
  5370. swal({
  5371. title: phraser('SUCCESS'),
  5372. html: phraser('SETTINGS_SUCCESSFULLY_SAVED'),
  5373. type: 'success',
  5374. confirmButtonText: phraser('OKAY'),
  5375. allowOutsideClick: false,
  5376. allowEscapeKey: false
  5377. }, function() {
  5378. window.location.reload();
  5379. });
  5380. } else {
  5381. swal({
  5382. title: phraser('ERROR'),
  5383. html: phraser('ACTION_NOT_AVAILABLE'),
  5384. type: 'error',
  5385. confirmButtonText: phraser('OKAY')
  5386. });
  5387. }
  5388. }
  5389. });
  5390. });
  5391. $('body').on('submit', '#change_email_form', function(e) {
  5392. e.preventDefault();
  5393. $("#change_email_form button").prop('disabled', true).html('<div class="loader_small" style="width: 18px;height: 18px;margin: 0 auto;"></div>');
  5394. $.ajax({
  5395. type: "POST",
  5396. url: "/settings_save.php",
  5397. data: {
  5398. change_email: true,
  5399. email: $("#email").val()
  5400. },
  5401. success: function(text) {
  5402. console.log(text);
  5403. $("#change_email_form button").prop('disabled', false).html(phraser('SAVE'));
  5404. if (text == 'errorEmailInvalid') {
  5405. swal({
  5406. title: phraser('ERROR'),
  5407. html: phraser('REGISTER_ERROR_EMAIL'),
  5408. type: 'error',
  5409. confirmButtonText: phraser('OKAY')
  5410. });
  5411. } else if (text == 'errorEmailTaken') {
  5412. swal({
  5413. title: phraser('ERROR'),
  5414. html: phraser('REGISTER_ERROR_EMAIL_TAKEN'),
  5415. type: 'error',
  5416. confirmButtonText: phraser('OKAY')
  5417. });
  5418. } else if (text == 'success') {
  5419. swal({
  5420. title: phraser('SUCCESS'),
  5421. html: phraser('SETTINGS_SUCCESSFULLY_SAVED'),
  5422. type: 'success',
  5423. confirmButtonText: phraser('OKAY'),
  5424. allowOutsideClick: false,
  5425. allowEscapeKey: false
  5426. }, function() {
  5427. window.location.reload();
  5428. });
  5429. } else {
  5430. swal({
  5431. title: phraser('ERROR'),
  5432. html: phraser('ACTION_NOT_AVAILABLE'),
  5433. type: 'error',
  5434. confirmButtonText: phraser('OKAY')
  5435. });
  5436. }
  5437. }
  5438. });
  5439. });
  5440. $('body').on('click', '#crash_manual_bet', function() {
  5441. $('#crash_manual_bet_holder').show();
  5442. $('#crash_auto_bet_holder').hide();
  5443. });
  5444. $('body').on('click', '#crash_auto_bet', function() {
  5445. $('#crash_manual_bet_holder').hide();
  5446. $('#crash_auto_bet_holder').show();
  5447. });
  5448. $('body').on('change', '#crash_auto', function() {
  5449. if ($(this).is(':checked')) {
  5450. $("#crash_form button").html(phraser('START_L'));
  5451. } else {
  5452. $("#crash_form button").html(phraser('PLACE_BET'));
  5453. }
  5454. });
  5455. $('body').on('submit', '#crash_form', function(e) {
  5456. e.preventDefault();
  5457. var btnText = $("#crash_form button").html();
  5458. var credits = parseFloat($('#crash_bet').val());
  5459. var cashout = parseFloat($('#crash_cashout').val())
  5460. var auto = $("#crash_auto").prop('checked');
  5461. $("#crash_form button").prop('disabled', true).html('<div class="loader_small" style="width: 18px;height: 18px;margin: 0 auto;"></div>');
  5462. if (auto && (isNaN(cashout) || cashout < 1)) {
  5463. swal({
  5464. title: phraser('ERROR'),
  5465. html: phraser('AUTO_BET_NEEDS_AUTO_CASHOUT'),
  5466. type: 'error',
  5467. confirmButtonText: phraser('OKAY')
  5468. });
  5469. $("#crash_form button").prop('disabled', false).html(btnText);
  5470. return;
  5471. }
  5472. if (isNaN(cashout)) {
  5473. $(".crash_cashout_label").html(phraser('NO_AUTO_CASHOUT'));
  5474. } else {
  5475. $(".crash_cashout_label").html(phraser('AUTO_CASHOUT_LABEL') + cashout);
  5476. }
  5477. $.ajax({
  5478. type: "POST",
  5479. url: "/crash_bet.php",
  5480. data: {
  5481. credits: credits,
  5482. cashout: cashout,
  5483. user_token: $("#user_token").val()
  5484. },
  5485. success: function(text) {
  5486. $("#crash_form button").prop('disabled', false).html(btnText);
  5487. if (text == 'errorCredits') {
  5488. needCredits();
  5489. } else if (text == 'errorValue') {
  5490. swal({
  5491. title: phraser('ERROR'),
  5492. html: phraser('MINIMUM_MAXIMUM_BET'),
  5493. type: 'error',
  5494. confirmButtonText: phraser('OKAY')
  5495. });
  5496. } else if (text == 'errorAction') {
  5497. swal({
  5498. title: phraser('ERROR'),
  5499. html: phraser('ACTION_NOT_AVAILABLE'),
  5500. type: 'error',
  5501. confirmButtonText: phraser('OKAY')
  5502. });
  5503. } else if (text == 'errorBets') {
  5504. swal({
  5505. title: phraser('ERROR'),
  5506. html: phraser('TOO_MANY_BETS_ONE'),
  5507. type: 'error',
  5508. confirmButtonText: phraser('OKAY')
  5509. });
  5510. } else if (text == 'errorLastRound') {
  5511. swal({
  5512. title: phraser('ERROR'),
  5513. html: phraser('ROUND_IN_PROGRESS'),
  5514. type: 'error',
  5515. confirmButtonText: phraser('OKAY')
  5516. });
  5517. } else if (text == 'errorCashout') {
  5518. swal({
  5519. title: phraser('ERROR'),
  5520. html: phraser('CASHOUT_MIN_MAX'),
  5521. type: 'error',
  5522. confirmButtonText: phraser('OKAY')
  5523. });
  5524. } else if (text == 'success') {
  5525. $(".crash_profit_label").attr('data-value', credits);
  5526. $(".crash_profit_label b").html('0');
  5527. $("#crash_form_cashout").fadeIn();
  5528. updateCredits(-1 * credits);
  5529. if (auto && !crashAutoBet) {
  5530. $("#crash_form_auto_stop").fadeIn();
  5531. }
  5532. crashAutoBet = auto;
  5533. }
  5534. }
  5535. });
  5536. });
  5537. $('body').on('submit', '#crash_form_cashout', function(e) {
  5538. e.preventDefault();
  5539. $("#crash_form_cashout button").prop('disabled', true).html('<div class="loader_small" style="width: 18px;height: 18px;margin: 0 auto;"></div>');
  5540. $.ajax({
  5541. type: "POST",
  5542. url: "/crash_bet.php",
  5543. data: {
  5544. cashout_action: true,
  5545. user_token: $("#user_token").val()
  5546. },
  5547. success: function(text) {
  5548. $("#crash_form_cashout button").prop('disabled', false).html(phraser('CASHOUT'));
  5549. if (text == 'errorAction') {
  5550. swal({
  5551. title: phraser('ERROR'),
  5552. html: phraser('ACTION_NOT_AVAILABLE'),
  5553. type: 'error',
  5554. confirmButtonText: phraser('OKAY')
  5555. });
  5556. } else if (text == 'errorLate') {
  5557. swal({
  5558. title: phraser('ERROR'),
  5559. html: phraser('YOU_WERE_TOO_LATE'),
  5560. type: 'error',
  5561. confirmButtonText: phraser('OKAY')
  5562. });
  5563. } else if (text == 'errorBets') {
  5564. swal({
  5565. title: phraser('ERROR'),
  5566. html: phraser('NO_BETS_IN_ROUND'),
  5567. type: 'error',
  5568. confirmButtonText: phraser('OKAY')
  5569. });
  5570. } else if (text == 'errorEarly') {
  5571. swal({
  5572. title: phraser('ERROR'),
  5573. html: phraser('TOO_EARLY_FOR_CASHOUT'),
  5574. type: 'error',
  5575. confirmButtonText: phraser('OKAY')
  5576. });
  5577. } else if (text == 'success') {
  5578. $("#crash_form_cashout").fadeOut();
  5579. crashAutoBet = false;
  5580. $("#crash_form_auto_stop").hide();
  5581. $(".crash_profit_label").attr('data-value', 0);
  5582. $(".crash_profit_label b").html('0');
  5583. }
  5584. }
  5585. });
  5586. });
  5587. $('body').on('submit', '#crash_form_auto_stop', function(e) {
  5588. e.preventDefault();
  5589. crashAutoBet = false;
  5590. $("#crash_form_auto_stop").fadeOut();
  5591. $(".crash_profit_label").attr('data-value', 0);
  5592. $(".crash_profit_label b").html('0');
  5593. });
  5594. $("body").on('click', '.crash_edit_link', function() {
  5595. var that = $(this);
  5596. var id = that.attr('id');
  5597. var value = parseFloat($('#crash_bet').val());
  5598. var newValue;
  5599. if (isNaN(value)) {
  5600. value = 0;
  5601. }
  5602. if (id == "crash_clear") {
  5603. newValue = '';
  5604. } else if (id == "crash_one") {
  5605. newValue = value + 1;
  5606. } else if (id == "crash_five") {
  5607. newValue = value + 5;
  5608. } else if (id == "crash_ten") {
  5609. newValue = value + 10;
  5610. } else if (id == "crash_half") {
  5611. newValue = value / 2;
  5612. } else if (id == "crash_double") {
  5613. newValue = value * 2;
  5614. } else if (id == "crash_max") {
  5615. newValue = parseFloat($("#credits").html());
  5616. }
  5617. if (newValue > 300) {
  5618. newValue = 100;
  5619. }
  5620. if (newValue > parseFloat($("#credits").html())) {
  5621. newValue = parseFloat($("#credits").html());
  5622. }
  5623. $('#crash_bet').val(newValue);
  5624. });
  5625.  
  5626.  
  5627. $('body').on('click', '.resend_withdraw_user', function() {
  5628. var that = $(this);
  5629. that.text('...');
  5630. $.ajax({
  5631. type: "GET",
  5632. url: "/withdraw_resend.php",
  5633. data: {
  5634. security_code: $(this).attr('data-code'),
  5635. user_id: $(this).attr('data-user')
  5636. },
  5637. success: function(text) {
  5638. if (text != 'success') {
  5639. swal({
  5640. title: phraser('ERROR'),
  5641. html: text,
  5642. type: 'error',
  5643. confirmButtonText: phraser('OKAY')
  5644. });
  5645. that.text(phraser('RESEND'));
  5646. } else {
  5647. swal({
  5648. title: phraser('SUCCESS'),
  5649. html: phraser(''),
  5650. type: 'success',
  5651. confirmButtonText: phraser('OKAY')
  5652. });
  5653. that.text(phraser('DONE')).removeClass('resend_withdraw_user');
  5654. }
  5655. }
  5656. });
  5657. });
  5658. $('body').on('submit', '#send_credits_steam', function(e) {
  5659. e.preventDefault();
  5660. $("#send_credits_steam button").prop('disabled', true).html('<div class="loader_small" style="width: 18px;height: 18px;margin: 0 auto;"></div>');
  5661. var credits = $("#send_steam_credits").val();
  5662. var steam_id = $("#send_steam_id").val();
  5663. $.ajax({
  5664. type: "GET",
  5665. url: "/send_credits.php",
  5666. data: {
  5667. steam_id: steam_id,
  5668. credits: credits,
  5669. user_token: $("#user_token").val()
  5670. },
  5671. success: function(text) {
  5672. $("#send_credits_steam button").prop('disabled', false).html(phraser('SEND'));
  5673. if (text == 'errorValue') {
  5674. swal({
  5675. title: phraser('ERROR'),
  5676. html: phraser('DAILY_SEND_LIMIT_NEW'),
  5677. type: 'error',
  5678. confirmButtonText: phraser('OKAY')
  5679. });
  5680. } else if (text == 'errorCredits') {
  5681. needCredits();
  5682. } else if (text == 'errorAction') {
  5683. swal({
  5684. title: phraser('ERROR'),
  5685. html: phraser('ACTION_NOT_AVAILABLE'),
  5686. type: 'error',
  5687. confirmButtonText: phraser('OKAY')
  5688. });
  5689. } else if (text == 'errorAmount') {
  5690. swal({
  5691. title: phraser('ERROR'),
  5692. html: phraser('SEND_ERROR_AMOUNT'),
  5693. type: 'error',
  5694. confirmButtonText: phraser('OKAY')
  5695. });
  5696. } else if (text == 'errorUser') {
  5697. swal({
  5698. title: phraser('ERROR'),
  5699. html: phraser('COULD_NOT_FIND_USER'),
  5700. type: 'error',
  5701. confirmButtonText: phraser('OKAY')
  5702. });
  5703. } else if (text == 'errorDeposit') {
  5704. swal({
  5705. title: phraser('ERROR'),
  5706. html: phraser('SEND_NEED_DEPOSIT'),
  5707. type: 'error',
  5708. confirmButtonText: phraser('OKAY')
  5709. });
  5710. } else {
  5711. updateCredits(-1 * credits);
  5712. $("#user_profile_links").show();
  5713. $("#send_credits").hide();
  5714. swal({
  5715. title: phraser('SUCCESS'),
  5716. html: phraser('CREDITS_SUCCESSFULLY_SENT'),
  5717. type: 'success',
  5718. confirmButtonText: phraser('OKAY')
  5719. });
  5720. }
  5721. }
  5722. });
  5723. });
  5724. $('body').on('click', '.withdraw_switch', function() {
  5725. var type = $(this).attr('data-type');
  5726. $(".withdraw_switch").removeClass('selected');
  5727. $(this).addClass('selected');
  5728. if (type == 'withdraw') {
  5729. $("#withdraw_form").show();
  5730. $("#withdraw_form_deals").hide();
  5731. botInventoryPage = 1;
  5732. loadBotInventory(false, false);
  5733. }
  5734. if (type == 'deals') {
  5735. $("#withdraw_form").hide();
  5736. $("#withdraw_form_deals").show();
  5737. $(".withdraw_deal").removeClass('selected');
  5738. $(".withdraw_deal").first().addClass('selected');
  5739. botDealsPage = 1;
  5740. loadBotDeals(false, 50, 0);
  5741. }
  5742. });
  5743. $('body').on('click', '.withdraw_deal', function() {
  5744. var min = $(this).attr('data-min');
  5745. var max = $(this).attr('data-max');
  5746. $(".withdraw_deal").removeClass('selected');
  5747. $(this).addClass('selected');
  5748. botDealsPage = 1;
  5749. loadBotDeals(false, min, max);
  5750. });
  5751. $('body').on('click', '.recruit_prize_pick', function() {
  5752. var that = $(this);
  5753. that.prop('disabled', true).html('<div class="loader_small" style="width: 18px;height: 18px;margin: 0 auto;"></div>');
  5754. $.ajax({
  5755. type: "GET",
  5756. url: "/recruits_save.php",
  5757. data: {
  5758. pick_reward: true,
  5759. prize_id: that.attr('data-prize')
  5760. },
  5761. success: function(text) {
  5762. if (text != 'success') {
  5763. swal({
  5764. title: phraser('ERROR'),
  5765. html: phraser('ACTION_NOT_AVAILABLE'),
  5766. type: 'error',
  5767. confirmButtonText: phraser('OKAY')
  5768. }, function() {
  5769. window.location.reload();
  5770. });
  5771. return;
  5772. }
  5773. swal({
  5774. title: phraser('SUCCESS'),
  5775. html: phraser('RECRUIT_REWARD_SAVED'),
  5776. type: 'success',
  5777. confirmButtonText: phraser('OKAY'),
  5778. allowOutsideClick: false,
  5779. allowEscapeKey: false
  5780. }, function() {
  5781. window.location.reload();
  5782. });
  5783. }
  5784. });
  5785. });
  5786. $('body').on('click', '.cases_list', function() {
  5787. $("#case_list_holder").hide();
  5788. $("#case_holder").html('<div class="loader_small" style="margin-top:30px;"></div>').show();
  5789. $.ajax({
  5790. type: "GET",
  5791. url: "/cases_load.php",
  5792. data: {
  5793. case_id: $(this).attr('data-id')
  5794. },
  5795. success: function(text) {
  5796. $("#case_holder").html(text);
  5797. }
  5798. });
  5799. });
  5800. $('body').on('click', '.cases_back', function() {
  5801. $("#case_holder").hide();
  5802. $("#case_list_holder").show();
  5803. loadPage('cases.php');
  5804. });
  5805. $('body').on('click', '#case_buy', function() {
  5806. var testSpin = false;
  5807. var button = $(this);
  5808. var buttonHTML = button.html();
  5809. var case_id = button.attr('data-id');
  5810. var case_price = button.attr('data-price');
  5811. button.prop('disabled', true).html('<div class="loader_small" style="width: 18px;height: 18px;margin: 0 auto;"></div>');
  5812. casesOpen(case_id, case_price, testSpin, button, buttonHTML);
  5813. });
  5814. $('body').on('click', '#case_test', function() {
  5815. var testSpin = true;
  5816. var button = $(this);
  5817. var buttonHTML = button.html();
  5818. var case_id = button.attr('data-id');
  5819. var case_price = button.attr('data-price');
  5820. button.prop('disabled', true).html('<div class="loader_small" style="width: 18px;height: 18px;margin: 0 auto;"></div>');
  5821. casesOpen(case_id, case_price, testSpin, button, buttonHTML);
  5822. });
  5823. $('body').on('click', '.roulette_bet_choice', function() {
  5824. $(".roulette_bet_choice").removeClass('roulette_choice_select');
  5825. $(this).addClass('roulette_choice_select');
  5826. });
  5827. $('body').on('submit', '.roulette_bet_form', function(e) {
  5828. e.preventDefault();
  5829. var button = $('.roulette_bet_form button');
  5830. var buttonHTML = $('.roulette_bet_form button').html();
  5831. var choice = $(".roulette_choice_select").attr('data-color');
  5832. var credits = parseFloat($('.roulette_form_value').val());
  5833. button.prop('disabled', true).html('<div class="loader_small loader_small_dark" style="width: 18px;height: 18px;margin: 0 auto;display:block;"></div>');
  5834. $.ajax({
  5835. type: "GET",
  5836. url: "/roulette_bet.php",
  5837. data: {
  5838. credits: credits,
  5839. choice: choice,
  5840. user_token: $("#user_token").val()
  5841. },
  5842. success: function(text) {
  5843. button.prop('disabled', false).html(buttonHTML);
  5844. if (text == 'errorCredits') {
  5845. needCredits();
  5846. } else if (text == 'errorValue') {
  5847. swal({
  5848. title: phraser('ERROR'),
  5849. html: phraser('MINIMUM_MAXIMUM_BET'),
  5850. type: 'error',
  5851. confirmButtonText: phraser('OKAY')
  5852. });
  5853. } else if (text == 'errorAction') {
  5854. swal({
  5855. title: phraser('ERROR'),
  5856. html: phraser('ACTION_NOT_AVAILABLE'),
  5857. type: 'error',
  5858. confirmButtonText: phraser('OKAY')
  5859. });
  5860. } else if (text == 'errorBets') {
  5861. swal({
  5862. title: phraser('ERROR'),
  5863. html: phraser('TOO_MANY_BETS'),
  5864. type: 'error',
  5865. confirmButtonText: phraser('OKAY')
  5866. });
  5867. } else if (text == 'errorTimer') {
  5868. swal({
  5869. title: phraser('ERROR'),
  5870. html: phraser('TIMER_IS_CLOSING'),
  5871. type: 'error',
  5872. confirmButtonText: phraser('OKAY')
  5873. });
  5874. } else if (text == 'errorLastRound') {
  5875. swal({
  5876. title: phraser('ERROR'),
  5877. html: phraser('LAST_ROUND_NOT_FINISHED'),
  5878. type: 'error',
  5879. confirmButtonText: phraser('OKAY')
  5880. });
  5881. } else if (text == 'errorChoiceMultiple') {
  5882. swal({
  5883. title: phraser('ERROR'),
  5884. html: phraser('ERROR_CHOICE_MULTIPLE'),
  5885. type: 'error',
  5886. confirmButtonText: phraser('OKAY')
  5887. });
  5888. } else if (text == 'success') {
  5889. updateCredits(-1 * credits);
  5890. }
  5891. }
  5892. });
  5893. });
  5894. $('body').on('click', '.case_contain_view', function() {
  5895. $(this).hide();
  5896. $(".case_contain_item").show();
  5897. });
  5898. $('body').on('click', '.betting_matches_table tr.betting_table_clickable td', function() {
  5899. var table = $(".betting_matches_table[data-type='" + $(this).parent().parent().parent().attr('data-type') + "']");
  5900. var firstRow = table.find('tr').first();
  5901. var thisRow = $(this).parent();
  5902. var game_id = thisRow.attr('data-id');
  5903. table.html('<tr>' + firstRow.html() + '</tr><tr>' + thisRow.html() + '</tr>');
  5904. $("#betting_bets_title, .betting_info").remove();
  5905. $("#betting_matches_title a").hide();
  5906. $("#betting_matches_title a:first-of-type").show();
  5907. $("#betting_matches_title a.selected").show();
  5908. $.ajax({
  5909. type: "GET",
  5910. url: "/betting_load.php",
  5911. data: {
  5912. game_id: game_id
  5913. },
  5914. success: function(text) {
  5915. table.after(text);
  5916. }
  5917. });
  5918. });
  5919. $('body').on('click', '.betting_switch', function() {
  5920. var type = $(this).attr('data-type');
  5921. $(".betting_switch").removeClass('selected');
  5922. $(this).addClass('selected');
  5923. if (type == "all") {
  5924. loadPage("betting.php");
  5925. return;
  5926. }
  5927. $(".betting_matches_table").hide();
  5928. $(".betting_matches_table[data-type='" + type + "']").show();
  5929. });
  5930. $('body').on('change', '#betting_event_select', function() {
  5931. if ($("#betting_event_select").val() == 'all') {
  5932. $(".betting_matches_table tr").removeClass('invisible').addClass('visible');
  5933. } else {
  5934. $(".betting_matches_table tr").removeClass('visible').addClass('invisible');
  5935. $(".betting_matches_table tr[data-event='" + $("#betting_event_select").val() + "'], .betting_matches_table tr:first-of-type").removeClass('invisible').addClass('visible');
  5936. }
  5937. $(".betting_matches_table .visible:odd td").css({
  5938. "background": "transparent"
  5939. });
  5940. $(".betting_matches_table .visible:even td").css({
  5941. "background": "rgba(0, 0, 0, 0.21)"
  5942. });
  5943. });
  5944. $('body').on('click', '.betting_stream_link', function(e) {
  5945. e.stopPropagation();
  5946. var streamURL = $(this).attr('data-link');
  5947. var streamWidth = $("#betting_stream_holder").width();
  5948. var streamHeight = $(window).height() - 50;
  5949. $("#betting_stream_holder").height(streamHeight).html('<div class="round_info_title" id="betting_bets_title"><a class="betting_hide_stream"><i class="fa fa-compress"></i> ' + phraser('HIDE') + '</a><i class="fa fa-video-camera"></i> ' + phraser('STREAM') + '</div><iframe src="' + streamURL + '" id="betting_stream_iframe" height="' + (streamHeight - 35) + '" allowfullscreen></iframe>').show();
  5950. });
  5951. $('body').on('click', '.betting_hide_stream', function() {
  5952. $("#betting_stream_holder").html('').hide();
  5953. });
  5954. $('body').on('click', '.buy_coins_item[data-id]', function() {
  5955. var buy_item_id = $(this).attr('data-id');
  5956. $.ajax({
  5957. type: "GET",
  5958. url: "/buy_process.php",
  5959. data: {
  5960. buy_item_id: buy_item_id
  5961. },
  5962. success: function(text) {
  5963. if (text == 'errorItem') {
  5964. swal({
  5965. title: phraser('ERROR'),
  5966. html: phraser('ITEM_WAS_NOT_FOUND'),
  5967. type: 'error',
  5968. confirmButtonText: phraser('OKAY')
  5969. });
  5970. } else if (text == 'errorSteamLevel') {
  5971. swal({
  5972. title: phraser('ERROR'),
  5973. html: phraser('STEAM_LEVEL_TOO_LOW_NEW'),
  5974. type: 'error',
  5975. confirmButtonText: phraser('OKAY')
  5976. });
  5977. } else {
  5978. var json = JSON.parse(text);
  5979. if (json.success == true) {
  5980. window.location = json.url;
  5981. } else {
  5982. swal({
  5983. title: phraser('ERROR'),
  5984. html: phraser('ACTION_NOT_AVAILABLE'),
  5985. type: 'error',
  5986. confirmButtonText: phraser('OKAY')
  5987. });
  5988. }
  5989. }
  5990. }
  5991. });
  5992. });
  5993. $('body').on('click', '.provably_fair_game', function() {
  5994. $(".provably_fair_content").hide();
  5995. $(this).next('.provably_fair_content').show();
  5996. });
  5997. $('body').on('submit', ".betting_comment", function(e) {
  5998. e.preventDefault();
  5999. var message = $("#betting_message_textarea").val();
  6000. var game_id = $("#betting_game_id").val();
  6001. $("#betting_message_textarea").val('');
  6002. $("#betting_message_send").prop('disabled', true).css("background-color", "#2d2d2d");
  6003. $.ajax({
  6004. type: "POST",
  6005. url: "/betting_message.php",
  6006. data: {
  6007. message: message,
  6008. game_id: game_id
  6009. },
  6010. success: function(text) {
  6011. if (text == "errorSpam") {
  6012. swal({
  6013. title: phraser('ERROR'),
  6014. html: phraser('SPAMMING_CHAT'),
  6015. type: 'error',
  6016. confirmButtonText: phraser('OKAY')
  6017. });
  6018. } else if (text == 'errorAction') {
  6019. swal({
  6020. title: phraser('ERROR'),
  6021. html: phraser('ACTION_NOT_AVAILABLE'),
  6022. type: 'error',
  6023. confirmButtonText: phraser('OKAY')
  6024. });
  6025. } else {
  6026. $.ajax({
  6027. type: "GET",
  6028. url: "/betting_load.php",
  6029. data: {
  6030. game_id: game_id
  6031. },
  6032. success: function(text) {
  6033. $("#betting_match_holder").replaceWith(text);
  6034. }
  6035. });
  6036. }
  6037. $("#betting_message_send").prop('disabled', false).css("background-color", "#e69b23");
  6038. }
  6039. });
  6040. });
  6041.  
  6042. $('body').on('click', '#entry_join', function(e) {
  6043. $(this).html('<div class="loader_small" style="margin-top:8px;"></div>');
  6044. var giveaway_id = $(this).attr('data-id');
  6045. var page = $(this).attr('data-page');
  6046. $.ajax({
  6047. type: "GET",
  6048. url: "/giveaway_bet.php",
  6049. data: {
  6050. enter: true,
  6051. giveaway_id: giveaway_id,
  6052. type: 'join'
  6053. },
  6054. success: function(text) {
  6055. if (text == 'errorFinished') {
  6056. swal({
  6057. title: phraser('ERROR'),
  6058. html: phraser('NO_OPEN_GIVEAWAY_WAS_FOUND'),
  6059. type: 'error',
  6060. confirmButtonText: phraser('OKAY')
  6061. });
  6062. } else if (text == 'errorPlaytime') {
  6063. swal({
  6064. title: phraser('ERROR'),
  6065. html: phraser('RECRUIT_ERROR_PLAYTIME'),
  6066. type: 'error',
  6067. confirmButtonText: phraser('OKAY')
  6068. });
  6069. } else if (text == 'errorSteamLevel') {
  6070. swal({
  6071. title: phraser('ERROR'),
  6072. html: phraser('STEAM_LEVEL_TOO_LOW_NEW'),
  6073. type: 'error',
  6074. confirmButtonText: phraser('OKAY')
  6075. });
  6076. } else if (text == 'errorEntry') {
  6077. swal({
  6078. title: phraser('ERROR'),
  6079. html: phraser('YOU_HAVE_ALREADY_ENTERED'),
  6080. type: 'error',
  6081. confirmButtonText: phraser('OKAY')
  6082. });
  6083. } else if (text == 'errorName') {
  6084. swal({
  6085. title: phraser('ERROR'),
  6086. html: phraser('GIVEAWAY_NEED_NAME'),
  6087. type: 'error',
  6088. confirmButtonText: phraser('OKAY')
  6089. });
  6090. }
  6091. loadPage(page + ".php");
  6092. }
  6093. });
  6094. });
  6095. $('body').on('click', '.entries', function(e) {
  6096. e.stopPropagation();
  6097. $(this).html('<div class="loader_small" style="margin-top:8px;"></div>');
  6098. var giveaway_id = $(this).attr('data-id');
  6099. var type = $(this).attr('data-type');
  6100. var url = $(this).attr('data-url');
  6101. var page = $(this).attr('data-page');
  6102. var popup = window.open(url, '_blank', 'height=500,width=500,toolbar=0,location=0,menubar=0');
  6103. var closeCheck = setInterval(function() {
  6104. if (popup == null || popup.closed) {
  6105. clearInterval(closeCheck);
  6106. onWindowClosed();
  6107. }
  6108. }, 500);
  6109. var onWindowClosed = function() {
  6110. $.ajax({
  6111. type: "GET",
  6112. url: "/giveaway_entries.php",
  6113. data: {
  6114. enter: true,
  6115. giveaway_id: giveaway_id,
  6116. type: type
  6117. },
  6118. success: function(text) {
  6119. if (text == 'errorFinished') {
  6120. swal({
  6121. title: phraser('ERROR'),
  6122. html: phraser('NO_OPEN_GIVEAWAY_WAS_FOUND'),
  6123. type: 'error',
  6124. confirmButtonText: phraser('OKAY')
  6125. });
  6126. } else if (text == 'errorAction') {
  6127. swal({
  6128. title: phraser('ERROR'),
  6129. html: phraser('ACTION_NOT_AVAILABLE'),
  6130. type: 'error',
  6131. confirmButtonText: phraser('OKAY')
  6132. });
  6133. } else if (text == 'errorEntry') {
  6134. swal({
  6135. title: phraser('ERROR'),
  6136. html: phraser('YOU_HAVE_ALREADY_ENTERED'),
  6137. type: 'error',
  6138. confirmButtonText: phraser('OKAY')
  6139. });
  6140. } else if (text == 'errorComplete') {
  6141. swal({
  6142. title: phraser('ERROR'),
  6143. html: phraser('TASK_NOT_COMPLETE'),
  6144. type: 'error',
  6145. confirmButtonText: phraser('OKAY')
  6146. });
  6147. }
  6148. loadPage(page + ".php");
  6149. }
  6150. });
  6151. }
  6152. });
  6153.  
  6154. $('body').on('submit', '#revolver_form', function(e) {
  6155. e.preventDefault();
  6156. $("#revolver_form button").prop('disabled', true).html('<div class="loader_small" style="width: 18px;height: 18px;margin: 2px auto;"></div>');
  6157. var value = $("#revolver_value").val();
  6158. $.ajax({
  6159. type: "GET",
  6160. url: "/revolver_bet.php",
  6161. data: {
  6162. credits: value,
  6163. user_token: $("#user_token").val()
  6164. },
  6165. success: function(text) {
  6166. $("#revolver_form button").prop('disabled', false).html(phraser('BET'));
  6167. if (text == 'errorCredits') {
  6168. needCredits();
  6169. } else if (text == 'errorMin') {
  6170. swal({
  6171. title: phraser('ERROR'),
  6172. html: phraser('MINIMUM_BET_SMALL'),
  6173. type: 'error',
  6174. confirmButtonText: phraser('ERROR')
  6175. });
  6176. } else if (text == 'errorAction') {
  6177. swal({
  6178. title: phraser('ERROR'),
  6179. html: phraser('ACTION_NOT_AVAILABLE'),
  6180. type: 'error',
  6181. confirmButtonText: phraser('OKAY')
  6182. });
  6183. } else if (text == 'errorBets') {
  6184. swal({
  6185. title: phraser('ERROR'),
  6186. html: phraser('ALREADY_IN_QUEUE'),
  6187. type: 'error',
  6188. confirmButtonText: phraser('OKAY')
  6189. });
  6190. } else if (text == 'errorCooldown') {
  6191. swal({
  6192. title: phraser('ERROR'),
  6193. html: phraser('REVOLVER_IS_COOLING_DOWN'),
  6194. type: 'error',
  6195. confirmButtonText: phraser('OKAY')
  6196. });
  6197. } else {
  6198. updateCredits(-1 * value);
  6199. }
  6200. }
  6201. });
  6202. });
  6203.  
  6204. $('body').on('click', '#show_chat_mobile', function() {
  6205. if ($(".chat").is(':visible')) {
  6206. $(".chat").stop(true).fadeOut(100);
  6207. } else {
  6208. $(".chat").stop(true).fadeIn(100);
  6209. }
  6210. $("#chat_cell").scrollTop(999999999, 0);
  6211. });
  6212.  
  6213. });
Add Comment
Please, Sign In to add comment