Advertisement
Guest User

Untitled

a guest
Aug 17th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.39 KB | None | 0 0
  1. function s(e) {
  2. e.preventDefault(), o.remClass("is-selected"), c.remClass("is-selected"), l.remClass("selected"), a.addClass("is-visible"), i.addClass("is-selected"), r.addClass("selected")
  3. }
  4.  
  5. function n(e) {
  6. e.preventDefault(), i.remClass("is-selected"), c.remClass("is-selected"), r.remClass("selected"), a.addClass("is-visible"), o.addClass("is-selected"), l.addClass("selected")
  7. }
  8. var a = t(".cd-user-modal"),
  9. i = t("#cd-login", a),
  10. o = t("#cd-signup", a),
  11. c = t("#cd-reset-password", a),
  12. e = t(".cd-switcher"),
  13. r = t("a", e)[0],
  14. l = t("a", e)[1],
  15. d = t(".cd-form-bottom-message a", i),
  16. p = t(".cd-form-bottom-message a", c),
  17. g = t(".top-bar-right");
  18. g.onclick = function (e) {
  19. e.target === g && t("ul", g).forEach(function (e) {
  20. e.toggleClass("is-visible")
  21. })
  22. }, t(".cd-signup").onclick = n, $(".cd-signin").on("click", s), a.onclick = function (e) {
  23. (e.target == a || e.target.classList.contains(".cd-close-form")) && a.remClass("is-visible")
  24. }, document.addEventListener("keyup", function (e) {
  25. "27" == e.which && a.remClass("is-visible")
  26. }), e.onclick = function (e) {
  27. e.target === r ? s(e) : n(e)
  28. }, t(".hide-password").forEach(function (e) {
  29. e.onclick = function () {
  30. var e = this.previousElementSibling;
  31. "password" == e.getAttribute("type") ? e.setAttribute("type", "text") : e.setAttribute("type", "password"), this.innerHTML = this.innerHTML == Lang.get("show") ? Lang.get("hide") : Lang.get("show")
  32. }
  33. }), d.onclick = function (e) {
  34. e.preventDefault(), i.remClass("is-selected"), o.remClass("is-selected"), c.addClass("is-selected")
  35. }, p.onclick = s
  36. }();
  37. var s = App.Path.Func,
  38. n = function (e, t) {
  39. switch (e) {
  40. case "error":
  41. App.Info("error", Lang.get("an_error_occured"), t);
  42. break;
  43. case "errors":
  44. App.Info("error", Lang.get("notification"), t);
  45. break;
  46. case "logging":
  47. App.Info("success", Lang.get("please_wait"), Lang.get("logging_in"), 3e3);
  48. break;
  49. case "activated":
  50. App.xModal.show(Lang.get("account_activated"), Lang.get("account_activated_msg"));
  51. break;
  52. case "passreset":
  53. App.xModal.show(Lang.get("notification"), Lang.get("pass_changed"));
  54. break;
  55. case "welcome":
  56. App.xModal.show(Lang.get("vfc_head"), Lang.get("vfc_body"));
  57. break;
  58. case "passform":
  59. App.xModal.show(Lang.get("check_email"), Lang.get("activation_send"));
  60. break;
  61. case "reset_info":
  62. App.xModal.show(Lang.get("check_email"), Lang.get("forgot_send"))
  63. }
  64. },
  65. a = function (e, t) {
  66. return t || App.Loading(Lang.get("please_wait")), App.Request("post", s, e)
  67. },
  68. i = function (e, t) {
  69. for (var s in t) e[s] = t[s];
  70. return e
  71. },
  72. t = {
  73. Modal: App.Find(".cd-user-modal")
  74. },
  75. o = function (e) {
  76. t.Modal.click(), e.target.reset()
  77. };
  78. ({
  79. init: function () {
  80. document.addEventListener("submit", this, !1), -1 !== window.location.href.indexOf("/auth?") && this.Activate()
  81. },
  82. handleEvent: function (e) {
  83. if ("submit" === e.type) {
  84. e.preventDefault();
  85. var t = App.ParseForm.call(e.target);
  86. switch (e.target.id) {
  87. case "logForm":
  88. this.Login(e, i(t.Data, {
  89. auth_type: "login"
  90. }));
  91. break;
  92. case "regForm":
  93. this.Register(e, i(t.Data, {
  94. auth_type: "signup"
  95. }));
  96. break;
  97. case "resetForm":
  98. this.Reset(e, i(t.Data, {
  99. auth_type: "reset"
  100. }));
  101. break;
  102. case "newPass":
  103. this.NewPass(e, i(t.Data, {
  104. auth_type: "newpass"
  105. }))
  106. }
  107. }
  108. },
  109. NewPass: function (e, t) {
  110. a(t).then(function (e) {
  111. App.Loading("close"), 1 == e ? n("passreset") : n("errors", e)
  112. })
  113. },
  114. Register: function (t, e) {
  115. a(e).then(function (e) {
  116. App.Loading("close"), 1 == e ? (n("welcome"), o(t)) : n("errors", e)
  117. })
  118. },
  119. Reset: function (t, e) {
  120. a(e).then(function (e) {
  121. App.Loading("close"), 2 == e ? (n("passform"), o(t)) : 1 == e ? (n("reset_info"), o(t)) : n("errors", e)
  122. })
  123. },
  124. Login: function (t, e) {
  125. a(e).then(function (e) {
  126. App.Loading("close"), 1 == e ? (o(t), n("logging"), setTimeout(function () {
  127. location.reload()
  128. }, 2500)) : n("error", e)
  129. })
  130. },
  131. Activate: function () {
  132. a({
  133. auth_type: "activation",
  134. code: window.location.href.split("?").pop()
  135. }, 1).then(function (e) {
  136. "success" == e ? n("activated") : "active" == e && (window.location.href = Conf.get("app_url"))
  137. })
  138. }
  139. }).init()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement