Skip to content

Commit

Permalink
just replace version number in version selector
Browse files Browse the repository at this point in the history
  • Loading branch information
recrwplay committed Aug 30, 2024
1 parent 0c340f7 commit f6b62ef
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions src/js/50-cheat-sheet-toggle.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,23 +233,13 @@ document.addEventListener('DOMContentLoaded', function () {

if (versionSelector) {
versionSelector.addEventListener('change', function (e) {
const target = e.target

const selectedProduct = prodSelector.selectedIndex
const current = target.dataset.current
const next = target.selectedOptions[0].dataset.version
let newUrl
if (selectionFromPath) {
const re = new RegExp(`/${current}/`)
newUrl = document.URL.replace(re, `/${next}/`)
} else {
newUrl = `${target.value}?product=${prodSelector.options[selectedProduct].value}`
}

const current = e.target.dataset.current
const next = e.target.selectedOptions[0].dataset.version
const re = new RegExp(`/${current}/`)
const newUrl = document.URL.replace(re, `/${next}/`)
if (window.ga) {
window.ga('send', 'event', 'version-select', 'From: ' + current + ';To:' + next + ';')
}

document.location.replace(newUrl)
})
}
Expand Down

0 comments on commit f6b62ef

Please sign in to comment.