2
2
* Licensed to the Apache Software Foundation (ASF) under one
3
3
* or more contributor license agreements. See the NOTICE file
4
4
* distributed with this work for additional information
5
- * regarding copyright ownership. The ASF licenses this file
5
+ * regarding copyright ownership. The ASF licenses this file
6
6
* to you under the Apache License, Version 2.0 (the
7
7
* "License"); you may not use this file except in compliance
8
8
* with the License. You may obtain a copy of the License at
17
17
* under the License.
18
18
*/
19
19
20
- /* Installation page display functions for install selector */
20
+ /* Installation page display functions for install selector.
21
+ This utility allows direct links to specific install instructions.
22
+ */
21
23
22
24
$ ( document ) . ready ( function ( ) {
23
25
function label ( lbl ) {
@@ -27,13 +29,13 @@ $(document).ready(function () {
27
29
}
28
30
29
31
function urlSearchParams ( searchString ) {
30
- let urlDict = new Map ( ) ;
32
+ let searchDict = new Map ( ) ;
31
33
let searchParams = searchString . substring ( 1 ) . split ( "&" ) ;
32
34
searchParams . forEach ( function ( element ) {
33
35
kvPair = element . split ( "=" ) ;
34
- urlDict . set ( kvPair [ 0 ] , kvPair [ 1 ] ) ;
36
+ searchDict . set ( kvPair [ 0 ] , kvPair [ 1 ] ) ;
35
37
} ) ;
36
- return urlDict ;
38
+ return searchDict ;
37
39
}
38
40
39
41
function is_a_match ( elem , text ) {
@@ -43,11 +45,10 @@ $(document).ready(function () {
43
45
}
44
46
}
45
47
46
- function setSelects ( ) {
47
- let urlParams = urlSearchParams ( window . location . search ) ;
48
+ function setSelects ( urlParams ) {
48
49
if ( urlParams . get ( 'version' ) )
49
50
versionSelect = urlParams . get ( 'version' ) ;
50
- $ ( '.current-version' ) . html ( versionSelect + ' <span class="caret"></span></button> ' ) ;
51
+ $ ( '.current-version' ) . html ( versionSelect + ' <span class="caret"></span>' ) ;
51
52
if ( urlParams . get ( 'platform' ) )
52
53
platformSelect = label ( urlParams . get ( 'platform' ) ) ;
53
54
if ( urlParams . get ( 'language' ) )
@@ -66,8 +67,9 @@ $(document).ready(function () {
66
67
$ ( 'button.opt' ) . each ( function ( ) { is_a_match ( $ ( this ) , environSelect ) } ) ;
67
68
68
69
showContent ( ) ;
69
- if ( window . location . href . indexOf ( "/get_started/" ) >= 0 ) {
70
- history . pushState ( null , null , '?version=' + versionSelect + '&platform=' + platformSelect + '&language=' + languageSelect + '&environ=' + environSelect + '&processor=' + processorSelect ) ;
70
+ let queryString = '?version=' + versionSelect + '&platform=' + platformSelect + '&language=' + languageSelect + '&environ=' + environSelect + '&processor=' + processorSelect
71
+ if ( window . location . href . indexOf ( "/get_started" ) >= 0 ) {
72
+ history . pushState ( null , null , queryString ) ;
71
73
}
72
74
}
73
75
@@ -80,8 +82,7 @@ $(document).ready(function () {
80
82
} ) ;
81
83
}
82
84
83
- showContent ( ) ;
84
- setSelects ( ) ;
85
+ setSelects ( urlSearchParams ( window . location . search ) ) ;
85
86
86
87
function setContent ( ) {
87
88
var el = $ ( this ) ;
@@ -90,27 +91,17 @@ $(document).ready(function () {
90
91
el . addClass ( 'active' ) ;
91
92
if ( $ ( this ) . hasClass ( "versions" ) ) {
92
93
$ ( '.current-version' ) . html ( $ ( this ) . text ( ) ) ;
93
- if ( window . location . search . indexOf ( "version" ) < 0 ) {
94
- if ( window . location . search . length > 0 ) {
95
- var url = 'index.html' + window . location . search . concat ( '&version=' + $ ( this ) . text ( ) ) ;
96
- } else {
97
- var url = 'index.html?version=' + $ ( this ) . text ( ) ;
98
- }
99
- history . pushState ( null , null , url ) ;
100
- } else {
101
- history . pushState ( null , null , 'index.html' + window . location . search . replace ( urlParams . get ( 'version' ) , $ ( this ) . text ( ) ) ) ;
102
- }
94
+ urlParams . set ( "version" , $ ( this ) . text ( ) ) ;
103
95
} else if ( $ ( this ) . hasClass ( "platforms" ) ) {
104
- history . pushState ( null , null , 'index.html' + window . location . search . replace ( '=' + urlParams . get ( ' platform' ) , '=' + label ( $ ( this ) . text ( ) ) ) ) ;
96
+ urlParams . set ( " platform" , label ( $ ( this ) . text ( ) ) ) ;
105
97
} else if ( $ ( this ) . hasClass ( "languages" ) ) {
106
- history . pushState ( null , null , 'index.html' + window . location . search . replace ( '=' + urlParams . get ( ' language' ) , '=' + label ( $ ( this ) . text ( ) ) ) ) ;
98
+ urlParams . set ( " language" , label ( $ ( this ) . text ( ) ) ) ;
107
99
} else if ( $ ( this ) . hasClass ( "processors" ) ) {
108
- history . pushState ( null , null , 'index.html' + window . location . search . replace ( '=' + urlParams . get ( ' processor' ) , '=' + label ( $ ( this ) . text ( ) ) ) ) ;
100
+ urlParams . set ( " processor" , label ( $ ( this ) . text ( ) ) ) ;
109
101
} else if ( $ ( this ) . hasClass ( "environs" ) ) {
110
- history . pushState ( null , null , 'index.html' + window . location . search . replace ( '=' + urlParams . get ( ' environ' ) , '=' + label ( $ ( this ) . text ( ) ) ) ) ;
102
+ urlParams . set ( " environ" , label ( $ ( this ) . text ( ) ) ) ;
111
103
}
112
-
113
- showContent ( ) ;
104
+ setSelects ( urlParams ) ;
114
105
}
115
106
116
107
$ ( '.opt-group' ) . on ( 'click' , '.opt' , setContent ) ;
0 commit comments