diff --git a/emhttp/plugins/dynamix/include/DefaultPageLayout.php b/emhttp/plugins/dynamix/include/DefaultPageLayout.php index f68444d62..1c3de385d 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,8 +586,26 @@ function flashReport() { }); } $(function() { - var tab = $.cookie('one')||$.cookie('tab')||'tab1'; - if (tab=='tab0') tab = 'tab'+$('input[name$="tabs"]').length; else if ($('#'+tab).length==0) {initab(); tab = 'tab1';} + let tab; + + + tab = $.cookie('tab')||'tab1'; + + + tab = $.cookie('one')||'tab1'; + + + tab = $.cookie('one')||'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 = '';