@@ -6,6 +6,11 @@ currentVersion = "";
6
6
// the fileRequested
7
7
fileRequested = "" ;
8
8
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
+
9
14
function versionSelector ( list ) {
10
15
11
16
// the version we want
@@ -33,14 +38,32 @@ function versionSelector(list) {
33
38
// alert(fileRequested);
34
39
35
40
// 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 ) ) {
37
42
newLink = "https://docs.openshift.com/enterprise/" +
38
43
newVersion +
39
44
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 ;
40
55
} else {
56
+ //if distro key is openshift enterprise
57
+ if ( dk == "openshift-enterprise" ) {
41
58
newLink = "https://docs.openshift.com/container-platform/" +
42
59
newVersion +
43
60
fileRequested ;
61
+ }
62
+ else if ( dk == "openshift-origin" ) {
63
+ newLink = "https://docs.okd.io/" +
64
+ newVersion +
65
+ fileRequested ;
66
+ }
44
67
}
45
68
46
69
// without doing async loads, there is no way to know if the path actually
@@ -57,7 +80,19 @@ function versionSelector(list) {
57
80
if ( jqXHR . status == 404 ) {
58
81
list . value = currentVersion ;
59
82
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
+ }
61
96
} else {
62
97
// do nothing, user doesn't want to search
63
98
}
@@ -247,4 +282,4 @@ function addReferrer() {
247
282
}
248
283
249
284
250
- }
285
+ }
0 commit comments