Skip to content

Commit 828e3fd

Browse files
authored
Merge pull request #60508 from gabriel-rh/SRVCOM-2431-fix-page-loader-js
SRVCOM-2431 fix page-loader.js for serverless
2 parents 8c0e28a + 7a5c67c commit 828e3fd

File tree

1 file changed

+38
-3
lines changed

1 file changed

+38
-3
lines changed

_javascripts/page-loader.js

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ currentVersion = "";
66
// the fileRequested
77
fileRequested = "";
88

9+
//Array prototype to check if an element is in an array
10+
Array.prototype.contains = function(obj) {
11+
return this.indexOf(obj) > -1;
12+
}
13+
914
function versionSelector(list) {
1015

1116
// the version we want
@@ -33,14 +38,32 @@ function versionSelector(list) {
3338
// alert(fileRequested);
3439

3540
// in 3.3 and above, we changed to container-platform
36-
if(newVersion == '3.0' || newVersion == '3.1' || newVersion == '3.2') {
41+
if(['3.0', '3.1', '3.2'].contains(newVersion)) {
3742
newLink = "https://docs.openshift.com/enterprise/" +
3843
newVersion +
3944
fileRequested;
45+
} else if (['3.65', '3.66', '3.67', '3.68', '3.69', '3.70', '3.71', '3.72', '3.73', '3.74', '4.0'].contains(newVersion)) {
46+
// check and handle links for RHACS versions
47+
newLink = "https://docs.openshift.com/acs/" +
48+
newVersion +
49+
fileRequested;
50+
} else if (['1.28', '1.29'].contains(newVersion)) {
51+
// check and handle links for Serverless versions
52+
newLink = "https://docs.openshift.com/serverless/" +
53+
newVersion +
54+
fileRequested;
4055
} else {
56+
//if distro key is openshift enterprise
57+
if (dk == "openshift-enterprise") {
4158
newLink = "https://docs.openshift.com/container-platform/" +
4259
newVersion +
4360
fileRequested;
61+
}
62+
else if (dk == "openshift-origin"){
63+
newLink = "https://docs.okd.io/" +
64+
newVersion +
65+
fileRequested;
66+
}
4467
}
4568

4669
// without doing async loads, there is no way to know if the path actually
@@ -57,7 +80,19 @@ function versionSelector(list) {
5780
if(jqXHR.status == 404) {
5881
list.value = currentVersion;
5982
if(confirm("This page doesn't exist in version " + newVersion + ". Click OK to search the " + newVersion + " docs OR Cancel to stay on this page.")) {
60-
window.location = "https://google.com/search?q=site:https://docs.openshift.com/container-platform/" + newVersion + " " + document.title;
83+
if (['3.65', '3.66', '3.67', '3.68', '3.69', '3.70', '3.71', '3.72', '3.73', '3.74', '4.0'].contains(newVersion)) {
84+
window.location = "https://google.com/search?q=site:https://docs.openshift.com/acs/" + newVersion + " " + document.title;}
85+
else if (['1.28', '1.29'].contains(newVersion)) {
86+
window.location = "https://google.com/search?q=site:https://docs.openshift.com/serverless/" + newVersion + " " + document.title;}
87+
else {
88+
if (dk == "openshift-enterprise"){
89+
window.location = "https://google.com/search?q=site:https://docs.openshift.com/enterprise/" + newVersion + " " + document.title;
90+
} else {
91+
if (dk == "openshift-origin"){
92+
window.location = "https://google.com/search?q=site:https://docs.okd.io/" + newVersion + " " + document.title;
93+
}
94+
}
95+
}
6196
} else {
6297
// do nothing, user doesn't want to search
6398
}
@@ -247,4 +282,4 @@ function addReferrer() {
247282
}
248283

249284

250-
}
285+
}

0 commit comments

Comments
 (0)