reset_pwd.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. const btnLoginPage = document.querySelector('.btn-login');
  2. const btnUserProfile = document.querySelector('.btn-userProfile');
  3. const btnLogout = document.querySelector('.btn-logout');
  4. function loginControl() {
  5. btnLoginPage.style.display = 'none';
  6. btnLogout.style.display = 'block';
  7. btnUserProfile.style.display = 'block';
  8. }
  9. loginControl();
  10. function renderXHR_data(jsonObj) {
  11. XHRstring = ''
  12. for (const [key, value] of Object.entries(jsonObj)) {
  13. console.log(value)
  14. if (typeof (value) == "object") {
  15. XHRstring += (key+'=['+value.join(',')+']&')
  16. }
  17. else {
  18. XHRstring += (key + '=' + value + '&')
  19. }
  20. }
  21. XHRstring = XHRstring.substring(0, XHRstring.length - 1);
  22. return XHRstring
  23. }
  24. $(".sender").click(function () {
  25. var pwd = $("#in_pwd").val();
  26. var code = $("#code").val();
  27. var url = "https://www.choozmo.com:8887/reset_pwd";
  28. var xhr = new XMLHttpRequest();
  29. xhr.open("POST", url);
  30. xhr.setRequestHeader("accept", "application/json");
  31. xhr.setRequestHeader("Content-Type", "application/json");
  32. xhr.onreadystatechange = function () {
  33. if (xhr.readyState === 4) {
  34. alert('重設成功')
  35. }};
  36. var data = `{"code":"`+ code+`","password":"`+pwd+`"}`
  37. xhr.send(data);
  38. });
  39. var loaded_data = ''
  40. function openNav() {
  41. document.getElementById("mySidenav").style.width = "250px";
  42. document.querySelector('.loader').style.display = "block";
  43. let token = getCookie('jwt_token');
  44. axios({
  45. method: 'post',
  46. url: 'https://www.choozmo.com:8887/history_input',
  47. headers: {
  48. 'accept': 'application/json',
  49. 'Authorization': `Bearer ${token}`
  50. }
  51. }).then(res => {
  52. console.log(res.data);
  53. loaded_data = res.data;
  54. for (var obj of loaded_data) {
  55. var historyList = document.querySelector('.historyList');
  56. var list = document.createElement('li');
  57. list.id = obj.id;
  58. // div-imgfr
  59. var divImgfr = document.createElement('div');
  60. divImgfr.classList.add('item_imgfr');
  61. var img = document.createElement('img');
  62. img.setAttribute('src', obj['image_urls'][0]);
  63. divImgfr.appendChild(img);
  64. // div-content
  65. var contentBox = document.createElement('div');
  66. contentBox.classList.add('content-box');
  67. var boxTitle = document.createElement('p');
  68. boxTitle.classList.add('box-title');
  69. boxTitle.textContent = obj.name;
  70. boxTitle.id = obj.id;
  71. boxTitle.setAttribute('onclick', `direct(${obj.id})`);
  72. var boxLink = document.createElement('span');
  73. boxLink.classList.add('box-link');
  74. boxLink.setAttribute("data-url", obj.link);
  75. boxLink.setAttribute('onclick', 'view()');
  76. boxLink.innerHTML = '<i class="fas fa-play-circle me-1"></i>觀看影片';
  77. contentBox.appendChild(boxTitle);
  78. contentBox.appendChild(boxLink);
  79. list.classList.add("historyList-item");
  80. list.setAttribute('onclick', `direct(${obj.id})`);
  81. list.appendChild(divImgfr);
  82. list.appendChild(contentBox);
  83. historyList.appendChild(list);
  84. }
  85. document.querySelector('.loader').style.display = "none";
  86. }).catch(err => {
  87. console.log(err);
  88. });
  89. }
  90. function direct(id) {
  91. location.href = `make_video.html?id=${id}`;
  92. }
  93. function view() {
  94. event.stopPropagation();
  95. console.log(event.target);
  96. if (event.target.nodeName === 'I') {
  97. return;
  98. } else {
  99. window.open(`http://${event.target.dataset.url}`, '_blank');
  100. }
  101. }