File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4747 }
4848 }
4949 } ;
50-
51- document . getElementById ( 'languages' ) . onchange = function ( ev ) {
52- if ( ev . currentTarget && ev . currentTarget . value ) {
53- location . href = ev . currentTarget . value ;
54- }
55- } ;
5650 </ script >
5751 </ body>
5852</ html>
Original file line number Diff line number Diff line change 44 < option value ="{{ lang.path }} "> {{ lang.label }}</ option >
55{% endfor %}
66</ select >
7+
8+ < script type ="text/javascript ">
9+ ( function ( ) {
10+ 'use strict' ;
11+ var langs = document . getElementById ( 'languages' ) ;
12+
13+ // Only apply this after we set the Selected option
14+ langs . onchange = function ( ev ) {
15+ if ( ev . currentTarget && ev . currentTarget . value ) {
16+ location . href = ev . currentTarget . value ;
17+ }
18+ } ;
19+
20+ if ( '/' === window . location . pathname ) {
21+ return ;
22+ }
23+
24+ var opts = langs . getElementsByTagName ( 'option' ) ,
25+ count = opts . length ;
26+
27+ for ( var i = 0 ; i < count ; i ++ ) {
28+ if ( - 1 === opts [ i ] . value . indexOf ( window . location . pathname ) ) {
29+ continue ;
30+ }
31+
32+ opts [ i ] . setAttribute ( 'selected' , 'selected' ) ;
33+ }
34+ } ) ( ) ;
35+ </ script >
You can’t perform that action at this time.
0 commit comments