mirror of
https://github.com/netbymatt/ws4kp.git
synced 2026-04-17 09:09:30 -07:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
55a4185465 | ||
|
|
5fd79f0b19 | ||
|
|
e9e68cc786 | ||
|
|
3bd3d44829 | ||
|
|
54632e4be5 |
2
dist/index.html
vendored
2
dist/index.html
vendored
File diff suppressed because one or more lines are too long
2
dist/resources/data.min.js
vendored
2
dist/resources/data.min.js
vendored
File diff suppressed because one or more lines are too long
2
dist/resources/ws.min.css
vendored
2
dist/resources/ws.min.css
vendored
File diff suppressed because one or more lines are too long
2
dist/resources/ws.min.js
vendored
2
dist/resources/ws.min.js
vendored
File diff suppressed because one or more lines are too long
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "ws4kp",
|
"name": "ws4kp",
|
||||||
"version": "5.6.0",
|
"version": "5.7.0",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "ws4kp",
|
"name": "ws4kp",
|
||||||
"version": "5.6.0",
|
"version": "5.7.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"eslint": "^8.21.0",
|
"eslint": "^8.21.0",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ws4kp",
|
"name": "ws4kp",
|
||||||
"version": "5.6.0",
|
"version": "5.7.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": {
|
||||||
|
|||||||
@@ -36,7 +36,9 @@ const init = () => {
|
|||||||
document.getElementById('NavigatePrevious').addEventListener('click', btnNavigatePreviousClick);
|
document.getElementById('NavigatePrevious').addEventListener('click', btnNavigatePreviousClick);
|
||||||
document.getElementById('NavigatePlay').addEventListener('click', btnNavigatePlayClick);
|
document.getElementById('NavigatePlay').addEventListener('click', btnNavigatePlayClick);
|
||||||
document.getElementById('ToggleFullScreen').addEventListener('click', btnFullScreenClick);
|
document.getElementById('ToggleFullScreen').addEventListener('click', btnFullScreenClick);
|
||||||
document.getElementById('btnGetGps').addEventListener('click', btnGetGpsClick);
|
const btnGetGps = document.getElementById('btnGetGps');
|
||||||
|
btnGetGps.addEventListener('click', btnGetGpsClick);
|
||||||
|
if (!navigator.geolocation) btnGetGps.style.display = 'none';
|
||||||
|
|
||||||
document.getElementById('divTwc').addEventListener('click', () => {
|
document.getElementById('divTwc').addEventListener('click', () => {
|
||||||
if (document.fullscreenElement) updateFullScreenNavigate();
|
if (document.fullscreenElement) updateFullScreenNavigate();
|
||||||
@@ -77,12 +79,16 @@ const init = () => {
|
|||||||
|
|
||||||
// Auto load the previous query
|
// Auto load the previous query
|
||||||
const query = localStorage.getItem('latLonQuery');
|
const query = localStorage.getItem('latLonQuery');
|
||||||
const latLon = localStorage.getItem('latLonLon');
|
const latLon = localStorage.getItem('latLon');
|
||||||
if (query && latLon) {
|
const fromGPS = localStorage.getItem('latLonFromGPS');
|
||||||
|
if (query && latLon && !fromGPS) {
|
||||||
const txtAddress = document.getElementById('txtAddress');
|
const txtAddress = document.getElementById('txtAddress');
|
||||||
txtAddress.value = query;
|
txtAddress.value = query;
|
||||||
loadData(JSON.parse(latLon));
|
loadData(JSON.parse(latLon));
|
||||||
}
|
}
|
||||||
|
if (fromGPS) {
|
||||||
|
btnGetGpsClick();
|
||||||
|
}
|
||||||
|
|
||||||
const twcPlay = localStorage.getItem('play');
|
const twcPlay = localStorage.getItem('play');
|
||||||
if (twcPlay === null || twcPlay === 'true') postMessage('navButton', 'play');
|
if (twcPlay === null || twcPlay === 'true') postMessage('navButton', 'play');
|
||||||
@@ -101,7 +107,9 @@ const init = () => {
|
|||||||
postMessage('navButton', 'play');
|
postMessage('navButton', 'play');
|
||||||
|
|
||||||
localStorage.removeItem('latLonQuery');
|
localStorage.removeItem('latLonQuery');
|
||||||
localStorage.removeItem('latLonLon');
|
localStorage.removeItem('latLon');
|
||||||
|
localStorage.removeItem('latLonFromGPS');
|
||||||
|
document.getElementById('btnGetGps').classList.remove('active');
|
||||||
});
|
});
|
||||||
|
|
||||||
// swipe functionality
|
// swipe functionality
|
||||||
@@ -129,14 +137,14 @@ const autocompleteOnSelect = async (suggestion, elem) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const doRedirectToGeometry = (geom) => {
|
const doRedirectToGeometry = (geom, haveDataCallback) => {
|
||||||
const latLon = { lat: round2(geom.y, 4), lon: round2(geom.x, 4) };
|
const latLon = { lat: round2(geom.y, 4), lon: round2(geom.x, 4) };
|
||||||
// Save the query
|
// Save the query
|
||||||
localStorage.setItem('latLonQuery', document.getElementById('txtAddress').value);
|
localStorage.setItem('latLonQuery', document.getElementById('txtAddress').value);
|
||||||
localStorage.setItem('latLonLon', JSON.stringify(latLon));
|
localStorage.setItem('latLon', JSON.stringify(latLon));
|
||||||
|
|
||||||
// get the data
|
// get the data
|
||||||
loadData(latLon);
|
loadData(latLon, haveDataCallback);
|
||||||
};
|
};
|
||||||
|
|
||||||
const btnFullScreenClick = () => {
|
const btnFullScreenClick = () => {
|
||||||
@@ -211,7 +219,7 @@ const btnNavigateMenuClick = () => {
|
|||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
const loadData = (_latLon) => {
|
const loadData = (_latLon, haveDataCallback) => {
|
||||||
// if latlon is provided store it locally
|
// if latlon is provided store it locally
|
||||||
if (_latLon) loadData.latLon = _latLon;
|
if (_latLon) loadData.latLon = _latLon;
|
||||||
// get the data
|
// get the data
|
||||||
@@ -221,7 +229,7 @@ const loadData = (_latLon) => {
|
|||||||
|
|
||||||
document.getElementById('txtAddress').blur();
|
document.getElementById('txtAddress').blur();
|
||||||
stopAutoRefreshTimer();
|
stopAutoRefreshTimer();
|
||||||
latLonReceived(latLon);
|
latLonReceived(latLon, haveDataCallback);
|
||||||
};
|
};
|
||||||
|
|
||||||
const swipeCallBack = (direction) => {
|
const swipeCallBack = (direction) => {
|
||||||
@@ -332,38 +340,39 @@ const postMessage = (type, myMessage = {}) => {
|
|||||||
navMessage({ type, message: myMessage });
|
navMessage({ type, message: myMessage });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getPosition = async () => new Promise((resolve) => {
|
||||||
|
navigator.geolocation.getCurrentPosition(resolve);
|
||||||
|
});
|
||||||
|
|
||||||
const btnGetGpsClick = async () => {
|
const btnGetGpsClick = async () => {
|
||||||
if (!navigator.geolocation) return;
|
if (!navigator.geolocation) return;
|
||||||
|
const btn = document.getElementById('btnGetGps');
|
||||||
|
|
||||||
const position = await (() => new Promise((resolve) => {
|
// toggle first
|
||||||
navigator.geolocation.getCurrentPosition(resolve);
|
if (btn.classList.contains('active')) {
|
||||||
}))();
|
btn.classList.remove('active');
|
||||||
|
localStorage.removeItem('latLonFromGPS');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// set gps active
|
||||||
|
btn.classList.add('active');
|
||||||
|
|
||||||
|
// get position
|
||||||
|
const position = await getPosition();
|
||||||
const { latitude, longitude } = position.coords;
|
const { latitude, longitude } = position.coords;
|
||||||
|
|
||||||
let data;
|
|
||||||
try {
|
|
||||||
data = await json('https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode', {
|
|
||||||
data: {
|
|
||||||
location: `${longitude},${latitude}`,
|
|
||||||
distance: 1000, // Find location up to 1 KM.
|
|
||||||
f: 'json',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
} catch (e) {
|
|
||||||
console.error('Unable to fetch reverse geocode');
|
|
||||||
console.error(e.status, e.responseJSONe);
|
|
||||||
}
|
|
||||||
const ZipCode = data.address.Postal;
|
|
||||||
const { City } = data.address;
|
|
||||||
const State = states.getTwoDigitCode(data.address.Region);
|
|
||||||
const Country = data.address.CountryCode;
|
|
||||||
const query = `${ZipCode}, ${City}, ${State}, ${Country}`;
|
|
||||||
|
|
||||||
const txtAddress = document.getElementById('txtAddress');
|
const txtAddress = document.getElementById('txtAddress');
|
||||||
txtAddress.value = query;
|
txtAddress.value = `${round2(latitude, 4)}, ${round2(longitude, 4)}`;
|
||||||
txtAddress.blur();
|
|
||||||
txtAddress.focus();
|
|
||||||
|
|
||||||
// Save the query
|
doRedirectToGeometry({ y: latitude, x: longitude }, (point) => {
|
||||||
localStorage.setItem('latLonQuery', query);
|
console.log(point);
|
||||||
|
const location = point.properties.relativeLocation.properties;
|
||||||
|
// Save the query
|
||||||
|
const query = `${location.city}, ${location.state}`;
|
||||||
|
localStorage.setItem('latLon', JSON.stringify({ lat: latitude, lon: longitude }));
|
||||||
|
localStorage.setItem('latLonQuery', query);
|
||||||
|
localStorage.setItem('latLonFromGPS', true);
|
||||||
|
txtAddress.value = `${location.city}, ${location.state}`;
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -49,10 +49,12 @@ const message = (data) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const getWeather = async (latLon) => {
|
const getWeather = async (latLon, haveDataCallback) => {
|
||||||
// get initial weather data
|
// get initial weather data
|
||||||
const point = await getPoint(latLon.lat, latLon.lon);
|
const point = await getPoint(latLon.lat, latLon.lon);
|
||||||
|
|
||||||
|
if (typeof haveDataCallback === 'function') haveDataCallback(point);
|
||||||
|
|
||||||
// get stations
|
// get stations
|
||||||
const stations = await json(point.properties.observationStations);
|
const stations = await json(point.properties.observationStations);
|
||||||
|
|
||||||
@@ -331,8 +333,8 @@ const AssignLastUpdate = (date) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const latLonReceived = (data) => {
|
const latLonReceived = (data, haveDataCallback) => {
|
||||||
getWeather(data);
|
getWeather(data, haveDataCallback);
|
||||||
AssignLastUpdate(null);
|
AssignLastUpdate(null);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -53,19 +53,33 @@ button {
|
|||||||
border: 1px solid darkgray;
|
border: 1px solid darkgray;
|
||||||
}
|
}
|
||||||
|
|
||||||
#btnGetGps img {
|
#btnGetGps {
|
||||||
|
img {
|
||||||
|
|
||||||
&.dark {
|
&.dark {
|
||||||
display: none;
|
display: none;
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) {
|
@media (prefers-color-scheme: dark) {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&.light {
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&.light {
|
&.active {
|
||||||
|
background-color: black;
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) {
|
@media (prefers-color-scheme: dark) {
|
||||||
display: none;
|
background-color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
img {
|
||||||
|
filter: invert(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -306,17 +320,21 @@ jsgif {
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
}
|
|
||||||
|
|
||||||
#loading .title {
|
.title {
|
||||||
font-family: Star4000 Large;
|
font-family: Star4000 Large;
|
||||||
font-size: 36px;
|
font-size: 36px;
|
||||||
color: yellow;
|
color: yellow;
|
||||||
margin-bottom: 40px;
|
margin-bottom: 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#loading .instructions {
|
.version {
|
||||||
font-size: 18pt;
|
margin-bottom: 35px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.instructions {
|
||||||
|
font-size: 18pt;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.heading {
|
.heading {
|
||||||
@@ -372,4 +390,12 @@ jsgif {
|
|||||||
visibility: hidden;
|
visibility: hidden;
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
transition: visibility 0s 1s, opacity 1s linear
|
transition: visibility 0s 1s, opacity 1s linear
|
||||||
|
}
|
||||||
|
|
||||||
|
.github-links {
|
||||||
|
width: 610px;
|
||||||
|
max-width: calc(100vw - 30px);
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-evenly;
|
||||||
|
flex-wrap: wrap;
|
||||||
}
|
}
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
<meta name="keywords" content="WeatherStar 4000+" />
|
<meta name="keywords" content="WeatherStar 4000+" />
|
||||||
<meta name="author" content="Matt Walsh" />
|
<meta name="author" content="Matt Walsh" />
|
||||||
<meta name="application-name" content="WeatherStar 4000+" />
|
<meta name="application-name" content="WeatherStar 4000+" />
|
||||||
<meta name="viewport" content="width=device-width,initial-scale=1;maximum-scale=1;minimum-scale=1">
|
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1">
|
||||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
|
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
|
||||||
<link rel="manifest" href="manifest.json" />
|
<link rel="manifest" href="manifest.json" />
|
||||||
@@ -81,6 +81,7 @@
|
|||||||
<div id="loading" width="640" height="480">
|
<div id="loading" width="640" height="480">
|
||||||
<div>
|
<div>
|
||||||
<div class="title">WeatherStar 4000+</div>
|
<div class="title">WeatherStar 4000+</div>
|
||||||
|
<div class="version">v<%- version %></div>
|
||||||
<div class="instructions">Enter your location above to continue</div>
|
<div class="instructions">Enter your location above to continue</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user