Guest User

Untitled

a guest
May 25th, 2017
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var game_id = 0;
  2. var addClickHandler;
  3. var addClickHandlerCreate;
  4. var addClickHandlerTradeup;
  5. var addClickHandlerJackpot;
  6.  
  7. function setGameId(e){
  8.     game_id = $(e).parent().parent().attr("game_id");
  9.     $("#ModalBodyCreate").empty();
  10.     $("#ModalBody").empty();
  11.     $("#ModalBodyJackpot").empty();
  12.     $("#ModalBody").load("../createGameInventory.php?create=0&game_id="+game_id, function() {
  13.         addClickHandler(); 
  14.         $("#modalItemsAdd").modal();
  15.     });
  16. }
  17.  
  18. function openModalCreate(){
  19.     $("#ModalBodyCreate").empty();
  20.     $("#ModalBody").empty();
  21.     $("#ModalBodyJackpot").empty();
  22.     $("#ModalBodyCreate").load("../createGameInventory.php?create=1&game_id="+game_id, function() {
  23.         addClickHandlerCreate();
  24.         $("#modalCreateGame").modal();
  25.     });
  26. }
  27.  
  28. function openModalJackpot(){
  29.     $("#ModalBodyCreate").empty();
  30.     $("#ModalBody").empty();
  31.     $("#ModalBodyJackpot").empty();
  32.     $("#ModalBodyJackpot").load("../joinJackpot.php", function() {
  33.         addClickHandlerJackpot();
  34.         $("#modalJackpot").modal();
  35.     });
  36. }
  37.  
  38.  
  39. function viewGame(e){
  40.     game_id = $(e).parent().parent().attr("game_id");
  41.     $("#ModalBodyView").html("<center><i class='fa fa-spinner fa-spin fa-4x fa-fw'></i></center>");
  42.     $("#modalViewGame").modal();
  43.     $("#ModalBodyView").load("duel-details.php?game_id="+game_id, function() {});
  44.         //addReloadHandler();  
  45. }
  46.  
  47. function viewGameModal(e){
  48.     game_id = $(e).parent().parent().attr("game_id");
  49.     $("#ModalBodyView").html("<center><i class='fa fa-spinner fa-spin fa-4x fa-fw'></i></center>");
  50.     $("#modalViewGame").modal();
  51.     $("#ModalBodyView").load("duel-details.php?game_id="+game_id, function() {});
  52.     //addReloadHandler();  
  53. }
  54.  
  55. //$("#ModalBody").load("../createGameInventory.php");
  56. $(document).ready(function(){
  57.    
  58.     jQuery.expr[':'].icontains = function(a, i, m) {
  59.         return jQuery(a).text().toUpperCase()
  60.         .indexOf(m[3].toUpperCase()) >= 0;
  61.     };
  62.        
  63.     $("#fname").keyup(function() {
  64.         var $rows = $("#userVorschlaege tr");
  65.         var val = $.trim(this.value);
  66.        
  67.         if(val === ""){
  68.             $("#userVorschlaege").hide();
  69.         }else{
  70.             $("#userVorschlaege").show();
  71.            
  72.         }
  73.            
  74.         if (val === "")
  75.             $rows.show();
  76.         else {
  77.             $rows.hide();
  78.             $rows.has("td:icontains(" + val + ")").show();
  79.         }
  80.     });
  81.    
  82.     var refreshing = {"duel_table" : true, "recent_openings" : true};
  83.     var requesting = false;
  84.     var timeouts = [];
  85.     var animations = [];
  86.     loadRecentOpening();
  87.    
  88.     var oldItem = [];
  89.     setInterval(function() {
  90.         if (refreshing["recent_openings"]){
  91.             $.post("recent.php", {refreshing: refreshing["recent_openings"]}).done(function(data){
  92.                 if(data.recentStatus == true){
  93.                     $("#notUpdatingWarning").hide();
  94.                     if(data && data.success == true){
  95.                         if (oldItem.indexOf(data.latest_item) === -1) {
  96.                             if (refreshing["recent_openings"]) loadRecentOpening();
  97.                         }
  98.                         oldItem = [];
  99.                         oldItem.push(data.latest_item);
  100.                     }
  101.                 }else{
  102.                     $("#notUpdatingWarning").show();   
  103.                 }
  104.             });
  105.         }
  106.     }, 7000);
  107.    
  108.     if(refreshing["duel_table"]){
  109.         setInterval(function() {
  110.             $('#DuelTableRefresh').load("../duel_table.php");
  111.         }, 2000);
  112.     }
  113.    
  114.     /*  Wut is dis
  115.     $('.selectpicker').selectpicker({
  116.         size: 4
  117.     });
  118.     */
  119.    
  120.     function randInt(min, max) {
  121.         min = Math.ceil(min);
  122.         max = Math.floor(max);
  123.         return Math.floor(Math.random() * (max - min + 1)) + min;
  124.     }
  125.    
  126.     String.prototype.replaceAll = function(search, replacement) {
  127.         var target = this;
  128.         return target.replace(new RegExp(search, 'g'), replacement);
  129.     };
  130.    
  131.     $(".menu-item").click(function() {
  132.         var linkItem = !($(this).attr('href') == null);
  133.         if (linkItem) NProgress.start();
  134.         var $el = $(this);
  135.         if (linkItem) NProgress.set(0.2);
  136.         $("#content").load($(this).attr("href"), function() {
  137.             if (linkItem) NProgress.done();
  138.             if ($el.attr("crateid")) {
  139.                 openload($el.attr("crateid"));
  140.             }
  141.         });
  142.     });
  143.  
  144.     function loadRecentOpening() {
  145.         $("#refresh").load("recent.php");
  146.         $('#onlineusers').load(document.URL +  ' #onlineusers');
  147.     /*  $('#userMessages').load(document.URL +  ' #userMessages');
  148.         $('#userMessagesHeader').load(document.URL +  ' #userMessagesHeader');
  149.         $('#userMessages2').load(document.URL +  ' #userMessages2');
  150.         $('#loadMessages').load(document.URL +  ' #loadMessages');
  151.         $('#loadNotifications').load(document.URL +  ' #loadNotifications');
  152.     */ 
  153.        
  154.         }
  155.    
  156.     function openload(crateid) {
  157.             requesting = false;
  158.             refreshing["recent_openings"] = true;
  159.             for (var i = 0; i < timeouts.length; i++) {
  160.                 clearTimeout(timeouts[i]);
  161.             }
  162.             for (var i = 0; i < animations.length; i++) {
  163.                 animations[i].stop();
  164.             }
  165.             $("#item-images").clearQueue();
  166.             $("#winner-item").clearQueue();
  167.             $("#winner-item-cell").clearQueue();
  168.             timeouts = [];
  169.             animations = [];
  170.             $("#open").unbind("click");
  171.             $("#open").click(function() {
  172.                 NProgress.start();
  173.                 if (!requesting) {
  174.                     requesting = true;
  175.                     refreshing["recent_openings"] = false;
  176.                     NProgress.set(0.4);
  177.                     var jqxhr1337 = $.post("crate.php?id="+crateid)
  178.                         .done(function(data) {
  179.                             if (data.success == true) {
  180.                                 NProgress.done();
  181.                                 $("#open").parent().hide();
  182.                                 $("#item-images").empty();
  183.                                 $("#item-images").css("margin-top",-2000);
  184.                                 data.randomItems.forEach(function(item, key) {
  185.                                     if (key == 400) {
  186.                                         var style = "box-shadow: #"+data.color+" 0px 0px 10px, #"+data.color+" 0px 0px 10px;";
  187.                                         $("#item-images").append('<div id="winner-item" style="background: url('+((data.hidden == true) ? "images/mystery_decal.png" : data.image)+');background-size: 190px 190px;display:block;width:190px;height:190px;margin:5px;'+style+'"><div id="winner-item-cell" class="glow-'+data.rarity.replaceAll(" ", "").toLowerCase()+'" style="display: table-cell; vertical-align: bottom;height: 190px;width:190px;"><font style="text-shadow: 0 0 10px #'+data.color+', 0 0 20px #'+data.color+', 0 0 30px #'+data.color+', 0 0 40px #'+data.color+', 0 0 70px #'+data.color+', 0 0 80px #'+data.color+', 0 0 100px #'+data.color+', 0 0 150px #'+data.color+';margin-top: -15px; display: block;" color="#'+data.color+'">'+((data.hidden == true) ? "Mystery Universal Decal" : data.name)+'</font></div></div>');
  188.                                     } else {
  189.                                         var style = "box-shadow: #"+item.color+" 0px 0px 10px, #"+item.color+" 0px 0px 10px;";
  190.                                         $("#item-images").append('<div style="background: url('+((item.hidden == true) ? "images/mystery_decal.png" : item.image)+');background-size: 190px 190px;display:block;width:190px;height:190px;margin:5px;'+style+'"><div class="glow-'+item.rarity.replaceAll(" ", "")+'" style="display: table-cell; vertical-align: bottom;height: 190px;width:190px;"><font style="text-shadow: 0 0 10px #'+item.color+', 0 0 20px #'+item.color+', 0 0 30px #'+item.color+', 0 0 40px #'+item.color+', 0 0 70px #'+item.color+', 0 0 80px #'+item.color+', 0 0 100px #'+item.color+', 0 0 150px #'+item.color+';margin-top: -15px; display: block;" color="#'+item.color+'">'+((item.hidden == true) ? "Mystery Universal Decal" : item.name)+'</font></div></div>');
  191.                                     }
  192.                                 });
  193.                                 $("#roll").fadeIn(1500);
  194.                                 $("#roll-background").fadeIn(1000);
  195.                                 $("#pick-line").fadeIn(2000);
  196.                                 refreshCurrency();
  197.                                 timeouts.push(setTimeout(function() {
  198.                                     animations.push($("#item-images"));
  199.                                     animations.push($("#winner-item"));
  200.                                     animations.push($("#winner-item-cell"));
  201.                                     $("#item-images").animate({marginTop: -60000+"px"}, 3000, 'linear', function() {
  202.                                         var wobble = randInt(0, 180);
  203.                                         $("#item-images").animate({marginTop: (-78010-wobble)+"px"}, 7000, 'easeOutExpo', function() {
  204.                                             timeouts.push(setTimeout(function() {
  205.                                                 requesting = false;
  206.                                                 $("#roll").fadeOut();
  207.                                                 $("#roll-background").fadeOut();
  208.                                                 $("#open").parent().show();    
  209.                                                 $("#opened-name").html("");
  210.                                                 $("#opened-rarity").html("");
  211.                                                 refreshing["recent_openings"] = true;
  212.                                                 loadRecentOpening();
  213.                                             }, 2000));
  214.                                             $("#item-images").animate({marginTop: "-78150px"}, 1000, 'easeOutExpo')
  215.                                             $(".win-info").css("text-shadow", "0 0 10px #"+data.color+" , 0 0 20px #"+data.color+" , 0 0 30px #"+data.color+" , 0 0 40px #"+data.color+" , 0 0 70px #"+data.color+" , 0 0 80px #"+data.color+" , 0 0 100px #"+data.color)
  216.                                             $(".win-info").css("color", "#"+data.color)
  217.                                             if (data.hidden == true) {
  218.                                                 $("#winner-item").css("background", "url("+data.image+")")
  219.                                                 $("#winner-item-cell").find("font").html(data.name)
  220.                                                 $("#opened-name").html(data.name);
  221.                                                 $("#opened-rarity").html(data.rarity);
  222.                                             } else {
  223.                                                 $("#opened-name").html(data.name);
  224.                                                 $("#opened-rarity").html(data.rarity);
  225.                                             }
  226.                                         //  new Audio('sounds/ending.mp3').play()
  227.                                        
  228.                                         //rank reload
  229.                                             $('#rankimage').load(document.URL +  ' #rankimage');
  230.                                            
  231.                                             $("#pick-line").hide();
  232.                                             $("#winner-item").animate({height: "300px", width: "300px"}, 1000, "easeOutExpo");
  233.                                             $("#winner-item-cell").animate({height: "300px", width: "300px"}, {duration: 1000, easing: "easeOutExpo", progress: function() {
  234.                                                 $("#winner-item").css("background-size", "100%")
  235.                                             }});
  236.                                         });
  237.                                     });
  238.                                 }, 1000));
  239.                             } else if (data.error) {
  240.                                 iziToast.warning({
  241.                                     title: 'Warning',
  242.                                     message: data.error,
  243.                                     timeout: 10000, //10 Sekunden anzeigen
  244.                                     icon: 'fa fa-exclamation-triangle',
  245.                                     position: 'bottomLeft',
  246.                                     transitionIn: 'fadeIn',
  247.                                     transitionOut: 'fadeOutLeft'
  248.                                 });
  249.                                 refreshing["recent_openings"] = true;
  250.                                 requesting = false;
  251.                             } else if (data.error2) {
  252.                                 iziToast.error({
  253.                                     title: 'Error',
  254.                                     message: data.error2,
  255.                                     timeout: 10000, //10 Sekunden anzeigen
  256.                                     icon: 'fa fa-exclamation-triangle',
  257.                                     position: 'bottomLeft',
  258.                                     transitionIn: 'fadeIn',
  259.                                     transitionOut: 'fadeOutLeft'
  260.                                 });
  261.                                 refreshing["recent_openings"] = true;
  262.                                 requesting = false;
  263.                             }
  264.                         })
  265.                         .fail(function() {
  266.                             requesting = false;
  267.                         });
  268.                 }
  269.             });
  270.     }
  271.    
  272.     $("#messagesClick").click(function() {
  273.         $("#messages").toggle();
  274.         $("#notifications").hide();
  275.     });
  276.    
  277.     $("#notificationsClick").click(function() {
  278.         $("#notifications").toggle();
  279.         $("#messages").hide();
  280.     });
  281.    
  282.     var arrayJoin = [];
  283.     var selectedItemsPrices = 0;
  284.        
  285.     addClickHandler = function() {
  286.         arrayJoin = [];
  287.         selectedItemsPrices = 0;
  288.         $(".duel_item").click(function() {
  289.             if(arrayJoin.length < 8){
  290.                 var id = $(this).attr("id");
  291.                 arrayJoin.push(id);
  292.                 var price = parseFloat(document.getElementById(id).getAttribute('price'));
  293.                 selectedItemsPrices = parseFloat(selectedItemsPrices) + price;
  294.                 document.getElementById("YourBetJoin").innerHTML = ""+selectedItemsPrices.toFixed(2)+"";
  295.                 $(this).parent().find(".clicked_container").css("height", "100%");
  296.  
  297.             }else{
  298.                 error("Error", "You can bet max. 8 Items!", "fa fa-times");
  299.             }  
  300.         });
  301.        
  302.         $(".clicked_container").click(function() {
  303.             var id = $(this).parent().find("img").first().attr("id");
  304.             $(this).css("height", "0");
  305.             arrayJoin.splice(arrayJoin.indexOf(id), 1);
  306.             var price = parseFloat(document.getElementById(id).getAttribute('price'));
  307.             selectedItemsPrices = parseFloat(selectedItemsPrices) - price;
  308.             document.getElementById("YourBetJoin").innerHTML = ""+selectedItemsPrices.toFixed(2)+"";       
  309.         });
  310.        
  311.         $("#joinGameSubmit").click(function() {
  312.             if(arrayJoin.length < 9){
  313.                 $.post("duel.php", {arrayJoin: arrayJoin, game_id:game_id}).done(function(data){
  314.                     if(data.duplicateItem == true){
  315.                         error("Error", "Something went wrong...", "fa fa-times");  
  316.                         $("#content").load("duel.php", function() {});
  317.                     }else if(data.already_joined == true){
  318.                         error("Too late!", "Someone already joined this duel!", "fa fa-times");
  319.                     }else if(data.no_value == true){
  320.                         error("Error", "You have to be in the bet area!", "fa fa-times");  
  321.                     }else if(data.array_count_too_much == true){
  322.                         error("Error", "You can not pick more than 8 Items!", "fa fa-times");  
  323.                     }
  324.                 });
  325.             }else{
  326.                 error("Error", "You can not pick more than 8 Items!", "fa fa-times");  
  327.             }  
  328.             arrayJoin = [];
  329.             selectedItemsPrices = 0;
  330.         });    
  331.        
  332.     }
  333.     addClickHandler();
  334.    
  335.     var arrayCreateGame = [];  
  336.     var selectedItemsPricesCreate = 0;
  337.    
  338.     addClickHandlerCreate = function() {
  339.         arrayCreateGame = [];
  340.         selectedItemsPricesCreate = 0;
  341.         $(".duel_item_create").click(function() {
  342.             if(arrayCreateGame.length < 8){
  343.                 var id = $(this).attr("id");
  344.                 arrayCreateGame.push(id);
  345.                 var price = parseFloat(document.getElementById(id).getAttribute('price'));
  346.                 selectedItemsPricesCreate = parseFloat(selectedItemsPricesCreate) + price;
  347.                 document.getElementById("YourBetCreate").innerHTML = ""+selectedItemsPricesCreate.toFixed(2)+"";               
  348.                 $(this).parent().find(".clicked_container_create").css("height", "100%");
  349.             }else{
  350.                 error("Error", "You can bet max. 8 Items!", "fa fa-times");
  351.             }  
  352.         });
  353.        
  354.         $(".clicked_container_create").click(function() {
  355.             var id = $(this).parent().find("img").first().attr("id");
  356.             $(this).css("height", "0");
  357.             arrayCreateGame.splice(arrayCreateGame.indexOf(id), 1);
  358.             var price = parseFloat(document.getElementById(id).getAttribute('price'));
  359.             selectedItemsPricesCreate = parseFloat(selectedItemsPricesCreate) - price;
  360.             document.getElementById("YourBetCreate").innerHTML = ""+selectedItemsPricesCreate.toFixed(2)+"";
  361.         });
  362.        
  363.         $("#createGame").click(function() {
  364.             if(arrayCreateGame.length < 9){
  365.                 $.post("duel.php", {arrayCreateGame: arrayCreateGame}).done(function(data){
  366.                     $("#content").load("duel.php", function() {});
  367.                     if(data.too_much_games == true){
  368.                         error("Error", "You can have max. one game at a time!", "fa fa-times");
  369.                     }else if(data.array_count_too_much == true){
  370.                         error("Error", "You can bet max. 8 Items!", "fa fa-times");
  371.                     }  
  372.                 });
  373.             }else{
  374.                 error("Error", "You can not pick more than 8 Items!", "fa fa-times");
  375.             }
  376.             arrayCreateGame = [];
  377.             selectedItemsPricesCreate = 0;
  378.         });
  379.     }
  380.     addClickHandlerCreate();
  381.    
  382.    
  383.     addClickHandlerTradeup = function() {
  384.         FirstItem = 0;
  385.         SecondItem = 0;
  386.         ThirdItem = 0;
  387.         FourthItem = 0;
  388.         FifthItem = 0;
  389.         rarityOverall = 0;
  390.        
  391.         $(".duel_item_tradeup").click(function() {
  392.             var id = $(this).attr("id");
  393.             var src = $(this).attr("src");
  394.             var rarity = $(this).attr("real_rarity");
  395.             var name = document.getElementById("item_info"+id).innerHTML;
  396.             $('.duel_item_container:not([real_rarity='+rarity+'])').hide()
  397.             var allHidden = false;
  398.            
  399.             if(FirstItem == 0){
  400.                 $(this).parent().hide();
  401.                 FirstItem = id;
  402.                 rarityOverall = rarity;
  403.                 document.getElementById("FirstItem").innerHTML = "<p>"+name+"</p><img item='"+id+"' id='tradeupItem' style='width: 70%;' src='"+src+"'</img>";
  404.                 $(this).parent().find(".clicked_container_tradeup").css("height", "100%");
  405.             }else if(SecondItem == 0){
  406.                 $(this).parent().hide();
  407.                 SecondItem = id;
  408.                 rarityOverall = rarity;
  409.                 document.getElementById("SecondItem").innerHTML = "<p>"+name+"</p><img item='"+id+"' id='tradeupItem' style='width: 70%;' src='"+src+"'</img>";
  410.                 $(this).parent().find(".clicked_container_tradeup").css("height", "100%");
  411.             }else if(ThirdItem == 0){
  412.                 $(this).parent().hide();
  413.                 ThirdItem = id;
  414.                 rarityOverall = rarity;
  415.                 document.getElementById("ThirdItem").innerHTML = "<p>"+name+"</p><img item='"+id+"' id='tradeupItem' style='width: 70%;' src='"+src+"'</img>";
  416.                 $(this).parent().find(".clicked_container_tradeup").css("height", "100%");
  417.             }else if(FourthItem == 0){
  418.                 $(this).parent().hide();
  419.                 FourthItem = id;
  420.                 rarityOverall = rarity;
  421.                 document.getElementById("FourthItem").innerHTML = "<p>"+name+"</p><img item='"+id+"' id='tradeupItem' style='width: 70%;' src='"+src+"'</img>";
  422.                 $(this).parent().find(".clicked_container_tradeup").css("height", "100%");
  423.             }else if(FifthItem == 0){
  424.                 $(this).parent().hide();
  425.                 FifthItem = id;
  426.                 rarityOverall = rarity;
  427.                 document.getElementById("FifthItem").innerHTML = "<p>"+name+"</p><img item='"+id+"' id='tradeupItem' style='width: 70%;' src='"+src+"'</img>";
  428.                 $(this).parent().find(".clicked_container_tradeup").css("height", "100%");
  429.             }else{
  430.                 error("Error", "You can not pick more than 5 Items!", "fa fa-times");
  431.             }
  432.            
  433.             $('#TradeupInventory').children().each(function() {
  434.                 if ($(this).is(":visible")) {
  435.                     allHidden = true;
  436.                 }
  437.             });
  438.            
  439.             if(!allHidden){
  440.                 $('#TradeupInventory').append('<h3>No more items available!</h3>');
  441.             }
  442.            
  443.         });
  444.        
  445.         $("#makeTradeup").click(function() {
  446.             var arrayTradeup = [];
  447.             arrayTradeup.push(FirstItem);
  448.             arrayTradeup.push(SecondItem);
  449.             arrayTradeup.push(ThirdItem);
  450.             arrayTradeup.push(FourthItem);
  451.             arrayTradeup.push(FifthItem);
  452.             console.log(arrayTradeup);
  453.             console.log(rarityOverall);
  454.             //$("#InnerTradeUpBox").slideUp(1000);
  455.            
  456.             if (!arrayTradeup.includes(0)){
  457.                 $('#ThirdItem').css('z-index', '1');
  458.                
  459.                 $('#FirstItem').animate({left: "33.3%"}, 400);
  460.                 $('#SecondItem').animate({left: "16.7%"}, 400);
  461.                 $('#FourthItem').animate({left: "-16.7%"}, 400);
  462.                 $('#FifthItem').animate({left: "-33.3%"}, 400);
  463.                
  464.                 setTimeout(function(){
  465.                     $('#FirstItem').css('visibility', 'hidden');
  466.                     $('#SecondItem').css('visibility', 'hidden');
  467.                     $('#FourthItem').css('visibility', 'hidden');
  468.                     $('#FifthItem').hide();
  469.                 }, 800);
  470.             }
  471.            
  472.             var postInAction = true;
  473.            
  474.             $.post("tradeup.php", {arrayTradeup:arrayTradeup, rarityOverall:rarityOverall}).done(function(data){
  475.                 if(data.allItemsAreRarity == true){
  476.                     if(data.winner_item_color != ""){
  477.                         winner_item_color = " ("+data.winner_item_color+")";
  478.                     }else{
  479.                         winner_item_color = "";
  480.                     }
  481.                     $("#WinnerItem").html("<p>"+data.winner_item_name+""+winner_item_color+"</p><img id='WinnerTradeUpImg' style='width:70%;box-shadow: rgb("+data.winner_item_rarity_color+") 0px 0px 10px, rgb("+data.winner_item_rarity_color+") 0px 0px 10px;' width='120px' src='"+data.winner_item_image+"'</img>");
  482.                     $("#makeTradeup").hide();
  483.                     $("#clearTradeup").hide();
  484.                     $('#backToTradeup').show();
  485.                    
  486.                     $('#ThirdItem').fadeOut(1000, function(){
  487.                         $('#WinnerItem').fadeIn(1000);
  488.                         success("Success", "You successfully traded up your items!", "fa fa-check");
  489.                     });
  490.                 }else if(data.hasDupes == true){
  491.                     error("Error", "Something went wrong...", "fa fa-times");
  492.                 }else{
  493.                     error("Error", "You have to pick 5 items!", "fa fa-times");
  494.                 }
  495.                
  496.                 postInAction = false;
  497.                
  498.             });
  499.            
  500.             if (!arrayTradeup.includes(0)){
  501.                 AnimateInterval = setInterval(function(){
  502.                     if (postInAction){
  503.                         $('#ThirdItem')
  504.                         .animate({'left':(-5)+'px'},75)
  505.                         .animate({'left':(+10)+'px'},65)
  506.                         .animate({'left':(-10)+'px'},55)
  507.                         .animate({'left':(+10)+'px'},31)
  508.                         .animate({'left':(-10)+'px'},31)
  509.                         .animate({'left':(+10)+'px'},55)
  510.                         .animate({'left':(-10)+'px'},65)
  511.                         .animate({'left':(+5)+'px'},75);
  512.                     }else{
  513.                         clearInterval(AnimateInterval);
  514.                     }
  515.                 }, 800);
  516.             }
  517.         });    
  518.        
  519.         $("#clearTradeup").click(function() {
  520.             NProgress.start();
  521.             $("#content").load("tradeup.php", function() {
  522.                 NProgress.done();
  523.             });
  524.         });
  525.  
  526.         $('#backToTradeup').click(function() {
  527.             NProgress.start();
  528.             $("#content").load("tradeup.php", function() {
  529.                 NProgress.done();
  530.             });
  531.         });
  532.        
  533.     }
  534.     addClickHandlerTradeup();
  535.    
  536.     /*
  537.     var already_updated = false;
  538.     addReloadHandler = function() {
  539.         already_updated = false;
  540.             ReloadTimer = setInterval(function() {
  541.                 if ($('#modalViewGame').is(':visible')) {
  542.                     console.log("found div");
  543.                     if(already_updated == false || game_id != 0){
  544.                         $.post("duel-details.php?game_id="+$("#ImportantGameID").html(), {refreshing: refreshing["recent_openings"]}).done(function(data){
  545.                             if(data && data.success == true){
  546.                                 $("#ModalBodyView").load("duel-details.php?game_id="+game_id, function() {});
  547.                                 already_updated = true;
  548.                                 clearInterval(ReloadTimer);
  549.                             }
  550.                         });
  551.                     }
  552.                 }
  553.             }, 1000);  
  554.     }
  555.     */
  556.    
  557.     var arrayJoinJackpot = []; 
  558.     var selectedItemsPricesJackpot = 0;
  559.    
  560.     addClickHandlerJackpot = function() {
  561.         arrayJoinJackpot = [];
  562.         selectedItemsPricesJackpot = 0;
  563.         $(".duel_item_create").click(function() {
  564.             if(arrayJoinJackpot.length < 10){
  565.                 var id = $(this).attr("id");
  566.                 arrayJoinJackpot.push(id);
  567.                 var price = parseFloat(document.getElementById(id).getAttribute('price'));
  568.                 selectedItemsPricesJackpot = parseFloat(selectedItemsPricesJackpot) + price;
  569.                 document.getElementById("YourBetCreate").innerHTML = ""+selectedItemsPricesJackpot.toFixed(2)+"";              
  570.                 $(this).parent().find(".clicked_container_create").css("height", "100%");
  571.             }else{
  572.                 error("Error", "You can deposit max. 10 Items!", "fa fa-times");   
  573.             }  
  574.         });
  575.        
  576.         $(".clicked_container_create").click(function() {
  577.             var id = $(this).parent().find("img").first().attr("id");
  578.             $(this).css("height", "0");
  579.             arrayJoinJackpot.splice(arrayJoinJackpot.indexOf(id), 1);
  580.             var price = parseFloat(document.getElementById(id).getAttribute('price'));
  581.             selectedItemsPricesJackpot = parseFloat(selectedItemsPricesJackpot) - price;
  582.             document.getElementById("YourBetCreate").innerHTML = ""+selectedItemsPricesJackpot.toFixed(2)+"";
  583.         });
  584.        
  585.         $("#joinJackpot").click(function() {
  586.             if(arrayJoinJackpot.length < 11){
  587.                 $.post("jackpot.php", {arrayJoinJackpot: arrayJoinJackpot}).done(function(data){
  588.                     if(data.max50Items == true){
  589.                         error("Error", "Max Jackpot items is 50!", "fa fa-times"); 
  590.                     }else if(data.max10Items == true){ 
  591.                         error("Error", "You can deposit max. 10 Items!", "fa fa-times");   
  592.                 }else{
  593.                         $("#content").load("jackpot.php", function() {});
  594.                         success("Success", "You are in! Good luck!", "fa fa-check");
  595.                     }
  596.                 });
  597.             }else{
  598.                 error("Error", "You can not pick more than 10 Items!", "fa fa-times");
  599.             }
  600.             arrayJoinJackpot = [];
  601.             selectedItemsPricesJackpot = 0;
  602.         });
  603.     }
  604.     addClickHandlerJackpot();  
  605.    
  606. });
  607.  
  608.     function tradeItems(){
  609.        
  610.     }
  611.  
  612.     function refreshDiv(){
  613.         $("#ModalBody").load("../createGameInventory.php");
  614.         $( ".duel_item_create" ).trigger( "click" );       
  615.         $( ".clicked_container_create" ).trigger( "click" );       
  616.     }
  617.  
  618.     function register() {
  619.         var username = $("#username").val();
  620.         var password = $("#password").val();
  621.         NProgress.start();
  622.         $.post("register.php", {username: username, password: password}).done(function(data){
  623.         NProgress.done();
  624.             if (data && data.success == true) {
  625.                 iziToast.success({
  626.                     title: 'Success',
  627.                     message: 'You have been successfully registered!',
  628.                     timeout: 5000, //10 Sekunden anzeigen
  629.                     icon: 'fa fa-check',
  630.                     position: 'bottomLeft',
  631.                     transitionIn: 'fadeIn',
  632.                     transitionOut: 'fadeOutLeft'
  633.                 });
  634.                 $("#content").load("login.php");
  635.             } else if (data && data.success == false) {
  636.                 if (data.type == "error")
  637.                     iziToast.error({
  638.                         title: 'Error',
  639.                         message: data.error,
  640.                         timeout: 5000, //10 Sekunden anzeigen
  641.                         icon: 'fa fa-times',
  642.                         position: 'bottomLeft',
  643.                         transitionIn: 'fadeIn',
  644.                         transitionOut: 'fadeOutLeft'
  645.                     });
  646.                 else
  647.                     iziToast.warning({
  648.                         title: 'Warning',
  649.                         message: data.error,
  650.                         timeout: 5000, //10 Sekunden anzeigen
  651.                         icon: 'fa fa-exclamation-triangle',
  652.                         position: 'bottomLeft',
  653.                         transitionIn: 'fadeIn',
  654.                         transitionOut: 'fadeOutLeft'
  655.                     });
  656.  
  657.             }
  658.         });
  659.     }
  660.    
  661.     function login() {
  662.         var username = $("#username").val();
  663.         var password = $("#password").val();
  664.         NProgress.start();
  665.         $.post("login.php", {username: username, password: password}).done(function(data){
  666.         NProgress.done();  
  667.             if (data && data.success == true) {
  668.                 iziToast.success({
  669.                     title: 'Success',
  670.                     message: 'You have been successfully logged in!',
  671.                     timeout: 5000, //10 Sekunden anzeigen
  672.                     icon: 'fa fa-check',
  673.                     position: 'bottomLeft',
  674.                     transitionIn: 'fadeIn',
  675.                     transitionOut: 'fadeOutLeft'
  676.                 });
  677.                 if (data.admin == true){
  678.                     $(".menu-loggedin-testing").show();
  679.                     $(".adminPanelButton").show();
  680.                     $("#testing-label").html('Testing-Panel');
  681.                 }
  682.                 if (data.dailyreward == true){
  683.                     iziToast.info({
  684.                         title: 'Info',
  685.                         message: 'You claimed your daily reward('+data.streak_keys+' Keys) for your '+data.login_streak+' days login streak. Thank you for being faithful!',
  686.                         timeout: 8000, //10 Sekunden anzeigen
  687.                         icon: 'fa fa-info',
  688.                         position: 'bottomLeft',
  689.                         transitionIn: 'fadeIn',
  690.                         transitionOut: 'fadeOutLeft'
  691.                     });
  692.                 }
  693.                 else if (data.dailyreward == false){
  694.                     iziToast.info({
  695.                         title: 'Info',
  696.                         message: 'You claimed your daily reward(2 Keys). Thank you for being faithful!',
  697.                         timeout: 8000, //10 Sekunden anzeigen
  698.                         icon: 'fa fa-info',
  699.                         position: 'bottomLeft',
  700.                         transitionIn: 'fadeIn',
  701.                         transitionOut: 'fadeOutLeft'
  702.                     });
  703.                 }              
  704.                 $(".menu-loggedin").show();
  705.                 $(".menu-loggedout").hide();
  706.                 $("#username-label").html('<img src="'+data.exp+'"/>'+data.username+'<div class="keyAmount menu-loggedin"><img src="images/key.png"><span id="currencyID">'+parseFloat(data.currency).toFixed(2)+'</span></div>');
  707.                 $("#messages").html('<div style="left: 20px;" class="arrow-up-messages"></div><span>You have <b>'+data.countedMessages+'</b> messages</span><ul id="loadMessages">Loading messages...</ul>');
  708.                 $("#notifications").html('<div style="left: 131px;" class="arrow-up-messages"></div><span>You have <b>'+data.countedNotifications+'</b> notifications</span><ul id="loadNotifications">Loading notifications...</ul>');
  709.                 $("#content").load("dashboard.php");
  710.             } else if (data && data.success == false) {
  711.                 if (data.type == "error")
  712.                     iziToast.error({
  713.                         title: 'Error',
  714.                         message: data.error,
  715.                         timeout: 5000, //10 Sekunden anzeigen
  716.                         icon: 'fa fa-times',
  717.                         position: 'bottomLeft',
  718.                         transitionIn: 'fadeIn',
  719.                         transitionOut: 'fadeOutLeft'
  720.                     });
  721.                 else
  722.                     iziToast.warning({
  723.                         title: 'Warning',
  724.                         message: data.error,
  725.                         timeout: 5000, //10 Sekunden anzeigen
  726.                         icon: 'fa fa-exclamation-triangle',
  727.                         position: 'bottomLeft',
  728.                         transitionIn: 'fadeIn',
  729.                         transitionOut: 'fadeOutLeft'
  730.                     });
  731.             }
  732.         });
  733.     }
  734.    
  735.     function logout() {
  736.         $(".menu-loggedin-testing").hide();
  737.         $(".menu-loggedin").hide();
  738.         $(".menu-loggedout").show();
  739.         $("#content").load("dashboard.php");
  740.         iziToast.success({
  741.             title: 'Success',
  742.             message: 'You have been successfully logged out!',
  743.             timeout: 5000, //10 Sekunden anzeigen
  744.             icon: 'fa fa-check',
  745.             position: 'bottomLeft',
  746.             transitionIn: 'fadeIn',
  747.             transitionOut: 'fadeOutLeft'
  748.         });
  749.     }
  750.    
  751.     function notAvailable(){
  752.         iziToast.warning({
  753.             title: 'Warning',
  754.             message: 'This function is currently unavailable! Sry brah :p',
  755.             timeout: 5000, //10 Sekunden anzeigen
  756.             icon: 'fa fa-exclamation-triangle',
  757.             position: 'bottomLeft',
  758.             transitionIn: 'fadeIn',
  759.             transitionOut: 'fadeOutLeft'
  760.         });
  761.     }
  762.    
  763.  
  764.     var openAdmin = false;
  765.     function testingMenuPoint() {
  766.         if(openAdmin){
  767.             $(".testMenu").slideUp(1500);
  768.             $(".games").slideDown(1500);
  769.             setTimeout(function(){
  770.                 $(".panelScrollIcon").removeClass("fa-arrow-up");
  771.                 $(".panelScrollIcon").addClass("fa-arrow-down");
  772.             },1500);
  773.             $('.testing-background').animate({ 'background-color': 'rgba(0, 0, 0, 0)' },1000); 
  774.             openAdmin = false;     
  775.         }else{
  776.             $(".games").slideUp(1500);
  777.             $(".testMenu").slideDown(1500);
  778.             setTimeout(function(){
  779.                 $(".panelScrollIcon").removeClass("fa-arrow-down");
  780.                 $(".panelScrollIcon").addClass("fa-arrow-up");
  781.             },1500);
  782.             $('.testing-background').animate({ 'background-color': 'rgba(0, 0, 0, 0.3)' },500);        
  783.             openAdmin = true;
  784.         }  
  785.     };
  786.    
  787.    
  788.     function sellItem(inv_id,price) {
  789.         $.post("delete.php" , {inv_id:inv_id,price:price} , function(data){
  790.             if(data)
  791.                 $("#item" + inv_id).fadeOut('fast' , function(){
  792.                 $(this).remove();
  793.                 $("#currencyID").animate({color:'#00FF00'}, 300);
  794.                 var oldCurrency = document.getElementById('currencyID');
  795.                 var newCurrency = parseFloat(oldCurrency.innerHTML) + parseFloat(price);
  796.                 $("#currencyID").html(newCurrency.toFixed(2));
  797.                 $("#currencyID").animate({color:'white'}, 600);
  798.                 var itemAmount = document.getElementById('itemAmount');
  799.                 var newAmount = parseInt(itemAmount.innerHTML) - parseInt(1);
  800.                 $("#itemAmount").html(newAmount);
  801.                
  802.                 iziToast.success({
  803.                     title: 'Success',
  804.                     message: 'You have successfully sold your item for '+parseFloat(price).toFixed(2)+' Keys!',
  805.                     timeout: 1000, //10 Sekunden anzeigen
  806.                     icon: 'fa fa-check',
  807.                     position: 'bottomLeft',
  808.                     transitionIn: 'fadeIn',
  809.                     transitionOut: 'fadeOutLeft'
  810.                 });
  811.             });
  812.         });
  813.        
  814.     }
  815.    
  816.     function refreshCurrency() {
  817.         $("#currencyID").animate({color:'#FF0000'}, 300);
  818.         var oldCurrency = document.getElementById('currencyID');
  819.         var newCurrency = parseFloat(oldCurrency.innerHTML) - parseFloat(1);
  820.         $("#currencyID").html(newCurrency.toFixed(2));
  821.         $("#currencyID").animate({color:'white'}, 600);
  822.     }
  823.  
  824.    
  825.     function sortDes(items, container){
  826.         var myArray = $(items);
  827.         var count = 0;
  828.         myArray.sort(function (a, b) {
  829.             a = parseInt($(a).attr("price"), 10);
  830.             b = parseInt($(b).attr("price"), 10);
  831.             count += 2;
  832.             if(a < b) {
  833.                 return 1;
  834.             } else if(a > b) {
  835.                 return -1;
  836.             } else {
  837.                 return 0;
  838.             }
  839.         });
  840.             $(container).append(myArray);
  841.     }
  842.    
  843.     function sortAsc(items, container){
  844.         var myArray = $(items);
  845.             var count = 0;
  846.             myArray.sort(function (a, b) {
  847.                 a = parseInt($(a).attr("price"), 10);
  848.                 b = parseInt($(b).attr("price"), 10);
  849.                 count += 2;
  850.                 if(a > b) {
  851.                     return 1;
  852.                 } else if(a < b) {
  853.                     return -1;
  854.                 } else {
  855.                     return 0;
  856.                 }
  857.             });
  858.             $(container).append(myArray);
  859.     }
  860.    
  861.     function sortRar(items, container){
  862.         var myArray = $(items);
  863.             var count = 0;
  864.             myArray.sort(function (a, b) {
  865.                 a = parseInt($(a).attr("rarity"), 10);
  866.                 b = parseInt($(b).attr("rarity"), 10);
  867.                 count += 2;
  868.                 if(a < b) {
  869.                     return 1;
  870.                 } else if(a > b) {
  871.                     return -1;
  872.                 } else {
  873.                     return 0;
  874.                 }
  875.             });
  876.             $(container).append(myArray);
  877.     }
  878.    
  879.     function sellallItems(rarityID, rarityName, price) {
  880.            
  881.             $.post("inventory.php", {rarityID: rarityID}, function(data){
  882.                 $("#content").load("inventory.php", function() {});
  883.                 success("Success", "Successfully sold your "+rarityName+" items for "+price+" Keys!", "fa fa-check");
  884.                 $("#currencyID").animate({color:'#00FF00'}, 300);
  885.                 var oldCurrency = document.getElementById('currencyID');
  886.                 var newCurrency = parseFloat(oldCurrency.innerHTML) + parseFloat(price);
  887.                 $("#currencyID").html(newCurrency.toFixed(2));
  888.                 $("#currencyID").animate({color:'white'}, 600);
  889.                 $('#itemAmount').load(document.URL +  ' #itemAmount');
  890.             });
  891.     };     
  892.    
  893.     function addTodo() {
  894.         var text = $("input[name=text]").val();
  895.         var priority = $("select[name=priority]").val();
  896.         var status = $("select[name=status]").val();
  897.        
  898.         // Date
  899.         var today = new Date();
  900.         var dd = today.getDate();
  901.         var mm = today.getMonth()+1; //January is 0!
  902.         var yyyy = today.getFullYear();
  903.         if(dd<10) {
  904.             dd='0'+dd
  905.         }
  906.         if(mm<10) {
  907.             mm='0'+mm
  908.         }
  909.         today = yyyy+'-'+mm+'-'+dd;
  910.        
  911.         // Post
  912.         if (text == "" || priority == "" || status == ""){
  913.             error("Missing Data", "Please fill out all fields!", "fa fa-exclamation-triangle");
  914.         }else{
  915.             $.post("todo_list.php", {text:text, priority:priority, status:status, datum:today}, function(data){
  916.                 $("#content").load("todo_list.php", function() {});
  917.                 success("Success", "Todo-Item succesfully added!", "fa fa-check");
  918.             });
  919.         }
  920.     };
  921.    
  922.     function closeTodo(todoID) {
  923.            
  924.             $.post("todo_list.php", {todoID: todoID}, function(data){
  925.                 $("#content").load("todo_list.php", function() {});
  926.                 success("Success", "You closed the todo entry with id "+todoID+".", "fa fa-check");
  927.             });
  928.     }; 
  929.    
  930.     function addItem() {
  931.         var item_id = $("input[name=item_id]").val();
  932.  
  933.            
  934.             $.post("edit-users.php", {userid: userid, item_id:item_id}, function(data){
  935.                 $("#content").load("edit-users/"+userid, function() {});
  936.                 success("Success", "Item with ID " +item_id+ " succesfully added to inventory!", "fa fa-check");
  937.             });
  938.     };
  939.    
  940.     function banUser(username) {
  941.  
  942.             $.post("profile_public.php", {username: username}, function(data){
  943.                 $("#content").load("profile_public.php/"+username, function() {});
  944.                 success("Success", "You permanently banned the user "+username+"!", "fa fa-check");
  945.             });
  946.     };
  947.  
  948.     function unbanUser(username, status) {
  949.  
  950.             $.post("profile_public.php", {username: username, status:status}, function(data){
  951.                 $("#content").load("profile_public.php/"+username, function() {});
  952.                 success("Success", "You unbanned the user "+username+"!", "fa fa-check");
  953.             });
  954.     }; 
  955.    
  956.     function buyItem(item_id, tradeid) {
  957.  
  958.            
  959.             $.post("trading.php", {userid: userid, item_id:item_id, tradeid:tradeid}, function(data){
  960.                 $("#content").load("trading.php", function() {});
  961.                
  962.            
  963.                 if (data.success == true){
  964.                                
  965.                     success("Success", "You successfully buyed Item with ID " +item_id+ "!", "fa fa-check");
  966.  
  967.                 }
  968.                
  969.                 else if (data.success == false){
  970.                    
  971.                     error("Error", "Item already selled!", "fa fa-check");
  972.  
  973.                 }  
  974.                
  975.                
  976.                
  977.             });
  978.     };
  979.  
  980.     function chatAdd() {
  981.         var msgText = $("input[name=msgText]").val();
  982.  
  983.            
  984.             $.post("chat.php", {userid:userid,msgText: msgText}, function(data){
  985.                
  986.            
  987.                 if (data.success == true){
  988.                                
  989.                     success("Success", "You successfully", "fa fa-check");
  990.                 }
  991.                
  992.                 else if (data.success == false){
  993.                    
  994.                     error("Error", "Item already selled!", "fa fa-check");
  995.  
  996.                 }  
  997.                
  998.                
  999.                
  1000.             });
  1001.     };
  1002.  
  1003.     function dismissMessage(dismissID) {
  1004.  
  1005.            
  1006.             $.post("index.php", {dismissID:dismissID}, function(data){
  1007.                
  1008.                 if (data.success == true){
  1009.                 success("Success", "You successfully marked your message as read!", "fa fa-check");
  1010.                 }
  1011.                
  1012.                
  1013.             });
  1014.     }; 
  1015.    
  1016.     // Toast's
  1017.         function error(customTitle, customMessage, customIcon) {
  1018.             iziToast.error({
  1019.                 title: customTitle,
  1020.                 message: customMessage,
  1021.                 icon: customIcon,
  1022.                 position: 'bottomLeft'
  1023.             });
  1024.         }
  1025.  
  1026.         function success(customTitle, customMessage, customIcon) {
  1027.             iziToast.success({
  1028.                 title: customTitle,
  1029.                 message: customMessage,
  1030.                 icon: customIcon,
  1031.                 position: 'bottomLeft'
  1032.             });
  1033.         }
  1034.        
  1035.        
  1036.         function searchUser(searchedName) {
  1037.             var $rows = $("#userVorschlaege");
  1038.             $("#content").load("profile_public.php/"+searchedName, function() {
  1039.                 $("#fname").val("");
  1040.                 $rows.hide();
  1041.             });
  1042.         }; 
  1043.  
  1044.         function decimalPlaces(num) {
  1045.           var match = (''+num).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);
  1046.           if (!match) { return 0; }
  1047.           return Math.max(
  1048.                0,
  1049.                // Number of digits right of decimal point.
  1050.                (match[1] ? match[1].length : 0)
  1051.                // Adjust for scientific notation.
  1052.                - (match[2] ? +match[2] : 0));
  1053.         }      
  1054.        
  1055.         function spinWheel(){
  1056.             var loading = false;
  1057.                 NProgress.start();
  1058.                 var flipResult = 0;
  1059.                 var bet = $("input[name=bet]").val();
  1060.                 //replace
  1061.                 if(!loading && parseFloat(document.getElementById('currencyID').innerHTML) >= parseFloat(bet)){
  1062.                     $("#loading").show();
  1063.                     loading = true;
  1064.                     $('#coin').removeClass();
  1065.                     if (!isNaN(bet) && bet != '' && bet != '0' && bet.indexOf('-') === -1 && bet >= '0.01' && decimalPlaces(bet) < 3){
  1066.                         NProgress.inc()
  1067.                         NProgress.set(0.6)
  1068.                         $.post("coinflip.php", {flipResult: flipResult, bet:bet}, function(data){
  1069.                             if(data.coinflipBan == true){
  1070.                                 error("Error", "Please wait "+data.waitTimeSeconds+" more second(s)!", "fa fa-times");
  1071.                                 loading = false;
  1072.                                 NProgress.done()
  1073.                                 $("#loading").hide();
  1074.                             }else{
  1075.                                 flipResult = data.flipResult;
  1076.                                 $("#loading").hide();
  1077.                                 setTimeout(function(){
  1078.                                     $("#currencyID").animate({color:'#FF0000'}, 300);
  1079.                                     var oldCurrency = document.getElementById('currencyID');
  1080.                                     var newCurrency = parseFloat(oldCurrency.innerHTML) - parseFloat(bet);
  1081.                                     $("#currencyID").html(newCurrency.toFixed(2));
  1082.                                     $("#currencyID").animate({color:'white'}, 600);    
  1083.                                     if(flipResult <= 50){
  1084.                                     $('#coin').addClass('heads');
  1085.                                         setTimeout(function(){
  1086.                                             success("Congrats!", "You won "+bet+" Keys!", "fa fa-check");
  1087.                                             $('#lastCoinflips tr:last').after('<tr>...</tr><tr>...</tr>');
  1088.                                             //new Audio('sounds/win.mp3').play()
  1089.                                             $("#currencyID").animate({color:'#00FF00'}, 300);
  1090.                                             var oldCurrency = document.getElementById('currencyID');
  1091.                                             var newCurrency = parseFloat(oldCurrency.innerHTML) + parseFloat(bet*2);
  1092.                                             $("#currencyID").html(newCurrency.toFixed(2));
  1093.                                             $("#currencyID").animate({color:'white'}, 600);                
  1094.                                             loading = false;
  1095.                                         }, 2800);
  1096.                                     }else{
  1097.                                         $('#coin').addClass('tails');
  1098.                                         setTimeout(function(){
  1099.                                             error("Ouch!", "You lost "+bet+" Keys. Better luck next time!", "fa fa-times");
  1100.                                             loading = false;
  1101.                                         }, 2800);
  1102.                                     }
  1103.                                 }, 300);
  1104.                             }
  1105.                         });
  1106.                     }else{
  1107.                         error("Error", "You have to enter a valid key number!", "fa fa-times");
  1108.                         loading = false;
  1109.                         $("#loading").hide();
  1110.                     }  
  1111.                 }else{
  1112.                     error("Error", "You don't have enough keys!", "fa fa-times");
  1113.                 }
  1114.             NProgress.done();
  1115.         }
  1116.        
  1117.         function increaseBet(value) {
  1118.  
  1119.             document.getElementById("CoinBet").value = parseFloat(document.getElementById("CoinBet").value) + parseFloat(value);
  1120.            
  1121.         };         
  1122.        
  1123.         function betValue(value) {
  1124.  
  1125.             var currency = document.getElementById('currencyID');
  1126.        
  1127.             if(value == 1){
  1128.                 document.getElementById("CoinBet").value = parseFloat(currency.innerHTML);
  1129.             }else if(value == 0){
  1130.                 $('#CoinBet').val('0')
  1131.             }else if(value == 'Double'){
  1132.                 document.getElementById("CoinBet").value = parseFloat(document.getElementById("CoinBet").value) *2;
  1133.             }else if(value == 'Half'){
  1134.                 document.getElementById("CoinBet").value = parseFloat(document.getElementById("CoinBet").value) /2;
  1135.             }  
  1136.         };     
  1137.  
  1138.         function onEnterPress(e) {
  1139.             if (e.keyCode == 13) {
  1140.                 login();
  1141.             return false;
  1142.             }
  1143.         }      
  1144.        
  1145.         function disconnectSteam() {
  1146.             var steam = true;
  1147.             NProgress.start();
  1148.             $.post("profile.php", {steam:steam}, function(data){                       
  1149.                 $("#content").load("profile.php", function() {});
  1150.                 success("Success", "You have successfully disconnected your Steam account!", "fa fa-check");               
  1151.             });
  1152.             NProgress.done();
  1153.         }; 
  1154.        
  1155.         function disconnectDiscord() {
  1156.             var discord = true;
  1157.             NProgress.start();
  1158.             $.post("profile.php", {discord:discord}, function(data){
  1159.                 $("#content").load("profile.php", function() {});
  1160.                 success("Success", "You have successfully disconnected your Discord account!", "fa fa-check");             
  1161.             });
  1162.             NProgress.done();
  1163.         }; 
  1164.  
  1165.         function disconnectPatreon() {
  1166.             var patreon = true;
  1167.             NProgress.start();
  1168.             $.post("profile.php", {patreon:patreon}, function(data){
  1169.                 $("#content").load("profile.php", function() {});
  1170.                 success("Success", "You have successfully disconnected your Patreon account!", "fa fa-check");             
  1171.             });
  1172.             NProgress.done();
  1173.         };         
  1174.  
  1175.         function updateInformation() { 
  1176.             var updateInformation = true;
  1177.             NProgress.start();
  1178.             $.post("profile.php", {updateInformation:updateInformation}, function(data){                       
  1179.                 $("#content").load("profile.php", function() {});
  1180.                 success("Success", "You have successfully updated your Steam informations!", "fa fa-check");               
  1181.             });
  1182.             NProgress.done();
  1183.         };     
  1184.        
  1185.         function resetAccount() {
  1186.             var resetAccount = true;
  1187.             NProgress.start();
  1188.             $.post("profile.php", {resetAccount:resetAccount}, function(data){
  1189.                 $("#content").load("profile.php", function() {});
  1190.                 success("Success", "You have successfully reseted your account!", "fa fa-check");  
  1191.                 $("#currencyID").html("47.00");            
  1192.             });
  1193.             NProgress.done();
  1194.         }; 
  1195.        
  1196. /*
  1197.         function gotoDuel(game_id) {                       
  1198.             $("#ModalBodyView").load("duel-details.php?game_id="+game_id, function() {
  1199.                 $("#modalViewGame").modal();
  1200.             });
  1201.         }; 
  1202. */     
  1203.         function duelSpin(flipResult, myid, winner_id,creator_id, joiner_id){
  1204.             var loading = false;
  1205.                 NProgress.start();
  1206.                     loading = true;
  1207.                     $('#coin').removeClass();
  1208.                         NProgress.inc()
  1209.                         NProgress.set(0.6)
  1210.                         $.post("duel-details.php", {flipResult: flipResult}, function(data){
  1211.                             setTimeout(function(){
  1212.                                 if(flipResult <= 50){
  1213.                                     $('#coin').addClass('heads');
  1214.                                     setTimeout(function(){
  1215.                                         $("#winner").slideDown(1400);
  1216.                                         if(winner_id == myid){
  1217.                                             success("Win", "Congratulations you have won the duel! You can now accept your items!", "fa fa-check");
  1218.                                         }else if(myid == creator_id || myid == joiner_id){
  1219.                                             error("Lose", "You lost the round! Better luck next time!", "fa fa-times");
  1220.                                         }      
  1221.                                         $('#Player1Img').addClass('winner');                                       
  1222.                                         $('#RightSide').addClass('lost');                          
  1223.                                     }, 2800);
  1224.                                 }else{
  1225.                                     $('#coin').addClass('tails');
  1226.                                     setTimeout(function(){
  1227.                                         $("#winner").slideDown(1400);
  1228.                                         if(winner_id == myid){
  1229.                                             success("Win", "Congratulations you have won the duel! You can now accept your items!", "fa fa-check");
  1230.                                         }else if(myid == creator_id || myid == joiner_id){
  1231.                                             error("Lose", "You lost the round! Better luck next time!", "fa fa-times");
  1232.                                         }              
  1233.                                         $('#Player2Img').addClass('winner');                                       
  1234.                                         $('#LeftSide').addClass('lost');                                       
  1235.                                     }, 2800);
  1236.                                 }
  1237.                             }, 300);
  1238.                         });    
  1239.             NProgress.done();
  1240.         }
  1241.  
  1242.         function acceptItems(game_id) {
  1243.             NProgress.start();
  1244.             document.getElementById("acceptButton").innerHTML = "<i class='fa fa-spinner fa-spin fa-1x fa-fw'></i>";   
  1245.             $.post("duel-details.php?game_id="+game_id, {game_id:game_id}, function(data){                     
  1246.                 success("Success", "You have successfully accepted your win!", "fa fa-check"); 
  1247.                 document.getElementById("acceptButton").innerHTML = "<i class='fa fa-check' aria-hidden='true'></i>";      
  1248.             });
  1249.             NProgress.done();
  1250.         }; 
  1251.  
  1252.         function acceptItemsAsAdmin(game_id) { 
  1253.             var adminAccept = true;
  1254.             document.getElementById("AdminAccept").innerHTML = "<i class='fa fa-spinner fa-spin fa-1x fa-fw'></i>";
  1255.             $.post("duel-details.php?game_id="+game_id, {game_id:game_id,adminAccept:adminAccept}, function(data){                     
  1256.                 success("Success", "You have successfully accepted the win for a user!", "fa fa-check");   
  1257.                 document.getElementById("AdminAccept").innerHTML = "<i class='fa fa-check' aria-hidden='true'></i>";           
  1258.             });
  1259.         };
  1260.        
  1261.        
  1262.           (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  1263.           (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  1264.           m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  1265.           })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
  1266.  
  1267.           ga('create', 'UA-96562797-1', 'auto');
  1268.           ga('send', 'pageview');
Add Comment
Please, Sign In to add comment