Remove Bandmap feature and related files

This commit removes the Bandmap feature, including its controller, views, JavaScript assets, and navigation menu entry. This is because it was broken upstream
pull/3349/head
Peter Goodhall 2025-10-02 09:46:01 +01:00
rodzic a158cc9614
commit 8ee56acb17
8 zmienionych plików z 31 dodań i 717 usunięć

Wyświetl plik

@ -22,7 +22,7 @@ $config['migration_enabled'] = TRUE;
|
*/
$config['migration_version'] = 212;
$config['migration_version'] = 213;
/*
|--------------------------------------------------------------------------

Wyświetl plik

@ -1,53 +0,0 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Dxcluster extends CI_Controller {
function __construct()
{
parent::__construct();
$this->load->model('user_model');
if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); }
$this->load->model('dxcluster_model');
}
function spots($band,$age = '', $de = '') {
if ($age == '') {
$age = $this->optionslib->get_option('dxcluster_maxage');
}
if ($de == '') {
$de = $this->optionslib->get_option('dxcluster_decont');
}
$calls_found=$this->dxcluster_model->dxc_spotlist($band, $age, $de);
header('Content-Type: application/json');
if ($calls_found) {
echo json_encode($calls_found, JSON_PRETTY_PRINT);
} else {
echo '{ "error": "not found" }';
}
}
function qrg_lookup($qrg) {
$call_found=$this->dxcluster_model->dxc_qrg_lookup($this->security->xss_clean($qrg));
header('Content-Type: application/json');
if ($call_found) {
echo json_encode($call_found, JSON_PRETTY_PRINT);
} else {
echo '{ "error": "not found" }';
}
}
function call($call) {
$this->load->model('logbook_model');
$date = date('Ymd', time());
$dxcc = $this->logbook_model->dxcc_lookup($call, $date);
if ($dxcc) {
header('Content-Type: application/json');
echo json_encode($dxcc, JSON_PRETTY_PRINT);
} else {
echo '{ "error": "not found" }';
}
}
}

Wyświetl plik

@ -0,0 +1,30 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/*
* Tag Cloudlog as 2.7.2
*/
class Migration_tag_2_7_2 extends CI_Migration {
public function up()
{
// Tag Cloudlog 2.7.2
$this->db->where('option_name', 'version');
$this->db->update('options', array('option_value' => '2.7.2'));
// Trigger Version Info Dialog
$this->db->where('option_type', 'version_dialog');
$this->db->where('option_name', 'confirmed');
$this->db->update('user_options', array('option_value' => 'false'));
}
public function down()
{
$this->db->where('option_name', 'version');
$this->db->update('options', array('option_value' => '2.7.1'));
}
}

Wyświetl plik

