From dacf004b36ddb8fd23cbb7b2c393844e0c09045b Mon Sep 17 00:00:00 2001 From: Kim Huebel Date: Sat, 30 Jan 2021 15:26:11 +0000 Subject: [PATCH] reworked showing of tabs For easier mainainance and for future developments configuration is modified Please take a look at config.js --- html/index.html | 18 ++++---- html/js/config.js | 14 +++---- html/js/functions.js | 98 +++++++++++--------------------------------- 3 files changed, 39 insertions(+), 91 deletions(-) diff --git a/html/index.html b/html/index.html index 4ff8034..b2c07a4 100644 --- a/html/index.html +++ b/html/index.html @@ -37,25 +37,25 @@ @@ -293,7 +293,7 @@ "order": [[ 0, "desc" ]] } ); - if (showSysInfoTab) { + if (sysinfo > 0) { var ws3 = new WebSocket("ws://" + window.location.hostname + ":5678/SYSINFO"); ws3.onmessage = function (event) { getSysInfo(document, event); @@ -327,7 +327,7 @@ t_qso.row('.selected').remove().draw( false ); } ); - if (showDAPNETMessagesTab) { + if (dapnet > 0) { var ws2 = new WebSocket("ws://" + window.location.hostname + ":5678/DAPNET"); ws2.onmessage = function (event) { getDapnetMessages(document, event); diff --git a/html/js/config.js b/html/js/config.js index 01df0ec..cee3047 100644 --- a/html/js/config.js +++ b/html/js/config.js @@ -10,13 +10,13 @@ var emergencylevel = 500; // 1 = show tab, 0 = suppress it -var showCurrTXTab = 1; -var showLastHeardTab = 1; -var showLocalHeadTab = 1; -var showInQSOTab = 1; -var showDAPNETMessagesTab = 1; -var showSysInfoTab = 1; -var showAboutTab = 1; +var currtx = 1; +var lastheard = 1; +var localheard = 1; +var qso = 1; +var dapnet = 1; +var sysinfo = 1; +var about = 1; // default-tab to show // chose from following list: CurrTXTab, LastHeardTab, LocalHeadTab, InQSOTab, DAPNETMessagesTab, SysInfoTab, AboutTab diff --git a/html/js/functions.js b/html/js/functions.js index d43fd67..3dc5a6b 100644 --- a/html/js/functions.js +++ b/html/js/functions.js @@ -602,100 +602,48 @@ function getSysInfo(document, event) { }); } +function activateDefaultTab(name) { + var element = document.getElementById(name + "-tab"); + element.classList.add("active"); + + var element = document.getElementById(name); + element.classList.add("show"); + element.classList.add("active"); +} + $(document).ready(function() { - if(showCurrTXTab == 0){ - document.getElementById("myTab").children[0].style.display="none"; - document.getElementById("currtx").style.display="none"; - } - if(showLastHeardTab == 0){ - document.getElementById("myTab").children[1].style.display="none"; - document.getElementById("lastheard").style.display="none"; - } - if(showLocalHeadTab == 0){ - document.getElementById("myTab").children[2].style.display="none"; - document.getElementById("localheard").style.display="none"; - } - if(showInQSOTab == 0){ - document.getElementById("myTab").children[3].style.display="none"; - document.getElementById("qso").style.display="none"; - } - if(showDAPNETMessagesTab == 0){ - document.getElementById("myTab").children[4].style.display="none"; - document.getElementById("dapnet").style.display="none"; - } - if(showSysInfoTab == 0){ - document.getElementById("myTab").children[5].style.display="none"; - document.getElementById("sysinfo").style.display="none"; - } - if(showAboutTab == 0){ - document.getElementById("myTab").children[6].style.display="none"; - document.getElementById("about").style.display="none"; + for (i = 0; i < document.getElementById("myTab").children.length; ++i) { + tabname = document.getElementById("myTab").children[i].getAttribute("name"); + if (eval(tabname) == 0) { + document.getElementById("myTab").children[i].style.display="none"; + document.getElementById(tabname).style.display="none"; + } } switch (defaultTab) { case "CurrTXTab": - var element = document.getElementById("currtx-tab"); - element.classList.add("active"); - - var element = document.getElementById("currtx"); - element.classList.add("show"); - element.classList.add("active"); + activateDefaultTab("currtx"); break; case "LastHeardTab": - var element = document.getElementById("lastheard-tab"); - element.classList.add("active"); - - var element = document.getElementById("lastheard"); - element.classList.add("show"); - element.classList.add("active"); + activateDefaultTab("lastheard"); break; case "LocalHeadTab": - var element = document.getElementById("localheard-tab"); - element.classList.add("active"); - - var element = document.getElementById("localheard"); - element.classList.add("show"); - element.classList.add("active"); + activateDefaultTab("localheard"); break; case "InQSOTab": - var element = document.getElementById("qso-tab"); - element.classList.add("active"); - - var element = document.getElementById("qso"); - element.classList.add("show"); - element.classList.add("active"); + activateDefaultTab("qso"); break; case "DAPNETMessagesTab": - var element = document.getElementById("dapnet-tab"); - element.classList.add("active"); - - var element = document.getElementById("dapnet"); - element.classList.add("show"); - element.classList.add("active"); + activateDefaultTab("dapnet"); break; case "SysInfoTab": - var element = document.getElementById("sysinfo-tab"); - element.classList.add("active"); - - var element = document.getElementById("sysinfo"); - element.classList.add("show"); - element.classList.add("active"); + activateDefaultTab("sysinfo"); break; case "AboutTab": - var element = document.getElementById("about-tab"); - element.classList.add("active"); - - var element = document.getElementById("about"); - element.classList.add("show"); - element.classList.add("active"); + activateDefaultTab("about"); break; default: - var element = document.getElementById("currtx-tab"); - element.classList.add("active"); - - var element = document.getElementById("currtx"); - element.classList.add("show"); - element.classList.add("active"); + activateDefaultTab("currtx"); break; } });