webchat: got active tab onclick working

This patch adds the ability to click on the already existing active tab
and have it populate the to_call input box.
This commit is contained in:
Hemna 2023-09-12 16:37:06 -04:00
parent 8a90d5480a
commit 1400e3e711
2 changed files with 9 additions and 9 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 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 += '<button onClick="$(\'#to_call\').val(\''+callsign+'\');" 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

@ -48,16 +48,16 @@
console.log('Wipe local storage');
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');
to_call.val(callsign);
});
});
// 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>