@ -1,66 +0,0 @@
<script>
var dxcluster_provider="<?php echo base_url(); ?>index.php/dxcluster";
var dxcluster_maxage=<?php echo $this->optionslib->get_option('dxcluster_maxage'); ?>;
var cat_timeout_interval="<?php echo $this->optionslib->get_option('cat_timeout_interval'); ?>";
</script>
<div class="container">
<br>
<center><button type="button" class="btn" id="menutoggle"><i class="fa fa-arrow-up" id="menutoggle_i"></i></button></center>
<h2 id="dxtitle"><?php echo $page_title; ?></h2>
<div class="tabs" id="dxtabs">
<ul class="nav nav-tabs" id="myTab" role="tablist">
<li class="nav-item">
<a class="nav-link active" href="index">BandMap</a>
</li>
<li class="nav-item">
<a class="nav-link" href="list">BandList</a>
</li>
</ul>
</div>
<div class="tab-content" id="myTabContent">
<div class="messages my-1 me-2"></div>
<div class="d-flex align-items-center">
<label class="my-1 me-2" for="radio"><?php echo lang('gen_hamradio_radio'); ?></label>
<select class="form-select form-select-sm radios my-1 me-sm-2 w-auto" id="radio" name="radio">
<option value="0" selected="selected"><?php echo lang('general_word_none'); ?></option>
<?php foreach ($radios->result() as $row) { ?>
<option value="<?php echo $row->id; ?>" <?php if($this->session->userdata('radio') == $row->id) { echo "selected=\"selected\""; } ?>><?php echo $row->radio; ?></option>
<?php } ?>
</select>
<label class="my-1 me-2" for="decontSelect">Spots de</label>
<select class="form-select form-select-sm my-1 me-sm-2 w-auto" id="decontSelect" name="dxcluster_decont" aria-describedby="dxcluster_decontHelp" required>
<option value="Any">*</option>
<option value="AF"<?php if ($this->optionslib->get_option('dxcluster_decont') == 'AF') { echo " selected"; } ?>>Africa</option>
<option value="AN"<?php if ($this->optionslib->get_option('dxcluster_decont') == 'AN') { echo " selected"; } ?>>Antarctica</option>
<option value="AS"<?php if ($this->optionslib->get_option('dxcluster_decont') == 'AS') { echo " selected"; } ?>>Asia</option>
<option value="EU"<?php if ($this->optionslib->get_option('dxcluster_decont') == 'EU') { echo " selected"; } ?>>Europe</option>
<option value="NA"<?php if ($this->optionslib->get_option('dxcluster_decont') == 'NA') { echo " selected"; } ?>>North America</option>
<option value="OC"<?php if ($this->optionslib->get_option('dxcluster_decont') == 'OC') { echo " selected"; } ?>>Oceania</option>
<option value="SA"<?php if ($this->optionslib->get_option('dxcluster_decont') == 'SA') { echo " selected"; } ?>>South America</option>
</select>
<label class="my-1 me-2" for="band"><?php echo lang('gen_hamradio_band'); ?></label>
<select id="band" class="form-select form-select-sm my-1 me-sm-2 w-auto" name="band">
<?php foreach($bands as $key=>$bandgroup) {
echo '<optgroup label="' . strtoupper($key) . '">';
foreach($bandgroup as $band) {
echo '<option value="' . $band . '"';
if ($band == "20m") echo ' selected';
echo '>' . $band . '</option>'."\n";
}
echo '</optgroup>';
}
?>
</select>
</div>
<figure class="highcharts-figure">
<div id="bandmap"></div>
<p class="highcharts-description">
</p>
</figure>
</div>
</div>

Wyświetl plik

