Advertisement
Guest User

Untitled

a guest
Oct 2nd, 2013
389
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var popup = !1,
  2.     local = 0,
  3.     notifId = 0,
  4.     tabActive = 0,
  5.     msgLoading = 0,
  6.     otp = 0,
  7.     success_login = !1,
  8.     MAIN_UPDATE_TIME = 15E3,
  9.     bCode = {
  10.         usd: 21,
  11.         rur: 22
  12.     };
  13. $.ajaxSetup({
  14.     type: "POST",
  15.     cache: !1,
  16.     beforeSend: showLoader,
  17.     error: showReqError,
  18.     complete: hideLoader
  19. });
  20. $(document).ready(function () {
  21.     "https://btc-e.com" != domain && "http://dev.btc-e.com" != domain && (local = 1);
  22.     loading = "<div class='mcenter'><img src='" + domain + "/images/loading.gif' alt='' class='center' style='padding-top: 60%;'/></div>";
  23.     loadingnorm = "<div class='mcenter'><img src='" + domain + "/images/loading.gif' alt='' class='center' /></div>";
  24.     icLoading = "<img src='" + domain + "/images/loading.gif' alt='loading' class='center' />";
  25.     icLoading2 = "<img src='" + domain + "/images/loading.gif' alt='loading' />";
  26.     icLoadingH =
  27.         "<img src='" + domain + "/images/loadh.gif' alt='loading' class='center' />";
  28.     icLoadingButton = "<img src='" + domain + "/images/loading.gif' alt='loading' style='padding-top: 7px;' class='center' />";
  29.     icOK = "<img src='" + domain + "/images/yes.png' alt='' />";
  30.     icErr = "<img src='" + domain + "/images/no.png' alt='' />";
  31.     0 < $("#nChatCon").size() && ($("#nChatInput").focus(), $("#nChat").scrollTop(9999999), 1 == auth && pusherStart());
  32.     $("#nChat").scroll(nChatScrollEvent);
  33.     0 < $("#orders-b-list").size() && 1 == auth && setTimeout(orders_update,
  34.         MAIN_UPDATE_TIME)
  35. });
  36. $(window).focus(focusEvent);
  37. $(window).blur(blurEvent);
  38. $(document).mousemove(mmEvent);
  39. $(document).click(clickEvent);
  40.  
  41. function focusEvent() {
  42.     tabActive = 1
  43. }
  44.  
  45. function blurEvent() {
  46.     tabActive = 0
  47. }
  48.  
  49. function mmEvent() {
  50.     tabActive = 1
  51. }
  52.  
  53. function clickEvent() {
  54.     popup && $(".popup").hide()
  55. }
  56.  
  57. function showLoader() {
  58.     $("#mainLoader").fadeTo(1, 1);
  59.     $("#loaderFade").fadeTo(1, 0.1)
  60. }
  61.  
  62. function hideLoader() {
  63.     $("#mainLoader").hide();
  64.     $("#loaderFade").hide()
  65. }
  66.  
  67. function showReqError() {
  68.     var a = "\u041e\u0448\u0438\u0431\u043a\u0430 \u043f\u0440\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0435. \u041f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435 \u043f\u043e\u0437\u0434\u043d\u0435\u0435.";
  69.     "ru" != locale && (a = "Request error. Please try again later.");
  70.     alert(a)
  71. }
  72.  
  73. function _url(a) {
  74.     return domain + "/ajax/" + a
  75. }
  76.  
  77. function spoiler(a) {
  78.     $(a).next("div").slideToggle("fast")
  79. }
  80.  
  81. function msgLoad(a, b) {
  82.     msgLoading = 1;
  83.     $("#msg-Loading").show();
  84.     $.post(_url("messages"), {
  85.         task: "msg_list",
  86.         dialog_with: a,
  87.         offset: b
  88.     }, function (a) {
  89.         var b = msg_list.scrollTop(),
  90.             e = msg_list.html();
  91.         msg_list.html(a);
  92.         msg_height = msg_list[0].scrollHeight;
  93.         msg_list.html(a + e).scrollTop(msg_height + b);
  94.         setTimeout("msgLoading = 0;", 500);
  95.         $("#msg-Loading").hide()
  96.     })
  97. }
  98.  
  99. function msgDel(a, b) {
  100.     $(b).html(icLoading2);
  101.     $.post(_url("messages"), {
  102.         task: "del",
  103.         id: a
  104.     }, function (c) {
  105.         -1 < c && ($("#msg-" + a).fadeOut("fast"), $(b).html(icOK), $("#mc").html(c), 0 == c && $("#msgbody").html("<h3 class='tcenter' style='margin: 15px;'>\u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u043d\u0435\u0442.</h3>"))
  106.     })
  107. }
  108.  
  109. function msgSend(a) {
  110.     var b = $("#to").val(),
  111.         c = $("#text").val();
  112.     showLoader();
  113.     $.post(_url("messages"), {
  114.         task: "send",
  115.         to: b,
  116.         message: c,
  117.         captcha: a
  118.     }, function (a) {
  119.         hideLoader();
  120.         "y" == a.error ? (nPopReady(430, 70), $("#nPopupCon").html(a.errortext)) : "y" == a.captcha ? (nPopReady(180, 145), $("#nPopupCon").html(a.captchatext)) : "n" == a.error && ($("#msgbody").html(a.message), npopHide())
  121.     }, "json")
  122. }
  123.  
  124. function pusherStart() {
  125.     pusher = new Pusher("4e0ebd7a8b66fa3554a4", {
  126.         encrypted: !0
  127.     });
  128.     test = 1 == local ? "test_" : "";
  129.     channel = pusher.subscribe(test + "chat_" + locale);
  130.     channel.bind("msg", nChatPutMsg);
  131.     channel.bind("msg_del", nChatDelMsg)
  132. }
  133.  
  134. function nChatScrollEvent() {
  135.     return nChatScroll(0, 0, !0)
  136. }
  137.  
  138. function nChatScroll(a, b, c) {
  139.     scroll = $("#nChat").scrollTop();
  140.     cur_scroll = scroll + $("#nChat").innerHeight();
  141.     scroll_height = $("#nChat")[0].scrollHeight;
  142.     cur_scroll > scroll_height - 30 - a ? c ? $("#nChatLockIcon").fadeOut(150) : $("#nChat").scrollTop(scroll_height) : c ? $("#nChatLockIcon").fadeIn(150) : 0 < b && $("#nChat").scrollTop(scroll - 26)
  143. }
  144.  
  145. function nChatSendMsg() {
  146.     var a = $("#chat-token").val(),
  147.         b = $("#nChatInput").val();
  148.     if ("" == b) return !1;
  149.     $("#nCiLoading").html(icLoading).fadeIn(50);
  150.     $.ajax({
  151.         url: _url("chat"),
  152.         data: {
  153.             task: "say",
  154.             msg: $("#nChatInput").val(),
  155.             token: a,
  156.             locale: locale
  157.         },
  158.         beforeSend: "",
  159.         success: function (a) {
  160.             1 == a.error && (nChatError(a.errorText), $("#nChatInput").val(b))
  161.         },
  162.         error: function () {
  163.             nChatError("request error")
  164.         },
  165.         complete: function () {
  166.             $("#nCiLoading").fadeOut()
  167.         },
  168.         dataType: "json"
  169.     });
  170.     $("#nChatInput").val("");
  171.     return !1
  172. }
  173.  
  174. function nChatError(a) {
  175.     $("#nChatErrors").html(a).fadeIn();
  176.     setTimeout('$("#nChatErrors").fadeOut();', 2E3)
  177. }
  178.  
  179. function nChatBan(a) {
  180.     $(a).hide();
  181.     $("#fade").fadeOut();
  182.     $("#nChatBanMenu").fadeOut();
  183.     showLoader();
  184.     $.post(_url("chat"), {
  185.         admtools: "nChatBanUser",
  186.         id: $("#mid").val(),
  187.         ttype: $("#ttype").val(),
  188.         time: $("#time").val(),
  189.         reason: $("#reason").val()
  190.     }, function () {
  191.         hideLoader()
  192.     })
  193. }
  194.  
  195. function nChatBanPopup(a) {
  196.     $("#fade").fadeTo(100, 0.3);
  197.     $("#nChatBanMenu").fadeIn(500);
  198.     $("#cbm").html("<p style='text-align: center; height: 100%; line-height: 200px;'><img src='" + domain + "/images/loading.gif' alt='' /></p>");
  199.     $.post(_url("chat"), {
  200.         admtools: "nBanTable",
  201.         id: a
  202.     }, function (b) {
  203.         $("#cbm").html(b);
  204.         $("#mid").val(a)
  205.     })
  206. }
  207.  
  208. function nChatMenu(a, b, c, d) {
  209.     var e = d.pageX ? d.pageX : d.clientX;
  210.     d = d.pageY ? d.pageY : d.clientY;
  211.     $("#cMenu").css("left", e).css("top", d).fadeIn(150);
  212.     $("#cMenuH").html(b);
  213.     0 != a ? ($("#cMenuPM").show().html("<a href='" + domain + "/messages/new/" + b + "/' class='profileBtn'>" + $("#cMenuPM-text").html() + "</a>"), $("#cMenuProfile").show().html("<a href='" + domain + "/profile/" + a + "' class='profileBtn'>" + $("#cMenuProfile-text").html() + "</a>")) : ($("#cMenuPM").hide(), $("#cMenuProfile").hide(), $("#cMenuBan").hide());
  214.     $("#cMenuInChat").show().html("<a href='javascript:void(0)' onclick='nInChat(\"" +
  215.         b + "\")' class='profileBtn '>" + $("#cMenuInChat-text").html() + "</a>");
  216.     0 != a && $("#cMenuBan").show().html("<a href='javascript:void(0)' onclick='nChatBanPopup(" + c + ")' class='profileBtn '>" + $("#cMenuBan-text").html() + "</a>");
  217.     $("#cMenuDel").show().html("<a href='javascript:void(0)' onclick='nChatMdel(" + c + ")' class='profileBtn '>" + $("#cMenuDel-text").html() + "</a>");
  218.     popup = !1;
  219.     setTimeout(function () {
  220.         popup = !0
  221.     }, 1)
  222. }
  223.  
  224. function nInChat(a) {
  225.     $("#nChatInput").val(a + ", ").focus()
  226. }
  227.  
  228. function nChatMdel(a) {
  229.     $.post(_url("chat"), {
  230.         admtools: "nDelMessage",
  231.         id: a
  232.     }, function () {})
  233. }
  234.  
  235. function nChatDelMsg(a) {
  236.     $("#msg" + a).hide()
  237. }
  238.  
  239. function nChatInsert(a) {
  240.     $("#nChatInput").val($("#nChatInput").val() + " " + a).focus();
  241.     $("#nChatSmiles").fadeToggle(50)
  242. }
  243.  
  244. function nChatSmilesToggle() {
  245.     $("#nChatSmiles").fadeToggle(50)
  246. }
  247.  
  248. function nChatPutMsg(a) {
  249.     a = JSON.parse(a);
  250.     u_style = a.login == auth_login ? "color: #193477 !important;" : "color: " + a.usr_clr;
  251.     m_style = a.msg.match(auth_login) ? "font-weight:bold;" : "";
  252.     var b = "<p id='msg" + a.msg_id + "' class='chatmessage' style='" + m_style + "display:none'>" + ("<a title='" + a.date + "' style='" + u_style + " !important; font-weight: bold;' href='javascript:void(0)' onclick='nChatMenu(" + a.uid + ', "' + a.login + '", ' + a.msg_id + ", event)'>" + a.login + "</a>") + ": <span>" + a.msg + "</span></p>";
  253.     $("#nChat").append(b);
  254.     old_msg_size =
  255.         0;
  256.     40 < $("#nChat p").length && (old_msg_size = $("#nChat p").first().innerHeight(), $("#nChat p").first().remove());
  257.     $("#msg" + a.msg_id).fadeIn(100);
  258.     console.log(old_msg_size);
  259.     new_msg_size = $("#msg" + a.msg_id).innerHeight();
  260.     nChatScroll(new_msg_size, old_msg_size)
  261. }
  262.  
  263. function reg_check(a, b, c) {
  264.     b = b.value;
  265.     $(document).ready(function () {
  266.         "" != b && ($("#" + a + "-regcheck").html(icLoading), $.post(_url("reg?check=" + a), {
  267.             data: b,
  268.             data2: c
  269.         }, function (b) {
  270.             $("#" + a + "-regcheck").html(b);
  271.             "psw" == a && "" != c && $("#psw2-regcheck").html(b);
  272.             reg_all_check()
  273.         }))
  274.     })
  275. }
  276.  
  277. function reg_input_check(a) {
  278.     if (!(!1 == reg_button_pressed && !1 == a)) {
  279.         var b = [],
  280.             c = $("#reg_login"),
  281.             d = $("#reg_psw1"),
  282.             e = $("#reg_psw2"),
  283.             f = $("#reg_email"),
  284.             h = $("#reg_eula"),
  285.             g = /^[a-z0-9!@#$%^&*(){}:;<>?=+-_~`.,]{6,64}$/i;
  286.         !1 == /^[a-z0-9\-\_\.]{2,}\@([a-z0-9\-\_]{2,}\.)+[a-z0-9]{2,4}$/i.test(f.val()) ? (f.addClass("reg_input_error"), b.push(LOC_REG_ERROR_EMAIL)) : clear_class(f);
  287.         !1 == /^[a-z0-9_]{3,16}$/i.test(c.val()) ? (c.addClass("reg_input_error"), b.push(LOC_REG_ERROR_LOGIN)) : clear_class(c);
  288.         !1 == g.test(d.val()) ? (d.addClass("reg_input_error"),
  289.             b.push(LOC_REG_ERROR_PASSWORD)) : clear_class(d);
  290.         !1 == g.test(e.val()) ? e.addClass("reg_input_error") : clear_class(e);
  291.         d.val() != e.val() ? (d.addClass("reg_input_error"), e.addClass("reg_input_error"), b.push(LOC_REG_ERROR_PASSWORDS_NOT_MATCH)) : "" != d.val() && (clear_class(d), clear_class(e));
  292.         !1 == h.prop("checked") ? ($("#reg_eula_label").addClass("reg_input_error"), b.push(LOC_REG_ERROR_EULA_NOT_CHECKED)) : clear_class(reg_eula_label);
  293.         0 < b.length ? (reg_button_pressed = !0, $(".reg_error").hide(), $("#reg_error_list").html("").show(),
  294.             $.each(b, function (a, b) {
  295.                 $("#reg_error_list").html($("#reg_error_list").html() + "<p>" + b + "</p>")
  296.             })) : 0 == b.length && !1 == a ? $("#reg_error_list").html("").hide() : a && $("#reg_form").submit()
  297.     }
  298. }
  299.  
  300. function eula_ch() {
  301.     0 == $("#eulach").val() ? $("#eulach").val(1) : $("#eulach").val(0)
  302. }
  303.  
  304. function clear_class(a) {
  305.     $(a).removeClass("reg_input_error")
  306. }
  307.  
  308. function reg_all_check() {
  309.     return !1
  310. }
  311.  
  312. function hide_popups() {
  313.     $(".popup").hide()
  314. }
  315.  
  316. function slider(a) {
  317.     var b = 650 * a - 650,
  318.         c = b + 15;
  319.     $(".ex_button").removeAttr("class");
  320.     $("#ex_but" + a).attr("class", "buttons_selected ex_button");
  321.     $("#sliders").animate({
  322.         left: "-" + c
  323.     }, "slow");
  324.     $("#sliders").animate({
  325.         left: "-" + b
  326.     }, "fast")
  327. }
  328.  
  329. function profile(a, b, c, d) {
  330.     $(document).ready(function () {
  331.         if (0 == $("#profile_uid").length) return !1;
  332.         $("#loading").html(icLoadingH);
  333.         $(".profileBtnHover").attr("class", "profileBtn");
  334.         $(d).attr("class", "profileBtnHover profileBtn");
  335.         "" != window.location.hash && 1 == c && (a = window.location.hash.substr(1));
  336.         $.ajax({
  337.             url: _url("profile"),
  338.             data: {
  339.                 task: a,
  340.                 data: b
  341.             },
  342.             beforeSend: "",
  343.             success: function (a) {
  344.                 $("#profile").html(a);
  345.                 $("#loading").html("")
  346.             }
  347.         })
  348.     })
  349. }
  350.  
  351. function npopHide() {
  352.     $(".npop").fadeOut("fast");
  353.     $("#fade").fadeOut("fast")
  354. }
  355.  
  356. function pe_check(a, b, c, d) {
  357.     c = c.value;
  358.     $(document).ready(function () {
  359.         "" != c && ($("#" + b + "-check").html(icLoading2), $.post(_url("reg?check=" + b), {
  360.             data: c,
  361.             data2: d
  362.         }, function (a) {
  363.             $("#" + b + "-check").html(a);
  364.             "psw" == b && "" != d && $("#psw2-check").html(a)
  365.         }))
  366.     })
  367. }
  368.  
  369. function pe_edit(a) {
  370.     $(".profile-edit").hide();
  371.     $("#tab-table td").removeAttr("class").attr("class", "pe-tab");
  372.     $("#tab-table td:last").removeAttr("class");
  373.     $("#" + a + "-tab").addClass("pe-selected-tab");
  374.     $("#" + a).show()
  375. }
  376.  
  377. function pe_passedit() {
  378.     showLoader();
  379.     $.post(_url("profile_edit"), {
  380.         edit: "pass",
  381.         psw: $("#psw").val(),
  382.         psw2: $("#psw2").val(),
  383.         oldpsw: $("#oldpass").val()
  384.     }, function (a) {
  385.         $("#pass-errors").html(a);
  386.         hideLoader()
  387.     })
  388. }
  389.  
  390. function pe_mainedit() {
  391.     showLoader();
  392.     $.post(_url("profile_edit"), {
  393.         edit: "main",
  394.         skype: $("#skp").val(),
  395.         email: $("#email").val(),
  396.         token: $("#token").val()
  397.     }, function (a) {
  398.         $("#main-errors").html(a);
  399.         hideLoader()
  400.     })
  401. }
  402.  
  403. function pe_secedit() {
  404.     var a = $('input[id="s_email"]').prop("checked");
  405.     showLoader();
  406.     $.post(_url("profile_edit"), {
  407.         edit: "security",
  408.         s_email: a
  409.     }, function (a) {
  410.         nPopReady(600, 70);
  411.         $("#nPopupCon").html(a);
  412.         hideLoader()
  413.     })
  414. }
  415.  
  416. function pe_confirm_email() {
  417.     showLoader();
  418.     $.post(_url("profile_edit"), {
  419.         act: "confirm_email"
  420.     }, function (a) {
  421.         nPopReady(430, 85);
  422.         $("#nPopupCon").html(a);
  423.         hideLoader()
  424.     })
  425. }
  426.  
  427. function billing_profile(a, b, c) {
  428.     $("#billing").html(icLoadingButton);
  429.     "" != window.location.hash && 1 == c && (a = window.location.hash.substr(1));
  430.     $.post(_url("billing"), {
  431.         act: a,
  432.         id: b
  433.     }, function (a) {
  434.         $("#billing").html(a);
  435.         window.scrollBy(0, document.body.offsetHeight)
  436.     })
  437. }
  438.  
  439. function trans_history(a, b, c, d, e) {
  440.     showLoader();
  441.     "" != window.location.hash && 1 == e && (act = window.location.hash.substr(1));
  442.     $.post(_url("billing"), {
  443.         act: "history",
  444.         id: a,
  445.         page: b,
  446.         view: c,
  447.         type: d
  448.     }, function (a) {
  449.         hideLoader();
  450.         $("#billing").html(a)
  451.     })
  452. }
  453.  
  454. function switch_pay(a) {
  455.     $(".payform").hide();
  456.     $(".banners-pay").hide();
  457.     $("#pay" + a).show();
  458.     $("#banners" + a).show()
  459. }
  460.  
  461. function unpay() {
  462.     var a = $("#purse").val(),
  463.         b = $("#summ").val();
  464.     $("#unpay").html(loadingnorm);
  465.     $.post(_url("billing"), {
  466.         act: "tryunpay",
  467.         purse: a,
  468.         summ: b
  469.     }, function (a) {
  470.         $("#unpay").html(a)
  471.     })
  472. }
  473.  
  474. function nPopReady(a, b) {
  475.     margin_t = b / 2;
  476.     margin_l = a / 2;
  477.     $("#nPopupCon").css("width", a);
  478.     $("#nPopupCon").css("height", b);
  479.     $("#nPopupCon").css("margin-top", -margin_t);
  480.     $("#nPopupCon").css("margin-left", -margin_l);
  481.     $("#fade").fadeTo(50, 0.7);
  482.     $("#nPopupCon").fadeIn(200)
  483. }
  484.  
  485. function withdraw_coin(a) {
  486.     var b = $("#sum").val(),
  487.         c = $("#address").val(),
  488.         d = $("#token").val();
  489.     sec_ask_otp(1);
  490.     showLoader();
  491.     $.post(_url("coins"), {
  492.         act: "withdraw",
  493.         sum: b,
  494.         address: c,
  495.         coin_id: a,
  496.         token: d,
  497.         otp: otp
  498.     }, function (a) {
  499.         nPopReady(430, 70);
  500.         $("#nPopupCon").html(a);
  501.         hideLoader()
  502.     })
  503. }
  504.  
  505. function withdraw_method_change() {
  506.     var a = $("#type option:selected").val(),
  507.         b = $("#desc" + a);
  508.     a == bCode.usd || a == bCode.rur ? $(".purse_block").hide() : $(".purse_block").show();
  509.     "" == b.html() ? $("#desc_container").hide() : ($("#desc_container").show(), $(".desc").hide(), b.show());
  510.     withdraw_calc()
  511. }
  512.  
  513. function withdraw() {
  514.     var a = $("#sum").val(),
  515.         b = $("#purse").val(),
  516.         c = $("#type option:selected").val(),
  517.         d = $("#token").val();
  518.     sec_ask_otp(1);
  519.     showLoader();
  520.     if (c == bCode.usd || c == bCode.rur) {
  521.         if (c == bCode.usd) var e = 1;
  522.         else c == bCode.rur && (e = 14);
  523.         withdraw_code(e, 1)
  524.     } else $.post(_url("billing"), {
  525.         act: "withdraw_request",
  526.         cur: $("#cur").val(),
  527.         sum: a,
  528.         purse: b,
  529.         type: c,
  530.         token: d,
  531.         otp: otp
  532.     }, function (a) {
  533.         nPopReady(430, 80);
  534.         $("#nPopupCon").html(a);
  535.         hideLoader()
  536.     })
  537. }
  538.  
  539. function withdraw_calc(a) {
  540.     var b = /^[0-9.]{1,}$/i,
  541.         c = $("#type option:selected").val(),
  542.         d = $("#sum"),
  543.         e = $("#wd_sum"),
  544.         f = Number(d.val()),
  545.         h = Number(e.val()),
  546.         g = $("#system_" + c + "_fee").val();
  547.     if (!b.test(f) || !b.test(h)) return a ? d.val("0") : e.val("0"), !1;
  548.     1 == a ? (sum = 100 * (h / (100 - g)), input = d) : (sum = f - f / 100 * g, input = e);
  549.     11 == c && (150 < f && 1E4 > f) && (sum = f - 150);
  550.     53 == c && (100 < f && 1E4 > f) && (sum = f - 100);
  551.     input.val(Math.floor(1E8 * sum) / 1E8)
  552. }
  553.  
  554. function withdraw_code(a, b) {
  555.     var c = $("#sum").val(),
  556.         d = $("#token").val();
  557.     b || sec_ask_otp(1);
  558.     $.post(_url("billing"), {
  559.         act: "withdraw_code",
  560.         sum: c,
  561.         currency: a,
  562.         token: d,
  563.         otp: otp
  564.     }, function (a) {
  565.         nPopReady(490, 90);
  566.         $("#nPopupCon").html(a);
  567.         hideLoader()
  568.     })
  569. }
  570.  
  571. function redeemCode() {
  572.     var a = $("#code").val();
  573.     showLoader();
  574.     $.post(_url("billing"), {
  575.         act: "redeem_code_2",
  576.         code: a
  577.     }, function (a) {
  578.         nPopReady(430, 70);
  579.         $("#nPopupCon").html(a);
  580.         hideLoader()
  581.     })
  582. }
  583.  
  584. function coins_withdraw_calc(a) {
  585.     var b = /^[0-9.]{1,}$/i,
  586.         c = Number($("#sum").val()),
  587.         d = Number($("#wd_sum").val()),
  588.         e = $("#coin_fee").html();
  589.     b.test(d) && 1 == a ? (a = d + e, 0 > a && (a = 0), $("#sum").val(1 * a.toFixed(8))) : b.test(c) && b.test(d) ? (a = c - e, 0 > a && (a = 0), $("#wd_sum").val(1 * a.toFixed(8))) : a ? $("#sum").val("0") : $("#wd_sum").val("0")
  590. }
  591.  
  592. function usd_calc(a, b, c) {
  593.     var d = /^[0-9.]{1,}$/i;
  594.     d.test($("#" + a).val()) ? d.test($("#" + b).val()) ? (a = $("#" + a).val() * $("#" + b).val(), $("#" + c).html(a.toFixed(2))) : $("#" + c).html("0") : $("#" + c).html("0")
  595. }
  596.  
  597. function ex_trade(a, b) {
  598.     "buy" == a && (tr = "b");
  599.     "sell" == a && (tr = "s");
  600.     var c = $("#token").val(),
  601.         d = $("#" + tr + "_btc").val(),
  602.         e = $("#" + tr + "_price").val();
  603.     showLoader();
  604.     $.post(_url("order"), {
  605.         trade: a,
  606.         btc_count: d,
  607.         btc_price: e,
  608.         pair: b,
  609.         token: c
  610.     }, function (a) {
  611.         "n" == a.error ? nPopReady(510, 240) : nPopReady(430, 70);
  612.         $("#nPopupCon").html(a.data);
  613.         hideLoader()
  614.     }, "json")
  615. }
  616.  
  617. function ex_calculate(a, b) {
  618.     "buy" == a && (tr = "b");
  619.     "sell" == a && (tr = "s");
  620.     var c = $("#" + tr + "_btc").val(),
  621.         d = $("#" + tr + "_price").val();
  622.     $("#" + tr + "_loading").html(loadingnorm);
  623.     $.post(_url("order"), {
  624.         calculate: a,
  625.         btc_count: c,
  626.         btc_price: d,
  627.         pair: b
  628.     }, function (a) {
  629.         $("#" + tr + "_all").html(a.all);
  630.         $("#" + tr + "_fee").html(a.fee);
  631.         $("#" + tr + "_comm").html(a.comm);
  632.         "y" == a.error ? $("#" + tr + "_error").show() : $("#" + tr + "_error").hide();
  633.         $("#" + tr + "_loading").html("")
  634.     }, "json")
  635. }
  636.  
  637. function cancel_order(a, b) {
  638.     showLoader();
  639.     $.post(_url("order"), {
  640.         act: "cancel",
  641.         id: a,
  642.         pair: b
  643.     }, function (b) {
  644.         "OK" == b ? ($("#sorder_link_" + a).html("<b>success</b>"), setTimeout(function () {
  645.             $("#sorder_" + a).fadeOut("fast")
  646.         }, 300)) : $("#sorder_link_" + a).html("<b>error (" + b + ")</b>");
  647.         hideLoader()
  648.     })
  649. }
  650.  
  651. function orders_update() {
  652.     var a = $("#pair").val();
  653.     $(".orders-loading").fadeTo(50, 0.3);
  654.     $.ajax({
  655.         url: _url("order"),
  656.         cache: !1,
  657.         type: "POST",
  658.         data: {
  659.             act: "orders_update",
  660.             pair: a
  661.         },
  662.         beforeSend: "",
  663.         success: main_update,
  664.         error: function () {
  665.             setTimeout(orders_update, 2 * MAIN_UPDATE_TIME)
  666.         },
  667.         dataType: "json"
  668.     })
  669. }
  670.  
  671. function main_update(a) {
  672.     var b = $("#orders_1").scrollTop(),
  673.         c = $("#orders_2").scrollTop();
  674.     $("#orders-b-list").html(a.buy);
  675.     $("#orders-s-list").html(a.sell);
  676.     setTimeout("ordersScroll(1, " + b + ")", 10);
  677.     setTimeout("ordersScroll(2, " + c + ")", 10);
  678.     $("#orders-self-list").html(a.self);
  679.     $(".orders-loading").fadeOut();
  680.     0 < $("#users-online").size() && $("#users-online").html(a.users_online);
  681.     $("#cur1").html(a.auth_cur1);
  682.     $("#cur2").html(a.auth_cur2);
  683.     $("#cur1_full").val(a.auth_cur1_full);
  684.     $("#cur2_full").val(a.auth_cur2_full);
  685.     $(".money_usd").html(a.money_usd);
  686.     $(".money_btc").html(a.money_btc);
  687.     $("#orders-stats").html(a.stats);
  688.     $("#min_price").html(a.min);
  689.     $("#max_price").html(a.max);
  690.     a.mes_count != $("#mes_count").html() && $("#mes_count").html(a.mes_count);
  691.     a.not_count != $("#not_count").html() && $("#not_count").html(a.not_count);
  692.     0 < a.mes_count && $("#mes_count").attr("style", "font-weight: bold").addClass("red");
  693.     0 < a.not_count && $("#not_count").attr("style", "font-weight: bold");
  694.     scroll_state = $("#trade_history").scrollTop();
  695.     $("#trade_history").html(a.trade_history).scrollTop(scroll_state);
  696.     "undefined" !== typeof a.notifs && $.each(a.notifs, function (a, b) {
  697.         notify(b.text, b.sound)
  698.     });
  699.     $.each(a.last, last_price_blink);
  700.     setTimeout("$('ul.pairs span').removeAttr('class');", 2E3);
  701.     "undefined" != typeof chart && (chart.clearChart(), data = google.visualization.arrayToDataTable(a.chart_data, !0), chart.draw(data, options));
  702.     setTimeout(orders_update, MAIN_UPDATE_TIME)
  703. }
  704.  
  705. function ordersScroll(a, b) {
  706.     $("#orders_" + a).scrollTop(b)
  707. }
  708.  
  709. function last_price_blink(a, b) {
  710.     last = $("#last" + a);
  711.     change = 1;
  712.     last.html() < b ? (last.attr("class", "greenbg"), icon = "\u2191") : last.html() > b ? (last.attr("class", "redbg"), icon = "\u2193") : change = 0;
  713.     1 == change && (last.html(b), a == $("#pair").val() && (document.title = "[" + icon + b + "] BTC-E"))
  714. }
  715.  
  716. function all_money(a, b) {
  717.     var c = $("#" + a).html();
  718.     "" == c && (c = $("#" + a).val());
  719.     $("#" + b).val(c)
  720. }
  721.  
  722. function a_calc() {
  723.     var a = $("#cur1_full").val(),
  724.         b = $("#b_price").val();
  725.     0 < a && 0 < b && (result = a / b - 1E-7);
  726.     $("#b_btc").val(result.toFixed(8))
  727. }
  728.  
  729. function captcha_refresh() {
  730.     $("#captcha-refresh").html(icLoading2);
  731.     $("#captcha").attr("src", domain + "/getcaptcha");
  732.     $("#captcha_input").val("")
  733. }
  734.  
  735. function a_deposit() {
  736.     var a = $("#sum").val(),
  737.         b = $("#text").val(),
  738.         c = $("#uid").val(),
  739.         d = $("#manual_uid").val(),
  740.         e = $("#login").val(),
  741.         f = $("#cur").val(),
  742.         h = $("#type").val(),
  743.         g = $('input[id="notify"]').prop("checked"),
  744.         j = $("#hold").val();
  745.     showLoader();
  746.     $.post(_url("profile"), {
  747.         task: "add_funds",
  748.         task2: "deposit",
  749.         sum: a,
  750.         text: b,
  751.         uid: c,
  752.         manual_uid: d,
  753.         login: e,
  754.         cur: f,
  755.         type: h,
  756.         notify: g,
  757.         hold: j
  758.     }, function (a) {
  759.         hideLoader();
  760.         "ok" == a ? alert("\u0423\u0441\u043f\u0435\u0448\u043d\u043e") : alert("\u0414\u0430\u043d\u043d\u044b\u0435 \u0432\u0432\u0435\u0434\u0435\u043d\u044b \u043d\u0435\u0432\u0435\u0440\u043d\u043e")
  761.     })
  762. }
  763.  
  764. function a_edit() {
  765.     var a = $("#user_email").val(),
  766.         b = $("#user_id").val();
  767.     showLoader();
  768.     $.post(_url("profile"), {
  769.         task: "a_edit",
  770.         save: 1,
  771.         new_email: a,
  772.         data: b
  773.     }, function (a) {
  774.         hideLoader();
  775.         0 == a.success ? alert(a.error) : alert("\u0443\u0441\u043f\u0435\u0448\u043d\u043e")
  776.     }, "json")
  777. }
  778.  
  779. function orders_history(a) {
  780.     pair = $("#pair option:selected").val();
  781.     status = $("#view option:selected").val();
  782.     type = $("#type option:selected").val();
  783.     $("#loading").html(icLoadingH);
  784.     $.post(_url("orders_history"), {
  785.         pair: pair,
  786.         status: status,
  787.         type: type,
  788.         page: a
  789.     }, function (a) {
  790.         $("#orders_history").html(a);
  791.         $("#loading").html("")
  792.     })
  793. }
  794.  
  795. function set_price(a, b, c) {
  796.     buy_price = $("#b_price");
  797.     buy_amount = $("#b_btc");
  798.     sell_price = $("#s_price");
  799.     sell_amount = $("#s_btc");
  800.     buy_price.val(b);
  801.     sell_price.val(b);
  802.     1 == a && buy_amount.val(c);
  803.     2 == a && sell_amount.val(c)
  804. }
  805.  
  806. function api_key_create() {
  807.     var a = $("#key_desc").val();
  808.     showLoader();
  809.     $.post(_url("api_keys"), {
  810.         task: "create",
  811.         desc: a
  812.     }, function () {
  813.         profile("api_keys");
  814.         hideLoader()
  815.     })
  816. }
  817.  
  818. function api_key_delete(a) {
  819.     showLoader();
  820.     $.post(_url("api_keys"), {
  821.         task: "delete",
  822.         id: a
  823.     }, function () {
  824.         profile("api_keys");
  825.         hideLoader()
  826.     })
  827. }
  828.  
  829. function api_key_save(a) {
  830.     var b = $('input[id="k_' + a + '_0"]').prop("checked"),
  831.         c = $('input[id="k_' + a + '_1"]').prop("checked"),
  832.         d = $('input[id="k_' + a + '_2"]').prop("checked"),
  833.         e = $('input[id="k_' + a + '_3"]').prop("checked");
  834.     showLoader();
  835.     $.post(_url("api_keys"), {
  836.         task: "save",
  837.         id: a,
  838.         k0: b,
  839.         k1: c,
  840.         k2: d,
  841.         k3: e
  842.     }, function () {
  843.         hideLoader()
  844.     })
  845. }
  846.  
  847. function autoSend_funds(a, b) {
  848.     1 == b ? act = "query" : (act = "send", $("#tid" + a).hide(), npopHide());
  849.     showLoader();
  850.     $.post(_url("autosend_funds"), {
  851.         act: act,
  852.         tid: a
  853.     }, function (a) {
  854.         nPopReady(480, 90);
  855.         $("#nPopupCon").html(a);
  856.         hideLoader()
  857.     })
  858. }
  859.  
  860. function lq_deposit() {
  861.     showLoader();
  862.     $.post(_url("liqpay"), {
  863.         amount: $("#lq_amount").val()
  864.     }, function (a) {
  865.         $("#operation_xml").val(a.xml);
  866.         $("#signature").val(a.sign);
  867.         $("#lq_form").submit();
  868.         hideLoader()
  869.     }, "json");
  870.     return !1
  871. }
  872.  
  873. function qiwi_deposit() {
  874.     var a = $("#qiwi_amount").val(),
  875.         b = $("#qiwi_to").val();
  876.     showLoader();
  877.     $.post(_url("qiwi"), {
  878.         amount: a,
  879.         to: b
  880.     }, function (c) {
  881.         !1 == c.error && (location = "http://w.qiwi.ru/setInetBill.do?txn_id=" + c.txn_id + "&from=" + c.from + "&to=" + b + "&summ=" + a + "&com=" + c.com + "&lifetime=72&check_agt=false");
  882.         !0 == c.error && alert(c.errorText);
  883.         hideLoader()
  884.     }, "json")
  885. }
  886.  
  887. function payeer_deposit() {
  888.     var a = $("#m_amount").val(),
  889.         b = $("#m_curr").val();
  890.     showLoader();
  891.     $.post(_url("billing"), {
  892.         act: "get_payeer_sign",
  893.         amount: a,
  894.         currency: b
  895.     }, function (a) {
  896.         a.success ? ($("#m_amount").val(a.data.amount), $("#m_sign").val(a.data.sign), $("#payeer_form").submit()) : alert(a.error);
  897.         hideLoader()
  898.     }, "json")
  899. }
  900.  
  901. function coin_new_address(a) {
  902.     showLoader();
  903.     $.post(_url("coins"), {
  904.         act: "new_address",
  905.         coin_id: a
  906.     }, function (a) {
  907.         hideLoader();
  908.         0 == a.success ? (nPopReady(510, 80), $("#nPopupCon").html(a.error)) : ($("#coin-address").html(a.new_address), $("#coin-address").fadeTo("slow", 0.1, function () {
  909.             $("#coin-address").fadeTo("slow", 1)
  910.         }))
  911.     }, "json")
  912. }
  913.  
  914. function notifToggleCh(a) {
  915.     !1 == $('input[id="' + a + '0"]').prop("checked") ? ($("#" + a + "1").removeAttr("checked").attr("disabled", "disabled"), $("#" + a + "2").removeAttr("checked").attr("disabled", "disabled")) : ($("#" + a + "1").removeAttr("disabled"), $("#" + a + "2").removeAttr("disabled"))
  916. }
  917.  
  918. function notifSettings() {
  919.     showLoader();
  920.     $.post(_url("notifications"), {
  921.         act: "settings"
  922.     }, function (a) {
  923.         nPopReady(480, 210);
  924.         $("#nPopupCon").html(a);
  925.         hideLoader()
  926.     })
  927. }
  928.  
  929. function notifSaveSettings() {
  930.     var a = $('input[id="c00"]').prop("checked"),
  931.         b = $('input[id="c01"]').prop("checked"),
  932.         c = $('input[id="c02"]').prop("checked"),
  933.         d = $('input[id="c10"]').prop("checked"),
  934.         e = $('input[id="c11"]').prop("checked"),
  935.         f = $('input[id="c12"]').prop("checked"),
  936.         h = $('input[id="c20"]').prop("checked"),
  937.         g = $('input[id="c21"]').prop("checked"),
  938.         j = $('input[id="c22"]').prop("checked"),
  939.         k = $('input[id="c30"]').prop("checked"),
  940.         l = $('input[id="c31"]').prop("checked"),
  941.         m = $('input[id="c32"]').prop("checked"),
  942.         n = $('input[id="c40"]').prop("checked"),
  943.         p = $('input[id="c41"]').prop("checked"),
  944.         q = $('input[id="c42"]').prop("checked");
  945.     showLoader();
  946.     $.post(_url("notifications"), {
  947.         act: "saveSettings",
  948.         c00: a,
  949.         c01: b,
  950.         c02: c,
  951.         c10: d,
  952.         c11: e,
  953.         c12: f,
  954.         c20: h,
  955.         c21: g,
  956.         c22: j,
  957.         c30: k,
  958.         c31: l,
  959.         c32: m,
  960.         c40: n,
  961.         c41: p,
  962.         c42: q
  963.     }, function () {
  964.         npopHide();
  965.         hideLoader()
  966.     })
  967. }
  968.  
  969. function notify(a, b) {
  970.     notifId++;
  971.     1 == b && $("#audioPM").get(0).play();
  972.     $("#notif-containter").show().append("<div id='notif" + notifId + "' class='notification'><a style='float:right;' href='javascript:void(0)' onclick='$(\"#notif" + notifId + '").fadeOut("slow", function(){$("#notif' + notifId + '").remove();$("#notif-containter").hide();});\'><img src=\'' + domain + "/images/1px.png' class='main-s main-s-close' /></a><div style='height:100%' onclick='window.location=\"" + domain + "/notifications\"'>" + a + "</div></div>");
  973.     $("#notif" + notifId).fadeIn("fast");
  974.     1 == tabActive && setInterval('$("#notif' + notifId + '").fadeOut("slow", function(){$("#notif' + notifId + '").remove();$("#notif-containter").hide();});', 1E4)
  975. }
  976.  
  977. function notifHide(a) {
  978.     $.post(_url("notifications"), {
  979.         act: "hideNotif",
  980.         id: a
  981.     }, function () {
  982.         0 == a ? location = domain + "/notifications" : $("#n" + a).hide()
  983.     })
  984. }
  985.  
  986. function sw_act(a, b) {
  987.     showLoader();
  988.     $.post(_url("billing"), {
  989.         act: "sw_act",
  990.         task: a,
  991.         id: b
  992.     }, function (a) {
  993.         nPopReady(430, 80);
  994.         $("#nPopupCon").html(a);
  995.         hideLoader()
  996.     })
  997. }
  998.  
  999. function sec_create_otp_key() {
  1000.     showLoader();
  1001.     $.post(_url("security_center"), {
  1002.         act: "create_OTP_Key",
  1003.         token: $("#token").val()
  1004.     }, function (a) {
  1005.         a.success ? (nPopReady(610, 150), $("#nPopupCon").html(a.data), $("#otp").focus()) : alert(a.error);
  1006.         hideLoader()
  1007.     }, "json");
  1008.     return !1
  1009. }
  1010.  
  1011. function sec_confirm_otp_key() {
  1012.     if (!1 == /^[0-9]{6}$/i.test($("#otp").val())) return $("#otp_error").show(), !1;
  1013.     showLoader();
  1014.     $.post(_url("security_center"), {
  1015.         act: "confirm_OTP_Key",
  1016.         keyId: $("#keyId").val(),
  1017.         otp: $("#otp").val(),
  1018.         token: $("#token").val()
  1019.     }, function (a) {
  1020.         a.success ? (npopHide(), profile("security/2fa")) : $("#otp_error").css({
  1021.             "font-weight": "bold"
  1022.         }).show().attr("title", a.error);
  1023.         hideLoader()
  1024.     }, "json")
  1025. }
  1026.  
  1027. function sec_del_otp_key() {
  1028.     if (confirmed = confirm(LOC_ARE_YOU_SURE)) sec_ask_otp(0), showLoader(), $.post(_url("security_center"), {
  1029.         act: "delete_OTP_Key",
  1030.         otp: otp,
  1031.         token: $("#token").val()
  1032.     }, function (a) {
  1033.         a.success ? profile("security/2fa") : alert(a.error);
  1034.         hideLoader()
  1035.     }, "json")
  1036. }
  1037.  
  1038. function sec_save_otp_key() {
  1039.     var a = $('input[id="s0"]').prop("checked"),
  1040.         b = $('input[id="s1"]').prop("checked"),
  1041.         c = $('input[id="s2"]').prop("checked");
  1042.     sec_ask_otp(0);
  1043.     showLoader();
  1044.     $.post(_url("security_center"), {
  1045.         act: "save_OTP_Key",
  1046.         s0: a,
  1047.         s1: b,
  1048.         s2: c,
  1049.         otp: otp,
  1050.         token: $("#token").val()
  1051.     }, function (a) {
  1052.         a.success || alert(a.error);
  1053.         profile("security/2fa");
  1054.         hideLoader()
  1055.     }, "json")
  1056. }
  1057.  
  1058. function sec_ask_otp(a) {
  1059.     otp = 0 == a && secure_sc || 1 == a && secure_wd ? prompt(LOC_CONFIRM_OTP, defaultText = "") : 0
  1060. }
  1061.  
  1062. function tryLogin() {
  1063.     if (success_login) return !0;
  1064.     $.ajax({
  1065.         url: _url("login"),
  1066.         cache: !1,
  1067.         type: "POST",
  1068.         data: {
  1069.             email: $("#email").val(),
  1070.             password: $("#password").val(),
  1071.             otp: $("#login-otp").val(),
  1072.             PoW_nonce: $("#PoW_nonce").val()
  1073.         },
  1074.         success: userLogin,
  1075.         error: function () {
  1076.             alert("server error")
  1077.         },
  1078.         complete: function () {
  1079.             hideLoader()
  1080.         },
  1081.         dataType: "json"
  1082.     });
  1083.     return !1
  1084. }
  1085.  
  1086. function userLogin(a) {
  1087.     a.success ? (a.data.PoW && $("#PoW_working").fadeTo(0, 0.1, function () {
  1088.         setTimeout(function () {
  1089.             $("#PoW_nonce").val(getPoW(a.data.work.target, a.data.work.data));
  1090.             $("#PoW_working").hide()
  1091.         }, 30)
  1092.     }), setTimeout(function () {
  1093.         a.data.otp ? ($("#login_con").hide(), $("#otp_con").fadeIn(100), $("#login-otp").val("").focus()) : (a.data.login_success && (success_login = !0, $("#login").attr("action", window.location.href)), $("#login").submit())
  1094.     }, 100)) : (alert(a.error), "-" != $("#login-otp").val() && $("#login-otp").val(""));
  1095.     $("#PoW_nonce").val("")
  1096. }
  1097.  
  1098. function getPoW(a, b) {
  1099.     var c = 0;
  1100.     do hash_hex = md5(md5(b + c)), hash = eval("(0x" + hash_hex + ")"), ++c; while (hash >= a);
  1101.     return c
  1102. }
  1103.  
  1104. function comm_replace(a) {~
  1105.     a.value.indexOf(",") && (a.value = a.value.replace(",", "."))
  1106. }
  1107.  
  1108. function ac_add_comm_butt() {
  1109.     $("#add_comm_butt").hide();
  1110.     $("#add_comm_con").fadeIn(300)
  1111. }
  1112.  
  1113. function ac_add_comment() {
  1114.     var a = $("#profile_uid").val();
  1115.     ac_add_comment_request(a, $("#comment_text").val())
  1116. }
  1117.  
  1118. function ac_add_comment_request(a, b) {
  1119.     showLoader();
  1120.     $.post(_url("profile"), {
  1121.         task: "add_admin_comment",
  1122.         uid: a,
  1123.         comment_text: b
  1124.     }, function (b) {
  1125.         b.success ? profile("admin_comments", a) : alert(b.error);
  1126.         hideLoader()
  1127.     }, "json")
  1128. }
  1129.  
  1130. function pTradeHistory(a) {
  1131.     pair = $("#pair option:selected").val();
  1132.     $.post(_url("profile"), {
  1133.         task: "trade_history",
  1134.         ajax: 1,
  1135.         pair: pair,
  1136.         page: a
  1137.     }, function (a) {
  1138.         $("#trade_list_con").html(a)
  1139.     })
  1140. }
  1141.  
  1142. function a_ban(a, b, c) {
  1143.     showLoader();
  1144.     $.post(_url("profile"), {
  1145.         task: "ban",
  1146.         type: a,
  1147.         status: b,
  1148.         uid: c
  1149.     }, function (d) {
  1150.         d.success ? (profile("info", c), 1 == b && ((comment = prompt("\u0417\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d\u043e. \u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439:")) ? (1 == a && (prefix = ":ban:"), 2 == a && (prefix = ":withdraw_ban:"), ac_add_comment_request(c, prefix + " " + comment)) : alert("\u043a\u043e\u043c\u043c\u0435\u043d\u0442 \u043d\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d"))) :
  1151.             alert(d.error);
  1152.         hideLoader()
  1153.     }, "json")
  1154. }
  1155.  
  1156. function meta_open_demo() {
  1157.     showLoader();
  1158.     $.post(_url("profile"), {
  1159.         task: "meta_trader",
  1160.         open_demo: 1
  1161.     }, function (a) {
  1162.         a.success ? (nPopReady(350, 140), $("#nPopupCon").html(a.data)) : alert(a.error);
  1163.         hideLoader()
  1164.     }, "json")
  1165. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement