Skip to content

Commit c70e3cb

Browse files
committed
Docs: Fix language switching for examples.
1 parent 4058d7c commit c70e3cb

File tree

1 file changed

+33
-19
lines changed

1 file changed

+33
-19
lines changed

docs/index.html

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -124,25 +124,27 @@ <h1><a href="http://threejs.org">three.js</a></h1>
124124
// Functionality for search/filter input field
125125
filterInput.onfocus = function ( event ) {
126126

127-
panel.classList.add('searchFocused');
127+
panel.classList.add( 'searchFocused' );
128128

129-
}
129+
};
130130

131131
filterInput.onblur = function ( event ) {
132132

133-
if(filterInput.value === '') {
134-
panel.classList.remove('searchFocused');
133+
if ( filterInput.value === '' ) {
134+
135+
panel.classList.remove( 'searchFocused' );
136+
135137
}
136138

137-
}
139+
};
138140

139-
exitSearchButton.onclick = function( event ) {
141+
exitSearchButton.onclick = function ( event ) {
140142

141143
filterInput.value = '';
142144
updateFilter();
143-
panel.classList.remove('searchFocused');
145+
panel.classList.remove( 'searchFocused' );
144146

145-
}
147+
};
146148

147149
filterInput.oninput = function ( event ) {
148150

@@ -181,7 +183,7 @@ <h1><a href="http://threejs.org">three.js</a></h1>
181183

182184
} );
183185

184-
link.classList.add('selected');
186+
link.classList.add( 'selected' );
185187

186188
} );
187189

@@ -241,7 +243,7 @@ <h1><a href="http://threejs.org">three.js</a></h1>
241243
var listElement = document.createElement( 'li' );
242244
categoryContent.appendChild( listElement );
243245

244-
var linkElement = createLink( pageName, pageURL )
246+
var linkElement = createLink( pageName, pageURL );
245247
listElement.appendChild( linkElement );
246248

247249
// Gather the main properties for the current subpage
@@ -253,9 +255,9 @@ <h1><a href="http://threejs.org">three.js</a></h1>
253255
linkElement: linkElement
254256
};
255257

256-
// Gather the document titles (used for easy access on browser navigation)
258+
// Gather the document titles (used for easy access on browser navigation)
257259

258-
titles[ pageURL ] = pageName;
260+
titles[ pageURL ] = pageName;
259261

260262
}
261263

@@ -275,10 +277,20 @@ <h1><a href="http://threejs.org">three.js</a></h1>
275277

276278
var hash = location.hash;
277279
if ( hash === '' ) return;
280+
278281
var docType = hash.substr( 0, hash.indexOf( '/' ) + 1 );
279282
var docLink = hash.substr( hash.indexOf( '/' ) + 1 );
280-
docLink = docLink.substr( docLink.indexOf( '/' ) );
281-
location.href = docType + language + docLink;
283+
284+
if ( /^(api|manual)/.test( hash.substring( 1 ) ) ) {
285+
286+
docLink = docLink.substr( docLink.indexOf( '/' ) );
287+
location.href = docType + language + docLink;
288+
289+
} else {
290+
291+
location.href = docType + docLink;
292+
293+
}
282294

283295
}
284296

@@ -302,12 +314,14 @@ <h1><a href="http://threejs.org">three.js</a></h1>
302314

303315
// Accentuate matching characters
304316

305-
for ( var i = 0; i < filterResults.length; i++ ) {
317+
for ( var i = 0; i < filterResults.length; i ++ ) {
306318

307319
var result = filterResults[ i ];
308320

309321
if ( result !== '' ) {
322+
310323
pageName = pageName.replace( result, '<b>' + result + '</b>' );
324+
311325
}
312326

313327
}
@@ -414,7 +428,7 @@ <h1><a href="http://threejs.org">three.js</a></h1>
414428
oldIframe = iframe;
415429
iframe = oldIframe.cloneNode();
416430

417-
if(hash) {
431+
if ( hash ) {
418432

419433
iframe.src = splitHash[ 0 ] + '.html' + splitHash[ 1 ];
420434
subtitle = titles[ splitHash[ 0 ] ] + splitHash[ 1 ] + ' – ';
@@ -443,7 +457,7 @@ <h1><a href="http://threejs.org">three.js</a></h1>
443457

444458
var dotIndex = pageName.indexOf( oldDelimiter );
445459

446-
if ( dotIndex !== -1 ) {
460+
if ( dotIndex !== - 1 ) {
447461

448462
parts = pageName.split( oldDelimiter );
449463
parts[ 1 ] = newDelimiter + parts[ 1 ];
@@ -461,7 +475,7 @@ <h1><a href="http://threejs.org">three.js</a></h1>
461475

462476
//
463477

464-
console.log([
478+
console.log( [
465479
' __ __',
466480
' __/ __\\ / __\\__ ____ _____ _____',
467481
'/ __/ /\\/ / /___\\/ ____\\/ _____\\/ _____\\',
@@ -470,7 +484,7 @@ <h1><a href="http://threejs.org">three.js</a></h1>
470484
'\\/__/ \\/__/\\/__/\\/__/ \\/_____/\\/_____/\\/__/ / / / ___/',
471485
' / __/ / \\__ \\',
472486
' \\/____/\\/_____/'
473-
].join('\n'));
487+
].join( '\n' ) );
474488

475489

476490
</script>

0 commit comments

Comments
 (0)