@ -1,101 +0,0 @@
<script>
var dxcluster_provider="<?php echo base_url(); ?>index.php/dxcluster";
var cat_timeout_interval="<?php echo $this->optionslib->get_option('cat_timeout_interval'); ?>";
var dxcluster_maxage=<?php echo $this->optionslib->get_option('dxcluster_maxage'); ?>;
var custom_date_format = "<?php echo $custom_date_format ?>";
</script>
<style>
.spotted_call {
cursor: alias;
}
.kHz::after {
content: " kHz";
}
.fresh{
-webkit-transition: all 15s ease;
-moz-transition: all 15s ease;
-o-transition: all 15s ease;
transition: all 15s ease;
--bs-table-bg: #5dade2;
--bs-table-accent-bg: #5dade2;
}
</style>
<div class="container">
<br>
<center><button type="button" class="btn" id="menutoggle"><i class="fa fa-arrow-up" id="menutoggle_i"></i></button></center>
<h2 id="dxtitle"><?php echo $page_title; ?></h2>
<div id="dxtabs" class="tabs">
<ul class="nav nav-tabs" id="myTab" role="tablist">
<li class="nav-item">
<a class="nav-link" href="index">BandMap</a>
</li>
<li class="nav-item">
<a class="nav-link active" href="list">BandList</a>
</li>
</ul>
</div>
<div class="tab-content" id="myTabContent">
<div class="messages my-1 me-2"></div>
<div class="d-flex align-items-center">
<label class="my-1 me-2" for="radio"><?php echo lang('gen_hamradio_radio'); ?></label>
<select class="form-select form-select-sm radios my-1 me-sm-2 w-auto" id="radio" name="radio">
<option value="0" selected="selected"><?php echo lang('general_word_none'); ?></option>
<?php foreach ($radios->result() as $row) { ?>
<option value="<?php echo $row->id; ?>" <?php if($this->session->userdata('radio') == $row->id) { echo "selected=\"selected\""; } ?>><?php echo $row->radio; ?></option>
<?php } ?>
</select>
<label class="my-1 me-2" for="decontSelect">Spots de</label>
<select class="form-select form-select-sm my-1 me-sm-2 w-auto" id="decontSelect" name="dxcluster_decont" aria-describedby="dxcluster_decontHelp" required>
<option value="Any">*</option>
<option value="AF"<?php if ($this->optionslib->get_option('dxcluster_decont') == 'AF') { echo " selected"; } ?>>Africa</option>
<option value="AN"<?php if ($this->optionslib->get_option('dxcluster_decont') == 'AN') { echo " selected"; } ?>>Antarctica</option>
<option value="AS"<?php if ($this->optionslib->get_option('dxcluster_decont') == 'AS') { echo " selected"; } ?>>Asia</option>
<option value="EU"<?php if ($this->optionslib->get_option('dxcluster_decont') == 'EU') { echo " selected"; } ?>>Europe</option>
<option value="NA"<?php if ($this->optionslib->get_option('dxcluster_decont') == 'NA') { echo " selected"; } ?>>North America</option>
<option value="OC"<?php if ($this->optionslib->get_option('dxcluster_decont') == 'OC') { echo " selected"; } ?>>Oceania</option>
<option value="SA"<?php if ($this->optionslib->get_option('dxcluster_decont') == 'SA') { echo " selected"; } ?>>South America</option>
</select>
<label class="my-1 me-2" for="band"><?php echo lang('gen_hamradio_band'); ?></label>
<select id="band" class="form-select form-select-sm my-1 me-sm-2 w-auto" name="band">
<option value="All">All</option>
<?php foreach($bands as $key=>$bandgroup) {
echo '<optgroup label="' . strtoupper($key) . '">';
foreach($bandgroup as $band) {
echo '<option value="' . $band . '"';
if ($band == "20m") echo ' selected';
echo '>' . $band . '</option>'."\n";
}
echo '</optgroup>';
}
?>
</select>
</div>
<p>
<table style="width:100%" class="table-sm table spottable table-bordered table-hover table-striped table-condensed">
<thead>
<tr class="log_title titles">
<th><?php echo lang('general_word_date'); ?>/<?php echo lang('general_word_time'); ?></th>
<th><?php echo lang('gen_hamradio_frequency'); ?></th>
<th><?php echo lang('gen_hamradio_call'); ?></th>
<th>DXCC</th>
<th><?php echo lang('gen_hamradio_call'); ?> Spotter</th>
</tr>
</thead>
<tbody class="spots_table_contents">
</tbody>
</table>
</div>
</div>
</div>

Wyświetl plik

@ -200,10 +200,6 @@
<a class="dropdown-item" href="<?php echo site_url('workabledxcc'); ?>" title="Upcoming DXPeditions"><i class="fas fa-globe"></i> Upcoming DXPeditions</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="<?php echo site_url('hamsat'); ?>" title="Hams.at"><i class="fas fa-list"></i> Hams.at</a>
<?php if ($this->optionslib->get_option('dxcache_url') != '') { ?>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="<?php echo site_url('bandmap/list'); ?>" title="Bandmap"><i class="fa fa-bezier-curve"></i> <?php echo lang('menu_bandmap'); ?></a>
<?php } ?>
<!-- <div class="dropdown-divider"></div> -->
<!-- a class="dropdown-item" href="<?php echo site_url('sattimers'); ?>" title="SAT Timers"><i class="fas fa-satellite"></i> SAT Timers</a> -->
</div>

Wyświetl plik

