mirror of
https://github.com/wavelog/wavelog.git
synced 2026-03-22 10:24:14 +00:00
initial proof of concept
This commit is contained in:
@@ -645,4 +645,34 @@ class QSO extends CI_Controller {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Open the API url which causes the browser to open the QSO live logging and populate the callsign with the data from the API
|
||||
*
|
||||
* Usage example:
|
||||
* https://<URL to Wavelog>/index.php/qso/log_qso?callsign=4W7EST
|
||||
*/
|
||||
|
||||
function log_qso() {
|
||||
// Check if users logged in
|
||||
$this->load->model('user_model');
|
||||
if ($this->user_model->validate_session() == 0) {
|
||||
// user is not logged in
|
||||
$this->session->set_flashdata('warning', __("You have to be logged in to access this URL."));
|
||||
redirect('user/login');
|
||||
}
|
||||
|
||||
// get the data from the API
|
||||
$data['callsign'] = $this->input->get('callsign', TRUE);
|
||||
$data['page_title'] = __("Call Transfer");
|
||||
|
||||
// load the QSO redirect page
|
||||
if ($data['callsign'] != "") {
|
||||
$this->load->view('interface_assets/header', $data);
|
||||
$this->load->view('qso/log_qso');
|
||||
} else {
|
||||
$this->session->set_flashdata('warning', __("No callsign provided."));
|
||||
redirect('dashboard');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
67
application/views/qso/log_qso.php
Normal file
67
application/views/qso/log_qso.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
// this file catches the callsign data, performs some JS magic and redirects to the QSO logging page
|
||||
|
||||
?>
|
||||
<div class="container">
|
||||
<h2><?php echo $page_title; ?></h2>
|
||||
|
||||
<p><?= __("Redirecting to QSO logging page..."); ?></p>
|
||||
</div>
|
||||
|
||||
|
||||
<script src="<?php echo base_url(); ?>assets/js/jquery-3.3.1.min.js"></script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
let call = "<?php echo $callsign; ?>";
|
||||
|
||||
// init some variables
|
||||
let qso_window_last_seen = Date.now() - 3600;
|
||||
let bc_qsowin = new BroadcastChannel('qso_window');
|
||||
let pong_rcvd = false;
|
||||
|
||||
// send the ping
|
||||
bc_qsowin.postMessage('ping');
|
||||
|
||||
// listen for the pong
|
||||
bc_qsowin.onmessage = function(ev) {
|
||||
if (ev.data === 'pong') {
|
||||
qso_window_last_seen = Date.now();
|
||||
pong_rcvd = true;
|
||||
}
|
||||
};
|
||||
|
||||
// init the broadcast channel
|
||||
let bc2qso = new BroadcastChannel('qso_wish');
|
||||
|
||||
// set some times
|
||||
let wait4pong = 2000; // we wait in max 2 seconds for the pong
|
||||
let check_intv = 100; // check every 100 ms
|
||||
|
||||
let check_pong = setInterval(function() {
|
||||
if (pong_rcvd || ((Date.now() - qso_window_last_seen) < wait4pong)) {
|
||||
// max time reached or pong received
|
||||
clearInterval(check_pong);
|
||||
bc2qso.postMessage({
|
||||
call: call
|
||||
});
|
||||
window.close();
|
||||
} else {
|
||||
clearInterval(check_pong);
|
||||
let cl = {};
|
||||
cl.call = call;
|
||||
let newWindow = window.open('<?php echo base_url(); ?>' + 'index.php/qso?manual=0', '_blank');
|
||||
|
||||
// wait for the ready message
|
||||
bc2qso.onmessage = function(ev) {
|
||||
if (ev.data === 'ready') {
|
||||
bc2qso.postMessage({
|
||||
call: cl.call
|
||||
});
|
||||
window.close();
|
||||
}
|
||||
};
|
||||
}
|
||||
}, check_intv);
|
||||
});
|
||||
</script>
|
||||
@@ -311,14 +311,18 @@ $( document ).ready(function() {
|
||||
}
|
||||
|
||||
var bc = new BroadcastChannel('qso_wish');
|
||||
bc.postMessage('ready');
|
||||
bc.onmessage = function (ev) {
|
||||
if (ev.data.ping) {
|
||||
let message={};
|
||||
message.pong=true;
|
||||
bc.postMessage(message);
|
||||
} else {
|
||||
$('#frequency').val(ev.data.frequency);
|
||||
$("#band").val(frequencyToBand(ev.data.frequency));
|
||||
console.log(ev.data);
|
||||
if (ev.data.frequency != null) {
|
||||
$('#frequency').val(ev.data.frequency);
|
||||
$("#band").val(frequencyToBand(ev.data.frequency));
|
||||
}
|
||||
if (ev.data.frequency_rx != "") {
|
||||
$('#frequency_rx').val(ev.data.frequency_rx);
|
||||
$("#band_rx").val(frequencyToBand(ev.data.frequency_rx));
|
||||
|
||||
Reference in New Issue
Block a user