From 193838b9d3e34f00c69eae13823024e18875e8a7 Mon Sep 17 00:00:00 2001 From: Ian Renton Date: Fri, 31 Oct 2025 10:50:49 +0000 Subject: [PATCH] Fix colours of table rows and JS exception on sig_refs being null. --- core/constants.py | 2 +- webassets/css/style.css | 8 -------- webassets/js/alerts.js | 15 ++++++++++++++- webassets/js/map.js | 10 ++++++---- webassets/js/spots.js | 25 ++++++++++++++++++++----- 5 files changed, 41 insertions(+), 19 deletions(-) diff --git a/core/constants.py b/core/constants.py index a3a09ac..2c19a39 100644 --- a/core/constants.py +++ b/core/constants.py @@ -216,7 +216,7 @@ DXCC_FLAGS = { 146: "\U0001F1F1\U0001F1F9", # LITHUANIA 147: "", # LORD HOWE ISLAND 148: "\U0001F1FB\U0001F1EA", # VENEZUELA - 149: "", # AZORES + 149: "\U0001F1F5\U0001F1F9", # AZORES 150: "\U0001F1E6\U0001F1FA", # AUSTRALIA 151: "", # MALYJ VYSOTSKIJ ISLAND 152: "\U0001F1F2\U0001F1F4", # MACAO diff --git a/webassets/css/style.css b/webassets/css/style.css index 887733f..6e3777e 100644 --- a/webassets/css/style.css +++ b/webassets/css/style.css @@ -59,14 +59,6 @@ button#add-spot-button { /* SPOTS/ALERTS PAGES, MAIN TABLE */ -/* Custom version of Bootstrap table colouring to colour 2 in every 4 rows, because of our second row per spot that -appears on mobile */ -.table-striped-custom > tbody > tr:nth-of-type(4n+3) > *, -.table-striped-custom > tbody > tr:nth-of-type(4n+4) > * { - --bs-table-color-type: var(--bs-table-striped-color); - --bs-table-bg-type: var(--bs-table-striped-bg); -} - td.nowrap, span.nowrap { text-wrap: nowrap; } diff --git a/webassets/js/alerts.js b/webassets/js/alerts.js index 3bc9223..909861d 100644 --- a/webassets/js/alerts.js +++ b/webassets/js/alerts.js @@ -51,7 +51,7 @@ function updateTable() { var showRef = $("#tableShowRef")[0].checked; // Populate table with headers - let table = $('').append(''); + let table = $('
').append(''); if (showStartTime) { table.find('thead tr').append(``); } @@ -107,10 +107,18 @@ function updateTable() { // Add a row to tbody for each alert in the provided list function addAlertRowsToTable(tbody, alerts) { + var count = 0; alerts.forEach(a => { // Create row let $tr = $(''); + // Apply striping to the table. We can't just use Bootstrap's table-striped class because we have all sorts of + // extra faff to deal with, like the mobile view having extra rows, and the On Now / Next 24h / Later banners + // which cause the table-striped colouring to go awry. + if (count % 2 == 1) { + $tr.addClass("table-active"); + } + // Use local time instead of UTC? var useLocalTime = $("#timeZone")[0].value == "local"; @@ -236,6 +244,9 @@ function addAlertRowsToTable(tbody, alerts) { // Second row for mobile view only, containing source, ref, freqs/modes & comment $tr2 = $(""); + if (count % 2 == 1) { + $tr2.addClass("table-active"); + } $td2 = $("
${useLocalTime ? "Start (Local)" : "Start UTC"}
"); if (showSource) { $td2.append(` `); @@ -251,6 +262,8 @@ function addAlertRowsToTable(tbody, alerts) { } $tr2.append($td2); tbody.append($tr2); + + count++; }); } diff --git a/webassets/js/map.js b/webassets/js/map.js index 9c74342..b861356 100644 --- a/webassets/js/map.js +++ b/webassets/js/map.js @@ -106,11 +106,13 @@ function getTooltipText(s) { // Format sig_refs var sig_refs = ""; - var items = [] - for (var i = 0; i < s["sig_refs"].length; i++) { - items[i] = `${s["sig_refs"][i]["id"]}` + if (s["sig_refs"] != null) { + var items = [] + for (var i = 0; i < s["sig_refs"].length; i++) { + items[i] = `${s["sig_refs"][i]["id"]}` + } + sig_refs = items.join(", "); } - sig_refs = items.join(", "); // DX ttt = `${dx_flag} ${dx_call}
`; diff --git a/webassets/js/spots.js b/webassets/js/spots.js index 01c4963..689cac1 100644 --- a/webassets/js/spots.js +++ b/webassets/js/spots.js @@ -43,7 +43,7 @@ function updateTable() { var showDE = $("#tableShowDE")[0].checked; // Populate table with headers - let table = $('').append(''); + let table = $('
').append(''); if (showTime) { table.find('thead tr').append(``); } @@ -76,10 +76,18 @@ function updateTable() { table.find('tbody').append(''); } + var count = 0; spots.forEach(s => { // Create row let $tr = $(''); + // Apply striping to the table. We can't just use Bootstrap's table-striped class because we have all sorts of + // extra faff to deal with, like the mobile view having extra rows, and the On Now / Next 24h / Later banners + // which cause the table-striped colouring to go awry. + if (count % 2 == 1) { + $tr.addClass("table-active"); + } + // Show faded out if QRT if (s["qrt"] == true) { $tr.addClass("table-faded"); @@ -161,11 +169,13 @@ function updateTable() { // Format sig_refs var sig_refs = ""; - var items = [] - for (var i = 0; i < s["sig_refs"].length; i++) { - items[i] = `${s["sig_refs"][i]["id"]}` + if (s["sig_refs"] != null) { + var items = [] + for (var i = 0; i < s["sig_refs"].length; i++) { + items[i] = `${s["sig_refs"][i]["id"]}` + } + sig_refs = items.join(", "); } - sig_refs = items.join(", "); // Format DE flag var de_flag = ""; @@ -224,6 +234,9 @@ function updateTable() { // Second row for mobile view only, containing type, ref & comment $tr2 = $(""); + if (count % 2 == 1) { + $tr2.addClass("table-active"); + } if (s["qrt"] == true) { $tr2.addClass("table-faded"); } @@ -242,6 +255,8 @@ function updateTable() { } $tr2.append($td2); table.find('tbody').append($tr2); + + count++; }); // Update DOM
${useLocalTime ? "Local" : "UTC"}
No spots match your filters.