@@ -15,26 +15,11 @@ let playing = false;
15
15
let progress ;
16
16
const weatherParameters = { } ;
17
17
18
- // auto refresh
19
- const AUTO_REFRESH_INTERVAL_MS = 500 ;
20
- const AUTO_REFRESH_TIME_MS = 600_000 ; // 10 min.
21
- const CHK_AUTO_REFRESH_SELECTOR = '#chkAutoRefresh' ;
22
- let AutoRefreshIntervalId = null ;
23
- let AutoRefreshCountMs = 0 ;
24
-
25
18
const init = async ( ) => {
26
19
// set up resize handler
27
20
window . addEventListener ( 'resize' , resize ) ;
28
21
resize ( ) ;
29
22
30
- // auto refresh
31
- const autoRefresh = localStorage . getItem ( 'autoRefresh' ) ;
32
- if ( ! autoRefresh || autoRefresh === 'true' ) {
33
- document . querySelector ( CHK_AUTO_REFRESH_SELECTOR ) . checked = true ;
34
- } else {
35
- document . querySelector ( CHK_AUTO_REFRESH_SELECTOR ) . checked = false ;
36
- }
37
- document . querySelector ( CHK_AUTO_REFRESH_SELECTOR ) . addEventListener ( 'change' , autoRefreshChange ) ;
38
23
generateCheckboxes ( ) ;
39
24
} ;
40
25
@@ -123,12 +108,6 @@ const updateStatus = (value) => {
123
108
if ( isPlaying ( ) && value . id === firstDisplayIndex && value . status === STATUS . loaded ) {
124
109
navTo ( msg . command . firstFrame ) ;
125
110
}
126
-
127
- // send loaded messaged to parent
128
- if ( countLoadedDisplays ( ) < displays . length ) return ;
129
-
130
- // everything loaded, set timestamps
131
- AssignLastUpdate ( new Date ( ) ) ;
132
111
} ;
133
112
134
113
// note: a display that is "still waiting"/"retrying" is considered loaded intentionally
@@ -202,8 +181,6 @@ const loadDisplay = (direction) => {
202
181
idx = wrap ( curIdx + ( i + 1 ) * direction , totalDisplays ) ;
203
182
if ( displays [ idx ] . status === STATUS . loaded && displays [ idx ] . timing . totalScreens > 0 ) break ;
204
183
}
205
- // if new display index is less than current display a wrap occurred, test for reload timeout
206
- if ( idx <= curIdx && refreshCheck ( ) ) return ;
207
184
const newDisplay = displays [ idx ] ;
208
185
// hide all displays
209
186
hideAllCanvases ( ) ;
@@ -320,83 +297,8 @@ const populateWeatherParameters = (params) => {
320
297
document . querySelector ( '#spanZoneId' ) . innerHTML = params . zoneId ;
321
298
} ;
322
299
323
- const autoRefreshChange = ( e ) => {
324
- const { checked } = e . target ;
325
-
326
- if ( checked ) {
327
- startAutoRefreshTimer ( ) ;
328
- } else {
329
- stopAutoRefreshTimer ( ) ;
330
- }
331
-
332
- localStorage . setItem ( 'autoRefresh' , checked ) ;
333
- } ;
334
-
335
- const AssignLastUpdate = ( date ) => {
336
- if ( date ) {
337
- document . querySelector ( '#spanLastRefresh' ) . innerHTML = date . toLocaleString ( 'en-US' , {
338
- weekday : 'short' , month : 'short' , day : 'numeric' , year : 'numeric' , hour : 'numeric' , minute : 'numeric' , second : 'numeric' , timeZoneName : 'short' ,
339
- } ) ;
340
- if ( document . querySelector ( CHK_AUTO_REFRESH_SELECTOR ) . checked ) startAutoRefreshTimer ( ) ;
341
- } else {
342
- document . querySelector ( '#spanLastRefresh' ) . innerHTML = '(none)' ;
343
- }
344
- } ;
345
-
346
300
const latLonReceived = ( data , haveDataCallback ) => {
347
301
getWeather ( data , haveDataCallback ) ;
348
- AssignLastUpdate ( null ) ;
349
- } ;
350
-
351
- const startAutoRefreshTimer = ( ) => {
352
- // Ensure that any previous timer has already stopped.
353
- // check if timer is running
354
- if ( AutoRefreshIntervalId ) return ;
355
-
356
- // Reset the time elapsed.
357
- AutoRefreshCountMs = 0 ;
358
-
359
- const AutoRefreshTimer = ( ) => {
360
- // Increment the total time elapsed.
361
- AutoRefreshCountMs += AUTO_REFRESH_INTERVAL_MS ;
362
-
363
- // Display the count down.
364
- let RemainingMs = ( AUTO_REFRESH_TIME_MS - AutoRefreshCountMs ) ;
365
- if ( RemainingMs < 0 ) {
366
- RemainingMs = 0 ;
367
- }
368
- const dt = new Date ( RemainingMs ) ;
369
- document . querySelector ( '#spanRefreshCountDown' ) . innerHTML = `${ dt . getMinutes ( ) . toString ( ) . padStart ( 2 , '0' ) } :${ dt . getSeconds ( ) . toString ( ) . padStart ( 2 , '0' ) } ` ;
370
-
371
- // Time has elapsed.
372
- if ( AutoRefreshCountMs >= AUTO_REFRESH_TIME_MS && ! isPlaying ( ) ) loadTwcData ( ) ;
373
- } ;
374
- AutoRefreshIntervalId = window . setInterval ( AutoRefreshTimer , AUTO_REFRESH_INTERVAL_MS ) ;
375
- AutoRefreshTimer ( ) ;
376
- } ;
377
- const stopAutoRefreshTimer = ( ) => {
378
- if ( AutoRefreshIntervalId ) {
379
- window . clearInterval ( AutoRefreshIntervalId ) ;
380
- document . querySelector ( '#spanRefreshCountDown' ) . innerHTML = '--:--' ;
381
- AutoRefreshIntervalId = null ;
382
- }
383
- } ;
384
-
385
- const refreshCheck = ( ) => {
386
- // Time has elapsed.
387
- if ( AutoRefreshCountMs >= AUTO_REFRESH_TIME_MS && isPlaying ( ) ) {
388
- loadTwcData ( ) ;
389
- return true ;
390
- }
391
- return false ;
392
- } ;
393
-
394
- const loadTwcData = ( ) => {
395
- if ( loadTwcData . callback ) loadTwcData . callback ( ) ;
396
- } ;
397
-
398
- const registerRefreshData = ( callback ) => {
399
- loadTwcData . callback = callback ;
400
302
} ;
401
303
402
304
const timeZone = ( ) => weatherParameters . timeZone ;
@@ -414,7 +316,5 @@ export {
414
316
msg ,
415
317
message ,
416
318
latLonReceived ,
417
- stopAutoRefreshTimer ,
418
- registerRefreshData ,
419
319
timeZone ,
420
320
} ;
0 commit comments