Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var erepublik = erepublik || {};
- $j.extend(erepublik, obj = {
- wheel_of_fortune: {
- init: function (a) {
- $j(".wof_pop .wof_title").sprite({
- fps: 8,
- no_of_frames: 16,
- play_frames: 16
- }), 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);
- for (var b = 1; 3 >= b; b++) {
- var c = a.prizes.jackpot[b].tooltip;
- $j(".wof_pop .jackpot_prizes li.prize_" + b).attr("title", c).tipsy()
- }
- for (var b = 1; 8 >= b; b++) {
- var c = a.prizes.prizes[b].tooltip;
- $j(".wof_pop .wof_wheel .wof_prize_tooltip.reward_" + b).attr("title", c).tipsy()
- }
- },
- spin: function (a, b, c) {
- 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;
- var d, e, f, g, h, i, j;
- 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, {
- rotation: i
- }).to(d, j, {
- rotation: h,
- ease: Expo.easeOut,
- onComplete: function () {
- 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)
- }
- }), f.to(smallWheel, 0, {
- rotation: i
- }).to(smallWheel, j, {
- rotation: -h,
- ease: Expo.easeOut
- }), g.to(mediumWheel, 0, {
- rotation: i
- }).to(mediumWheel, j, {
- rotation: h,
- ease: Expo.easeOut
- })
- },
- showPrize: function (a) {
- if (6 == a.result) return erepublik.wheel_of_fortune.showJackpot(a), !1;
- var b = $j(".wof_pop .wof_prize"),
- c = $j(".wof_pop .wof_prize_title"),
- d = $j(".wof_pop .wof_prize_glow"),
- e = $j("#i18n_You_won").val();
- global_wof_build_data && (b.attr({
- "class": "wof_prize " + global_wof_build_data.prizes.prizes[a.result].type + " show"
- }), 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 () {
- b.addClass("animated tada")
- }, 100), setTimeout(function () {
- d.addClass("animate")
- }, 300))
- },
- showJackpot: function (a) {
- var b = $j(".wof_pop .wof_prize"),
- c = $j(".wof_pop .wof_prize_title"),
- d = $j(".wof_pop .wof_prize_glow"),
- e = $j("#i18n_You_won").val();
- 3 == a.jackpot && ($j(".wof_pop .post_to_feed").css("display", "table"), setTimeout(function () {
- $j(".wof_pop .post_to_feed").addClass("animated fadeInRight")
- }, 100)), global_wof_build_data && (b.attr({
- "class": "wof_prize " + global_wof_build_data.prizes.jackpot[a.jackpot].type + " show"
- }), d.addClass("show"), c.html(e + ": " + global_wof_build_data.prizes.jackpot[a.jackpot].tooltip).addClass("show"), setTimeout(function () {
- b.addClass("animated tada")
- }, 100), setTimeout(function () {
- d.addClass("animate")
- }, 300))
- },
- getRotationDegrees: function (a) {
- var b = a.css("-webkit-transform") || a.css("-moz-transform") || a.css("-ms-transform") || a.css("-o-transform") || a.css("transform");
- if ("none" !== b) var c = b.split("(")[1].split(")")[0].split(","),
- d = c[0], e = c[1], f = Math.round(Math.atan2(e, d) * (180 / Math.PI));
- else var f = 0;
- return 0 > f ? f += 360 : f
- },
- showWheelOverlay: function () {
- var a = new TimelineMax,
- b = $j(".wof_pop .wof_overlay");
- b.css("display", "block"), a.to(b, .5, {
- delay: 6,
- opacity: 1
- }).to(b, 2, {
- delay: .85,
- opacity: 0,
- onComplete: function () {
- b.css("display", "none")
- }
- })
- },
- checkFreeSpin: function (a) {
- var b = $j(".powerspin_sidebar");
- if ("undefined" == typeof a.prizes) var c = a.free_spin;
- else var c = a.progress.free_spin; if (parseInt(c, 10) > 0) {
- b.hasClass("show_free") || b.addClass("show_free");
- var d = new TimelineMax,
- e = $j(".wof_pop .wof_btn"),
- f = $j("#i18n_Free_Spin").attr("val");
- $j(".wof_pop .wof_btn .spin_cost span").html(f), "gold" === e.data("last-spin") ? d.to(e, .5, {
- rotationY: 180,
- onComplete: function () {
- setTimeout(function () {
- e.addClass("free_spin")
- }, 150)
- }
- }).to(e, .5, {
- rotationY: 360
- }).to(e, 0, {
- delay: 1,
- rotationY: 0
- }) : e.addClass("free_spin"), e.data("last-spin", "free")
- } else {
- 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");
- var d = new TimelineMax,
- e = $j(".wof_pop .wof_btn");
- "free" === e.data("last-spin") ? d.to(e, .5, {
- rotationY: 180,
- onComplete: function () {
- setTimeout(function () {
- $j(".wof_pop .wof_btn").removeClass("free_spin")
- }, 150)
- }
- }).to(e, .5, {
- rotationY: 360
- }).to(e, 0, {
- delay: 1,
- rotationY: 0
- }) : $j(".wof_pop .wof_btn").removeClass("free_spin"), e.data("last-spin", "gold")
- }
- },
- showMessageBox: function (a) {
- $j(".wof_pop .message_box").addClass("show").find("span").html(a)
- },
- hideMessageBox: function () {
- $j(".wof_pop .message_box").removeClass("show")
- }
- }
- }), $j(function () {
- $j("#launch_wof").click(function () {
- var a = "http://" + erepublik.settings.hostname + "/" + erepublik.settings.culture + "/main/wheeloffortune-build",
- b = $j(".wof_pop #wof_token").val();
- $j(".wof_pop .message_box").click(function () {
- erepublik.wheel_of_fortune.hideMessageBox()
- }), $j(".wof_pop").lightbox_me({
- centered: !0,
- closeClick: !1,
- onLoad: function () {
- $j.post(a, {
- _token: b
- }, function (a) {
- global_wof_build_data = a, erepublik.wheel_of_fortune.init(a)
- })
- }
- })
- }), $j(".wof_btn").click(function () {
- var a = "http://" + erepublik.settings.hostname + "/" + erepublik.settings.culture + "/main/wheeloffortune-spin",
- b = $j(".wof_pop #wof_token").val(),
- c = $j(".wof_pop").hasClass("locked");
- c || $j.post(a, {
- _token: b,
- _currentCost: global_wof_build_data.cost
- }, function (a) {
- erepublik.wheel_of_fortune.spin(8, 3, a), $j(".wof_pop").addClass("locked")
- })
- }), $j(".wof_pop .post_to_feed").click(function () {
- var a = $j(".wof_pop .post_to_feed");
- $j.post("/en/main/wall-post/automatic/", {
- _token: $j("#_token").val(),
- message: "power_spin"
- }, function () {}, "json"), a.hasClass("animated") && (a.addClass("fadeOutLeft"), setTimeout(function () {
- a.css("display", "none"), a.removeClass("animated fadeInRight fadeOutLeft")
- }, 500))
- })
- });
Advertisement
Add Comment
Please, Sign In to add comment