Compare commits

..

11 Commits

Author SHA1 Message Date
Matt Walsh
095761ee81 5.21.5 2025-05-29 21:04:51 -05:00
Matt Walsh
21e528aaa3 fix for kiosk mode scrollbars #86 2025-05-29 21:03:48 -05:00
Matt Walsh
a92c632937 5.21.4 2025-05-29 20:24:08 -05:00
Matt Walsh
6073fd1733 better missing data handling for current conditions #87 2025-05-29 20:23:55 -05:00
Matt Walsh
5da8185633 Merge pull request #89 from kevinastone/patch-2
Gracefully shutdown on both SIGINT + SIGTERM
2025-05-29 20:02:43 -05:00
Kevin Stone
cf5c818ee3 Gracefully shutdown on both SIGINT + SIGTERM
Most service managers (systemd, docker, etc) use SIGTERM as the shutdown signal by default rather than SIGINT (which is used for interactive CTRL-C).
2025-05-29 17:37:40 -07:00
Matt Walsh
97cec114f6 Merge branch 'main' of github.com:netbymatt/ws4kp 2025-05-29 17:03:55 -05:00
Matt Walsh
7efd2e8db7 add scanlines 2025-05-29 17:03:50 -05:00
Matt Walsh
8c28f41d54 Merge pull request #85 from dylan-park/readme-patch-1
update local run instructions in README
2025-05-29 14:45:07 -05:00
Dylan Park
e9d603fbfc update local run instructions in README 2025-05-29 14:24:05 -05:00
Matt Walsh
32aa43c5b1 update user-agent header, now allowed in some browsers 2025-05-29 14:18:49 -05:00
17 changed files with 189 additions and 19 deletions

View File

@@ -31,7 +31,7 @@ To run via Node locally:
git clone https://github.com/netbymatt/ws4kp.git git clone https://github.com/netbymatt/ws4kp.git
cd ws4kp cd ws4kp
npm i npm i
node index.js node index.mjs
``` ```
To run via Docker: To run via Docker:

View File

@@ -99,8 +99,11 @@ const server = app.listen(port, () => {
}); });
// graceful shutdown // graceful shutdown
process.on('SIGINT', () => { const gracefulShutdown = () => {
server.close(() => { server.close(() => {
console.log('Server closed'); console.log('Server closed');
}); });
}); };
process.on('SIGINT', gracefulShutdown);
process.on('SIGTERM', gracefulShutdown);

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{ {
"name": "ws4kp", "name": "ws4kp",
"version": "5.21.3", "version": "5.21.5",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "ws4kp", "name": "ws4kp",
"version": "5.21.3", "version": "5.21.5",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"dotenv": "^16.5.0", "dotenv": "^16.5.0",

View File

@@ -1,6 +1,6 @@
{ {
"name": "ws4kp", "name": "ws4kp",
"version": "5.21.3", "version": "5.21.5",
"description": "Welcome to the WeatherStar 4000+ project page!", "description": "Welcome to the WeatherStar 4000+ project page!",
"main": "index.mjs", "main": "index.mjs",
"type": "module", "type": "module",

Binary file not shown.

After

Width:  |  Height:  |  Size: 893 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 367 B

View File

@@ -38,6 +38,7 @@ const init = () => {
document.querySelector('#NavigateNext').addEventListener('click', btnNavigateNextClick); document.querySelector('#NavigateNext').addEventListener('click', btnNavigateNextClick);
document.querySelector('#NavigatePrevious').addEventListener('click', btnNavigatePreviousClick); document.querySelector('#NavigatePrevious').addEventListener('click', btnNavigatePreviousClick);
document.querySelector('#NavigatePlay').addEventListener('click', btnNavigatePlayClick); document.querySelector('#NavigatePlay').addEventListener('click', btnNavigatePlayClick);
document.querySelector('#ToggleScanlines').addEventListener('click', btnNavigateToggleScanlines);
document.querySelector(TOGGLE_FULL_SCREEN_SELECTOR).addEventListener('click', btnFullScreenClick); document.querySelector(TOGGLE_FULL_SCREEN_SELECTOR).addEventListener('click', btnFullScreenClick);
const btnGetGps = document.querySelector(BNT_GET_GPS_SELECTOR); const btnGetGps = document.querySelector(BNT_GET_GPS_SELECTOR);
btnGetGps.addEventListener('click', btnGetGpsClick); btnGetGps.addEventListener('click', btnGetGpsClick);
@@ -344,6 +345,11 @@ const btnNavigatePlayClick = () => {
return false; return false;
}; };
const btnNavigateToggleScanlines = () => {
settings.scanLines.value = !settings.scanLines.value;
return false;
};
// post a message to the iframe // post a message to the iframe
const postMessage = (type, myMessage = {}) => { const postMessage = (type, myMessage = {}) => {
navMessage({ type, message: myMessage }); navMessage({ type, message: myMessage });

View File

@@ -50,6 +50,8 @@ class CurrentWeather extends WeatherDisplay {
stillWaiting: () => this.stillWaiting(), stillWaiting: () => this.stillWaiting(),
}); });
if (observations.features.length === 0) throw new Error(`No features returned for station: ${station.properties.stationIdentifier}, trying next station`);
// test data quality // test data quality
if (observations.features[0].properties.temperature.value === null if (observations.features[0].properties.temperature.value === null
|| observations.features[0].properties.windSpeed.value === null || observations.features[0].properties.windSpeed.value === null
@@ -59,10 +61,11 @@ class CurrentWeather extends WeatherDisplay {
|| observations.features[0].properties.dewpoint.value === null || observations.features[0].properties.dewpoint.value === null
|| observations.features[0].properties.barometricPressure.value === null) { || observations.features[0].properties.barometricPressure.value === null) {
observations = undefined; observations = undefined;
throw new Error(`Unable to get observations: ${station.properties.stationIdentifier}, trying next station`); throw new Error(`Incomplete data set for: ${station.properties.stationIdentifier}, trying next station`);
} }
} catch (error) { } catch (error) {
console.error(error); console.error(error);
observations = undefined;
} }
} }
// test for data received // test for data received

