From ea3e8a8d7b6251e3174bd88213e02ff51cd0790b Mon Sep 17 00:00:00 2001 From: dlandon Date: Sun, 8 Dec 2024 07:08:22 -0600 Subject: [PATCH 1/3] Fix tabbed mode erratic operation. --- .../plugins/dynamix/include/DefaultPageLayout.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/emhttp/plugins/dynamix/include/DefaultPageLayout.php b/emhttp/plugins/dynamix/include/DefaultPageLayout.php index ee4ab10ff..64d8c3015 100644 --- a/emhttp/plugins/dynamix/include/DefaultPageLayout.php +++ b/emhttp/plugins/dynamix/include/DefaultPageLayout.php @@ -200,11 +200,11 @@ function settab(tab) { $.cookie('one','tab1'); - + $.cookie('one',tab); - $.cookie(($.cookie('one')==null?'tab':'one'),tab); + $.cookie('one',tab); } function done(key) { @@ -586,7 +586,16 @@ function flashReport() { }); } $(function() { - var tab = $.cookie('one')||$.cookie('tab')||'tab1'; + + + const tab = $.cookie('tab')||'tab1'; + + + const tab = $.cookie('one')||'tab1'; + + + const tab = $.cookie('one')||'tab1'; + if (tab=='tab0') tab = 'tab'+$('input[name$="tabs"]').length; else if ($('#'+tab).length==0) {initab(); tab = 'tab1';} $('#'+tab).attr('checked', true); updateTime(); From 67e92aa5e75aa5459a0e202960a5cdb3c1f85b9e Mon Sep 17 00:00:00 2001 From: dlandon Date: Sun, 8 Dec 2024 08:38:45 -0600 Subject: [PATCH 2/3] Variable have to be 'let' and not 'const'. --- emhttp/plugins/dynamix/include/DefaultPageLayout.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/emhttp/plugins/dynamix/include/DefaultPageLayout.php b/emhttp/plugins/dynamix/include/DefaultPageLayout.php index 64d8c3015..a40d99ecc 100644 --- a/emhttp/plugins/dynamix/include/DefaultPageLayout.php +++ b/emhttp/plugins/dynamix/include/DefaultPageLayout.php @@ -588,13 +588,13 @@ function flashReport() { $(function() { - const tab = $.cookie('tab')||'tab1'; + let tab = $.cookie('tab')||'tab1'; - const tab = $.cookie('one')||'tab1'; + let tab = $.cookie('one')||'tab1'; - const tab = $.cookie('one')||'tab1'; + let tab = $.cookie('one')||'tab1'; if (tab=='tab0') tab = 'tab'+$('input[name$="tabs"]').length; else if ($('#'+tab).length==0) {initab(); tab = 'tab1';} $('#'+tab).attr('checked', true); From d9383e7db40a3d8cc9e61be12904e28bae6fd4fa Mon Sep 17 00:00:00 2001 From: dlandon Date: Sun, 8 Dec 2024 12:48:12 -0600 Subject: [PATCH 3/3] Readability improvement. --- .../dynamix/include/DefaultPageLayout.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/emhttp/plugins/dynamix/include/DefaultPageLayout.php b/emhttp/plugins/dynamix/include/DefaultPageLayout.php index a40d99ecc..304a0bdeb 100644 --- a/emhttp/plugins/dynamix/include/DefaultPageLayout.php +++ b/emhttp/plugins/dynamix/include/DefaultPageLayout.php @@ -586,17 +586,26 @@ function flashReport() { }); } $(function() { + let tab; - let tab = $.cookie('tab')||'tab1'; + tab = $.cookie('tab')||'tab1'; - let tab = $.cookie('one')||'tab1'; + tab = $.cookie('one')||'tab1'; - let tab = $.cookie('one')||'tab1'; + tab = $.cookie('one')||'tab1'; - if (tab=='tab0') tab = 'tab'+$('input[name$="tabs"]').length; else if ($('#'+tab).length==0) {initab(); tab = 'tab1';} + /* Check if the tab is 'tab0' */ + if (tab === 'tab0') { + /* Set tab to the last available tab based on input[name$="tabs"] length */ + tab = 'tab' + $('input[name$="tabs"]').length; + } else if ($('#' + tab).length === 0) { + /* If the tab element does not exist, initialize a tab and set to 'tab1' */ + initab(); + tab = 'tab1'; + } $('#'+tab).attr('checked', true); updateTime(); $.jGrowl.defaults.closeTemplate = '';