Browse Source

Update docs/index.html

sunxueqing 6 years ago
parent
commit
09ea0c4668
1 changed files with 19 additions and 0 deletions
  1. 19 0
      docs/index.html

+ 19 - 0
docs/index.html

@@ -69,6 +69,8 @@
 
 				language = value;
 				createNavigation();
+				updateFilter();
+				autoChangeUrlLanguage(language);
 
 			}
 
@@ -226,6 +228,23 @@
 
 			}
 
+			// Auto change language url. If a reader open a document in English, when he click "zh", the document he read will auto change into Chinese version
+
+			function autoChangeUrlLanguage( language ) {
+
+				var hash = location.hash;
+				if( !hash ){
+
+					return;
+
+				}
+				var docType = hash.substr( 0, hash.indexOf( '/' ) + 1 );
+				var docLink = hash.substr( hash.indexOf( '/' ) + 1 );
+				docLink = docLink.substr( docLink.indexOf( '/' ) );
+				location.href = docType + language + docLink;
+
+			}
+
 
 			// Filtering