diff --git a/application/controllers/Bandmap.php b/application/controllers/Bandmap.php index 1719d891..f8c7e26b 100644 --- a/application/controllers/Bandmap.php +++ b/application/controllers/Bandmap.php @@ -11,6 +11,11 @@ class Bandmap extends CI_Controller { } function index() { + $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.js', diff --git a/application/views/bandmap/index.php b/application/views/bandmap/index.php index 8e5d6d3c..a933678c 100644 --- a/application/views/bandmap/index.php +++ b/application/views/bandmap/index.php @@ -1,31 +1,38 @@ -
+

-
- +
+
+ + + + + +
- -
-

diff --git a/assets/js/sections/bandmap.js b/assets/js/sections/bandmap.js index 520d9fc0..dfd89c07 100644 --- a/assets/js/sections/bandmap.js +++ b/assets/js/sections/bandmap.js @@ -147,7 +147,7 @@ $(function() { function set_chart(band,maxAgeMinutes) { let dxurl = dxcluster_provider + "/spots/" + band + "/" +maxAgeMinutes; $.ajax({ - url: dxurl, + url: dxurl, cache: false, dataType: "json" }).done(function(dxspots) { @@ -169,3 +169,62 @@ $(function() { set_chart($('#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);