diff --git a/ydb/core/cms/ui/cms.js b/ydb/core/cms/ui/cms.js index 780fd71c6529..8403bc7def28 100644 --- a/ydb/core/cms/ui/cms.js +++ b/ydb/core/cms/ui/cms.js @@ -1,15 +1,32 @@ 'use strict'; +function setLocation(parameters) { + window.location.hash = $.param(parameters); +} + +function showTab(parameters) { + $('.nav-tabs a[href="#' + parameters.page + '"]').tab('show'); +} + +function setTab(parameters) { + setLocation(parameters); + showTab(parameters); +} + function main() { // making main container wider //$('.container').toggleClass('container container-fluid'); if (window.location.hash == '') { - window.location.hash = 'page=configs'; + var activeTabs = $('.nav-tabs a.active'); + for (var i = 0; i < activeTabs.length; ++i) { + setTab({page: activeTabs[i].hash.substr(1)}); + break; + } } else { window.location.hash.substr(1).split('&').forEach((o) => { var a = o.split('='); Parameters[a[0]] = decodeURIComponent(a[1]); } ); if (Parameters.page !== undefined) { - $('.nav-tabs a[href="#' + Parameters.page + '"]').tab('show'); + showTab(Parameters); } if (Parameters.show !== undefined) { for (var id of Parameters.show.split(',')) { @@ -21,8 +38,7 @@ function main() { document.getElementById('host-ref').textContent += " - " + window.location.hostname; $('.nav-tabs a').on('shown.bs.tab', function (e) { - Parameters.page = e.target.hash.substr(1); - window.location.hash = $.param(Parameters); + setLocation({page: e.target.hash.substr(1)}); }) initCommon(); diff --git a/ydb/core/cms/ui/configs.js b/ydb/core/cms/ui/configs.js index 1efcb0cdf509..573784ee5d26 100644 --- a/ydb/core/cms/ui/configs.js +++ b/ydb/core/cms/ui/configs.js @@ -313,7 +313,7 @@ function onYamlConfigEnabledFetched(data) { if (data['enabled']) { $('#yaml-configs-enabled-warning').show(); } else if ($('#yaml-config').hasClass('active')) { - $('#cms-nav a[href="#configs"]').tab('show'); + setTab({page: 'configs'}); } } }