diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2024-01-07 17:43:05 +0100 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2024-01-07 17:43:05 +0100 |
commit | b40299538a73d25d096d8f58f1468cd7f647a3f9 (patch) | |
tree | c7635cc964ad790a6f520862e948c16a2b2021a4 /static | |
parent | c2742cde3d034b2af9bbcee90765338ee094e6cc (diff) | |
download | cats-radio-node-b40299538a73d25d096d8f58f1468cd7f647a3f9.tar.gz cats-radio-node-b40299538a73d25d096d8f58f1468cd7f647a3f9.tar.bz2 cats-radio-node-b40299538a73d25d096d8f58f1468cd7f647a3f9.zip |
Add first iteration of send page, and fake-radio
Diffstat (limited to 'static')
-rw-r--r-- | static/main.js | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/static/main.js b/static/main.js new file mode 100644 index 0000000..8687dc1 --- /dev/null +++ b/static/main.js @@ -0,0 +1,28 @@ +async function btn_send_packet() { + + let data = { + 'comment': null, + }; + + if (document.getElementById('with_comment').checked) { + data.comment = document.getElementById('whisker_comment').value; + } + + await post('/api/send_packet', data); +} + +async function post(url, data) { + const params = { + method: "POST", + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(data), + }; + + let response = await fetch(url, params); + if (!response.ok) { + const text = await response.text(); + alert(`Error Sending: ${response.statusText} ${text}`); + } +} |