Guest User

Untitled

a guest
Jan 16th, 2014
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var erepublik = erepublik || {};
  2. $j.extend(erepublik, obj = {
  3.     wheel_of_fortune: {
  4.         init: function (a) {
  5.             $j(".wof_pop .wof_title").sprite({
  6.                 fps: 8,
  7.                 no_of_frames: 16,
  8.                 play_frames: 16
  9.             }), a.error ? "NO_GOLD" == a.message ? erepublik.wheel_of_fortune.showMessageBox("Insufficient Gold.") : erepublik.wheel_of_fortune.showMessageBox("Error! Please refresh if you believe this is not supposed to happen.") : $j(".wof_pop").removeClass("locked"), erepublik.wheel_of_fortune.checkFreeSpin(a), $j(".wof_pop .jackpot_stars").attr("class", "jackpot_stars star_" + a.progress.jackpot);
  10.             for (var b = 1; 3 >= b; b++) {
  11.                 var c = a.prizes.jackpot[b].tooltip;
  12.                 $j(".wof_pop .jackpot_prizes li.prize_" + b).attr("title", c).tipsy()
  13.             }
  14.             for (var b = 1; 8 >= b; b++) {
  15.                 var c = a.prizes.prizes[b].tooltip;
  16.                 $j(".wof_pop .wof_wheel .wof_prize_tooltip.reward_" + b).attr("title", c).tipsy()
  17.             }
  18.         },
  19.         spin: function (a, b, c) {
  20.             if (c.error) return "NO_GOLD" == c.message ? erepublik.wheel_of_fortune.showMessageBox("Insufficient Gold.") : erepublik.wheel_of_fortune.showMessageBox("Error! Please refresh if you believe this wasn't supposed to happen."), !1;
  21.             var d, e, f, g, h, i, j;
  22.             d = $j(".wof_pop .wof_wheel"), mediumWheel = $j(".wof_pop .wof_medium_wheel"), smallWheel = $j(".wof_pop .wof_small_wheel"), j = 6, e = new TimelineMax, f = new TimelineMax, g = new TimelineMax, $j(".wof_pop .wof_prize").hasClass("show") && ($j(".wof_pop .wof_prize").removeClass("show animated tada"), $j(".wof_pop .wof_prize_glow").removeClass("show animate"), $j(".wof_pop .wof_prize_title").removeClass("show"), $j(".wof_prize_glow_stars_1, .wof_prize_glow_stars_2").removeClass("show")), h = 1800 + 360 / a * c.result - 360 / a + Math.floor(36 * Math.random() + 5), i = erepublik.wheel_of_fortune.getRotationDegrees(d), $j("#side_bar_gold_account_value").html(c.account), global_wof_build_data.cost = c.cost, erepublik.wheel_of_fortune.showWheelOverlay(), $j(".wof_pop .post_to_feed").hasClass("animated") && ($j(".wof_pop .post_to_feed").css("display", "none"), $j(".wof_pop .post_to_feed").removeClass("animated fadeOutLeft fadeInRight")), e.to(d, 0, {
  23.                 rotation: i
  24.             }).to(d, j, {
  25.                 rotation: h,
  26.                 ease: Expo.easeOut,
  27.                 onComplete: function () {
  28.                     erepublik.wheel_of_fortune.showPrize(c), $j(".wof_pop").removeClass("locked"), $j(".wof_pop .jackpot_stars").attr("class", "jackpot_stars star_" + c.jackpot), erepublik.wheel_of_fortune.checkFreeSpin(c)
  29.                 }
  30.             }), f.to(smallWheel, 0, {
  31.                 rotation: i
  32.             }).to(smallWheel, j, {
  33.                 rotation: -h,
  34.                 ease: Expo.easeOut
  35.             }), g.to(mediumWheel, 0, {
  36.                 rotation: i
  37.             }).to(mediumWheel, j, {
  38.                 rotation: h,
  39.                 ease: Expo.easeOut
  40.             })
  41.         },
  42.         showPrize: function (a) {
  43.             if (6 == a.result) return erepublik.wheel_of_fortune.showJackpot(a), !1;
  44.             var b = $j(".wof_pop .wof_prize"),
  45.                 c = $j(".wof_pop .wof_prize_title"),
  46.                 d = $j(".wof_pop .wof_prize_glow"),
  47.                 e = $j("#i18n_You_won").val();
  48.             global_wof_build_data && (b.attr({
  49.                 "class": "wof_prize " + global_wof_build_data.prizes.prizes[a.result].type + " show"
  50.             }), d.addClass("show"), $j(".wof_prize_glow_stars_1, .wof_prize_glow_stars_2").addClass("show"), c.html(e + ": " + global_wof_build_data.prizes.prizes[a.result].tooltip).addClass("show"), setTimeout(function () {
  51.                 b.addClass("animated tada")
  52.             }, 100), setTimeout(function () {
  53.                 d.addClass("animate")
  54.             }, 300))
  55.         },
  56.         showJackpot: function (a) {
  57.             var b = $j(".wof_pop .wof_prize"),
  58.                 c = $j(".wof_pop .wof_prize_title"),
  59.                 d = $j(".wof_pop .wof_prize_glow"),
  60.                 e = $j("#i18n_You_won").val();
  61.             3 == a.jackpot && ($j(".wof_pop .post_to_feed").css("display", "table"), setTimeout(function () {
  62.                 $j(".wof_pop .post_to_feed").addClass("animated fadeInRight")
  63.             }, 100)), global_wof_build_data && (b.attr({
  64.                 "class": "wof_prize " + global_wof_build_data.prizes.jackpot[a.jackpot].type + " show"
  65.             }), d.addClass("show"), c.html(e + ": " + global_wof_build_data.prizes.jackpot[a.jackpot].tooltip).addClass("show"), setTimeout(function () {
  66.                 b.addClass("animated tada")
  67.             }, 100), setTimeout(function () {
  68.                 d.addClass("animate")
  69.             }, 300))
  70.         },
  71.         getRotationDegrees: function (a) {
  72.             var b = a.css("-webkit-transform") || a.css("-moz-transform") || a.css("-ms-transform") || a.css("-o-transform") || a.css("transform");
  73.             if ("none" !== b) var c = b.split("(")[1].split(")")[0].split(","),
  74.             d = c[0], e = c[1], f = Math.round(Math.atan2(e, d) * (180 / Math.PI));
  75.             else var f = 0;
  76.             return 0 > f ? f += 360 : f
  77.         },
  78.         showWheelOverlay: function () {
  79.             var a = new TimelineMax,
  80.                 b = $j(".wof_pop .wof_overlay");
  81.             b.css("display", "block"), a.to(b, .5, {
  82.                 delay: 6,
  83.                 opacity: 1
  84.             }).to(b, 2, {
  85.                 delay: .85,
  86.                 opacity: 0,
  87.                 onComplete: function () {
  88.                     b.css("display", "none")
  89.                 }
  90.             })
  91.         },
  92.         checkFreeSpin: function (a) {
  93.             var b = $j(".powerspin_sidebar");
  94.             if ("undefined" == typeof a.prizes) var c = a.free_spin;
  95.             else var c = a.progress.free_spin; if (parseInt(c, 10) > 0) {
  96.                 b.hasClass("show_free") || b.addClass("show_free");
  97.                 var d = new TimelineMax,
  98.                     e = $j(".wof_pop .wof_btn"),
  99.                     f = $j("#i18n_Free_Spin").attr("val");
  100.                 $j(".wof_pop .wof_btn .spin_cost span").html(f), "gold" === e.data("last-spin") ? d.to(e, .5, {
  101.                     rotationY: 180,
  102.                     onComplete: function () {
  103.                         setTimeout(function () {
  104.                             e.addClass("free_spin")
  105.                         }, 150)
  106.                     }
  107.                 }).to(e, .5, {
  108.                     rotationY: 360
  109.                 }).to(e, 0, {
  110.                     delay: 1,
  111.                     rotationY: 0
  112.                 }) : e.addClass("free_spin"), e.data("last-spin", "free")
  113.             } else {
  114.                 b.removeClass("show_free"), $j(".wof_pop .wof_btn .spin_cost em").html(a.cost), $j(".wof_pop .wof_btn .spin_cost span").html("Gold");
  115.                 var d = new TimelineMax,
  116.                     e = $j(".wof_pop .wof_btn");
  117.                 "free" === e.data("last-spin") ? d.to(e, .5, {
  118.                     rotationY: 180,
  119.                     onComplete: function () {
  120.                         setTimeout(function () {
  121.                             $j(".wof_pop .wof_btn").removeClass("free_spin")
  122.                         }, 150)
  123.                     }
  124.                 }).to(e, .5, {
  125.                     rotationY: 360
  126.                 }).to(e, 0, {
  127.                     delay: 1,
  128.                     rotationY: 0
  129.                 }) : $j(".wof_pop .wof_btn").removeClass("free_spin"), e.data("last-spin", "gold")
  130.             }
  131.         },
  132.         showMessageBox: function (a) {
  133.             $j(".wof_pop .message_box").addClass("show").find("span").html(a)
  134.         },
  135.         hideMessageBox: function () {
  136.             $j(".wof_pop .message_box").removeClass("show")
  137.         }
  138.     }
  139. }), $j(function () {
  140.     $j("#launch_wof").click(function () {
  141.         var a = "http://" + erepublik.settings.hostname + "/" + erepublik.settings.culture + "/main/wheeloffortune-build",
  142.             b = $j(".wof_pop #wof_token").val();
  143.         $j(".wof_pop .message_box").click(function () {
  144.             erepublik.wheel_of_fortune.hideMessageBox()
  145.         }), $j(".wof_pop").lightbox_me({
  146.             centered: !0,
  147.             closeClick: !1,
  148.             onLoad: function () {
  149.                 $j.post(a, {
  150.                     _token: b
  151.                 }, function (a) {
  152.                     global_wof_build_data = a, erepublik.wheel_of_fortune.init(a)
  153.                 })
  154.             }
  155.         })
  156.     }), $j(".wof_btn").click(function () {
  157.         var a = "http://" + erepublik.settings.hostname + "/" + erepublik.settings.culture + "/main/wheeloffortune-spin",
  158.             b = $j(".wof_pop #wof_token").val(),
  159.             c = $j(".wof_pop").hasClass("locked");
  160.         c || $j.post(a, {
  161.             _token: b,
  162.             _currentCost: global_wof_build_data.cost
  163.         }, function (a) {
  164.             erepublik.wheel_of_fortune.spin(8, 3, a), $j(".wof_pop").addClass("locked")
  165.         })
  166.     }), $j(".wof_pop .post_to_feed").click(function () {
  167.         var a = $j(".wof_pop .post_to_feed");
  168.         $j.post("/en/main/wall-post/automatic/", {
  169.             _token: $j("#_token").val(),
  170.             message: "power_spin"
  171.         }, function () {}, "json"), a.hasClass("animated") && (a.addClass("fadeOutLeft"), setTimeout(function () {
  172.             a.css("display", "none"), a.removeClass("animated fadeInRight fadeOutLeft")
  173.         }, 500))
  174.     })
  175. });
Advertisement
Add Comment
Please, Sign In to add comment