My SMM panel
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 
 

147 строки
3.9 KiB

  1. import RegisterArea from './register-area/register-area.vue'
  2. import Panel from './panel/panel.vue'
  3. import '../scss/main.scss'
  4. import { createApp } from 'vue'
  5. importAll(require.context('../images', false, /\.(png|jpe?g|svg)$/))
  6. let heroText = document.querySelectorAll(".landing-hero h2,.landing-hero p")
  7. let registerToggles = document.querySelectorAll(".register-btn, .register-area\
  8. .cancel-button, .services-cards button")
  9. let token = getCookie('XSRF-TOKEN')
  10. function importAll(r) {
  11. return r.keys().map(r)
  12. }
  13. function getCookie(name) {
  14. var re = new RegExp(name + "=([^;]+)")
  15. var value = re.exec(document.cookie)
  16. return (value != null) ? unescape(value[1]) : null
  17. }
  18. function getToken(app) {
  19. fetch("/sanctum/csrf-cookie", {
  20. method: 'GET'
  21. }).then( () => {
  22. token = getCookie('XSRF-TOKEN')
  23. })
  24. app.token = token
  25. }
  26. function login(event) {
  27. fetch("/login", {
  28. method: 'POST',
  29. headers: {'Content-Type': 'application/json',
  30. 'Accept': 'application/json',
  31. 'X-XSRF-TOKEN': token},
  32. body: JSON.stringify({"email":
  33. document.getElementById("login_email").value,
  34. "password": document.getElementById("login_password").value}),
  35. }).then(response => {
  36. if (response.ok) {
  37. window.location.assign("/panel")
  38. } else {
  39. document.querySelector("#login_form .error").innerText =
  40. "Invalid credentials."
  41. }
  42. })
  43. event.preventDefault()
  44. event.stopPropogation()
  45. }
  46. function getUser(app) {
  47. fetch("/panel/user", {
  48. method: 'GET',
  49. headers: {'Content-Type': 'application/json',
  50. 'Accept': 'application/json',
  51. 'X-XSRF-TOKEN': token},
  52. }).then(response => {
  53. return response.json()
  54. }).then(data => {
  55. app.user = data
  56. })
  57. /* return this.user.name */
  58. }
  59. function getOrders(app) {
  60. fetch("/panel/orders", {
  61. method: 'GET',
  62. headers: {'Content-Type': 'application/json',
  63. 'Accept': 'application/json',
  64. 'X-XSRF-TOKEN': token},
  65. }).then(response => {
  66. return response.json()
  67. }).then(data => {
  68. app.orders = data
  69. })
  70. }
  71. //Attempt to resend the verification link
  72. function resendLink(event) {
  73. fetch("/resend-verification", {
  74. method: 'POST',
  75. headers: {'Content-Type': 'application/json',
  76. 'Accept': 'application/json',
  77. 'X-XSRF-TOKEN': token},
  78. }).then(response => {
  79. if (response.ok) {
  80. event.target.parentNode.getElementsByTagName('h3')[0].innerText =
  81. "The link has been resent."
  82. } else {
  83. event.target.parentNode.getElementsByTagName('h3')[0].innerText =
  84. `${response.status} : ${response.statusText}`
  85. }
  86. })
  87. event.stopPropogation();
  88. event.preventDefault();
  89. }
  90. function toggleNav() {
  91. heroText.forEach(item => {
  92. item.classList.toggle("hidden")
  93. })
  94. document.querySelector("nav form.login").classList.toggle("active")
  95. this.classList.toggle("toggled")
  96. }
  97. if (window.location.pathname == '/') {
  98. document.getElementById('nav_toggle').addEventListener('click', toggleNav)
  99. document.querySelector('#login_form button').addEventListener('click', login)
  100. const app = createApp(RegisterArea).mount('#app')
  101. // app.token = token
  102. if (!token) {getToken(app)}
  103. //Triggers for registration menu
  104. for (let i = 0; i < registerToggles.length; i++) {
  105. registerToggles[i].addEventListener("click", function() {
  106. document.querySelector(".register-area").classList.add("active")
  107. app.active = 'register'
  108. })
  109. }
  110. document.getElementById("forgot-password-btn").onclick = event => {
  111. document.querySelector(".register-area").classList.add("active")
  112. app.active = 'forgot'
  113. event.preventDefault()
  114. }
  115. //FAQ collapsibles
  116. let cols = document.getElementsByClassName("collapsible");
  117. for (let i = 0; i < cols.length; i++) {
  118. cols[i].addEventListener("click", function() {
  119. this.classList.toggle("active");
  120. });
  121. }
  122. } else if (window.location.pathname == '/verify-email') {
  123. document.getElementById('resend_verification').addEventListener("click", resendLink)
  124. } else if (window.location.pathname == '/panel') {
  125. if (!token) {getToken(app)}
  126. const app = createApp(Panel).mount('#panel')
  127. window.onhashchange = ()=>{app.active = location.hash}
  128. getUser(app)
  129. getOrders(app)
  130. }