From 11736ea938755f08dd644887236d7a36c43c54b6 Mon Sep 17 00:00:00 2001 From: Andreas Date: Sun, 27 Dec 2020 09:37:48 +0100 Subject: [PATCH] [Contesting] Added saving and restoring of contestid, exchangetype and exchangesent. --- application/views/interface_assets/footer.php | 5 +++ assets/js/sections/contesting.js | 36 +++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php index ec61fb40..f44fbf6f 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -2575,6 +2575,11 @@ function deleteQsl(id) { $("#exch_sent").val(+$("#exch_sent").val() + 1); } $("#callsign").focus(); + + // Store contest session + localStorage.setItem("contestid", $("#contestname").val()); + localStorage.setItem("exchangetype", $('input[name=exchangeradio]:checked', '#qso_input').val()); + localStorage.setItem("exchangesent", $("#exch_sent").val()); } }); } diff --git a/assets/js/sections/contesting.js b/assets/js/sections/contesting.js index 2145c553..42975b83 100644 --- a/assets/js/sections/contesting.js +++ b/assets/js/sections/contesting.js @@ -4,6 +4,42 @@ $("#callsign").focus(); // Init serial sent as 1 when loading page $("#exch_sent").val(1); +$( document ).ready(function() { + restoreContestSession(); +}); + +// We are restoring the settings in the contest logging form here +function restoreContestSession() { + var contestname = localStorage.getItem("contestid"); + + if (contestname != null) { + $("#contestname").val(contestname); + } + + var exchangetype = localStorage.getItem("exchangetype"); + + if (exchangetype == "other") { + $("[name=exchangeradio]").val(["other"]); + } + + var exchangesent = localStorage.getItem("exchangesent"); + + if (exchangesent != null) { + $("#exch_sent").val(exchangesent); + } +} + +// Storing the contestid in contest session +$('#contestname').change(function() { + localStorage.setItem("contestid", $("#contestname").val()); +}); + +// Storing the exchange type in contest session +$('input[type=radio][name=exchangeradio]').change(function() { + localStorage.setItem("exchangetype", $('input[name=exchangeradio]:checked', '#qso_input').val()); +}); + + // realtime clock $(function($) { var options = {