summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlejandro Sirgo Rica <asirgo@soleta.eu>2024-07-23 12:40:12 +0200
committerAlejandro Sirgo Rica <asirgo@soleta.eu>2024-07-25 09:48:12 +0200
commit52b61df025641d3070140ce4fa0bd28aead047e4 (patch)
tree27bdbe1b5ca58c3d08437c3d610c94012fe696fb
parentc5a8c82b35704d2c7f1bb567095708d2c88169a1 (diff)
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.
-rw-r--r--ogcp/static/js/ogcp.js10
-rw-r--r--ogcp/templates/base.html2
2 files changed, 7 insertions, 5 deletions
diff --git a/ogcp/static/js/ogcp.js b/ogcp/static/js/ogcp.js
index 548122b..af95dde 100644
--- a/ogcp/static/js/ogcp.js
+++ b/ogcp/static/js/ogcp.js
@@ -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);
}
diff --git a/ogcp/templates/base.html b/ogcp/templates/base.html
index fad931a..b6fcb94 100644
--- a/ogcp/templates/base.html
+++ b/ogcp/templates/base.html
@@ -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