main.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. window.onload = function() {
  2. // autoTriggerFunction();
  3. };
  4. function autoTriggerFunction() {
  5. var button = document.getElementById("update_all_bt");
  6. button.click();
  7. }
  8. // const textbox = document.querySelector('#cmd label textarea');
  9. // textbox.addEventListener('input', () => {
  10. // textbox.scrollTop = textbox.scrollHeight;
  11. // console.log('input');
  12. // });
  13. // textbox.addEventListener('change', () => {
  14. // textbox.scrollTop = textbox.scrollHeight;
  15. // console.log('change');
  16. // });
  17. function scrollTextboxToBottom() {
  18. var textbox = document.querySelector('.textbox_container label textarea');
  19. textbox.scrollTop = textbox.scrollHeight*10;
  20. }
  21. window.addEventListener('DOMContentLoaded', scrollTextboxToBottom);
  22. var checkboxes = document.querySelectorAll('input[type="checkbox"]');
  23. checkboxes.forEach(function(checkbox) {
  24. checkbox.addEventListener("change", function() {
  25. fetch("http://127.0.0.1:7866/endpoint", {
  26. method: "POST",
  27. headers: {
  28. "Content-Type": "application/json",
  29. },
  30. body: JSON.stringify({'task': 'change_checkbox', 'ckid': checkbox.id}),
  31. })
  32. .then((response) => response.json())
  33. .then((data) => {
  34. console.log(data.result)
  35. });
  36. });
  37. });