Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if ($.fn.itemRotator = function (n) {
- var i = {
- speed : 600
- },
- t = $.extend(i, n);
- this.each(function (i) {
- function l() {
- r < c - 1 ? r++ : r = 0,
- f || e.clearQueue().animate({
- top : - (r * u)
- }, t.speed)
- }
- function a() {
- y = setInterval(l, 3e3)
- }
- var o = $(this),
- s = $(".item-icons div", o),
- e = o.find(".item-icons"),
- c = s.length,
- u = s.height(),
- v = c * u,
- p = [],
- r = 1,
- y,
- f = !1,
- h = null;
- $(".item-icons", o).css("width", v),
- $(".item-box").eq(i).mouseenter(function () {
- f = !0
- }).mouseleave(function () {
- f = !1
- }).find("li").mouseenter(function () {
- var n = $(this).data("idx");
- h = e.children('[data-idx="{0}"]'.format(n)),
- e.css({
- top : - (h.index() * u)
- })
- }),
- startTime = n.speed * i * 2,
- setTimeout(function () {
- a()
- }, startTime)
- })
- }, $.fn.tabs = function () {
- var n = this.filter(".active");
- return $(".content-holder.dn").hide().removeClass("dn"),
- this.click(function () {
- var i = $(this);
- i.addClass("active"),
- n != null && (n.removeClass("active"), $("#" + n.data("tab")).hide()),
- $("#" + i.data("tab")).show(),
- n = i
- })
- }, gachapon === undefined) {
- function popupShow(n, t) {
- var i = nexon.gnt.popupShow(),
- r;
- return i.wrap.addClass(n),
- i.center.html($("#" + n).html()),
- r = i.center.outerHeight(!0) + 30,
- $(window).height() > r && (i.wrap.addClass("popupCenter"), i.wrap.css("margin-top", - (r / 2))),
- typeof t == "function" && (nexon.gnt.hideCallback = t),
- i
- }
- var gachapon = function () {
- this.init()
- };
- gachapon.prototype = {
- init : function () {
- this.spin_types = [],
- this.is_service_on = null,
- this.event_no = null,
- this.spin_cnt = 0,
- this.spinItems = [],
- this.spin_use_id = null,
- this.spinning = !1,
- this.prizeItems = null,
- this.nx = null,
- this.opts = {
- prepaid : ".nx_prepaid",
- credit : ".nx_credit"
- },
- this.apicall("ServiceInfo", function (n) {
- this.is_service_on = n.is_service_on,
- this.event_no = n.event_no,
- this.updateSpinBtn()
- }),
- this.apicall("GetSpinItem", function (n) {
- var f,
- r,
- i,
- u;
- for (this.spin_types = n, r = 0; r < n.length; r++)
- 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);
- for (f = $(".currentSpins select"), r = 0; r < this.spinItems[0].length; r++)
- i = this.spinItems[0][r], $('<option value="{0}" data-price="{2}">{1}</option>'.format(i.spin_item_id, i.quantity, i.price)).appendTo(f);
- u = t.spinItems[1][0].price,
- $(".spin2_price").text(u.digits())
- }),
- this.apicall("GetItemList", function (n) {
- this.prizeItems = n
- });
- var t = this;
- $(function () {
- for (t.pager = new pageHelper($("#history_pager"), {
- prev5Btn : null,
- next5Btn : null
- }), t.dom = {
- congrats : $(".congrats"),
- animations : $("#reels .reel-animation"),
- multipliers : $("#reels .multiplier"),
- slots : $("#reels .reel-strip"),
- prizes : $("#prize-codes"),
- spin_more : $("#spend-more"),
- not_spin_more : $("#buy-more"),
- spin_more_pay_type : $("#spend-more input:radio[name=payment-type]")
- }, n = 0; n < 3; n++) {
- var i = t.dom.slots.eq(n);
- i.children().clone().appendTo(i)
- }
- t.dom.spin_more.find(".btn-close").click(function () {
- t.showSpinMore(!1)
- }),
- t.dom.spin_more.find("#spend-btn").click(function (n) {
- n.preventDefault();
- var i = t.dom.spin_more_pay_type.filter(":checked").val();
- t.runSpin2(i == "prepaid")
- }),
- t.dom.spin_more_pay_type.click(function () {
- var u = $(this).val(),
- r = $(this).parents(".nx-total").first(),
- i = t.spinItems[1][0].price,
- f = r.find(".spin2_price");
- oPrice = f.filter("." + u),
- oPrice.text(i.digits()),
- f.not(oPrice).empty(),
- r.find(".remain_prepaid").text((t.nx.prepaid - (u == "prepaid" ? i : 0)).digits()),
- r.find(".remain_credit").text((t.nx.credit - (u == "credit" ? i : 0)).digits())
- }),
- t.dom.prizes.find("ul > li p").text("Coupon Code")
- }),
- this.updateSpinCnt(),
- this.updateNXBalance()
- },
- apicall : function (n, t, i) {
- typeof n == "string" && (n = {
- api : n
- });
- var r = this;
- $.ajax({
- type : "POST",
- url : "API.asmx/" + n.api,
- dataType : "json",
- data : n.data,
- contentType : "application/json; charset=utf-8",
- success : function (u) {
- var f = typeof u.d == "string" ? eval("(" + u.d + ")") : u.d;
- if (f.code == 0) {
- typeof t == "function" && t.call(r, f.data);
- return
- }
- typeof i == "function" && i.call(r, f) || $(function () {
- var i = "",
- t;
- switch (f.code) {
- case 10:
- i = "Your log-in session has been expired! Please log-in again.";
- break;
- case 20:
- popupShow("noCharacter").center.find(".gnt_button").not(".gnt_goto").click(function (n) {
- n.preventDefault(),
- nexon.play("SVG011"),
- nexon.gnt.popupHide()
- });
- return
- }
- if (i != "") {
- nexon.gnt.popupError(i);
- return
- }
- t = "";
- switch (n.api) {
- case "GetNXBalance":
- t = "B";
- break;
- case "GetSpinCount":
- t = "C";
- break;
- case "ServiceInfo":
- t = "S";
- break;
- case "GetItemList":
- t = "I";
- break;
- case "RunSpin":
- t = "R";
- break;
- case "PurchaseSpin":
- t = "P"
- }
- 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))
- })
- },
- fail : function (n) {
- nexon.gnt.popupError(n)
- }
- })
- },
- updateNXBalance : function () {
- nexon.sso.isLoggedIn && this.apicall("GetNXBalance", function (n) {
- this.nx = n,
- $(this.opts.credit).text(n.credit.digits()),
- $(this.opts.prepaid).text(n.prepaid.digits())
- })
- },
- updateSpinBtn : function () {},
- updateSpinCnt : function () {
- if (!nexon.sso.isLoggedIn) {
- $(".spins-left").text(0);
- return
- }
- this.apicall("GetSpinCount", function (n) {
- $(".spins-left").text(n),
- this.spin_cnt = n,
- this.updateSpinBtn()
- })
- },
- purchaseSpin : function (n, t, i, r) {
- nexon.sso.isLoggedIn && n !== undefined && ($("#gnt_popup_center").startWaiting(), t === undefined && (t = !1), this.apicall({
- api : "purchaseSpin",
- data : '{"item_idx": "{0}", "IsPrepaid": {1}}'.format(n, t)
- }, function (n) {
- $("#gnt_popup_center").stopWaiting(),
- typeof i == "function" && i.call(this, n),
- this.updateSpinCnt(),
- this.updateNXBalance()
- }, function (n) {
- $("#gnt_popup_center").stopWaiting(),
- typeof r == "function" && r.call(this);
- switch (n.code) {
- case 3:
- return nexon.gnt.popupError("You don't have enought NX"),
- !0;
- case 5:
- return popupShow("level30"),
- !0
- }
- }))
- },
- useSpin : function (n, t, i) {
- nexon.sso.isLoggedIn && (t === undefined && (t = ""), this.apicall({
- api : "RunSpin",
- data : '{"spin_type": {0}, "spin_use_id": "{1}"}'.format(n, t)
- }, function (n) {
- this.updateSpinBtn(),
- typeof i == "function" && i.call(this, n)
- }, function (n) {
- switch (n.code) {
- case 1001:
- return nexon.gnt.popupError("You nave no spin now."),
- !0
- }
- }))
- },
- runSpin1 : function () {
- var t,
- n;
- if (!this.spinning) {
- if (this.spin_cnt == 0) {
- $("#more-spins-btn").click();
- return
- }
- this.spinning = !0,
- t = +new Date,
- this.dom.congrats.hide(),
- this.dom.multipliers.hide(),
- this.dom.prizes.find("ul > li:nth-child(2)").remove(),
- this.dom.prizes.find("ul > li p").text("Coupon Code"),
- this.spin_use_id == null,
- this.dom.slots.animate({
- top : "-=1000"
- }, 1e3, "easeInQuad").animate({
- top : "-=6500"
- }, 1e3, "linear"),
- n = this,
- this.useSpin(1, "", function (i) {
- var r = +new Date - t;
- this.spin_use_id = i.spin_use_id,
- setTimeout(function () {
- n.selectPrize(0, i.prizes[2]),
- setTimeout(function () {
- n.selectPrize(2, i.prizes[1]),
- setTimeout(function () {
- n.selectPrize(1, i.prizes[0], function () {
- n.dom.congrats.show(),
- n.updateSpinCnt(),
- n.showSpinMore(!0),
- n.showHistory(),
- n.spinning = !1
- })
- }, 700)
- }, 700)
- }, 500 - r)
- }, function (n) {
- switch (n.code) {
- case 1001:
- return nexon.gnt.popupError("You don't have enough spin now."),
- !0
- }
- })
- }
- },
- selectPrize : function (n, t, i) {
- var r = 171,
- e = this.dom.slots.eq(n),
- f = e.children('[data-idx="{0}"]'.format(t.item_idx)),
- u = f.eq(1).index();
- e.stop().clearQueue().css({
- top : - (r * (u - 15))
- }).animate({
- top : - (r * u)
- }, 2e3, "easeOutQuad", function () {
- window.gachapon.dom.prizes.find("ul:eq({0}) > li > p".format(n)).text(t.coupon_code),
- $(this).css({
- top : - (r * f.eq(0).index()),
- position : "relative",
- "z-index" : 10
- }),
- typeof i == "function" && i.call(this)
- }),
- this.dom.animations.eq(n).hide()
- },
- showSpinMore : function (n) {
- var t,
- i,
- u,
- r;
- 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({
- opacity : 1
- }, {
- queue : !1,
- duration : "slow"
- }), u = i.offset().top + 260, r = $(window).height(), $(document).scrollTop() + r < u && $("body,html").animate({
- scrollTop : u - r
- }, "slow")) : this.dom.spin_more.slideUp("slow").animate({
- opacity : 0
- }, {
- queue : !1,
- duration : "slow"
- })
- },
- runSpin2 : function (n) {
- var u,
- i,
- t,
- r;
- if (this.spin_use_id != null && !this.spinning) {
- if (this.spin_use_id == "used") {
- nexon.gnt.popupError("you can use this change at once.");
- return
- }
- this.spinning = !0,
- u = +new Date,
- i = this,
- this.dom.multipliers.eq(0).show(),
- t = 0,
- r = setInterval(function () {
- i.dom.multipliers.eq(t).hide(),
- t++,
- t %= 3,
- i.dom.multipliers.eq(t).show()
- }, 150),
- this.dom.spin_more.startWaiting(),
- this.purchaseSpin(this.spinItems[1][0].spin_item_id, n, function () {
- this.useSpin(2, this.spin_use_id, function (n) {
- this.spin_use_id = "used";
- var i = +new Date - u,
- t = this;
- setTimeout(function () {
- t.dom.spin_more.stopWaiting(),
- clearInterval(r);
- var u = n.prizes[0].GroupID,
- f = n.prizes[0].coupon_code,
- i = (u == "A" ? 2 : u == "B" ? 3 : 1) - 1;
- t.dom.multipliers.hide().eq(i).show(),
- $("<li><p>{0}</p></li>".format(f)).appendTo(t.dom.prizes.children().eq(i)),
- t.showSpinMore(!1),
- t.showHistory(),
- t.spinning = !1
- }, 1e3 - i)
- }, function () {
- this.spinning = !1,
- this.dom.spin_more.stopWaiting()
- })
- }, function () {
- this.spinning = !1,
- this.dom.spin_more.stopWaiting()
- })
- }
- },
- showHistory : function (n, t) {
- var r = $("#coupon-history"),
- i;
- if (!r.is(":hidden")) {
- if (i = r.find("tbody"), !nexon.sso.isLoggedIn) {
- $('<tr><td colspan="4" class="c-text" style="padding:10px">Log in to see this information</td></tr>').appendTo(i.empty());
- return
- }
- r.startWaiting(),
- n === undefined && (n = 1),
- t === undefined && (t = 10),
- this.apicall({
- api : "getHistory",
- data : '{ "page": {0}, "list_cnt": {1}}'.format(n, t)
- }, function (t) {
- var f,
- u;
- for (i.empty(), f = 0; f < t.list.length; f++)
- 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);
- i.children(":even").addClass("add-bg2"),
- this.pager.update(t.total_cnt, n).find("a").click(function (n) {
- n.preventDefault();
- var t = $(this).data("page");
- window.gachapon.showHistory(t)
- }),
- $("#coupon-history tbody > tr").balloon({
- position : "left",
- contents : function () {
- var n = $(this).data("img");
- return '<img src="{0}" />'.format(n)
- },
- minLifetime : 0,
- showDuration : 0,
- hideDuration : 0
- }),
- r.stopWaiting()
- })
- }
- }
- },
- window.gachapon = new gachapon
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement