@@ -7,6 +7,7 @@ class WindowHashManager {
77 this . tabFilter = "" ;
88 this . tabsShown = true ;
99 this . channelsShown = true ;
10+ this . lightMode = false ;
1011 this . plotChannels = { } ;
1112 this . filters = { } ;
1213 this . minTxPeriod = 0.0 ;
@@ -17,6 +18,15 @@ class WindowHashManager {
1718 this . update ( ) ;
1819 }
1920
21+ lightDarkClick ( event ) {
22+ this . lightMode = ! this . lightMode ;
23+
24+ document . getElementById ( "runtimepy" )
25+ . setAttribute ( "data-bs-theme" , this . lightMode ? "light" : "dark" ) ;
26+
27+ this . update ( ) ;
28+ }
29+
2030 channelClick ( event ) {
2131 this . channelsShown = ! this . channelsShown ;
2232
@@ -106,6 +116,12 @@ class WindowHashManager {
106116 channelsButton . addEventListener ( "click" , this . channelClick . bind ( this ) ) ;
107117 }
108118
119+ /* Click handler for light/dark toggle. */
120+ let lightDarkButton = document . getElementById ( "theme-button" ) ;
121+ if ( lightDarkButton ) {
122+ lightDarkButton . addEventListener ( "click" , this . lightDarkClick . bind ( this ) ) ;
123+ }
124+
109125 /* Click handlers for new window buttons. */
110126 for ( const button of document . querySelectorAll ( ".window-button" ) ) {
111127 button . onclick = ( ) => {
@@ -150,13 +166,6 @@ class WindowHashManager {
150166 }
151167 }
152168
153- if ( split . includes ( "hide-tabs" ) ) {
154- tabButton . click ( ) ;
155- }
156- if ( split . includes ( "hide-channels" ) ) {
157- channelsButton . click ( ) ;
158- }
159-
160169 /* Check for tab filter. */
161170 for ( let item of split ) {
162171 if ( item . includes ( "=" ) ) {
@@ -171,6 +180,16 @@ class WindowHashManager {
171180 }
172181 }
173182 }
183+
184+ if ( split . includes ( "hide-tabs" ) ) {
185+ tabButton . click ( ) ;
186+ }
187+ if ( split . includes ( "hide-channels" ) ) {
188+ channelsButton . click ( ) ;
189+ }
190+ if ( split . includes ( "light-mode" ) ) {
191+ lightDarkButton . click ( ) ;
192+ }
174193 }
175194 }
176195
@@ -199,6 +218,9 @@ class WindowHashManager {
199218 if ( ! this . channelsShown ) {
200219 hash += ",hide-channels"
201220 }
221+ if ( this . lightMode ) {
222+ hash += ",light-mode" ;
223+ }
202224
203225 if ( this . minTxPeriod != 0.0 ) {
204226 hash += `,min-tx-period-ms=${ this . minTxPeriod } ` ;
0 commit comments