From f6b62ef804b969485863281754079af77b3a26b2 Mon Sep 17 00:00:00 2001 From: Neil Dewhurst Date: Fri, 30 Aug 2024 13:07:33 +0100 Subject: [PATCH] just replace version number in version selector --- src/js/50-cheat-sheet-toggle.js | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/js/50-cheat-sheet-toggle.js b/src/js/50-cheat-sheet-toggle.js index 5f75db95..ffa4127e 100644 --- a/src/js/50-cheat-sheet-toggle.js +++ b/src/js/50-cheat-sheet-toggle.js @@ -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) }) }