From 3b4138990c0f4cd7a7bc69d7b973ca6fa1b620b5 Mon Sep 17 00:00:00 2001 From: int2001 Date: Tue, 25 Jul 2023 05:42:02 +0000 Subject: [PATCH] Don't rerender list/map if band is not populated --- assets/js/sections/bandmap.js | 4 ++ assets/js/sections/bandmap_list.js | 85 ++++++++++++++++-------------- 2 files changed, 49 insertions(+), 40 deletions(-) diff --git a/assets/js/sections/bandmap.js b/assets/js/sections/bandmap.js index 368135aa..096c11b7 100644 --- a/assets/js/sections/bandmap.js +++ b/assets/js/sections/bandmap.js @@ -123,6 +123,7 @@ $(function() { } function update_chart(band,maxAgeMinutes) { + if ((band != '') && (band !== undefined)) { let dxurl = dxcluster_provider + "/spots/" + band + "/" +maxAgeMinutes; $.ajax({ url: dxurl, @@ -141,10 +142,12 @@ $(function() { bandMapChart.series[0].setData(spots4chart); bandMapChart.redraw(); }); + } } function set_chart(band, de, maxAgeMinutes) { + if ((band != '') && (band !== undefined)) { let dxurl = dxcluster_provider + "/spots/" + band + "/" +maxAgeMinutes + "/" + de; $.ajax({ url: dxurl, @@ -161,6 +164,7 @@ $(function() { } bandMapChart=render_chart(band,spots4chart); }); + } } $("#menutoggle").on("click", function() { diff --git a/assets/js/sections/bandmap_list.js b/assets/js/sections/bandmap_list.js index b326e3de..adc1ba30 100644 --- a/assets/js/sections/bandmap_list.js +++ b/assets/js/sections/bandmap_list.js @@ -8,47 +8,52 @@ $(function() { function fill_list(band,de,maxAgeMinutes) { - let dxurl = dxcluster_provider + "/spots/" + band + "/" +maxAgeMinutes + "/" + de; - $.ajax({ - url: dxurl, - cache: false, - dataType: "json" - }).done(function(dxspots) { - var table = $('.spottable').DataTable(); - table.page.len(50); - let oldtable=table.data(); - table.clear(); - if (dxspots.length>0) { - dxspots.sort(SortByQrg); - dxspots.forEach((single) => { - var data=[]; - data[0]=[]; - data[0].push(single.when_pretty); - data[0].push(single.frequency + " kHz"); - data[0].push((single.worked_call ?'' : '')+single.spotted+(single.worked_call ? '' : '')); - data[0].push(single.dxcc_spotted.entity); - data[0].push(single.spotter); - if (oldtable.length > 0) { - let update=false; - oldtable.each( function (srow) { - if (JSON.stringify(srow) === JSON.stringify(data[0])) { - update=true; - } - }); - if (!update) { // Sth. Fresh? So highlight - table.rows.add(data).draw().nodes().to$().addClass("fresh bg-info"); - } else { - table.rows.add(data).draw(); + var table = $('.spottable').DataTable(); + if ((band != '') && (band !== undefined)) { + let dxurl = dxcluster_provider + "/spots/" + band + "/" +maxAgeMinutes + "/" + de; + $.ajax({ + url: dxurl, + cache: false, + dataType: "json" + }).done(function(dxspots) { + table.page.len(50); + let oldtable=table.data(); + table.clear(); + if (dxspots.length>0) { + dxspots.sort(SortByQrg); + dxspots.forEach((single) => { + var data=[]; + data[0]=[]; + data[0].push(single.when_pretty); + data[0].push(single.frequency + " kHz"); + data[0].push((single.worked_call ?'' : '')+single.spotted+(single.worked_call ? '' : '')); + data[0].push(single.dxcc_spotted.entity); + data[0].push(single.spotter); + if (oldtable.length > 0) { + let update=false; + oldtable.each( function (srow) { + if (JSON.stringify(srow) === JSON.stringify(data[0])) { + update=true; + } + }); + if (!update) { // Sth. Fresh? So highlight + table.rows.add(data).draw().nodes().to$().addClass("fresh bg-info"); + } else { + table.rows.add(data).draw(); + } + } else { + table.rows.add(data).draw(); } - } else { - table.rows.add(data).draw(); - } - }); - setTimeout(function(){ // Remove Highlights within 15sec - $(".fresh").removeClass("bg-info"); - },1000); - } - }); + }); + setTimeout(function(){ // Remove Highlights within 15sec + $(".fresh").removeClass("bg-info"); + },1000); + } + }); + } else { + table.clear(); + table.draw(); + } } function highlight_current_qrg(qrg) {