function sukses() { var status = ""; url = "https://www.playtime.zone/game/favourite/"; if (status == "") { swal({ title: "You must login", text: "To add favorite you must login", type: "error", showCancelButton: true, confirmButtonText: "Login", closeOnConfirm: false, }, function(isConfirm) { if (isConfirm) { window.location.replace("https://www.playtime.zone/login"); } }); } else { swal({ title: "Favorite Added", text: "Game added to your favorite list", type: "success" }, function() { window.location.replace(url); }); } }; function suksesUnFav() { url = "https://www.playtime.zone/game/unfavourite/"; swal({ title: "Favorite Removed", text: "Game removed from your favorite list", type: "success" }, function() { window.location.replace(url); }); } $(document).ready(function() { $("#submitRating").hide(); }); $("#setRate").click(function() { $("#submitRating").show(); }); $(function() { var $rateYo = $("#setRate").rateYo(); $("#submitRating").click(function() { var ratingScore = $rateYo.rateYo("rating"); var currentUrl = "https://www.playtime.zone/game/favourite/"; $.ajax({ type: "POST", url: "https://www.playtime.zone/game/rating", data: { gameId: "", rating: ratingScore }, dataType: "JSON ", success: function() { $("#rtng").hide(); swal({ title: "Rating Succeed", text: "Thanks for rating the game", type: "success" }, function(isConfirm) { window.location.replace(currentUrl); }); }, error: function() { console.log("error"); } }); }); });