mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2026-04-02 08:12:21 -07:00
refactor: Consolidate tab initialization logic using shared utility function
This commit is contained in:
@@ -118,29 +118,10 @@ function loadTabContent(target) {
|
||||
}
|
||||
|
||||
function initializeTabs() {
|
||||
const key = "activeSysinfoTab";
|
||||
let selectedTab = "tabServer"; // fallback default
|
||||
|
||||
const cached = getCache(key);
|
||||
if (!emptyArr.includes(cached)) {
|
||||
selectedTab = cached;
|
||||
}
|
||||
|
||||
// Activate the correct tab
|
||||
const $tabLink = $('.nav-tabs a[id="' + selectedTab + '"]');
|
||||
$tabLink.tab('show');
|
||||
|
||||
// Get the pane's ID from the tab's href attribute
|
||||
const targetSelector = $tabLink.attr("href");
|
||||
loadTabContent(targetSelector);
|
||||
|
||||
// On tab change
|
||||
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
|
||||
const newTabId = $(e.target).attr('id');
|
||||
setCache(key, newTabId);
|
||||
|
||||
const newTarget = $(e.target).attr("href");
|
||||
loadTabContent(newTarget);
|
||||
initializeTabsShared({
|
||||
cacheKey: 'activeSysinfoTab',
|
||||
defaultTab: 'tabServer',
|
||||
onTabChange: loadTabContent
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user