Added Lists

这个提交包含在:
int2001 2023-07-22 16:23:10 +00:00
父节点 cd373c3fbd
当前提交 fb73793a23
共有 3 个文件被更改,包括 173 次插入0 次删除

查看文件

@ -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);
}
}

查看文件

@ -0,0 +1,56 @@
<script>
var dxcluster_provider="<?php echo base_url(); ?>index.php/dxcluster";
var cat_timeout_interval="<?php echo $this->optionslib->get_option('cat_timeout_interval'); ?>";
</script>
<div class="container">
<br>
<h2><?php echo $page_title; ?></h2>
<div class="messages"></div>
<div class="form-inline">
<label class="my-1 mr-2" for="radio"><?php echo lang('gen_hamradio_radio'); ?></label>
<select class="form-control-sm radios my-1 mr-sm-2" 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 mr-2" for="band"><?php echo lang('gen_hamradio_band'); ?></label>
<select id="band" class="form-control-sm my-1 mr-sm-2" 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>
<div class="card log">
<div class="card-header"><h5 class="card-title">DXCluster</h5></div>
<p>
<table style="width:100%" class="table-sm table spottable table-bordered table-hover table-striped table-condensed text-center">
<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>
</tr>
</thead>
<tbody class="spots_table_contents">
</tbody>
</table>
</div>
</div>
</div>

查看文件

@ -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('<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);
});