From 8cc2a716455630cb1e3fd4e731a364fa29c10bf4 Mon Sep 17 00:00:00 2001 From: Vikram Goyal Date: Fri, 17 May 2019 15:04:58 +1000 Subject: [PATCH] updating page-loader.js --- _javascripts/page-loader.js | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/_javascripts/page-loader.js b/_javascripts/page-loader.js index 283da86b81..0ae2edffee 100644 --- a/_javascripts/page-loader.js +++ b/_javascripts/page-loader.js @@ -6,17 +6,28 @@ function versionSelector(list) { // the new final link to load newLink = ""; + // the fileRequested + var fileRequested = ""; + // spilt the current path var pathArray = window.location.pathname.split( '/' ); // so we can get the current version currentVersion = pathArray[2]; - // the file path is just the version number + the end of the path - var fileRequested = - window.location.pathname.substring( - window.location.pathname.lastIndexOf(currentVersion) + - currentVersion.length); + // if switching major versions, just take the user to the main landing page + // as files change a lot between major versions. + + if(currentVersion.charAt(0) === newVersion.charAt(0)) { + // the file path is just the version number + the end of the path + fileRequested = + window.location.pathname.substring( + window.location.pathname.lastIndexOf(currentVersion) + + currentVersion.length); + } else { + fileRequested = "/welcome/index.html"; + } + // alert(fileRequested);