Advertisement
Rapptz

Untitled

Jun 20th, 2012
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 13.33 KB | None | 0 0
  1. if ($.fn.itemRotator = function (n) {
  2.     var i = {
  3.         speed : 600
  4.     },
  5.     t = $.extend(i, n);
  6.     this.each(function (i) {
  7.         function l() {
  8.             r < c - 1 ? r++ : r = 0,
  9.             f || e.clearQueue().animate({
  10.                 top :  - (r * u)
  11.             }, t.speed)
  12.         }
  13.         function a() {
  14.             y = setInterval(l, 3e3)
  15.         }
  16.         var o = $(this),
  17.         s = $(".item-icons div", o),
  18.         e = o.find(".item-icons"),
  19.         c = s.length,
  20.         u = s.height(),
  21.         v = c * u,
  22.         p = [],
  23.         r = 1,
  24.         y,
  25.         f = !1,
  26.         h = null;
  27.         $(".item-icons", o).css("width", v),
  28.         $(".item-box").eq(i).mouseenter(function () {
  29.             f = !0
  30.         }).mouseleave(function () {
  31.             f = !1
  32.         }).find("li").mouseenter(function () {
  33.             var n = $(this).data("idx");
  34.             h = e.children('[data-idx="{0}"]'.format(n)),
  35.             e.css({
  36.                 top :  - (h.index() * u)
  37.             })
  38.         }),
  39.         startTime = n.speed * i * 2,
  40.         setTimeout(function () {
  41.             a()
  42.         }, startTime)
  43.     })
  44. }, $.fn.tabs = function () {
  45.     var n = this.filter(".active");
  46.     return $(".content-holder.dn").hide().removeClass("dn"),
  47.     this.click(function () {
  48.         var i = $(this);
  49.         i.addClass("active"),
  50.         n != null && (n.removeClass("active"), $("#" + n.data("tab")).hide()),
  51.         $("#" + i.data("tab")).show(),
  52.         n = i
  53.     })
  54. }, gachapon === undefined) {
  55.     function popupShow(n, t) {
  56.         var i = nexon.gnt.popupShow(),
  57.         r;
  58.         return i.wrap.addClass(n),
  59.         i.center.html($("#" + n).html()),
  60.         r = i.center.outerHeight(!0) + 30,
  61.         $(window).height() > r && (i.wrap.addClass("popupCenter"), i.wrap.css("margin-top",  - (r / 2))),
  62.         typeof t == "function" && (nexon.gnt.hideCallback = t),
  63.         i
  64.     }
  65.     var gachapon = function () {
  66.         this.init()
  67.     };
  68.     gachapon.prototype = {
  69.         init : function () {
  70.             this.spin_types = [],
  71.             this.is_service_on = null,
  72.             this.event_no = null,
  73.             this.spin_cnt = 0,
  74.             this.spinItems = [],
  75.             this.spin_use_id = null,
  76.             this.spinning = !1,
  77.             this.prizeItems = null,
  78.             this.nx = null,
  79.             this.opts = {
  80.                 prepaid : ".nx_prepaid",
  81.                 credit : ".nx_credit"
  82.             },
  83.             this.apicall("ServiceInfo", function (n) {
  84.                 this.is_service_on = n.is_service_on,
  85.                 this.event_no = n.event_no,
  86.                 this.updateSpinBtn()
  87.             }),
  88.             this.apicall("GetSpinItem", function (n) {
  89.                 var f,
  90.                 r,
  91.                 i,
  92.                 u;
  93.                 for (this.spin_types = n, r = 0; r < n.length; r++)
  94.                     i = n[r], typeof this.spinItems[i.item_type - 1] != "object" && (this.spinItems[i.item_type - 1] = []), this.spinItems[i.item_type - 1].push(i);
  95.                 for (f = $(".currentSpins select"), r = 0; r < this.spinItems[0].length; r++)
  96.                     i = this.spinItems[0][r], $('<option value="{0}" data-price="{2}">{1}</option>'.format(i.spin_item_id, i.quantity, i.price)).appendTo(f);
  97.                 u = t.spinItems[1][0].price,
  98.                 $(".spin2_price").text(u.digits())
  99.             }),
  100.             this.apicall("GetItemList", function (n) {
  101.                 this.prizeItems = n
  102.             });
  103.             var t = this;
  104.             $(function () {
  105.                 for (t.pager = new pageHelper($("#history_pager"), {
  106.                             prev5Btn : null,
  107.                             next5Btn : null
  108.                         }), t.dom = {
  109.                         congrats : $(".congrats"),
  110.                         animations : $("#reels .reel-animation"),
  111.                         multipliers : $("#reels .multiplier"),
  112.                         slots : $("#reels .reel-strip"),
  113.                         prizes : $("#prize-codes"),
  114.                         spin_more : $("#spend-more"),
  115.                         not_spin_more : $("#buy-more"),
  116.                         spin_more_pay_type : $("#spend-more input:radio[name=payment-type]")
  117.                     }, n = 0; n < 3; n++) {
  118.                     var i = t.dom.slots.eq(n);
  119.                     i.children().clone().appendTo(i)
  120.                 }
  121.                 t.dom.spin_more.find(".btn-close").click(function () {
  122.                     t.showSpinMore(!1)
  123.                 }),
  124.                 t.dom.spin_more.find("#spend-btn").click(function (n) {
  125.                     n.preventDefault();
  126.                     var i = t.dom.spin_more_pay_type.filter(":checked").val();
  127.                     t.runSpin2(i == "prepaid")
  128.                 }),
  129.                 t.dom.spin_more_pay_type.click(function () {
  130.                     var u = $(this).val(),
  131.                     r = $(this).parents(".nx-total").first(),
  132.                     i = t.spinItems[1][0].price,
  133.                     f = r.find(".spin2_price");
  134.                     oPrice = f.filter("." + u),
  135.                     oPrice.text(i.digits()),
  136.                     f.not(oPrice).empty(),
  137.                     r.find(".remain_prepaid").text((t.nx.prepaid - (u == "prepaid" ? i : 0)).digits()),
  138.                     r.find(".remain_credit").text((t.nx.credit - (u == "credit" ? i : 0)).digits())
  139.                 }),
  140.                 t.dom.prizes.find("ul > li p").text("Coupon Code")
  141.             }),
  142.             this.updateSpinCnt(),
  143.             this.updateNXBalance()
  144.         },
  145.         apicall : function (n, t, i) {
  146.             typeof n == "string" && (n = {
  147.                     api : n
  148.                 });
  149.             var r = this;
  150.             $.ajax({
  151.                 type : "POST",
  152.                 url : "API.asmx/" + n.api,
  153.                 dataType : "json",
  154.                 data : n.data,
  155.                 contentType : "application/json; charset=utf-8",
  156.                 success : function (u) {
  157.                     var f = typeof u.d == "string" ? eval("(" + u.d + ")") : u.d;
  158.                     if (f.code == 0) {
  159.                         typeof t == "function" && t.call(r, f.data);
  160.                         return
  161.                     }
  162.                     typeof i == "function" && i.call(r, f) || $(function () {
  163.                         var i = "",
  164.                         t;
  165.                         switch (f.code) {
  166.                         case 10:
  167.                             i = "Your log-in session has been expired! Please log-in again.";
  168.                             break;
  169.                         case 20:
  170.                             popupShow("noCharacter").center.find(".gnt_button").not(".gnt_goto").click(function (n) {
  171.                                 n.preventDefault(),
  172.                                 nexon.play("SVG011"),
  173.                                 nexon.gnt.popupHide()
  174.                             });
  175.                             return
  176.                         }
  177.                         if (i != "") {
  178.                             nexon.gnt.popupError(i);
  179.                             return
  180.                         }
  181.                         t = "";
  182.                         switch (n.api) {
  183.                         case "GetNXBalance":
  184.                             t = "B";
  185.                             break;
  186.                         case "GetSpinCount":
  187.                             t = "C";
  188.                             break;
  189.                         case "ServiceInfo":
  190.                             t = "S";
  191.                             break;
  192.                         case "GetItemList":
  193.                             t = "I";
  194.                             break;
  195.                         case "RunSpin":
  196.                             t = "R";
  197.                             break;
  198.                         case "PurchaseSpin":
  199.                             t = "P"
  200.                         }
  201.                         nexon.gnt.popupError("Error {0}: Oops! Something has gone wrong. Please try refreshing your browser. If the issue continues, please submit a ticket with the error number.".format(t + f.code))
  202.                     })
  203.                 },
  204.                 fail : function (n) {
  205.                     nexon.gnt.popupError(n)
  206.                 }
  207.             })
  208.         },
  209.         updateNXBalance : function () {
  210.             nexon.sso.isLoggedIn && this.apicall("GetNXBalance", function (n) {
  211.                 this.nx = n,
  212.                 $(this.opts.credit).text(n.credit.digits()),
  213.                 $(this.opts.prepaid).text(n.prepaid.digits())
  214.             })
  215.         },
  216.         updateSpinBtn : function () {},
  217.         updateSpinCnt : function () {
  218.             if (!nexon.sso.isLoggedIn) {
  219.                 $(".spins-left").text(0);
  220.                 return
  221.             }
  222.             this.apicall("GetSpinCount", function (n) {
  223.                 $(".spins-left").text(n),
  224.                 this.spin_cnt = n,
  225.                 this.updateSpinBtn()
  226.             })
  227.         },
  228.         purchaseSpin : function (n, t, i, r) {
  229.             nexon.sso.isLoggedIn && n !== undefined && ($("#gnt_popup_center").startWaiting(), t === undefined && (t = !1), this.apicall({
  230.                     api : "purchaseSpin",
  231.                     data : '{"item_idx": "{0}", "IsPrepaid": {1}}'.format(n, t)
  232.                 }, function (n) {
  233.                     $("#gnt_popup_center").stopWaiting(),
  234.                     typeof i == "function" && i.call(this, n),
  235.                     this.updateSpinCnt(),
  236.                     this.updateNXBalance()
  237.                 }, function (n) {
  238.                     $("#gnt_popup_center").stopWaiting(),
  239.                     typeof r == "function" && r.call(this);
  240.                     switch (n.code) {
  241.                     case 3:
  242.                         return nexon.gnt.popupError("You don't have enought NX"),
  243.                         !0;
  244.                     case 5:
  245.                         return popupShow("level30"),
  246.                         !0
  247.                     }
  248.                 }))
  249.         },
  250.         useSpin : function (n, t, i) {
  251.             nexon.sso.isLoggedIn && (t === undefined && (t = ""), this.apicall({
  252.                     api : "RunSpin",
  253.                     data : '{"spin_type": {0}, "spin_use_id": "{1}"}'.format(n, t)
  254.                 }, function (n) {
  255.                     this.updateSpinBtn(),
  256.                     typeof i == "function" && i.call(this, n)
  257.                 }, function (n) {
  258.                     switch (n.code) {
  259.                     case 1001:
  260.                         return nexon.gnt.popupError("You nave no spin now."),
  261.                         !0
  262.                     }
  263.                 }))
  264.         },
  265.         runSpin1 : function () {
  266.             var t,
  267.             n;
  268.             if (!this.spinning) {
  269.                 if (this.spin_cnt == 0) {
  270.                     $("#more-spins-btn").click();
  271.                     return
  272.                 }
  273.                 this.spinning = !0,
  274.                 t = +new Date,
  275.                 this.dom.congrats.hide(),
  276.                 this.dom.multipliers.hide(),
  277.                 this.dom.prizes.find("ul > li:nth-child(2)").remove(),
  278.                 this.dom.prizes.find("ul > li p").text("Coupon Code"),
  279.                 this.spin_use_id == null,
  280.                 this.dom.slots.animate({
  281.                     top : "-=1000"
  282.                 }, 1e3, "easeInQuad").animate({
  283.                     top : "-=6500"
  284.                 }, 1e3, "linear"),
  285.                 n = this,
  286.                 this.useSpin(1, "", function (i) {
  287.                     var r = +new Date - t;
  288.                     this.spin_use_id = i.spin_use_id,
  289.                     setTimeout(function () {
  290.                         n.selectPrize(0, i.prizes[2]),
  291.                         setTimeout(function () {
  292.                             n.selectPrize(2, i.prizes[1]),
  293.                             setTimeout(function () {
  294.                                 n.selectPrize(1, i.prizes[0], function () {
  295.                                     n.dom.congrats.show(),
  296.                                     n.updateSpinCnt(),
  297.                                     n.showSpinMore(!0),
  298.                                     n.showHistory(),
  299.                                     n.spinning = !1
  300.                                 })
  301.                             }, 700)
  302.                         }, 700)
  303.                     }, 500 - r)
  304.                 }, function (n) {
  305.                     switch (n.code) {
  306.                     case 1001:
  307.                         return nexon.gnt.popupError("You don't have enough spin now."),
  308.                         !0
  309.                     }
  310.                 })
  311.             }
  312.         },
  313.         selectPrize : function (n, t, i) {
  314.             var r = 171,
  315.             e = this.dom.slots.eq(n),
  316.             f = e.children('[data-idx="{0}"]'.format(t.item_idx)),
  317.             u = f.eq(1).index();
  318.             e.stop().clearQueue().css({
  319.                 top :  - (r * (u - 15))
  320.             }).animate({
  321.                 top :  - (r * u)
  322.             }, 2e3, "easeOutQuad", function () {
  323.                 window.gachapon.dom.prizes.find("ul:eq({0}) > li > p".format(n)).text(t.coupon_code),
  324.                 $(this).css({
  325.                     top :  - (r * f.eq(0).index()),
  326.                     position : "relative",
  327.                     "z-index" : 10
  328.                 }),
  329.                 typeof i == "function" && i.call(this)
  330.             }),
  331.             this.dom.animations.eq(n).hide()
  332.         },
  333.         showSpinMore : function (n) {
  334.             var t,
  335.             i,
  336.             u,
  337.             r;
  338.             n ? (t = this.spinItems[1][0].price, i = this.dom.spin_more, this.updateNXBalance(), this.nx.prepaid < t && this.nx.credit < t ? i = $("#buy-more") : (this.dom.spin_more_pay_type.removeAttr("disable"), selRadio = this.dom.spin_more_pay_type.eq(0), (this.nx.prepaid < t || this.nx.credit < t) && (disable = this.dom.spin_more_pay_type.filter("[value={0}]".format(this.nx.prepaid < t ? "prepaid" : "credit")).attr("disable", "disable"), selRadio = this.dom.spin_more_pay_type.not(disable)), selRadio.click()), i.css("opacity", 0).slideDown("slow").animate({
  339.                     opacity : 1
  340.                 }, {
  341.                     queue : !1,
  342.                     duration : "slow"
  343.                 }), u = i.offset().top + 260, r = $(window).height(), $(document).scrollTop() + r < u && $("body,html").animate({
  344.                     scrollTop : u - r
  345.                 }, "slow")) : this.dom.spin_more.slideUp("slow").animate({
  346.                 opacity : 0
  347.             }, {
  348.                 queue : !1,
  349.                 duration : "slow"
  350.             })
  351.         },
  352.         runSpin2 : function (n) {
  353.             var u,
  354.             i,
  355.             t,
  356.             r;
  357.             if (this.spin_use_id != null && !this.spinning) {
  358.                 if (this.spin_use_id == "used") {
  359.                     nexon.gnt.popupError("you can use this change at once.");
  360.                     return
  361.                 }
  362.                 this.spinning = !0,
  363.                 u = +new Date,
  364.                 i = this,
  365.                 this.dom.multipliers.eq(0).show(),
  366.                 t = 0,
  367.                 r = setInterval(function () {
  368.                         i.dom.multipliers.eq(t).hide(),
  369.                         t++,
  370.                         t %= 3,
  371.                         i.dom.multipliers.eq(t).show()
  372.                     }, 150),
  373.                 this.dom.spin_more.startWaiting(),
  374.                 this.purchaseSpin(this.spinItems[1][0].spin_item_id, n, function () {
  375.                     this.useSpin(2, this.spin_use_id, function (n) {
  376.                         this.spin_use_id = "used";
  377.                         var i = +new Date - u,
  378.                         t = this;
  379.                         setTimeout(function () {
  380.                             t.dom.spin_more.stopWaiting(),
  381.                             clearInterval(r);
  382.                             var u = n.prizes[0].GroupID,
  383.                             f = n.prizes[0].coupon_code,
  384.                             i = (u == "A" ? 2 : u == "B" ? 3 : 1) - 1;
  385.                             t.dom.multipliers.hide().eq(i).show(),
  386.                             $("<li><p>{0}</p></li>".format(f)).appendTo(t.dom.prizes.children().eq(i)),
  387.                             t.showSpinMore(!1),
  388.                             t.showHistory(),
  389.                             t.spinning = !1
  390.                         }, 1e3 - i)
  391.                     }, function () {
  392.                         this.spinning = !1,
  393.                         this.dom.spin_more.stopWaiting()
  394.                     })
  395.                 }, function () {
  396.                     this.spinning = !1,
  397.                     this.dom.spin_more.stopWaiting()
  398.                 })
  399.             }
  400.         },
  401.         showHistory : function (n, t) {
  402.             var r = $("#coupon-history"),
  403.             i;
  404.             if (!r.is(":hidden")) {
  405.                 if (i = r.find("tbody"), !nexon.sso.isLoggedIn) {
  406.                     $('<tr><td colspan="4" class="c-text" style="padding:10px">Log in to see this information</td></tr>').appendTo(i.empty());
  407.                     return
  408.                 }
  409.                 r.startWaiting(),
  410.                 n === undefined && (n = 1),
  411.                 t === undefined && (t = 10),
  412.                 this.apicall({
  413.                     api : "getHistory",
  414.                     data : '{ "page": {0}, "list_cnt": {1}}'.format(n, t)
  415.                 }, function (t) {
  416.                     var f,
  417.                     u;
  418.                     for (i.empty(), f = 0; f < t.list.length; f++)
  419.                         u = t.list[f], $('<tr data-img="{4}"><td class="adl-pad">{0}</td><td class="c-text">{1}</td><td class="c-text">{2}</td><td class="c-text">{3}</td></tr>'.format(u.received_date.GetDate().format("mm/dd/yyyy"), u.Item_name, u.coupon_code, u.RedeemBy, "http://nxcache.nexon.net/maplestory/shop/gachapon/season/{0}/{1}/{2}.png".format(this.event_no, u.GroupID, u.Item_name))).appendTo(i);
  420.                     i.children(":even").addClass("add-bg2"),
  421.                     this.pager.update(t.total_cnt, n).find("a").click(function (n) {
  422.                         n.preventDefault();
  423.                         var t = $(this).data("page");
  424.                         window.gachapon.showHistory(t)
  425.                     }),
  426.                     $("#coupon-history tbody > tr").balloon({
  427.                         position : "left",
  428.                         contents : function () {
  429.                             var n = $(this).data("img");
  430.                             return '<img src="{0}" />'.format(n)
  431.                         },
  432.                         minLifetime : 0,
  433.                         showDuration : 0,
  434.                         hideDuration : 0
  435.                     }),
  436.                     r.stopWaiting()
  437.                 })
  438.             }
  439.         }
  440.     },
  441.     window.gachapon = new gachapon
  442. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement