diff --git a/application/controllers/Qso.php b/application/controllers/Qso.php
index 028a89527..0e64e53c3 100644
--- a/application/controllers/Qso.php
+++ b/application/controllers/Qso.php
@@ -147,16 +147,16 @@ class QSO extends CI_Controller {
//change to create_qso function as add and create_qso duplicate functionality
$this->logbook_model->create_qso();
- $retuner=[];
- $actstation=$this->stations->find_active() ?? '';
- $returner['activeStationId'] = $actstation;
- $profile_info = $this->stations->profile($actstation)->row();
- $returner['activeStationTXPower'] = xss_clean($profile_info->station_power);
- $returner['activeStationOP'] = xss_clean($this->session->userdata('operator_callsign'));
+ $returner=[];
+ $actstation=$this->stations->find_active() ?? '';
+ $returner['activeStationId'] = $actstation;
+ $profile_info = $this->stations->profile($actstation)->row();
+ $returner['activeStationTXPower'] = xss_clean($profile_info->station_power);
+ $returner['activeStationOP'] = xss_clean($this->session->userdata('operator_callsign'));
$returner['message']='success';
// Get last 5 qsos
- echo json_encode($returner);
+ echo json_encode($returner);
}
}
@@ -205,13 +205,9 @@ class QSO extends CI_Controller {
$this->load->model('winkey');
// call settings from model winkey
- $data['result'] = $this->winkey->settings($this->session->userdata('user_id'), $this->session->userdata('station_profile_id'));
+ $data['result'] = $this->winkey->settings($this->session->userdata('user_id'), $this->stations->find_active());
- if ($data['result'] == false) {
- $this->load->view('qso/components/winkeysettings', $data);
- } else {
- $this->load->view('qso/components/winkeysettings_results', $data);
- }
+ $this->load->view('qso/components/winkeysettings', $data);
}
function cwmacrosave(){
@@ -233,7 +229,7 @@ class QSO extends CI_Controller {
$data = [
'user_id' => $this->session->userdata('user_id'),
- 'station_location_id' => $this->session->userdata('station_profile_id'),
+ 'station_location_id' => $this->stations->find_active(),
'function1_name' => $function1_name,
'function1_macro' => $function1_macro,
'function2_name' => $function2_name,
@@ -262,7 +258,7 @@ class QSO extends CI_Controller {
header('Content-Type: application/json; charset=utf-8');
// Call settings_json from model winkey
- echo $this->winkey->settings_json($this->session->userdata('user_id'), $this->session->userdata('station_profile_id'));
+ echo $this->winkey->settings_json($this->session->userdata('user_id'), $this->stations->find_active());
}
function edit_ajax() {
@@ -340,20 +336,20 @@ class QSO extends CI_Controller {
function qsl_sent_ajax() {
$id = str_replace('"', "", $this->input->post("id", TRUE));
$method = str_replace('"', "", $this->input->post("method", TRUE));
-
+
$this->load->model('logbook_model');
$this->load->model('user_model');
-
+
header('Content-Type: application/json');
-
+
if(!$this->user_model->authorize(2)) {
echo json_encode(array('message' => 'Error'));
-
+
}
else {
// Update Logbook to Mark Paper Card Sent
$this->logbook_model->paperqsl_update_sent($id, $method);
-
+
echo json_encode(array('message' => 'OK'));
}
}
diff --git a/application/models/Winkey.php b/application/models/Winkey.php
index 43938fd41..28a142388 100644
--- a/application/models/Winkey.php
+++ b/application/models/Winkey.php
@@ -20,13 +20,13 @@ class Winkey extends CI_Model
$this->db->where('user_id', $user_id);
$this->db->where('station_location_id', $station_location_id);
$query = $this->db->get('cwmacros');
-
+
if ($query->num_rows() > 0) {
// return $query->row() as json
return json_encode($query->row());
} else {
// return json with status not found
- return json_encode(array('status' => 'not found'));
+ return json_encode(array('status' => 'not found'));
}
}
@@ -46,4 +46,4 @@ class Winkey extends CI_Model
}
}
-?>
\ No newline at end of file
+?>
diff --git a/application/views/qso/components/winkeysettings.php b/application/views/qso/components/winkeysettings.php
index 74a1fbc05..22241c582 100644
--- a/application/views/qso/components/winkeysettings.php
+++ b/application/views/qso/components/winkeysettings.php
@@ -1,24 +1,15 @@
-
-
+
diff --git a/application/views/qso/components/winkeysettings_results.php b/application/views/qso/components/winkeysettings_results.php
deleted file mode 100644
index bd85f9337..000000000
--- a/application/views/qso/components/winkeysettings_results.php
+++ /dev/null
@@ -1,96 +0,0 @@
-
-
-
-
diff --git a/application/views/qso/index.php b/application/views/qso/index.php
index ac6103ea1..84d1e0d3f 100644
--- a/application/views/qso/index.php
+++ b/application/views/qso/index.php
@@ -646,12 +646,7 @@
-
+
diff --git a/assets/js/winkey.js b/assets/js/winkey.js
index c6195fe9c..74df8e7d7 100644
--- a/assets/js/winkey.js
+++ b/assets/js/winkey.js
@@ -69,9 +69,8 @@ let connectButton = document.getElementById("connectButton");
let statusBar = document.getElementById("statusBar");
//Couple the elements to the Events
-connectButton.addEventListener("click", clickConnect)
-sendButton.addEventListener("click", clickSend)
-// statusButton.addEventListener("click", clickStatus)
+connectButton.addEventListener("click", clickConnect);
+sendButton.addEventListener("click", clickSend);
//When the connectButton is pressed
async function clickConnect() {
@@ -92,7 +91,7 @@ navigator.serial.addEventListener('connect', e => {
statusBar.innerText = `Connected to ${e.port}`;
connectButton.innerText = "Disconnect"
});
-
+
navigator.serial.addEventListener('disconnect', e => {
statusBar.innerText = `Disconnected`;
connectButton.innerText = "Connect"
@@ -130,7 +129,7 @@ async function connect() {
const encoder = new TextEncoderStream();
outputDone = encoder.readable.pipeTo(port.writable);
outputStream = encoder.writable;
-
+
writeToByte("0x00, 0x02");
writeToByte("0x02, 0x00");
@@ -151,7 +150,7 @@ async function connect() {
//Write to the Serial port
async function writeToStream(line) {
var enc = new TextEncoder(); // always utf-8
-
+
const writer = outputStream.getWriter();
writer.write(line);
writer.releaseLock();
@@ -190,7 +189,7 @@ async function disconnect() {
function clickSend() {
writeToStream(sendText.value);
writeToStream("\r");
-
+
//and clear the input field, so it's clear it has been sent
sendText.value = "";
@@ -249,23 +248,7 @@ async function readLoop() {
}
}
-function closeModal() {
- var container = document.getElementById("modals-here")
- var backdrop = document.getElementById("modal-backdrop")
- var modal = document.getElementById("modal")
-
- modal.classList.remove("show")
- backdrop.classList.remove("show")
-
- getMacros();
-
- setTimeout(function() {
- container.removeChild(backdrop)
- container.removeChild(modal)
- }, 200)
-}
-
-function UpdateMacros(macrotext) {
+function UpdateMacros(macrotext) {
// Get the values from the form set to uppercase
let CALL = document.getElementById("callsign").value.toUpperCase();
@@ -303,7 +286,7 @@ function getMacros() {
const morsekey_func3_Button = document.getElementById('morsekey_func3');
morsekey_func3_Button.textContent = 'F3 (' + function3Name + ')';
-
+
const morsekey_func4_Button = document.getElementById('morsekey_func4');
morsekey_func4_Button.textContent = 'F4 (' + function4Name + ')';
@@ -311,3 +294,73 @@ function getMacros() {
morsekey_func5_Button.textContent = 'F5 (' + function5Name + ')';
});
}
+
+$('#winkey_settings').click(function (event) {
+ $.ajax({
+ url: base_url + 'index.php/qso/winkeysettings',
+ type: 'post',
+ success: function (html) {
+ BootstrapDialog.show({
+ title: 'Winkey Macros',
+ size: BootstrapDialog.SIZE_NORMAL,
+ cssClass: 'options',
+ nl2br: false,
+ message: html,
+ onshown: function(dialog) {
+ },
+ buttons: [{
+ label: 'Save',
+ cssClass: 'btn-primary btn-sm',
+ id: 'saveButton',
+ action: function (dialogItself) {
+ winkey_macro_save();
+ dialogItself.close();
+ }
+ },
+ {
+ label: lang_admin_close,
+ cssClass: 'btn-sm',
+ id: 'closeButton',
+ action: function (dialogItself) {
+ $('#optionButton').prop("disabled", false);
+ dialogItself.close();
+ }
+ }],
+ onhide: function(dialogRef){
+ $('#optionButton').prop("disabled", false);
+ },
+ });
+ }
+ });
+});
+
+function winkey_macro_save() {
+ $.ajax({
+ url: base_url + 'index.php/qso/cwmacrosave',
+ type: 'post',
+ data: {
+ function1_name: $('#function1_name').val(),
+ function1_macro: $('#function1_macro').val(),
+ function2_name: $('#function2_name').val(),
+ function2_macro: $('#function2_macro').val(),
+ function3_name: $('#function3_name').val(),
+ function3_macro: $('#function3_macro').val(),
+ function4_name: $('#function4_name').val(),
+ function4_macro: $('#function4_macro').val(),
+ function5_name: $('#function5_name').val(),
+ function5_macro: $('#function5_macro').val(),
+ },
+ success: function (html) {
+ BootstrapDialog.alert({
+ title: 'INFO',
+ message: 'Macros were saved.',
+ type: BootstrapDialog.TYPE_INFO,
+ closable: false,
+ draggable: false,
+ callback: function (result) {
+ getMacros();
+ }
+ });
+ }
+ });
+}