aboutsummaryrefslogtreecommitdiffstats
path: root/static
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2024-01-16 22:18:32 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2024-01-16 22:18:32 +0100
commit81a61c28619ef9f32e79e5698bc4162ca1ceb82d (patch)
treed274a43a7b05a0a48269af1f32f616951b0c4288 /static
parent6db211a70f95c339710ac73ec12d9e7c5664a278 (diff)
downloadcats-radio-node-81a61c28619ef9f32e79e5698bc4162ca1ceb82d.tar.gz
cats-radio-node-81a61c28619ef9f32e79e5698bc4162ca1ceb82d.tar.bz2
cats-radio-node-81a61c28619ef9f32e79e5698bc4162ca1ceb82d.zip
Add Destination to Send page
Diffstat (limited to 'static')
-rw-r--r--static/main.js26
1 files changed, 25 insertions, 1 deletions
diff --git a/static/main.js b/static/main.js
index 8687dc1..ad50976 100644
--- a/static/main.js
+++ b/static/main.js
@@ -1,13 +1,37 @@
-async function btn_send_packet() {
+async function btn_add_destination() {
+ const template = document.getElementById('destination_template');
+
+ let clon = template.content.cloneNode(true);
+ document.getElementById('destinations').appendChild(clon);
+}
+
+async function btn_remove_destination(element_clicked) {
+ element_clicked.parentElement.remove()
+}
+async function btn_send_packet() {
let data = {
'comment': null,
+ 'destinations': [],
};
if (document.getElementById('with_comment').checked) {
data.comment = document.getElementById('whisker_comment').value;
}
+ const destinations = document.getElementById('destinations');
+ const destList = destinations.querySelectorAll("p.destination");
+ for (let i = 0; i < destList.length; i++) {
+ const dest_callsign = destList[i].querySelector("input.dest_callsign").value;
+ const dest_ssid_str = destList[i].querySelector("input.dest_ssid").value;
+ const dest_ssid = parseInt(dest_ssid_str, 10);
+ if (dest_ssid < 0 || dest_ssid > 255) {
+ alert("SSID must be between 0 and 255");
+ return;
+ }
+ data.destinations.push({'callsign': dest_callsign, 'ssid': dest_ssid});
+ }
+
await post('/api/send_packet', data);
}