reset_pwd_email.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. const btnLoginPage = document.querySelector('.btn-login');
  2. const sender = document.querySelector('.sender');
  3. let language = localStorage.getItem('lan');
  4. function loginControl() {
  5. btnLoginPage.style.display = 'block';
  6. }
  7. loginControl();
  8. function get_jwt_token(){
  9. jwt_raw = document.cookie.split(';').filter(s=>s.includes('jwt_token'))[0];
  10. if(!jwt_raw) {return}
  11. return jwt_raw.split('=')[1];
  12. }
  13. function checkToken() {
  14. let jwt_token = get_jwt_token();
  15. }
  16. checkToken();
  17. $(".sender").click(function () {
  18. sender.setAttribute('disabled', '');
  19. sender.value = '處理中';
  20. if(language == 'en') {
  21. sender.value = 'Processing';
  22. }
  23. setTimeout(function () {
  24. sender.removeAttribute('disabled')
  25. sender.value = '送出';
  26. if(language == 'en') {
  27. sender.value = 'Submit';
  28. }
  29. }, 10000);
  30. console.log('clicked')
  31. var email = $("#in_email").val()
  32. var url = "https://www.choozmo.com:8887/send_reset_pwd?user_id=-1&email="+email;
  33. var xhr = new XMLHttpRequest();
  34. xhr.open("GET", url);
  35. xhr.setRequestHeader("accept", "application/json");
  36. xhr.onreadystatechange = function () {
  37. if (xhr.readyState === 4) {
  38. let title = '請查看信箱';
  39. if(language == 'en') {
  40. title = 'Please chek your email box';
  41. }
  42. Swal.fire({
  43. title: title,
  44. icon: 'info',
  45. confirmButtonColor: '#3085d6',
  46. });
  47. }};
  48. xhr.send();
  49. });
  50. let lan = localStorage.getItem('lan');
  51. $('.dropdown-toggle').click(() => {
  52. lan = localStorage.getItem('lan');
  53. checkLan();
  54. });
  55. checkLan();
  56. function checkLan() {
  57. if(lan == 'en') {
  58. $('.btn-makev').css('display', 'none');
  59. $('.btn-makelong').css('display', 'none');
  60. } else {
  61. $('.btn-makev').css('display', 'block');
  62. $('.btn-makelong').css('display', 'block');
  63. }
  64. }
  65. var loaded_data = ''
  66. function openNav() {
  67. document.getElementById("mySidenav").style.width = "250px";
  68. document.querySelector('.loader').style.display = "block";
  69. let token = getCookie('jwt_token');
  70. axios({
  71. method: 'post',
  72. url: 'https://www.choozmo.com:8887/history_input',
  73. headers: {
  74. 'accept': 'application/json',
  75. 'Authorization': `Bearer ${token}`
  76. }
  77. }).then(res => {
  78. console.log(res.data);
  79. loaded_data = res.data;
  80. var historyList = document.querySelector('.historyList');
  81. historyList.innerHTML = '';
  82. for (var obj of loaded_data) {
  83. var list = document.createElement('li');
  84. list.id = obj.id;
  85. // div-imgfr
  86. var divImgfr = document.createElement('div');
  87. divImgfr.classList.add('item_imgfr');
  88. var img = document.createElement('img');
  89. img.setAttribute('src', obj['image_urls'][0]);
  90. divImgfr.appendChild(img);
  91. // div-content
  92. var contentBox = document.createElement('div');
  93. contentBox.classList.add('content-box');
  94. var boxTitle = document.createElement('p');
  95. boxTitle.classList.add('box-title');
  96. boxTitle.textContent = obj.name;
  97. boxTitle.id = obj.id;
  98. boxTitle.setAttribute('onclick', `direct(${obj.id})`);
  99. var boxLink = document.createElement('span');
  100. boxLink.classList.add('box-link');
  101. boxLink.setAttribute("data-url", obj.link);
  102. boxLink.setAttribute('onclick', 'view()');
  103. boxLink.innerHTML = '<i class="fas fa-play-circle me-1"></i>觀看影片';
  104. contentBox.appendChild(boxTitle);
  105. contentBox.appendChild(boxLink);
  106. list.classList.add("historyList-item");
  107. list.setAttribute('onclick', `direct(${obj.id})`);
  108. list.appendChild(divImgfr);
  109. list.appendChild(contentBox);
  110. historyList.appendChild(list);
  111. }
  112. document.querySelector('.loader').style.display = "none";
  113. }).catch(err => {
  114. console.log(err);
  115. });
  116. }
  117. function direct(id) {
  118. location.href = `make_video2.html?id=${id}`;
  119. }
  120. function view() {
  121. event.stopPropagation();
  122. console.log(event.target);
  123. if (event.target.nodeName === 'I') {
  124. return;
  125. } else {
  126. window.open(`http://${event.target.dataset.url}`, '_blank');
  127. }
  128. }