@ -1,254 +0,0 @@
$(function() {
(function(H) {
H.seriesTypes.timeline.prototype.distributeDL = function() {
var series = this,
dataLabelsOptions = series.options.dataLabels,
options,
pointDLOptions,
newOptions = {},
visibilityIndex = 1,
j = 2,
distance;
series.points.forEach(function(point, i) {
distance = dataLabelsOptions.distance;
if (point.visible && !point.isNull) {
options = point.options;
pointDLOptions = point.options.dataLabels;
if (!series.hasRendered) {
point.userDLOptions = H.merge({}, pointDLOptions);
}
/*
if (i === j || i === j + 1) {
distance = distance * 2.5
if (i === j + 1) {
j += 4
}
}
*/
if (i % 6 == 0) { distance = distance * 1; }
if (i % 6 == 1) { distance = distance * -1; }
if (i % 6 == 2) { distance = distance * 2; }
if (i % 6 == 3) { distance = distance * -2; }
if (i % 6 == 4) { distance = distance * 3; }
if (i % 6 == 5) { distance = distance * -3; }
newOptions[series.chart.inverted ? 'x' : 'y'] = distance;
// newOptions[series.chart.inverted ? 'x' : 'y'] = dataLabelsOptions.alternate && (visibilityIndex % 3 != 0) ? -distance : distance;
options.dataLabels = H.merge(newOptions, point.userDLOptions);
visibilityIndex++;
}
});
}
}(Highcharts));
var bandMapChart;
var color = ifDarkModeThemeReturn('white', 'grey');
function render_chart (band,spot_data) {
let chartObject=Highcharts.chart('bandmap', {
chart: {
type: 'timeline',
zoomType: 'x',
inverted: true,
backgroundColor: getBodyBackground(),
height: '800px'
},
accessibility: {
screenReaderSection: {
beforeChartFormat: '<h5>{chartTitle}</h5>' +
'<div>{typeDescription}</div>' +
'<div>{chartSubtitle}</div>' +
'<div>{chartLongdesc}</div>' +
'<div>{viewTableButton}</div>'
},
point: {
valueDescriptionFormat: '{index}. {point.label}. {point.description}.'
}
},
xAxis: {
lineColor: color,
visible: true,
type: 'linear',
labels: {
style: {
color: color,
}
}
},
yAxis: {
visible: false,
},
title: {
text: band,
style: {
color: color
}
},
series: [ { data: spot_data } ]
});
return chartObject;
}
function SortByQrg(a, b){
var a = a.frequency;
var b = b.frequency;
return ((a< b) ? -1 : ((a> b) ? 1 : 0));
}
function reduce_spots(spotobject) {
let unique=[];
spotobject.forEach((single) => {
if (!spotobject.find((item) => ((item.spotted == single.spotted) && (item.frequency == single.frequency) && (Date.parse(item.when)>Date.parse(single.when))))) {
unique.push(single);
}
});
return unique;
}
function convert2high(spotobject) {
let ret={};
ret.name=spotobject.spotted;
ret.x=spotobject.frequency;
ret.description=spotobject.frequency + " / "+Math.round( (Date.now() - Date.parse(spotobject.when)) / 1000 / 60)+"min. ago";
ret.dataLabels={};
ret.dataLabels.alternate=true;
ret.dataLabels.distance=200;
return ret;
}
function update_chart(band,maxAgeMinutes) {
if ((band != '') && (band !== undefined)) {
let dxurl = dxcluster_provider + "/spots/" + band + "/" +maxAgeMinutes;
$.ajax({
url: dxurl,
cache: false,
dataType: "json"
}).done(function(dxspots) {
spots4chart=[];
if (dxspots.length>0) {
dxspots.sort(SortByQrg);
dxspots=reduce_spots(dxspots);
dxspots.forEach((single) => {
spots4chart.push(convert2high(single));
});
}
bandMapChart.title.text=band;
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,
cache: false,
dataType: "json"
}).done(function(dxspots) {
spots4chart=[];
if (dxspots.length>0) {
dxspots.sort(SortByQrg);
dxspots=reduce_spots(dxspots);
dxspots.forEach((single) => {
spots4chart.push(convert2high(single));
});
}
bandMapChart=render_chart(band,spots4chart);
});
}
}
$("#menutoggle").on("click", function() {
if ($('.navbar').is(":hidden")) {
$('.navbar').show();
$('#dxtabs').show();
$('#dxtitle').show();
$('#menutoggle_i').removeClass('fa-arrow-down');
$('#menutoggle_i').addClass('fa-arrow-up');
} else {
$('.navbar').hide();
$('#dxtabs').hide();
$('#dxtitle').hide();
$('#menutoggle_i').removeClass('fa-arrow-up');
$('#menutoggle_i').addClass('fa-arrow-down');
}
});
set_chart($('#band option:selected').val(), $('#decontSelect option:selected').val(), dxcluster_maxage);
setInterval(function () { update_chart($('#band option:selected').val(),dxcluster_maxage); },60000);
$("#band").on("change",function() {
set_chart($('#band option:selected').val(), $('#decontSelect option:selected').val(), dxcluster_maxage);
});
$("#decontSelect").on("change",function() {
set_chart($('#band option:selected').val(), $('#decontSelect option:selected').val(), dxcluster_maxage);
});
});
var updateFromCAT = function() {
if($('select.radios option:selected').val() != '0') {
radioID = $('select.radios option:selected').val();
$.getJSON( base_url + "index.php/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('<div class="alert alert-danger radio_login_error" role="alert"><i class="fas fa-broadcast-tower"></i> You\'re not logged it. Please <a href="'+base_url+'">login</a></div>');
}
}
// 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('<div class="alert alert-danger radio_timeout_error" role="alert"><i class="fas fa-broadcast-tower"></i> Radio connection timed-out: ' + $('select.radios option:selected').text() + ' data is ' + data.updated_minutes_ago + ' minutes old.</div>');
} 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 = '<i class="fas fa-broadcast-tower"></i><span style="margin-left:10px;"></span><b>TX:</b> '+(Math.round(parseInt(data.frequency)/100)/10000).toFixed(4)+' MHz';
if(data.mode != null) {
text = text+'<span style="margin-left:10px"></span>'+data.mode;
}
if(data.power != null && data.power != 0) {
text = text+'<span style="margin-left:10px"></span>'+data.power+' W';
}
if (! $('#radio_cat_state').length) {
$('.messages').prepend('<div aria-hidden="true"><div id="radio_cat_state" class="alert alert-success radio_cat_state" role="alert">'+text+'</div></div>');
} 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);

