1
1
'use strict' ;
2
2
3
- /* global default_theme, hljs, ClipboardJS */
3
+ /* global default_theme, default_dark_theme, default_light_theme, hljs, ClipboardJS */
4
4
5
5
// Fix back button cache problem
6
6
window . onunload = function ( ) { } ;
@@ -329,11 +329,11 @@ aria-label="Show hidden lines"></button>';
329
329
themePopup . querySelectorAll ( '.theme-selected' ) . forEach ( function ( el ) {
330
330
el . classList . remove ( 'theme-selected' ) ;
331
331
} ) ;
332
- const selected = get_saved_theme ( ) ?? " default_theme" ;
333
- var element = themePopup . querySelector ( " button#" + selected ) ;
332
+ const selected = get_saved_theme ( ) ?? ' default_theme' ;
333
+ let element = themePopup . querySelector ( ' button#' + selected ) ;
334
334
if ( element === null ) {
335
335
// Fall back in case there is no "Default" item.
336
- element = themePopup . querySelector ( " button#" + get_theme ( ) ) ;
336
+ element = themePopup . querySelector ( ' button#' + get_theme ( ) ) ;
337
337
}
338
338
element . classList . add ( 'theme-selected' ) ;
339
339
}
@@ -345,7 +345,7 @@ aria-label="Show hidden lines"></button>';
345
345
}
346
346
347
347
function get_saved_theme ( ) {
348
- var theme = null ;
348
+ let theme = null ;
349
349
try {
350
350
theme = localStorage . getItem ( 'mdbook-theme' ) ;
351
351
} catch ( e ) {
@@ -359,22 +359,22 @@ aria-label="Show hidden lines"></button>';
359
359
}
360
360
361
361
function get_theme ( ) {
362
- var theme = get_saved_theme ( ) ;
362
+ const theme = get_saved_theme ( ) ;
363
363
if ( theme === null || theme === undefined || ! themeIds . includes ( theme ) ) {
364
364
if ( typeof default_dark_theme === 'undefined' ) {
365
365
// A customized index.hbs might not define this, so fall back to
366
366
// old behavior of determining the default on page load.
367
367
return default_theme ;
368
368
}
369
- return window . matchMedia ( " (prefers-color-scheme: dark)" ) . matches
369
+ return window . matchMedia ( ' (prefers-color-scheme: dark)' ) . matches
370
370
? default_dark_theme
371
371
: default_light_theme ;
372
372
} else {
373
373
return theme ;
374
374
}
375
375
}
376
376
377
- var previousTheme = default_theme ;
377
+ let previousTheme = default_theme ;
378
378
function set_theme ( theme , store = true ) {
379
379
let ace_theme ;
380
380
@@ -420,9 +420,9 @@ aria-label="Show hidden lines"></button>';
420
420
updateThemeSelected ( ) ;
421
421
}
422
422
423
- const query = window . matchMedia ( " (prefers-color-scheme: dark)" ) ;
424
- query . onchange = function ( event ) {
425
- set_theme ( get_theme ( ) , false ) ;
423
+ const query = window . matchMedia ( ' (prefers-color-scheme: dark)' ) ;
424
+ query . onchange = function ( ) {
425
+ set_theme ( get_theme ( ) , false ) ;
426
426
} ;
427
427
428
428
// Set theme.
@@ -445,7 +445,7 @@ aria-label="Show hidden lines"></button>';
445
445
} else {
446
446
return ;
447
447
}
448
- if ( theme === " default_theme" || theme == null ) {
448
+ if ( theme === ' default_theme' || theme = == null ) {
449
449
delete_saved_theme ( ) ;
450
450
set_theme ( get_theme ( ) , false ) ;
451
451
} else {
0 commit comments