Compare commits

...

6 Commits

Author SHA1 Message Date
Matt Walsh
f7505e3e6f 5.4.0 2022-12-08 16:25:24 -06:00
Matt Walsh
705fa9f582 dark mode, page only 2022-12-08 16:25:12 -06:00
Matt Walsh
5edf5cc947 cleanup 2022-12-08 15:05:51 -06:00
Matt Walsh
d0382e0de1 better error handlig of shared data 2022-12-08 14:41:15 -06:00
Matt Walsh
69d14236f1 hourly graph uses image with internal canvas for drawing 2022-12-08 09:23:26 -06:00
Matt Walsh
64fb06d7b4 capture distribution files 2022-12-07 15:39:34 -06:00
22 changed files with 125 additions and 66 deletions

2
dist/index.html vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{ {
"name": "ws4kp", "name": "ws4kp",
"version": "5.3.0", "version": "5.4.0",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "ws4kp", "name": "ws4kp",
"version": "5.3.0", "version": "5.4.0",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"eslint": "^8.21.0", "eslint": "^8.21.0",

View File

@@ -1,6 +1,6 @@
{ {
"name": "ws4kp", "name": "ws4kp",
"version": "5.3.0", "version": "5.4.0",
"description": "Welcome to the WeatherStar 4000+ project page!", "description": "Welcome to the WeatherStar 4000+ project page!",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

View File

@@ -23,7 +23,7 @@ const categories = [
'Airport', 'Ferry', 'Marina', 'Pier', 'Port', 'Resort', // POI/Travel 'Airport', 'Ferry', 'Marina', 'Pier', 'Port', 'Resort', // POI/Travel
'Postal', 'Populated Place', 'Postal', 'Populated Place',
]; ];
const cats = categories.join(','); const category = categories.join(',');
const init = () => { const init = () => {
document.getElementById('txtAddress').addEventListener('focus', (e) => { document.getElementById('txtAddress').addEventListener('focus', (e) => {
@@ -54,7 +54,7 @@ const init = () => {
params: { params: {
f: 'json', f: 'json',
countryCode: 'USA', // 'USA,PRI,VIR,GUM,ASM', countryCode: 'USA', // 'USA,PRI,VIR,GUM,ASM',
category: cats, category,
maxSuggestions: 10, maxSuggestions: 10,
}, },
dataType: 'json', dataType: 'json',

View File

@@ -55,7 +55,9 @@ class CurrentWeather extends WeatherDisplay {
// test for data received // test for data received
if (!observations) { if (!observations) {
console.error('All current weather stations exhausted'); console.error('All current weather stations exhausted');
this.setStatus(STATUS.failed); if (this.enabled) this.setStatus(STATUS.failed);
// send failed to subscribers
this.getDataCallback(undefined);
return; return;
} }
// preload the icon // preload the icon

View File

@@ -28,6 +28,10 @@ class HourlyGraph extends WeatherDisplay {
if (!super.getData()) return; if (!super.getData()) return;
const data = await getHourlyData(); const data = await getHourlyData();
if (data === undefined) {
this.setStatus(STATUS.failed);
return;
}
// get interesting data // get interesting data
const temperature = data.map((d) => d.temperature); const temperature = data.map((d) => d.temperature);
@@ -42,18 +46,20 @@ class HourlyGraph extends WeatherDisplay {
} }
drawCanvas() { drawCanvas() {
if (!this.canvas) this.canvas = this.elem.querySelector('.chart canvas'); if (!this.image) this.image = this.elem.querySelector('.chart img');
// get available space // get available space
const boundingRect = this.canvas.getBoundingClientRect(); const availableWidth = 532;
const availableWidth = boundingRect.width; const availableHeight = 285;
const availableHeight = boundingRect.height;
this.canvas.width = availableWidth; this.image.width = availableWidth;
this.canvas.height = availableHeight; this.image.height = availableHeight;
// get context // get context
const ctx = this.canvas.getContext('2d'); const canvas = document.createElement('canvas');
canvas.width = availableWidth;
canvas.height = availableHeight;
const ctx = canvas.getContext('2d');
ctx.imageSmoothingEnabled = false; ctx.imageSmoothingEnabled = false;
// calculate time scale // calculate time scale
@@ -93,9 +99,14 @@ class HourlyGraph extends WeatherDisplay {
}); });
// temperature axis labels // temperature axis labels
this.elem.querySelector('.y-axis .l-1').innerHTML = maxTemp; // limited to 3 characters, sacraficing degree character
this.elem.querySelector('.y-axis .l-2').innerHTML = midTemp; const degree = String.fromCharCode(176);
this.elem.querySelector('.y-axis .l-3').innerHTML = minTemp; this.elem.querySelector('.y-axis .l-1').innerHTML = (maxTemp + degree).substring(0, 3);
this.elem.querySelector('.y-axis .l-2').innerHTML = (midTemp + degree).substring(0, 3);
this.elem.querySelector('.y-axis .l-3').innerHTML = (minTemp + degree).substring(0, 3);
// set the image source
this.image.src = canvas.toDataURL();
super.drawCanvas(); super.drawCanvas();
this.finishDraw(); this.finishDraw();

View File

@@ -37,12 +37,13 @@ class Hourly extends WeatherDisplay {
} catch (e) { } catch (e) {
console.error('Get hourly forecast failed'); console.error('Get hourly forecast failed');
console.error(e.status, e.responseJSON); console.error(e.status, e.responseJSON);
this.setStatus(STATUS.failed); if (this.enabled) this.setStatus(STATUS.failed);
// return undefined to other subscribers
this.getDataCallback(undefined);
return; return;
} }
this.data = await Hourly.parseForecast(forecast.properties); this.data = await Hourly.parseForecast(forecast.properties);
this.getDataCallback(); this.getDataCallback();
if (!superResponse) return; if (!superResponse) return;

View File

@@ -23,6 +23,7 @@ let AutoRefreshCountMs = 0;
const init = async () => { const init = async () => {
// set up resize handler // set up resize handler
window.addEventListener('resize', resize); window.addEventListener('resize', resize);
resize();
// auto refresh // auto refresh
const TwcAutoRefresh = localStorage.getItem('TwcAutoRefresh'); const TwcAutoRefresh = localStorage.getItem('TwcAutoRefresh');

View File

@@ -367,8 +367,6 @@ class Radar extends WeatherDisplay {
} }
RadarContext.putImageData(RadarImageData, 0, 0); RadarContext.putImageData(RadarImageData, 0, 0);
// MapContext.drawImage(RadarContext.canvas, 0, 0);
} }
static mergeDopplerRadarImage(mapContext, radarContext) { static mergeDopplerRadarImage(mapContext, radarContext) {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -89,7 +89,7 @@
top: 0px; top: 0px;
left: 50px; left: 50px;
canvas { img {
width: 532px; width: 532px;
height: 285px; height: 285px;
} }

View File

@@ -5,6 +5,17 @@
body { body {
font-family: "Star4000"; font-family: "Star4000";
@media (prefers-color-scheme: dark) {
background-color: #000000;
color: white;
}
a {
@media (prefers-color-scheme: dark) {
color: lightblue;
}
}
} }
input, input,
@@ -20,12 +31,42 @@ button {
#txtAddress { #txtAddress {
width: 490px; width: 490px;
font-size: 16pt; font-size: 16pt;
@media (prefers-color-scheme: dark) {
background-color: #000000;
color: white;
border: 1px solid darkgray;
}
} }
#btnGetGps, #btnGetGps,
#btnGetLatLng, #btnGetLatLng,
#btnClearQuery { #btnClearQuery {
font-size: 16pt; font-size: 16pt;
@media (prefers-color-scheme: dark) {
background-color: #000000;
color: white;
}
border: 1px solid darkgray;
}
#btnGetGps img {
&.dark {
display: none;
@media (prefers-color-scheme: dark) {
display: inline-block;
}
}
&.light {
@media (prefers-color-scheme: dark) {
display: none;
}
}
} }
.autocomplete-suggestions { .autocomplete-suggestions {
@@ -90,6 +131,11 @@ button {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
background-color: #000000; background-color: #000000;
@media (prefers-color-scheme: dark) {
background-color: rgb(48, 48, 48);
}
color: #ffffff; color: #ffffff;
width: 100%; width: 100%;
} }

View File

@@ -61,7 +61,7 @@
<div id="divQuery"> <div id="divQuery">
<form id="frmGetLatLng"> <form id="frmGetLatLng">
<input id="txtAddress" type="text" value="" placeholder="Zip or City, State" /><button id="btnGetGps" type="button" title="Get GPS Location"><img id="imgGetGps" src="images/nav/ic_gps_fixed_black_18dp_1x.png" /></button> <input id="txtAddress" type="text" value="" placeholder="Zip or City, State" /><button id="btnGetGps" type="button" title="Get GPS Location"><img src="images/nav/ic_gps_fixed_black_18dp_1x.png" class="light"/><img src="images/nav/ic_gps_fixed_white_18dp_1x.png" class="dark"/></button>
<input id="btnGetLatLng" type="submit" value="GO" /> <input id="btnGetLatLng" type="submit" value="GO" />
<input id="btnClearQuery" type="reset" value="Reset" /> <input id="btnClearQuery" type="reset" value="Reset" />
</form> </form>

View File

@@ -11,7 +11,7 @@
<div class="label l-3">55</div> <div class="label l-3">55</div>
</div> </div>
<div class="chart"> <div class="chart">
<canvas id="chart-area"></canvas> <img id="chart-area"></img>
</div> </div>
<div class="x-axis"> <div class="x-axis">
<div class="label l-1">12a</div> <div class="label l-1">12a</div>

View File

@@ -1,43 +1,43 @@
<div class="header"> <div class="header">
<div class="logo"><img src="images/Logo3.png" /></div> <div class="logo"><img src="images/Logo3.png" /></div>
<div class="title dual"> <div class="title dual">
<div class="top"> <div class="top">
Local Local
</div> </div>
<div class="bottom"> <div class="bottom">
Radar Radar
</div> </div>
</div> </div>
<div class="right"> <div class="right">
<div class="precip"> <div class="precip">
<div class="precip-header">PRECIP</div> <div class="precip-header">PRECIP</div>
<div class="scale"> <div class="scale">
<div class="text">Light</div> <div class="text">Light</div>
<div class="scale-table"> <div class="scale-table">
<div class="box box-1"></div> <div class="box box-1"></div>
<div class="box box-2"></div> <div class="box box-2"></div>
<div class="box box-3"></div> <div class="box box-3"></div>
<div class="box box-4"></div> <div class="box box-4"></div>
<div class="box box-5"></div> <div class="box box-5"></div>
<div class="box box-6"></div> <div class="box box-6"></div>
<div class="box box-7"></div> <div class="box box-7"></div>
<div class="box box-7"></div> <div class="box box-7"></div>
</div> </div>
<div class="text">Heavy</div> <div class="text">Heavy</div>
</div> </div>
<div class="time"></div> <div class="time"></div>
</div> </div>
</div> </div>
</div> </div>
<div class="main radar"> <div class="main radar">
<div class="container"> <div class="container">
<div class="scroll-area"> <div class="scroll-area">
<div class="frame template"> <div class="frame template">
<div class="map"> <div class="map">
<img src="images/4000RadarMap2.jpg" /> <img src="images/4000RadarMap2.jpg" />
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>