Wyświetl plik

@ -1,238 +0,0 @@
$(function() {
function SortByQrg(a, b){
var a = a.frequency;
var b = b.frequency;
return ((a< b) ? -1 : ((a> b) ? 1 : 0));
}
function get_dtable () {
var table = $('.spottable').DataTable({
"retrieve":true,
'columnDefs': [
{
'targets': 1, "type":"num",
'createdCell': function (td, cellData, rowData, row, col) {
$(td).addClass("kHz");
}
},
{
'targets': 2,
'createdCell': function (td, cellData, rowData, row, col) {
$(td).addClass("spotted_call");
$(td).attr( "title", "Click to prepare logging" );
}
}
],
"language": {
url: getDataTablesLanguageUrl(),
}
});
return table;
}
function fill_list(band,de,maxAgeMinutes) {
// var table = $('.spottable').DataTable();
var table = get_dtable();
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=[];
if (single.cnfmd_call) {
addon_class="text-success";
} else if (single.worked_call) {
addon_class="text-warning";
} else {
addon_class="";
}
data[0]=[];
data[0].push(single.when_pretty);
data[0].push(single.frequency*1);
data[0].push((addon_class != '' ?'<span class="'+addon_class+'">' : '')+single.spotted+(addon_class != '' ? '</span>' : ''));
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 table-info");
} else {
table.rows.add(data).draw();
}
} else {
table.rows.add(data).draw();
}
});
setTimeout(function(){ // Remove Highlights within 15sec
$(".fresh").removeClass("bg-info");
},1000);
}
});
} else {
table.clear();
table.draw();
}
}
function highlight_current_qrg(qrg) {
var table=get_dtable();
// var table=$('.spottable').DataTable();
table.rows().every(function() {
var d=this.data();
var distance=Math.abs(parseInt(d[1])-qrg);
if (distance<=20) {
distance++;
alpha=(.5/distance);
this.nodes().to$().css('--bs-table-bg', 'rgba(0,0,255,' + alpha + ')');
this.nodes().to$().css('--bs-table-accent-bg', 'rgba(0,0,255,' + alpha + ')');
} else {
this.nodes().to$().css('--bs-table-bg', '');
this.nodes().to$().css('--bs-table-accent-bg', '');
}
});
}
var table=get_dtable();
table.order([1, 'asc']);
table.clear();
fill_list($('#band option:selected').val(), $('#decontSelect option:selected').val(),dxcluster_maxage);
setInterval(function () { fill_list($('#band option:selected').val(), $('#decontSelect option:selected').val(),dxcluster_maxage); },60000);
$("#decontSelect").on("change",function() {
table.clear();
fill_list($('#band option:selected').val(), $('#decontSelect option:selected').val(),dxcluster_maxage);
});
$("#band").on("change",function() {
table.clear();
fill_list($('#band option:selected').val(), $('#decontSelect option:selected').val(),dxcluster_maxage);
});
$("#spottertoggle").on("click", function() {
if (table.column(4).visible()) {
table.column(4).visible(false);
} else {
table.column(4).visible(true);
}
});
var qso_window_last_seen=Date.now()-3600;
var bc_qsowin = new BroadcastChannel('qso_window');
bc_qsowin.onmessage = function (ev) {
if (ev.data == 'pong') {
qso_window_last_seen=Date.now();
}
};
setInterval(function () { bc_qsowin.postMessage('ping') },500);
var bc2qso = new BroadcastChannel('qso_wish');
$(document).on('click','.spotted_call', function() {
if (Date.now()-qso_window_last_seen < 2000) {
bc2qso.postMessage({ frequency: this.parentNode.cells[1].textContent*1000, call: this.innerText });
} else {
let cl={};
cl.qrg=this.parentNode.cells[1].textContent*1000;
cl.call=this.innerText;
window.open(base_url + 'index.php/qso?manual=0','_blank');
setTimeout(function () {
bc2qso.postMessage({ frequency: cl.qrg, call: cl.call })
},2500); // Wait at least 2500ms for new-Window to appear, before posting data to it
}
});
$("#menutoggle").on("click", function() {
if ($('.navbar').is(":hidden")) {
$('.navbar').show();
$('#dxtabs').show();
$('#dxtitle').show();
$('#menutoggle_i').removeClass('fa-arrow-down');
$('#menutoggle_i').addClass('fa-arrow-up');
} else {
$('.navbar').hide();
$('#dxtabs').hide();
$('#dxtitle').hide();
$('#menutoggle_i').removeClass('fa-arrow-up');
$('#menutoggle_i').addClass('fa-arrow-down');
}
});
var updateFromCAT = function() {
if($('select.radios option:selected').val() != '0') {
radioID = $('select.radios option:selected').val();
$.getJSON( base_url+"index.php/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('<div class="alert alert-danger radio_login_error" role="alert"><i class="fas fa-broadcast-tower"></i> You\'re not logged it. Please <a href="'+base_url+'">login</a></div>');
}
}
// 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('<div class="alert alert-danger radio_timeout_error" role="alert"><i class="fas fa-broadcast-tower"></i> Radio connection timed-out: ' + $('select.radios option:selected').text() + ' data is ' + data.updated_minutes_ago + ' minutes old.</div>');
} 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 = '<i class="fas fa-broadcast-tower"></i><span style="margin-left:10px;"></span><b>TX:</b> '+(Math.round(parseInt(data.frequency)/100)/10000).toFixed(4)+' MHz';
highlight_current_qrg((parseInt(data.frequency))/1000);
if(data.mode != null) {
text = text+'<span style="margin-left:10px"></span>'+data.mode;
}
if(data.power != null && data.power != 0) {
text = text+'<span style="margin-left:10px"></span>'+data.power+' W';
}
if (! $('#radio_cat_state').length) {
$('.messages').prepend('<div aria-hidden="true"><div id="radio_cat_state" class="alert alert-success radio_cat_state" role="alert">'+text+'</div></div>');
} else {
$('#radio_cat_state').html(text);
}
}
}
});
}
};
$.fn.dataTable.moment(custom_date_format + ' HH:mm');
// Update frequency every three second
setInterval(updateFromCAT, 3000);
// If a radios selected from drop down select radio update.
$('.radios').change(updateFromCAT);
});