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.
This commit is contained in:
Hemna 2023-09-12 15:44:34 -04:00
parent b4e02c760e
commit 8a90d5480a
2 changed files with 10 additions and 1 deletions

View File

@ -172,7 +172,7 @@ function create_callsign_tab(callsign, active=false) {
}
item_html = '<li class="nav-item" role="presentation">';
item_html += '<button class="nav-link '+active_str+'" id="'+tab_id+'" data-bs-toggle="tab" data-bs-target="#'+tab_content+'" type="button" role="tab" aria-controls="'+callsign+'" aria-selected="true">';
item_html += '<button callsign="'+callsign+'" class="nav-link '+active_str+'" id="'+tab_id+'" data-bs-toggle="tab" data-bs-target="#'+tab_content+'" type="button" role="tab" aria-controls="'+callsign+'" aria-selected="true">';
item_html += callsign+'&nbsp;&nbsp;';
item_html += '<span onclick="delete_tab(\''+callsign+'\');">×</span>';
item_html += '</button></li>'

View File

@ -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);
});
</script>
</head>