Added Code to get latest radio freq/mode when application is used, radio must be selected

pull/106/merge
Peter Goodhall 2012-04-08 13:17:14 +01:00
rodzic 0e2ada2126
commit 510af39f5c
4 zmienionych plików z 206 dodań i 2 usunięć

Wyświetl plik

@ -12,12 +12,15 @@ class QSO extends CI_Controller {
public function index()
{
$this->load->model('cat');
$this->load->model('logbook_model');
$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'); }
$data['notice'] = false;
$data['notice'] = false;
$data['radios'] = $this->cat->radios();
$data['query'] = $this->logbook_model->last_ten();
$this->load->library('form_validation');
@ -45,6 +48,7 @@ class QSO extends CI_Controller {
$this->session->set_userdata('mode', $this->input->post('mode'));
$this->session->set_userdata('sat_name', $this->input->post('sat_name'));
$this->session->set_userdata('sat_mode', $this->input->post('sat_mode'));
$this->session->set_userdata('radio', $this->input->post('radio'));
// Get last Ten QSOs
$data['query'] = $this->logbook_model->last_ten();

Wyświetl plik

@ -0,0 +1,46 @@
<?php
class Radio extends CI_Controller {
public function index()
{
}
function status() {
$this->load->model('cat');
print_r($this->cat->status());
}
function frequency($id) {
//$this->db->where('radio', $result['radio']);
$this->db->select('frequency');
$this->db->where('id', $id);
$query = $this->db->get('cat');
if ($query->num_rows() > 0)
{
foreach ($query->result() as $row)
{
echo $row->frequency;
}
}
}
function mode($id) {
//$this->db->where('radio', $result['radio']);
$this->db->select('mode');
$this->db->where('id', $id);
$query = $this->db->get('cat');
if ($query->num_rows() > 0)
{
foreach ($query->result() as $row)
{
echo strtoupper($row->mode);
}
}
}
}
?>

Wyświetl plik

@ -43,8 +43,34 @@
}
function status() {
//$this->db->where('radio', $result['radio']);
$this->db->limit(1);
$query = $this->db->get('cat');
if ($query->num_rows() > 0)
{
foreach ($query->result() as $row)
{
$data = array(
'radio' => $row->radio,
'frequency' => $row->frequency,
'mode' => $row->mode
);
}
}
return $data;
}
/* Return list of radios */
function radios() {
$this->db->select('id, radio');
$query = $this->db->get('cat');
return $query;
}
}
?>

Wyświetl plik

@ -182,7 +182,14 @@
<table>
<tr>
<td>Radio</td>
<td><input type="text" name="equipment" value="" /></td>
<td>
<select class="radios" name="radio">
<option value="0" selected="selected">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>
</td>
</tr>
<tr>
<td>Frequency</td>
@ -281,6 +288,127 @@
i=0;
$(document).ready(function(){
/* Javascript for controlling rig frequency. */
// Update frequency every second
setInterval(function() {
if($('select.radios option:selected').val() != '0') {
// Get frequency
$.get('radio/frequency/' + $('select.radios option:selected').val(), function(result) {
$('#frequency').val(result);
if(result >= "100000" && result <= "200000") {
$(".band").val('160m');
}
if(result >= "300000" && result <= "400000") {
$(".band").val('80m');
}
if(result >= "525000" && result <= "54500") {
$(".band").val('60m');
}
if(result >= "700000" && result <= "750000") {
$(".band").val('40m');
}
if(result >= "1000000" && result <= "110000") {
$(".band").val('30m');
}
if(result >= "1400000" && result <= "1440000") {
$(".band").val('20m');
}
if(result >= "1800000" && result <= "1900000") {
$(".band").val('17m');
}
if(result >= "2100000" && result <= "2160000") {
$(".band").val('15m');
}
if(result >= "2400000" && result <= "2500000") {
$(".band").val('12m');
}
if(result >= "2800000" && result <= "3000000") {
$(".band").val('10m');
}
if(result >= "5000000" && result <= "5600000") {
$(".band").val('6m');
}
if(result >= "14400000" && result <= "14700000") {
$(".band").val('2m');
}
if(result >= "43000000" && result <= "44000000") {
$(".band").val('70cm');
}
});
// Get Mode
$.get('radio/mode/' + $('select.radios option:selected').val(), function(result) {
if (result == "LSB" || result == "USB" || result == "SSB") {
$(".mode").val('SSB');
} else {
$(".mode").val(result);
}
});
}
}, 1000);
// If a radios selected from drop down select radio update.
$('.radios').change(function() {
if($('select.radios option:selected').val() != '0') {
// Get frequency
$.get('radio/frequency/' + $('select.radios option:selected').val(), function(result) {
$('#frequency').val(result);
if(result >= "100000" && result <= "200000") {
$(".band").val('160m');
}
if(result >= "300000" && result <= "400000") {
$(".band").val('80m');
}
if(result >= "525000" && result <= "54500") {
$(".band").val('60m');
}
if(result >= "700000" && result <= "750000") {
$(".band").val('40m');
}
if(result >= "1000000" && result <= "110000") {
$(".band").val('30m');
}
if(result >= "1400000" && result <= "1440000") {
$(".band").val('20m');
}
if(result >= "1800000" && result <= "1900000") {
$(".band").val('17m');
}
if(result >= "2100000" && result <= "2160000") {
$(".band").val('15m');
}
if(result >= "2400000" && result <= "2500000") {
$(".band").val('12m');
}
if(result >= "2800000" && result <= "3000000") {
$(".band").val('10m');
}
if(result >= "5000000" && result <= "5600000") {
$(".band").val('6m');
}
if(result >= "14400000" && result <= "14700000") {
$(".band").val('2m');
}
if(result >= "43000000" && result <= "44000000") {
$(".band").val('70cm');
}
});
// Get Mode
$.get('radio/mode/' + $('select.radios option:selected').val(), function(result) {
if (result == "LSB" || result == "USB" || result == "SSB") {
$(".mode").val('SSB');
} else {
$(".mode").val(result);
}
});
}
});
/* On Page Load */
var catcher = function() {
var changed = false;