File size: 1,303 Bytes
2319518
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
window.onload = function() {
  // autoTriggerFunction();
};

function autoTriggerFunction() {
  var button = document.getElementById("update_all_bt");
  button.click();
}

// const textbox = document.querySelector('#cmd label textarea');

// textbox.addEventListener('input', () => {
//   textbox.scrollTop = textbox.scrollHeight;
//   console.log('input');
// });
// textbox.addEventListener('change', () => {
//   textbox.scrollTop = textbox.scrollHeight;
//   console.log('change');
// });

function scrollTextboxToBottom() {
  var textbox = document.querySelector('.textbox_container label textarea');
  textbox.scrollTop = textbox.scrollHeight*10;
}
window.addEventListener('DOMContentLoaded', scrollTextboxToBottom);


var checkboxes = document.querySelectorAll('input[type="checkbox"]');
checkboxes.forEach(function(checkbox) {
  checkbox.addEventListener("change", function() {
    console.log(location.hostname)
    var _server_url = "http://"+location.hostname+":7866/endpoint";
    fetch(_server_url, {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
      },
      body: JSON.stringify({'task': 'change_checkbox', 'ckid': checkbox.id}),
    })
    .then((response) => response.json())
    .then((data) => {
      console.log(data.result)
    });
  });
});