js: use div instead of br in client pills

Improve html structure inside client pills so the values can be
obtained with jquery by matching the name field of the div.
master
Alejandro Sirgo Rica 2024-07-23 12:40:12 +02:00
parent c5a8c82b35
commit 52b61df025
2 changed files with 7 additions and 5 deletions

View File

@ -10,7 +10,7 @@ async function show_client_mac(pill_id) {
return
}
const ip = pill.html().split('<br>')[1]
const ip = $('[name="ip"]', pill).html()
if (!macs.get(ip)) {
const resp = await fetch('/client/mac?ip=' + ip);
@ -19,7 +19,7 @@ async function show_client_mac(pill_id) {
}
const mac = macs.get(ip)
pill.append('<br>' + mac);
pill.append('<div name="mac">' + mac + '</div>');
}
function showSelectedClient(client_checkbox) {
@ -33,8 +33,10 @@ function showSelectedClient(client_checkbox) {
if (client_checkbox.checked) {
if (!($('#' + pill_id).length)) {
$(container).append('<div class="badge badge-pill og-pill badge-light" ' +
'id="'+ pill_id + '">' + client_name +
'<br>' + client_checkbox.value + '</div>');
'id="'+ pill_id + '">' +
'<div name="name">' + client_name + '</div>' +
'<div name="ip">' + client_checkbox.value + '</div>'+
'</div>');
show_client_mac(pill_id);
}

View File

@ -108,7 +108,7 @@
<!-- ChartJS -->
<script src="{{ url_for('static', filename='AdminLTE/plugins/chart.js/Chart.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/ogcp.js') }}?v=13"></script>
<script src="{{ url_for('static', filename='js/ogcp.js') }}?v=14"></script>
<script>
// error messages