|
@@ -151,7 +151,12 @@
|
|
|
|
|
|
// Activate content and title change on browser navigation
|
|
// Activate content and title change on browser navigation
|
|
|
|
|
|
- window.onpopstate = createNewIframe;
|
|
|
|
|
|
+ window.onpopstate = function() {
|
|
|
|
+
|
|
|
|
+ updateNavigation();
|
|
|
|
+ createNewIframe();
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
|
|
// Create the navigation panel and configure the iframe
|
|
// Create the navigation panel and configure the iframe
|
|
|
|
|
|
@@ -189,14 +194,7 @@
|
|
window.location.hash = pageURL;
|
|
window.location.hash = pageURL;
|
|
panel.classList.remove( 'open' );
|
|
panel.classList.remove( 'open' );
|
|
|
|
|
|
-
|
|
|
|
- content.querySelectorAll( 'a' ).forEach( function ( item ) {
|
|
|
|
-
|
|
|
|
- item.classList.remove( 'selected' );
|
|
|
|
-
|
|
|
|
- } );
|
|
|
|
-
|
|
|
|
- link.classList.add( 'selected' );
|
|
|
|
|
|
+ updateNavigation();
|
|
|
|
|
|
} );
|
|
} );
|
|
|
|
|
|
@@ -224,7 +222,7 @@
|
|
}
|
|
}
|
|
|
|
|
|
const categories = list[ language ];
|
|
const categories = list[ language ];
|
|
- const selectedPage = window.location.hash.substring( 1 );
|
|
|
|
|
|
+ const selectedPage = window.location.hash.substring( 1 ).replace( /\.html$/, '' );
|
|
|
|
|
|
for ( const category in categories ) {
|
|
for ( const category in categories ) {
|
|
|
|
|
|
@@ -286,6 +284,26 @@
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ function updateNavigation() {
|
|
|
|
+
|
|
|
|
+ const selectedPage = window.location.hash.substring( 1 ).replace( /\.html$/, '' );
|
|
|
|
+
|
|
|
|
+ content.querySelectorAll( 'a' ).forEach( function ( item ) {
|
|
|
|
+
|
|
|
|
+ if ( item.href.includes( selectedPage ) ) {
|
|
|
|
+
|
|
|
|
+ item.classList.add( 'selected' );
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+
|
|
|
|
+ item.classList.remove( 'selected' );
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ } );
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
// 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
|
|
// 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 ) {
|
|
function autoChangeUrlLanguage( language ) {
|
|
@@ -430,6 +448,7 @@
|
|
} else {
|
|
} else {
|
|
|
|
|
|
window.location.hash = newHash;
|
|
window.location.hash = newHash;
|
|
|
|
+ updateNavigation();
|
|
createNewIframe();
|
|
createNewIframe();
|
|
|
|
|
|
}
|
|
}
|