|
32 | 32 | <!-- Custom theme stylesheets --> |
33 | 33 |
|
34 | 34 |
|
35 | | - <!-- Provide site root to javascript --> |
| 35 | + <!-- Provide site root and default themes to javascript --> |
36 | 36 | <script> |
37 | | - var path_to_root = ""; |
38 | | - var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "navy" : "light"; |
| 37 | + const path_to_root = ""; |
| 38 | + const default_light_theme = "light"; |
| 39 | + const default_dark_theme = "navy"; |
39 | 40 | </script> |
40 | 41 | <!-- Start loading toc.js asap --> |
41 | 42 | <script src="toc.js"></script> |
|
45 | 46 | <!-- Work around some values being stored in localStorage wrapped in quotes --> |
46 | 47 | <script> |
47 | 48 | try { |
48 | | - var theme = localStorage.getItem('mdbook-theme'); |
49 | | - var sidebar = localStorage.getItem('mdbook-sidebar'); |
| 49 | + let theme = localStorage.getItem('mdbook-theme'); |
| 50 | + let sidebar = localStorage.getItem('mdbook-sidebar'); |
50 | 51 |
|
51 | 52 | if (theme.startsWith('"') && theme.endsWith('"')) { |
52 | 53 | localStorage.setItem('mdbook-theme', theme.slice(1, theme.length - 1)); |
|
60 | 61 |
|
61 | 62 | <!-- Set the theme before any content is loaded, prevents flash --> |
62 | 63 | <script> |
63 | | - var theme; |
| 64 | + const default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? default_dark_theme : default_light_theme; |
| 65 | + let theme; |
64 | 66 | try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { } |
65 | 67 | if (theme === null || theme === undefined) { theme = default_theme; } |
66 | 68 | const html = document.documentElement; |
|
73 | 75 |
|
74 | 76 | <!-- Hide / unhide sidebar before it is displayed --> |
75 | 77 | <script> |
76 | | - var sidebar = null; |
77 | | - var sidebar_toggle = document.getElementById("sidebar-toggle-anchor"); |
| 78 | + let sidebar = null; |
| 79 | + const sidebar_toggle = document.getElementById("sidebar-toggle-anchor"); |
78 | 80 | if (document.body.clientWidth >= 1080) { |
79 | 81 | try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { } |
80 | 82 | sidebar = sidebar || 'visible'; |
|
110 | 112 | <i class="fa fa-paint-brush"></i> |
111 | 113 | </button> |
112 | 114 | <ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu"> |
| 115 | + <li role="none"><button role="menuitem" class="theme" id="default_theme">Auto</button></li> |
113 | 116 | <li role="none"><button role="menuitem" class="theme" id="light">Light</button></li> |
114 | 117 | <li role="none"><button role="menuitem" class="theme" id="rust">Rust</button></li> |
115 | 118 | <li role="none"><button role="menuitem" class="theme" id="coal">Coal</button></li> |
|
0 commit comments