Skip to content

Commit f0166ec

Browse files
committed
removed existing auto-reload
1 parent 1983d02 commit f0166ec

File tree

7 files changed

+5
-118
lines changed

7 files changed

+5
-118
lines changed

server/scripts/index.mjs

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { json } from './modules/utils/fetch.mjs';
22
import noSleep from './modules/utils/nosleep.mjs';
33
import {
4-
message as navMessage, isPlaying, resize, resetStatuses, latLonReceived, stopAutoRefreshTimer, registerRefreshData,
4+
message as navMessage, isPlaying, resize, resetStatuses, latLonReceived,
55
} from './modules/navigation.mjs';
66
import { round2 } from './modules/utils/units.mjs';
77
import { parseQueryString } from './modules/share.mjs';
@@ -32,8 +32,6 @@ const init = () => {
3232
e.target.select();
3333
});
3434

35-
registerRefreshData(loadData);
36-
3735
document.querySelector('#NavigateMenu').addEventListener('click', btnNavigateMenuClick);
3836
document.querySelector('#NavigateRefresh').addEventListener('click', btnNavigateRefreshClick);
3937
document.querySelector('#NavigateNext').addEventListener('click', btnNavigateNextClick);
@@ -249,7 +247,6 @@ const loadData = (_latLon, haveDataCallback) => {
249247
if (!latLon) return;
250248

251249
document.querySelector(TXT_ADDRESS_SELECTOR).blur();
252-
stopAutoRefreshTimer();
253250
latLonReceived(latLon, haveDataCallback);
254251
};
255252

server/scripts/modules/navigation.mjs

-100
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,11 @@ let playing = false;
1515
let progress;
1616
const weatherParameters = {};
1717

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-
2518
const init = async () => {
2619
// set up resize handler
2720
window.addEventListener('resize', resize);
2821
resize();
2922

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);
3823
generateCheckboxes();
3924
};
4025

@@ -123,12 +108,6 @@ const updateStatus = (value) => {
123108
if (isPlaying() && value.id === firstDisplayIndex && value.status === STATUS.loaded) {
124109
navTo(msg.command.firstFrame);
125110
}
126-
127-
// send loaded messaged to parent
128-
if (countLoadedDisplays() < displays.length) return;
129-
130-
// everything loaded, set timestamps
131-
AssignLastUpdate(new Date());
132111
};
133112

134113
// note: a display that is "still waiting"/"retrying" is considered loaded intentionally
@@ -202,8 +181,6 @@ const loadDisplay = (direction) => {
202181
idx = wrap(curIdx + (i + 1) * direction, totalDisplays);
203182
if (displays[idx].status === STATUS.loaded && displays[idx].timing.totalScreens > 0) break;
204183
}
205-
// if new display index is less than current display a wrap occurred, test for reload timeout
206-
if (idx <= curIdx && refreshCheck()) return;
207184
const newDisplay = displays[idx];
208185
// hide all displays
209186
hideAllCanvases();
@@ -320,83 +297,8 @@ const populateWeatherParameters = (params) => {
320297
document.querySelector('#spanZoneId').innerHTML = params.zoneId;
321298
};
322299

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-
346300
const latLonReceived = (data, haveDataCallback) => {
347301
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;
400302
};
401303

402304
const timeZone = () => weatherParameters.timeZone;
@@ -414,7 +316,5 @@ export {
414316
msg,
415317
message,
416318
latLonReceived,
417-
stopAutoRefreshTimer,
418-
registerRefreshData,
419319
timeZone,
420320
};

server/styles/main.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/styles/main.css.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/styles/scss/_page.scss

+1-2
Original file line numberDiff line numberDiff line change
@@ -745,8 +745,7 @@ body {
745745
>.heading,
746746
#enabledDisplays,
747747
#settings,
748-
#divInfo,
749-
#divRefresh {
748+
#divInfo {
750749
display: none;
751750
}
752751
}

views/index.ejs

-5
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,6 @@
163163
Zone Id: <span id="spanZoneId"></span><br />
164164
</div>
165165

166-
<div id="divRefresh">
167-
Last Update: <span id="spanLastRefresh">(None)</span><br />
168-
<input id="chkAutoRefresh" name="chkAutoRefresh" type="checkbox" /><label id="lblRefreshCountDown" for="chkAutoRefresh">Auto Refresh: <span id="spanRefreshCountDown">--:--</span></label>
169-
</div>
170-
171166
</body>
172167

173168
</html>

ws4kp.code-workspace

+1-5
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,7 @@
5252
"[html]": {
5353
"editor.defaultFormatter": "j69.ejs-beautify"
5454
},
55-
"files.exclude": {
56-
"**/node_modules": true,
57-
"**/debug.log": true,
58-
"server/scripts/custom.js": true
59-
},
55+
"files.exclude": {},
6056
"files.eol": "\n",
6157
"editor.formatOnSave": true,
6258
"editor.codeActionsOnSave": {

0 commit comments

Comments
 (0)