[docs] Update switchers 4 (#16922)

- update version switcher
- update language switcher
This commit is contained in:
bstankix
2023-04-13 14:50:30 +02:00
committed by GitHub
parent 19e914a46e
commit c7bb2bd119

View File

@@ -36,6 +36,7 @@ function addLegalNotice() {
$(document).ready(function () {
createVersions();
updateTitleTag();
updateLanguageSelector();
init_col_sections();
init_switchers();
handleSwitcherParam();
@@ -53,12 +54,12 @@ $(document).ready(function () {
// Determine where we'd go if clicking on a version selector option
function getPageUrlWithVersion(version) {
var currentURL = window.location.href;
var newURL = currentURL.replace(getCurrentVersion(), version);
return encodeURI(newURL);
const currentUrl = window.location.href;
const pattern = new RegExp('(?:http|https)\:\/\/.*?\/');
const newUrl = currentUrl.match(pattern) + version + '/index.html';
return encodeURI(newUrl);
}
function createSphinxTabSets() {
var sphinxTabSets = $('.sphinxtabset');
var tabSetCount = 1000;
@@ -131,9 +132,15 @@ function createVersions() {
})
var downloadBtn = $('#download-zip-btn');
downloadBtn.attr('href', '/archives/' + currentVersion + '.zip')
}
function updateLanguageSelector() {
const currentVersion = getCurrentVersion();
$('[aria-labelledby="language-selector"]').find('a').each(function(){
const newUrl = $(this).attr('href').replace('latest', currentVersion);
$(this).attr('href', newUrl);
});
}
function addTableSort() {
var tables = $('table.table');
@@ -318,4 +325,4 @@ function initBenchmarkPickers() {
$('#performance-information-frequently-asked-questions section').find('h2').removeClass('expanded');
$('#performance-information-frequently-asked-questions section p, #performance-information-frequently-asked-questions section table').hide();
}
}
}