diff --git a/application/controllers/Bandmap.php b/application/controllers/Bandmap.php index f8c7e26b..e40363c8 100644 --- a/application/controllers/Bandmap.php +++ b/application/controllers/Bandmap.php @@ -26,4 +26,21 @@ class Bandmap extends CI_Controller { $this->load->view('bandmap/index'); $this->load->view('interface_assets/footer', $footerData); } + + function list() { + $this->load->model('cat'); + $this->load->model('bands'); + $data['radios'] = $this->cat->radios(); + $data['bands'] = $this->bands->get_user_bands_for_qso_entry(); + + $footerData = []; + $footerData['scripts'] = [ + 'assets/js/sections/bandmap_list.js', + ]; + + $data['page_title'] = "DXCluster"; + $this->load->view('interface_assets/header', $data); + $this->load->view('bandmap/list'); + $this->load->view('interface_assets/footer', $footerData); + } } diff --git a/application/views/bandmap/list.php b/application/views/bandmap/list.php new file mode 100644 index 00000000..4f7a55c4 --- /dev/null +++ b/application/views/bandmap/list.php @@ -0,0 +1,56 @@ + + + +
+
+ +

+
+
+ + + + + +
+ +
+
DXCluster
+

+ + + + + + + + + + + + + +
/DXCC
+

+
+ + diff --git a/assets/js/sections/bandmap_list.js b/assets/js/sections/bandmap_list.js new file mode 100644 index 00000000..91717e78 --- /dev/null +++ b/assets/js/sections/bandmap_list.js @@ -0,0 +1,100 @@ +$(function() { + + function SortByQrg(a, b){ + var a = a.frequency; + var b = b.frequency; + return ((a< b) ? -1 : ((a> b) ? 1 : 0)); + } + + + function fill_list(band,maxAgeMinutes) { + let dxurl = dxcluster_provider + "/spots/" + band + "/" +maxAgeMinutes; + $.ajax({ + url: dxurl, + cache: false, + dataType: "json" + }).done(function(dxspots) { + var table = $('.spottable').DataTable(); + table.clear(); + table.page.len(50); + table.order([1, 'asc']); + if (dxspots.length>0) { + dxspots.sort(SortByQrg); + dxspots.forEach((single) => { + var data = [[ single.when, single.frequency, single.spotted, single.dxcc_spotted.call ]]; + table.rows.add(data).draw(); + // add to datatable single + }); + } + }); + } + + fill_list($('#band option:selected').val(),30); + setInterval(function () { fill_list($('#band option:selected').val(),30); },60000); + $("#band").on("change",function() { + fill_list($('#band option:selected').val(),30); + }); + + + var updateFromCAT = function() { + if($('select.radios option:selected').val() != '0') { + radioID = $('select.radios option:selected').val(); + $.getJSON( "radio/json/" + radioID, function( data ) { + + if (data.error) { + if (data.error == 'not_logged_in') { + $(".radio_cat_state" ).remove(); + if($('.radio_login_error').length == 0) { + $('.messages').prepend(''); + } + } + // Put future Errorhandling here + } else { + if($('.radio_login_error').length != 0) { + $(".radio_login_error" ).remove(); + } + var band = frequencyToBand(data.frequency); + + if (band !== $("#band").val()) { + $("#band").val(band); + $("#band").trigger("change"); + } + + var minutes = Math.floor(cat_timeout_interval / 60); + + if(data.updated_minutes_ago > minutes) { + $(".radio_cat_state" ).remove(); + if($('.radio_timeout_error').length == 0) { + $('.messages').prepend(''); + } else { + $('.radio_timeout_error').html('Radio connection timed-out: ' + $('select.radios option:selected').text() + ' data is ' + data.updated_minutes_ago + ' minutes old.'); + } + } else { + $(".radio_timeout_error" ).remove(); + text = 'TX: '+(Math.round(parseInt(data.frequency)/100)/10000).toFixed(4)+' MHz'; + if(data.mode != null) { + text = text+''+data.mode; + } + if(data.power != null && data.power != 0) { + text = text+''+data.power+' W'; + } + if (! $('#radio_cat_state').length) { + $('.messages').prepend(''); + } else { + $('#radio_cat_state').html(text); + } + } + } + }); + } +}; + +// Update frequency every three second +// setInterval(updateFromCAT, 3000); + +// If a radios selected from drop down select radio update. +$('.radios').change(updateFromCAT); + +}); + +