View File

@@ -33,6 +33,12 @@ const init = () => {
[1.5, 'Very Slow'], [1.5, 'Very Slow'],
], ],
}); });
settings.scanLines = new Setting('scanLines', {
name: 'Scan Lines',
defaultValue: false,
changeAction: scanLineChange,
sticky: true,
});
settings.units = new Setting('units', { settings.units = new Setting('units', {
name: 'Units', name: 'Units',
type: 'select', type: 'select',
@@ -85,6 +91,18 @@ const kioskChange = (value) => {
} }
}; };
const scanLineChange = (value) => {
const container = document.getElementById('container');
const navIcons = document.getElementById('ToggleScanlines');
if (value) {
container.classList.add('scanlines');
navIcons.classList.add('on');
} else {
container.classList.remove('scanlines');
navIcons.classList.remove('on');
}
};
const unitChange = () => { const unitChange = () => {
// reload the data at the top level to refresh units // reload the data at the top level to refresh units
// after the initial load // after the initial load

View File

@@ -5,6 +5,11 @@ const text = (url, params) => fetchAsync(url, 'text', params);
const blob = (url, params) => fetchAsync(url, 'blob', params); const blob = (url, params) => fetchAsync(url, 'blob', params);
const fetchAsync = async (_url, responseType, _params = {}) => { const fetchAsync = async (_url, responseType, _params = {}) => {
// add user agent header to json request at api.weather.gov
const headers = {};
if (_url.toString().match(/api\.weather\.gov/)) {
headers['user-agent'] = 'Weatherstar 4000+; weatherstar@netbymatt.com';
}
// combine default and provided parameters // combine default and provided parameters
const params = { const params = {
method: 'GET', method: 'GET',
@@ -12,6 +17,7 @@ const fetchAsync = async (_url, responseType, _params = {}) => {
type: 'GET', type: 'GET',
retryCount: 0, retryCount: 0,
..._params, ..._params,
headers,
}; };
// store original number of retries // store original number of retries
params.originalRetries = params.retryCount; params.originalRetries = params.retryCount;

View File

@@ -189,7 +189,7 @@ class Setting {
break; break;
case 'checkbox': case 'checkbox':
default: default:
this.element.checked = newValue; this.element.querySelector('input').checked = newValue;
} }
this.storeToLocalStorage(this.myValue); this.storeToLocalStorage(this.myValue);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -23,6 +23,8 @@ body {
&.kiosk { &.kiosk {
margin: 0px; margin: 0px;
overflow: hidden;
width: 100vw;
} }
} }
@@ -141,6 +143,10 @@ body {
} }
} }
.kiosk #divTwc {
max-width: unset;
}
#divTwcLeft { #divTwcLeft {
display: none; display: none;
text-align: right; text-align: right;
@@ -322,10 +328,6 @@ body {
transform-origin: unset; transform-origin: unset;
} }
.kiosk #divTwc #container {
transform-origin: 0 0;
}
#loading { #loading {
width: 640px; width: 640px;
height: 480px; height: 480px;
@@ -426,10 +428,6 @@ body {
} }
} }
.kiosk #divTwc {
justify-content: unset;
}
#divTwc:fullscreen #display, #divTwc:fullscreen #display,
.kiosk #divTwc #display { .kiosk #divTwc #display {
position: relative; position: relative;
@@ -458,6 +456,30 @@ body {
cursor: pointer; cursor: pointer;
} }
#ToggleScanlines {
display: inline-block;
.on {
display: none;
}
.off {
display: inline-block;
}
&.on {
.on {
display: inline-block;
}
.off {
display: none;
}
}
}
.visible { .visible {
visibility: visible; visibility: visible;
opacity: 1; opacity: 1;
@@ -750,6 +772,7 @@ body {
#divQuery, #divQuery,
>.info, >.info,
>.related-links,
>.heading, >.heading,
#enabledDisplays, #enabledDisplays,
#settings, #settings,

View File

@@ -13,4 +13,5 @@
@use 'almanac'; @use 'almanac';
@use 'hazards'; @use 'hazards';
@use 'media'; @use 'media';
@use 'spc-outlook'; @use 'spc-outlook';
@use 'shared/scanlines';

View File

@@ -0,0 +1,106 @@
/* REGULAR SCANLINES SETTINGS */
// width of 1 scanline (min.: 1px)
$scan-width: 1px;
// emulates a damage-your-eyes bad pre-2000 CRT screen ♥ (true, false)
$scan-crt: false;
// frames-per-second (should be > 1), only applies if $scan-crt: true;
$scan-fps: 20;
// scanline-color (rgba)
$scan-color: rgba(#000, .3);
// set z-index on 8, like in ♥ 8-bits ♥, or…
// set z-index on 2147483648 or more to enable scanlines on Chrome fullscreen (doesn't work in Firefox or IE);
$scan-z-index: 2147483648;
/* MOVING SCANLINE SETTINGS */
// moving scanline (true, false)
$scan-moving-line: true;
// opacity of the moving scanline
$scan-opacity: .75;
/* MIXINS */
// apply CRT animation: @include scan-crt($scan-crt);
@mixin scan-crt($scan-crt) {
@if $scan-crt==true {
animation: scanlines 1s steps($scan-fps) infinite;
}
@else {
animation: none;
}
}
// apply CRT animation: @include scan-crt($scan-crt);
@mixin scan-moving($scan-moving-line) {
@if $scan-moving-line==true {
animation: scanline 6s linear infinite;
}
@else {
animation: none;
}
}
/* CSS .scanlines CLASS */
.scanlines {
position: relative;
overflow: hidden; // only to animate the unique scanline
&:before,
&:after {
display: block;
pointer-events: none;
content: '';
position: absolute;
}
// unique scanline travelling on the screen
&:before {
// position: absolute;
// bottom: 100%;
width: 100%;
height: $scan-width * 1;
z-index: $scan-z-index + 1;
background: $scan-color;
opacity: $scan-opacity;
// animation: scanline 6s linear infinite;
@include scan-moving($scan-moving-line);
}
// the scanlines, so!
&:after {
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: $scan-z-index;
background: linear-gradient(to bottom,
transparent 50%,
$scan-color 51%);
background-size: 100% $scan-width*2;
@include scan-crt($scan-crt);
}
}
/* ANIMATE UNIQUE SCANLINE */
@keyframes scanline {
0% {
transform: translate3d(0, 200000%, 0);
// bottom: 0%; // to have a continuous scanline move, use this line (here in 0% step) instead of transform and write, in &:before, { position: absolute; bottom: 100%; }
}
}
@keyframes scanlines {
0% {
background-position: 0 50%;
// bottom: 0%; // to have a continuous scanline move, use this line (here in 0% step) instead of transform and write, in &:before, { position: absolute; bottom: 100%; }
}
}

View File

@@ -145,6 +145,10 @@
<img class="navButton off" src="images/nav/ic_volume_off_white_24dp_2x.png" title="Unmute" /> <img class="navButton off" src="images/nav/ic_volume_off_white_24dp_2x.png" title="Unmute" />
<img class="navButton on" src="images/nav/ic_volume_on_white_24dp_2x.png" title="Mute" /> <img class="navButton on" src="images/nav/ic_volume_on_white_24dp_2x.png" title="Mute" />
</div> </div>
<div id="ToggleScanlines">
<img class="navButton off" src="images/nav/ic_scanlines_off_white_24dp_2x.png" title="Scan lines on" />
<img class="navButton on" src="images/nav/ic_scanlines_on_white_24dp_2x.png" title="Scan lines off" />
</div>
<img id="ToggleFullScreen" class="navButton" src="images/nav/ic_fullscreen_white_24dp_2x.png" title="Enter Fullscreen" /> <img id="ToggleFullScreen" class="navButton" src="images/nav/ic_fullscreen_white_24dp_2x.png" title="Enter Fullscreen" />
</div> </div>
</div> </div>