From 8a90d5480ae379a3af225a4f73d452c8d5ae402e Mon Sep 17 00:00:00 2001 From: Hemna Date: Tue, 12 Sep 2023 15:44:34 -0400 Subject: [PATCH] webchat: set to_call to value of tab when selected This patch will set the to_call form field to the callsign of the tab when the tab is activated in the UI. NOTE: still need to populate it when clicking on the already active tab. --- aprsd/web/chat/static/js/send-message.js | 2 +- aprsd/web/chat/templates/index.html | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/aprsd/web/chat/static/js/send-message.js b/aprsd/web/chat/static/js/send-message.js index 73242e4..8cd3ac0 100644 --- a/aprsd/web/chat/static/js/send-message.js +++ b/aprsd/web/chat/static/js/send-message.js @@ -172,7 +172,7 @@ function create_callsign_tab(callsign, active=false) { } item_html = '' diff --git a/aprsd/web/chat/templates/index.html b/aprsd/web/chat/templates/index.html index b56f647..3f92c2f 100644 --- a/aprsd/web/chat/templates/index.html +++ b/aprsd/web/chat/templates/index.html @@ -49,6 +49,15 @@ localStorage.clear(); }); }); + + // When a tab is clicked, populate the to_call form field. + $(document).on('shown.bs.tab', 'button[data-bs-toggle="tab"]', function (e) { + var tab = $(e.target); + var callsign = tab.attr("callsign"); + var to_call = $('#to_call'); + console.log("Tab clicked on " + callsign); + to_call.val(callsign); + });