reset_pwd.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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. let lan = localStorage.getItem('lan');
  25. $('.dropdown-toggle').click(() => {
  26. lan = localStorage.getItem('lan');
  27. checkLan();
  28. });
  29. checkLan();
  30. function checkLan() {
  31. if(lan == 'en') {
  32. $('.btn-makev').css('display', 'none');
  33. $('.btn-makelong').css('display', 'none');
  34. } else {
  35. $('.btn-makev').css('display', 'block');
  36. $('.btn-makelong').css('display', 'block');
  37. }
  38. }
  39. $(".sender").click(function () {
  40. var pwd = $("#in_pwd").val();
  41. var code = $("#code").val();
  42. var url = "https://www.choozmo.com:8887/reset_pwd";
  43. var xhr = new XMLHttpRequest();
  44. xhr.open("POST", url);
  45. xhr.setRequestHeader("accept", "application/json");
  46. xhr.setRequestHeader("Content-Type", "application/json");
  47. xhr.onreadystatechange = function () {
  48. if (xhr.readyState === 4) {
  49. alert('重設成功')
  50. }};
  51. var data = `{"code":"`+ code+`","password":"`+pwd+`"}`
  52. xhr.send(data);
  53. });
  54. var loaded_data = ''
  55. function openNav() {
  56. document.getElementById("mySidenav").style.width = "250px";
  57. document.querySelector('.loader').style.display = "block";
  58. let token = getCookie('jwt_token');
  59. axios({
  60. method: 'post',
  61. url: 'https://www.choozmo.com:8887/history_input',
  62. headers: {
  63. 'accept': 'application/json',
  64. 'Authorization': `Bearer ${token}`
  65. }
  66. }).then(res => {
  67. console.log(res.data);
  68. loaded_data = res.data;
  69. var historyList = document.querySelector('.historyList');
  70. historyList.innerHTML = '';
  71. for (var obj of loaded_data) {
  72. var list = document.createElement('li');
  73. list.id = obj.id;
  74. // div-imgfr
  75. var divImgfr = document.createElement('div');
  76. divImgfr.classList.add('item_imgfr');
  77. var img = document.createElement('img');
  78. img.setAttribute('src', obj['image_urls'][0]);
  79. divImgfr.appendChild(img);
  80. // div-content
  81. var contentBox = document.createElement('div');
  82. contentBox.classList.add('content-box');
  83. var boxTitle = document.createElement('p');
  84. boxTitle.classList.add('box-title');
  85. boxTitle.textContent = obj.name;
  86. boxTitle.id = obj.id;
  87. boxTitle.setAttribute('onclick', `direct(${obj.id})`);
  88. var boxLink = document.createElement('span');
  89. boxLink.classList.add('box-link');
  90. boxLink.setAttribute("data-url", obj.link);
  91. boxLink.setAttribute('onclick', 'view()');
  92. boxLink.innerHTML = '<i class="fas fa-play-circle me-1"></i>觀看影片';
  93. contentBox.appendChild(boxTitle);
  94. contentBox.appendChild(boxLink);
  95. list.classList.add("historyList-item");
  96. list.setAttribute('onclick', `direct(${obj.id})`);
  97. list.appendChild(divImgfr);
  98. list.appendChild(contentBox);
  99. historyList.appendChild(list);
  100. }
  101. document.querySelector('.loader').style.display = "none";
  102. }).catch(err => {
  103. console.log(err);
  104. });
  105. }
  106. function direct(id) {
  107. location.href = `make_video2.html?id=${id}`;
  108. }
  109. function view() {
  110. event.stopPropagation();
  111. console.log(event.target);
  112. if (event.target.nodeName === 'I') {
  113. return;
  114. } else {
  115. window.open(`http://${event.target.dataset.url}`, '_blank');
  116. }
  117. }