Merge branch 'master' of github.com:netbymatt/ws4kp
This commit is contained in:
commit
4363f3967f
71
.github/workflows/codeql-analysis.yml
vendored
Normal file
71
.github/workflows/codeql-analysis.yml
vendored
Normal file
|
@ -0,0 +1,71 @@
|
|||
# For most projects, this workflow file will not need changing; you simply need
|
||||
# to commit it to your repository.
|
||||
#
|
||||
# You may wish to alter this file to override the set of languages analyzed,
|
||||
# or to provide custom queries or build logic.
|
||||
name: "CodeQL"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
pull_request:
|
||||
# The branches below must be a subset of the branches above
|
||||
branches: [master]
|
||||
schedule:
|
||||
- cron: '0 11 * * 6'
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
name: Analyze
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
# Override automatic language detection by changing the below list
|
||||
# Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python']
|
||||
language: ['javascript']
|
||||
# Learn more...
|
||||
# https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
# We must fetch at least the immediate parents so that if this is
|
||||
# a pull request then we can checkout the head.
|
||||
fetch-depth: 2
|
||||
|
||||
# If this run was triggered by a pull request event, then checkout
|
||||
# the head of the pull request instead of the merge commit.
|
||||
- run: git checkout HEAD^2
|
||||
if: ${{ github.event_name == 'pull_request' }}
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v1
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||
# By default, queries listed here will override any specified in a config file.
|
||||
# Prefix the list here with "+" to use these queries and those in the config file.
|
||||
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
||||
|
||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||
# If this step fails, then you should remove it and run the build manually (see below)
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@v1
|
||||
|
||||
# ℹ️ Command-line programs to run using the OS shell.
|
||||
# 📚 https://git.io/JvXDl
|
||||
|
||||
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
||||
# and modify them (or add more) to build your code if your project
|
||||
# uses a compiled language
|
||||
|
||||
#- run: |
|
||||
# make bootstrap
|
||||
# make release
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v1
|
1
.vscode/launch.json
vendored
1
.vscode/launch.json
vendored
|
@ -14,6 +14,7 @@
|
|||
"skipFiles": [
|
||||
"<node_internals>/**",
|
||||
"**/*.min.js",
|
||||
"**/vendor/**"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
2
dist/index.html
vendored
2
dist/index.html
vendored
|
@ -1 +1 @@
|
|||
<!DOCTYPE html><html lang="en" xmlns="http://www.w3.org/1999/xhtml"><head><meta charset="utf-8"><link rel="preload" href="fonts/Star4000.woff" as="font" crossorigin="anonymous"><link rel="preload" href="fonts/Star 4 Radar.woff" as="font" crossorigin="anonymous"><link rel="preload" href="fonts/Star4000 Extended.woff" as="font" crossorigin="anonymous"><link rel="preload" href="fonts/Star4000 Large Compressed.woff" as="font" crossorigin="anonymous"><link rel="preload" href="fonts/Star4000 Large.woff" as="font" crossorigin="anonymous"><link rel="preload" href="fonts/Star4000 Small.woff" as="font" crossorigin="anonymous"><title>WeatherStar 4000+</title><meta name="description" content="Web based WeatherStar 4000 simulator that reports current and forecast weather conditions plus a few extras!"><meta name="keywords" content="WeatherStar 4000+"><meta name="author" content="Matt Walsh"><meta name="application-name" content="WeatherStar 4000+"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="apple-mobile-web-app-capable" content="yes"><meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"><link rel="manifest" href="manifest.json"><link rel="icon" href="images/Logo192.png"><link rel="stylesheet" type="text/css" href="resources/ws.min.css?_=3.5.0"><script type="text/javascript" src="resources/data.min.js"></script><script type="text/javascript" src="resources/ws.min.js?_=3.5.0"></script></head><body><div id="divQuery"><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="btnGetLatLng" type="submit" value="GO"> <input id="btnClearQuery" type="reset" value="Reset"></form><div id="divLat"></div><div id="divLng"></div></div><br><img id="imgPause1x" src="images/nav/ic_pause_white_24dp_1x.png"> <img id="imgPause2x" src="images/nav/ic_pause_white_24dp_2x.png"><div id="version" style="display:none">3.5.0</div><div id="divTwc"><div id="display"><div id="container"></div></div><div id="divTwcBottom"><div id="divTwcBottomLeft"><a id="aMenuBottom" href="#" class="NavigateMenu"><img src="images/nav/ic_menu_white_24dp_1x.png" title="Menu"></a><a id="aPreviousBottom" href="#" class="NavigatePrevious"><img src="images/nav/ic_skip_previous_white_24dp_1x.png" title="Previous"></a><a id="aNextBottom" href="#" class="NavigateNext"><img src="images/nav/ic_skip_next_white_24dp_1x.png" title="Next"></a><a id="aPlayBottom" href="#" class="NavigatePlay"><img src="images/nav/ic_play_arrow_white_24dp_1x.png" title="Play"></a></div><div id="divTwcBottomMiddle"><a id="aRefreshBottom" href="#" class="NavigateRefresh"><img src="images/nav/ic_refresh_white_24dp_1x.png" title="Refresh"></a></div><div id="divTwcBottomRight"><a id="aFullScreenBottom" href="#" class="ToggleFullScreen"><img src="images/nav/ic_fullscreen_exit_white_24dp_1x.png" title="Exit Fullscreen"></a></div></div></div><br><div class="info"><a href="https://github.com/netbymatt/ws4kp#weatherstar-4000">More information</a></div><div class="heading">Selected displays</div><div id="enabledDisplays"></div><div id="divInfo">Location: <span id="spanCity"></span> <span id="spanState"></span><br>Station Id: <span id="spanStationId"></span><br>Radar Id: <span id="spanRadarId"></span><br>Zone Id: <span id="spanZoneId"></span><br></div><div id="divRefresh">Last Update: <span id="spanLastRefresh">(None)</span><br><input id="chkAutoRefresh" name="chkAutoRefresh" type="checkbox"><label id="lblRefreshCountDown" for="chkAutoRefresh">Auto Refresh: <span id="spanRefreshCountDown">--:--</span></label></div><div id="divUnits">Units: <input id="radEnglish" name="radUnits" type="radio" value="ENGLISH"><label for="radEnglish">English</label> <input id="radMetric" name="radUnits" type="radio" value="METRIC"><label for="radMetric">Metric</label></div></body></html>
|
||||
<!DOCTYPE html><html lang="en" xmlns="http://www.w3.org/1999/xhtml"><head><meta charset="utf-8"><link rel="preload" href="fonts/Star4000.woff" as="font" crossorigin="anonymous"><link rel="preload" href="fonts/Star 4 Radar.woff" as="font" crossorigin="anonymous"><link rel="preload" href="fonts/Star4000 Extended.woff" as="font" crossorigin="anonymous"><link rel="preload" href="fonts/Star4000 Large Compressed.woff" as="font" crossorigin="anonymous"><link rel="preload" href="fonts/Star4000 Large.woff" as="font" crossorigin="anonymous"><link rel="preload" href="fonts/Star4000 Small.woff" as="font" crossorigin="anonymous"><title>WeatherStar 4000+</title><meta name="description" content="Web based WeatherStar 4000 simulator that reports current and forecast weather conditions plus a few extras!"><meta name="keywords" content="WeatherStar 4000+"><meta name="author" content="Matt Walsh"><meta name="application-name" content="WeatherStar 4000+"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="apple-mobile-web-app-capable" content="yes"><meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"><link rel="manifest" href="manifest.json"><link rel="icon" href="images/Logo192.png"><link rel="stylesheet" type="text/css" href="resources/ws.min.css?_=3.6.2"><script type="text/javascript" src="resources/data.min.js?_=3.6.2"></script><script type="text/javascript" src="resources/ws.min.js?_=3.6.2"></script></head><body><div id="divQuery"><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="btnGetLatLng" type="submit" value="GO"> <input id="btnClearQuery" type="reset" value="Reset"></form><div id="divLat"></div><div id="divLng"></div></div><br><img id="imgPause1x" src="images/nav/ic_pause_white_24dp_1x.png"> <img id="imgPause2x" src="images/nav/ic_pause_white_24dp_2x.png"><div id="version" style="display:none">3.6.2</div><div id="divTwc"><div id="container"><div id="loading" width="640" height="480"><div><div class="title">WeatherStar 4000+</div><div class="instructions">Enter your location above to continue</div></div></div></div><div id="divTwcBottom"><div id="divTwcBottomLeft"><img id="NavigateMenu" class="navButton" src="images/nav/ic_menu_white_24dp_1x.png" title="Menu"> <img id="NavigatePrevious" class="navButton" src="images/nav/ic_skip_previous_white_24dp_1x.png" title="Previous"> <img id="NavigateNext" class="navButton" src="images/nav/ic_skip_next_white_24dp_1x.png" title="Next"> <img id="NavigatePlay" class="navButton" src="images/nav/ic_play_arrow_white_24dp_1x.png" title="Play"></div><div id="divTwcBottomMiddle"><img id="NavigateRefresh" class="navButton" src="images/nav/ic_refresh_white_24dp_1x.png" title="Refresh"></div><div id="divTwcBottomRight"><img id="ToggleFullScreen" class="navButton" src="images/nav/ic_fullscreen_exit_white_24dp_1x.png" title="Exit Fullscreen"></div></div></div><br><div class="info"><a href="https://github.com/netbymatt/ws4kp#weatherstar-4000">More information</a></div><div class="heading">Selected displays</div><div id="enabledDisplays"></div><div id="divInfo">Location: <span id="spanCity"></span> <span id="spanState"></span><br>Station Id: <span id="spanStationId"></span><br>Radar Id: <span id="spanRadarId"></span><br>Zone Id: <span id="spanZoneId"></span><br></div><div id="divRefresh">Last Update: <span id="spanLastRefresh">(None)</span><br><input id="chkAutoRefresh" name="chkAutoRefresh" type="checkbox"><label id="lblRefreshCountDown" for="chkAutoRefresh">Auto Refresh: <span id="spanRefreshCountDown">--:--</span></label></div><div id="divUnits">Units: <input id="radEnglish" name="radUnits" type="radio" value="ENGLISH"><label for="radEnglish">English</label> <input id="radMetric" name="radUnits" type="radio" value="METRIC"><label for="radMetric">Metric</label></div></body></html>
|
2
dist/resources/ws.min.css
vendored
2
dist/resources/ws.min.css
vendored
|
@ -1 +1 @@
|
|||
@font-face{font-family:Star4000;src:url(../fonts/Star4000.woff) format('woff')}body{font-family:Star4000}button,input{font-family:Star4000}#imgGetGps{height:13px;vertical-align:middle}#txtAddress{width:490px;font-size:16pt}#btnClearQuery,#btnGetGps,#btnGetLatLng{font-size:16pt}.autocomplete-suggestions{background-color:#fff;border:1px solid #000}.autocomplete-suggestion{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-size:16pt}.autocomplete-selected{background-color:#00f;color:#fff}#divTwc{display:block;background-color:#000;color:#fff;width:100%;max-width:640px}#divTwcLeft{display:none;text-align:right;flex-direction:column;vertical-align:middle}#divTwcLeft>div{flex:1;padding-right:12px;display:flex;flex-direction:column;justify-content:center}#divTwcRight{text-align:left;display:none;flex-direction:column;vertical-align:middle}#divTwcRight>div{flex:1;padding-left:12px;display:flex;flex-direction:column;justify-content:center}#divTwcBottom{display:flex;flex-direction:row;background-color:#000;color:#fff;width:100%}#divTwcBottom>div{padding-left:6px;padding-right:6px}#divTwcBottomLeft{flex:1;text-align:left}#divTwcBottomMiddle{flex:0;text-align:center}#divTwcBottomRight{flex:1;text-align:right}#divTwcNavContainer{display:none}#divTwcNav{width:100%;display:flex;flex-direction:row;background-color:#000;color:#fff;max-width:640px}#divTwcNav>div{padding-left:6px;padding-right:6px}#divTwcNavLeft{flex:1;text-align:left}#divTwcNavMiddle{flex:0;text-align:center}#divTwcNavRight{flex:1;text-align:right}#imgPause1x,#imgPause2x{visibility:hidden;position:absolute}.HideCursor{cursor:none!important}#txtScrollText{width:475px}@font-face{font-family:Star4000;src:url(../fonts/Star4000.woff) format('woff')}@font-face{font-family:"Star 4 Radar";src:url('../fonts/Star 4 Radar.woff') format('woff')}@font-face{font-family:'Star4000 Extended';src:url('../fonts/Star4000 Extended.woff') format('woff')}@font-face{font-family:Star4000LCN;src:url(../fonts/Star4000LCN.woff) format('woff')}@font-face{font-family:'Star4000 Large Compressed';src:url('../fonts/Star4000 Large Compressed.woff') format('woff')}@font-face{font-family:'Star4000 Large';src:url('../fonts/Star4000 Large.woff') format('woff')}@font-face{font-family:'Star4000 Small';src:url('../fonts/Star4000 Small.woff') format('woff')}#display{font-family:Star4000;margin:0;width:100%}jsgif{display:none}#Star4000{font-family:Star4000}#Star4000Extended{font-family:'Star4000 Extended'}#Star4000LargeCompressed{font-family:'Star4000 Large Compressed'}#Star4000Large{font-family:'Star4000 Large'}#Star4000LargeCompressedNumbers{font-family:Star4000LCN}#Star4000Small{font-family:'Star4000 Small'}#Star4Radar{font-family:'Star 4 Radar'}#container{position:relative;width:100%;max-width:640px}#container canvas{width:100%}.heading{font-weight:700;margin-top:15px}#enabledDisplays{margin-bottom:15px}#enabledDisplays label{display:block;max-width:300px}#divTwcBottom img{zoom:150%}#divTwc:fullscreen{display:flex;align-items:center;justify-content:center}#divTwc:fullscreen #display{position:relative}#divTwc:fullscreen #divTwcBottom{display:flex;flex-direction:row;background-color:rgb(0 0 0 / .5);color:#fff;width:100%;position:absolute;bottom:0}@media screen and (orientation:portrait){#divTwc:fullscreen canvas{width:100vw;max-width:100vw;height:auto}}@media screen and (orientation:landscape){#divTwc:fullscreen canvas{height:100vh;max-height:100vh;width:auto}}
|
||||
@font-face{font-family:Star4000;src:url(../fonts/Star4000.woff) format('woff')}body{font-family:Star4000}button,input{font-family:Star4000}#imgGetGps{height:13px;vertical-align:middle}#txtAddress{width:490px;font-size:16pt}#btnClearQuery,#btnGetGps,#btnGetLatLng{font-size:16pt}.autocomplete-suggestions{background-color:#fff;border:1px solid #000}.autocomplete-suggestion{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-size:16pt}.autocomplete-selected{background-color:#00f;color:#fff}#divTwc{display:block;background-color:#000;color:#fff;width:100%;max-width:640px}#divTwcLeft{display:none;text-align:right;flex-direction:column;vertical-align:middle}#divTwcLeft>div{flex:1;padding-right:12px;display:flex;flex-direction:column;justify-content:center}#divTwcRight{text-align:left;display:none;flex-direction:column;vertical-align:middle}#divTwcRight>div{flex:1;padding-left:12px;display:flex;flex-direction:column;justify-content:center}#divTwcBottom{display:flex;flex-direction:row;background-color:#000;color:#fff;width:100%}#divTwcBottom>div{padding-left:6px;padding-right:6px}#divTwcBottomLeft{flex:1;text-align:left}#divTwcBottomMiddle{flex:0;text-align:center}#divTwcBottomRight{flex:1;text-align:right}#divTwcNavContainer{display:none}#divTwcNav{width:100%;display:flex;flex-direction:row;background-color:#000;color:#fff;max-width:640px}#divTwcNav>div{padding-left:6px;padding-right:6px}#divTwcNavLeft{flex:1;text-align:left}#divTwcNavMiddle{flex:0;text-align:center}#divTwcNavRight{flex:1;text-align:right}#imgPause1x,#imgPause2x{visibility:hidden;position:absolute}.HideCursor{cursor:none!important}#txtScrollText{width:475px}@font-face{font-family:Star4000;src:url(../fonts/Star4000.woff) format('woff')}@font-face{font-family:"Star 4 Radar";src:url('../fonts/Star 4 Radar.woff') format('woff')}@font-face{font-family:'Star4000 Extended';src:url('../fonts/Star4000 Extended.woff') format('woff')}@font-face{font-family:Star4000LCN;src:url(../fonts/Star4000LCN.woff) format('woff')}@font-face{font-family:'Star4000 Large Compressed';src:url('../fonts/Star4000 Large Compressed.woff') format('woff')}@font-face{font-family:'Star4000 Large';src:url('../fonts/Star4000 Large.woff') format('woff')}@font-face{font-family:'Star4000 Small';src:url('../fonts/Star4000 Small.woff') format('woff')}#display{font-family:Star4000;margin:0;width:100%}jsgif{display:none}#Star4000{font-family:Star4000}#Star4000Extended{font-family:'Star4000 Extended'}#Star4000LargeCompressed{font-family:'Star4000 Large Compressed'}#Star4000Large{font-family:'Star4000 Large'}#Star4000LargeCompressedNumbers{font-family:Star4000LCN}#Star4000Small{font-family:'Star4000 Small'}#Star4Radar{font-family:'Star 4 Radar'}#container{position:relative;width:100%;height:100%;max-height:480;background-image:url(http://localhost:8080/images/BackGround1_1.png)}#divTwc:fullscreen #container{background-image:none}#loading{width:640px;height:480px;max-width:100%;text-shadow:4px 4px #000;display:flex;align-items:center;text-align:center;justify-content:center}#loading .title{font-family:Star4000 Large;font-size:36px;color:#ff0;margin-bottom:40px}#loading .instructions{font-size:18pt}#container canvas{width:100%}.heading{font-weight:700;margin-top:15px}#enabledDisplays{margin-bottom:15px}#enabledDisplays label{display:block;max-width:300px}#divTwcBottom img{zoom:150%}#divTwc:fullscreen{display:flex;align-items:center;justify-content:center;align-content:center}#divTwc:fullscreen #display{position:relative}#divTwc:fullscreen #divTwcBottom{display:flex;flex-direction:row;background-color:rgb(0 0 0 / .5);color:#fff;width:100%;position:absolute;bottom:0}@media screen and (orientation:portrait){#divTwc:fullscreen canvas{width:100vw;max-width:100vw;height:auto}#divTwc:fullscreen #container{width:100vw;height:auto;max-height:unset;max-width:unset}}@media screen and (orientation:landscape){#divTwc:fullscreen canvas{height:100vh;max-height:100vh;width:auto}#divTwc:fullscreen #container{height:100vh;width:auto;max-width:100vw;max-height:unset}}.navButton{cursor:pointer}.visible{visibility:visible;opacity:1;transition:opacity 1s linear}.hidden{visibility:hidden;opacity:0;transition:visibility 0s 1s,opacity 1s linear}
|
6
dist/resources/ws.min.js
vendored
6
dist/resources/ws.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -30,7 +30,6 @@ const js_sources = [
|
|||
'server/scripts/vendor/auto/jquery.js',
|
||||
'server/scripts/vendor/jquery.autocomplete.min.js',
|
||||
'server/scripts/vendor/auto/nosleep.js',
|
||||
'server/scripts/vendor/jquery.touchswipe.min.js',
|
||||
'server/scripts/index.js',
|
||||
'server/scripts/libgif.js',
|
||||
'server/scripts/vendor/auto/luxon.js',
|
||||
|
|
4
server/images/.directory
Normal file
4
server/images/.directory
Normal file
|
@ -0,0 +1,4 @@
|
|||
[Dolphin]
|
||||
PreviewsShown=true
|
||||
Timestamp=2020,10,1,21,36,7
|
||||
Version=4
|
|
@ -1,5 +1,6 @@
|
|||
/* globals NoSleep, states, navigation */
|
||||
$(() => {
|
||||
'use strict';
|
||||
/* globals NoSleep, states, navigation, UNITS, utils */
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
index.init();
|
||||
});
|
||||
|
||||
|
@ -11,8 +12,6 @@ const index = (() => {
|
|||
const _AutoRefreshTotalIntervalMs = 600000; // 10 min.
|
||||
const _NoSleep = new NoSleep();
|
||||
|
||||
let divTwcBottom;
|
||||
|
||||
let _AutoSelectQuery = false;
|
||||
|
||||
let _LastUpdate = null;
|
||||
|
@ -21,28 +20,6 @@ const index = (() => {
|
|||
|
||||
let _FullScreenOverride = false;
|
||||
|
||||
const init = () => {
|
||||
divTwcBottom = $('#divTwcBottom');
|
||||
$('#txtAddress').on('focus', (e) => {
|
||||
$(e.target).select();
|
||||
}).focus();
|
||||
|
||||
$('.NavigateMenu').on('click', btnNavigateMenu_click);
|
||||
$('.NavigateRefresh').on('click', btnNavigateRefresh_click);
|
||||
$('.NavigateNext').on('click', btnNavigateNext_click);
|
||||
$('.NavigatePrevious').on('click', btnNavigatePrevious_click);
|
||||
$('.NavigatePlay').on('click', btnNavigatePlay_click);
|
||||
|
||||
$('#btnGetGps').on('click', btnGetGps_click);
|
||||
|
||||
$('#divTwc').on('click', (e) => {
|
||||
if (document.fullscreenElement) UpdateFullScreenNavigate(e);
|
||||
});
|
||||
|
||||
$(document).on('keydown', document_keydown);
|
||||
document.addEventListener('touchmove', e => { if (_FullScreenOverride) e.preventDefault(); });
|
||||
$('.ToggleFullScreen').on('click', btnFullScreen_click);
|
||||
|
||||
const categories = [
|
||||
'Land Features',
|
||||
'Bay', 'Channel', 'Cove', 'Dam', 'Delta', 'Gulf', 'Lagoon', 'Lake', 'Ocean', 'Reef', 'Reservoir', 'Sea', 'Sound', 'Strait', 'Waterfall', 'Wharf', // Water Features
|
||||
|
@ -55,6 +32,26 @@ const index = (() => {
|
|||
];
|
||||
const cats = categories.join(',');
|
||||
|
||||
const init = () => {
|
||||
document.getElementById('txtAddress').addEventListener('focus', (e) => {
|
||||
e.target.select();
|
||||
});
|
||||
|
||||
document.getElementById('NavigateMenu').addEventListener('click', btnNavigateMenu_click);
|
||||
document.getElementById('NavigateRefresh').addEventListener('click', btnNavigateRefresh_click);
|
||||
document.getElementById('NavigateNext').addEventListener('click', btnNavigateNext_click);
|
||||
document.getElementById('NavigatePrevious').addEventListener('click', btnNavigatePrevious_click);
|
||||
document.getElementById('NavigatePlay').addEventListener('click', btnNavigatePlay_click);
|
||||
document.getElementById('ToggleFullScreen').addEventListener('click', btnFullScreen_click);
|
||||
document.getElementById('btnGetGps').addEventListener('click', btnGetGps_click);
|
||||
|
||||
document.getElementById('divTwc').addEventListener('click', () => {
|
||||
if (document.fullscreenElement) UpdateFullScreenNavigate();
|
||||
});
|
||||
|
||||
document.addEventListener('keydown', document_keydown);
|
||||
document.addEventListener('touchmove', e => { if (_FullScreenOverride) e.preventDefault(); });
|
||||
|
||||
$('#frmGetLatLng #txtAddress').devbridgeAutocomplete({
|
||||
serviceUrl: location.protocol + '//geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/suggest',
|
||||
deferRequestBy: 300,
|
||||
|
@ -100,28 +97,29 @@ const index = (() => {
|
|||
const TwcQuery = localStorage.getItem('TwcQuery');
|
||||
if (TwcQuery) {
|
||||
_AutoSelectQuery = true;
|
||||
$('#txtAddress').val(TwcQuery)
|
||||
.blur()
|
||||
.focus();
|
||||
const txtAddress = document.getElementById('txtAddress');
|
||||
txtAddress.value = TwcQuery;
|
||||
txtAddress.blur();
|
||||
txtAddress.focus();
|
||||
}
|
||||
|
||||
const TwcPlay = localStorage.getItem('TwcPlay');
|
||||
if (TwcPlay === null || TwcPlay === 'true') postMessage('navButton', 'play');
|
||||
|
||||
$('#btnClearQuery').on('click', () => {
|
||||
$('#spanCity').text('');
|
||||
$('#spanState').text('');
|
||||
$('#spanStationId').text('');
|
||||
$('#spanRadarId').text('');
|
||||
$('#spanZoneId').text('');
|
||||
document.getElementById('btnClearQuery').addEventListener('click', () => {
|
||||
document.getElementById('spanCity').innerHTML = '';
|
||||
document.getElementById('spanState').innerHTML = '';
|
||||
document.getElementById('spanStationId').innerHTML = '';
|
||||
document.getElementById('spanRadarId').innerHTML = '';
|
||||
document.getElementById('spanZoneId').innerHTML = '';
|
||||
|
||||
localStorage.removeItem('TwcScrollText');
|
||||
localStorage.removeItem('TwcScrollTextChecked');
|
||||
|
||||
$('#chkAutoRefresh').prop('checked', 'checked');
|
||||
document.getElementById('chkAutoRefresh').checked = true;
|
||||
localStorage.removeItem('TwcAutoRefresh');
|
||||
|
||||
$('#radEnglish').prop('checked', 'checked');
|
||||
document.getElementById('radEnglish').checked = true;
|
||||
localStorage.removeItem('TwcUnits');
|
||||
|
||||
localStorage.removeItem('TwcPlay');
|
||||
|
@ -132,21 +130,16 @@ const index = (() => {
|
|||
|
||||
const TwcUnits = localStorage.getItem('TwcUnits');
|
||||
if (!TwcUnits || TwcUnits === 'ENGLISH') {
|
||||
$('#radEnglish').prop('checked', 'checked');
|
||||
document.getElementById('radEnglish').checked = true;
|
||||
} else if (TwcUnits === 'METRIC') {
|
||||
$('#radMetric').prop('checked', 'checked');
|
||||
document.getElementById('radMetric').checked = true;
|
||||
}
|
||||
|
||||
$('input[type=\'radio\'][name=\'radUnits\']').on('change', (e) => {
|
||||
const Units = $(e.target).val();
|
||||
e;
|
||||
localStorage.setItem('TwcUnits', Units);
|
||||
AssignLastUpdate();
|
||||
postMessage('units', Units);
|
||||
});
|
||||
document.getElementById('radEnglish').addEventListener('change', changeUnits);
|
||||
document.getElementById('radMetric').addEventListener('change', changeUnits);
|
||||
|
||||
$('#chkAutoRefresh').on('change', (e) => {
|
||||
const Checked = $(e.target).is(':checked');
|
||||
document.getElementById('chkAutoRefresh').addEventListener('change', (e) => {
|
||||
const Checked = e.target.checked;
|
||||
|
||||
if (_LastUpdate) {
|
||||
if (Checked) {
|
||||
|
@ -161,38 +154,42 @@ const index = (() => {
|
|||
|
||||
const TwcAutoRefresh = localStorage.getItem('TwcAutoRefresh');
|
||||
if (!TwcAutoRefresh || TwcAutoRefresh === 'true') {
|
||||
$('#chkAutoRefresh').prop('checked', 'checked');
|
||||
document.getElementById('chkAutoRefresh').checked = true;
|
||||
} else {
|
||||
$('#chkAutoRefresh').prop('checked', '');
|
||||
document.getElementById('chkAutoRefresh').checked = false;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
const autocompleteOnSelect = (suggestion) => {
|
||||
let request;
|
||||
const changeUnits = (e) => {
|
||||
const Units = e.target.value;
|
||||
e;
|
||||
localStorage.setItem('TwcUnits', Units);
|
||||
AssignLastUpdate();
|
||||
postMessage('units', Units);
|
||||
};
|
||||
|
||||
const autocompleteOnSelect = async (suggestion) => {
|
||||
// Do not auto get the same city twice.
|
||||
if (this.previousSuggestionValue === suggestion.value) return;
|
||||
|
||||
if (overrides[suggestion.value]) {
|
||||
doRedirectToGeometry(overrides[suggestion.value]);
|
||||
} else {
|
||||
request = $.ajax({
|
||||
url: location.protocol + '//geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/find',
|
||||
const data = await utils.fetch.json('https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/find', {
|
||||
data: {
|
||||
text: suggestion.value,
|
||||
magicKey: suggestion.data,
|
||||
f: 'json',
|
||||
},
|
||||
});
|
||||
request.done((data) => {
|
||||
|
||||
const loc = data.locations[0];
|
||||
if (loc) {
|
||||
doRedirectToGeometry(loc.feature.geometry);
|
||||
} else {
|
||||
alert('An unexpected error occurred. Please try a different search string.');
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -200,7 +197,7 @@ const index = (() => {
|
|||
const latLon = {lat:Math.round2(geom.y, 4), lon:Math.round2(geom.x, 4)};
|
||||
LoadTwcData(latLon);
|
||||
// Save the query
|
||||
localStorage.setItem('TwcQuery', $('#txtAddress').val());
|
||||
localStorage.setItem('TwcQuery', document.getElementById('txtAddress').value);
|
||||
};
|
||||
|
||||
const btnFullScreen_click = () => {
|
||||
|
@ -235,7 +232,6 @@ const index = (() => {
|
|||
// iOS doesn't support FullScreen API.
|
||||
window.scrollTo(0, 0);
|
||||
_FullScreenOverride = true;
|
||||
$(window).resize();
|
||||
}
|
||||
|
||||
UpdateFullScreenNavigate();
|
||||
|
@ -246,7 +242,6 @@ const index = (() => {
|
|||
|
||||
if (_FullScreenOverride) {
|
||||
_FullScreenOverride = false;
|
||||
$(window).resize();
|
||||
}
|
||||
|
||||
if (document.exitFullscreen) {
|
||||
|
@ -275,18 +270,13 @@ const index = (() => {
|
|||
// if there's no data stop
|
||||
if (!latLon) return;
|
||||
|
||||
$('#txtAddress').blur();
|
||||
document.getElementById('txtAddress').blur();
|
||||
StopAutoRefreshTimer();
|
||||
_LastUpdate = null;
|
||||
AssignLastUpdate();
|
||||
|
||||
postMessage('latLon', latLon);
|
||||
|
||||
postMessage('units', $('input[type=\'radio\'][name=\'radUnits\']:checked').val());
|
||||
|
||||
const display = $('#display');
|
||||
display.on('keydown', document_keydown);
|
||||
|
||||
const SwipeCallBack = (event, direction) => {
|
||||
switch (direction) {
|
||||
case 'left':
|
||||
|
@ -300,19 +290,19 @@ const index = (() => {
|
|||
}
|
||||
};
|
||||
|
||||
display.swipe({
|
||||
//Generic swipe handler for all directions
|
||||
swipeRight: SwipeCallBack,
|
||||
swipeLeft: SwipeCallBack,
|
||||
});
|
||||
// display.swipe({
|
||||
// //Generic swipe handler for all directions
|
||||
// swipeRight: SwipeCallBack,
|
||||
// swipeLeft: SwipeCallBack,
|
||||
// });
|
||||
};
|
||||
|
||||
const AssignLastUpdate = () => {
|
||||
let LastUpdate = '(None)';
|
||||
|
||||
if (_LastUpdate) {
|
||||
switch ($('input[type=\'radio\'][name=\'radUnits\']:checked').val()) {
|
||||
case 'ENGLISH':
|
||||
switch (navigation.units()) {
|
||||
case UNITS.english:
|
||||
LastUpdate = _LastUpdate.toLocaleString('en-US', { weekday: 'short', month: 'short', day: 'numeric', year: 'numeric', hour: 'numeric', minute: 'numeric', second: 'numeric', timeZoneName: 'short' });
|
||||
break;
|
||||
default:
|
||||
|
@ -321,9 +311,9 @@ const index = (() => {
|
|||
}
|
||||
}
|
||||
|
||||
$('#spanLastRefresh').html(LastUpdate);
|
||||
document.getElementById('spanLastRefresh').innerHTML = LastUpdate;
|
||||
|
||||
if (_LastUpdate && $('#chkAutoRefresh').is(':checked')) StartAutoRefreshTimer();
|
||||
if (_LastUpdate && document.getElementById('chkAutoRefresh').checked) StartAutoRefreshTimer();
|
||||
};
|
||||
|
||||
const btnNavigateRefresh_click = () => {
|
||||
|
@ -350,8 +340,9 @@ const index = (() => {
|
|||
let _NavigateFadeIntervalId = null;
|
||||
|
||||
const UpdateFullScreenNavigate = () => {
|
||||
$(document.activeElement).blur();
|
||||
divTwcBottom.fadeIn2();
|
||||
document.activeElement.blur();
|
||||
document.getElementById('divTwcBottom').classList.remove('hidden');
|
||||
document.getElementById('divTwcBottom').classList.add('visible');
|
||||
|
||||
if (_NavigateFadeIntervalId) {
|
||||
clearTimeout(_NavigateFadeIntervalId);
|
||||
|
@ -360,7 +351,8 @@ const index = (() => {
|
|||
|
||||
_NavigateFadeIntervalId = setTimeout(() => {
|
||||
if (document.fullscreenElement) {
|
||||
divTwcBottom.fadeOut2();
|
||||
document.getElementById('divTwcBottom').classList.remove('visible');
|
||||
document.getElementById('divTwcBottom').classList.add('hidden');
|
||||
}
|
||||
|
||||
}, 2000);
|
||||
|
@ -403,55 +395,6 @@ const index = (() => {
|
|||
}
|
||||
};
|
||||
|
||||
$.fn.fadeIn2 = function () {
|
||||
const _self = this;
|
||||
let opacity = 0.0;
|
||||
let IntervalId = null;
|
||||
|
||||
if (_self.css('opacity') !== '0') return;
|
||||
|
||||
_self.css('visibility', 'visible');
|
||||
_self.css('opacity', '0.0');
|
||||
|
||||
IntervalId = window.setInterval(() => {
|
||||
opacity += 0.1;
|
||||
opacity = Math.round2(opacity, 1);
|
||||
_self.css('opacity', opacity.toString());
|
||||
|
||||
if (opacity === 1.0) {
|
||||
//_self.css("visibility", "");
|
||||
_self.css('visibility', 'visible');
|
||||
window.clearInterval(IntervalId);
|
||||
}
|
||||
}, 50);
|
||||
|
||||
return _self;
|
||||
};
|
||||
|
||||
$.fn.fadeOut2 = function () {
|
||||
const _self = this;
|
||||
let opacity = 1.0;
|
||||
let IntervalId = null;
|
||||
|
||||
if (_self.css('opacity') !== '1') return;
|
||||
|
||||
_self.css('visibility', 'visible');
|
||||
_self.css('opacity', '1.0');
|
||||
|
||||
IntervalId = window.setInterval(() => {
|
||||
opacity -= 0.2;
|
||||
opacity = Math.round2(opacity, 1);
|
||||
_self.css('opacity', opacity.toString());
|
||||
|
||||
if (opacity === 0) {
|
||||
_self.css('visibility', 'hidden');
|
||||
window.clearInterval(IntervalId);
|
||||
}
|
||||
}, 50);
|
||||
|
||||
return _self;
|
||||
};
|
||||
|
||||
Math.round2 = (value, decimals) => Number(Math.round(value + 'e' + decimals) + 'e-' + decimals);
|
||||
|
||||
const btnNavigatePlay_click = () => {
|
||||
|
@ -463,7 +406,7 @@ const index = (() => {
|
|||
|
||||
// read and dispatch an event from the iframe
|
||||
const message = (data) => {
|
||||
// test for trust
|
||||
const playButton = document.getElementById('NavigatePlay');
|
||||
// dispatch event
|
||||
if (!data.type) return;
|
||||
switch (data.type) {
|
||||
|
@ -479,19 +422,15 @@ const index = (() => {
|
|||
case 'isPlaying':
|
||||
localStorage.setItem('TwcPlay', navigation.isPlaying());
|
||||
|
||||
|
||||
if (navigation.isPlaying()) {
|
||||
noSleepEnable();
|
||||
$('img[src=\'images/nav/ic_play_arrow_white_24dp_1x.png\']').attr('title', 'Pause');
|
||||
$('img[src=\'images/nav/ic_play_arrow_white_24dp_1x.png\']').attr('src', 'images/nav/ic_pause_white_24dp_1x.png');
|
||||
$('img[src=\'images/nav/ic_play_arrow_white_24dp_2x.png\']').attr('title', 'Pause');
|
||||
$('img[src=\'images/nav/ic_play_arrow_white_24dp_2x.png\']').attr('src', 'images/nav/ic_pause_white_24dp_2x.png');
|
||||
playButton.title = 'Pause';
|
||||
playButton.src = 'images/nav/ic_pause_white_24dp_1x.png';
|
||||
} else {
|
||||
noSleepDisable();
|
||||
|
||||
$('img[src=\'images/nav/ic_pause_white_24dp_1x.png\']').attr('title', 'Play');
|
||||
$('img[src=\'images/nav/ic_pause_white_24dp_1x.png\']').attr('src', 'images/nav/ic_play_arrow_white_24dp_1x.png');
|
||||
$('img[src=\'images/nav/ic_pause_white_24dp_2x.png\']').attr('title', 'Play');
|
||||
$('img[src=\'images/nav/ic_pause_white_24dp_2x.png\']').attr('src', 'images/nav/ic_play_arrow_white_24dp_2x.png');
|
||||
playButton.title = 'Play';
|
||||
playButton.src = 'images/nav/ic_play_arrow_white_24dp_1x.png';
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -524,7 +463,7 @@ const index = (() => {
|
|||
RemainingMs = 0;
|
||||
}
|
||||
const dt = new Date(RemainingMs);
|
||||
$('#spanRefreshCountDown').html((dt.getMinutes() < 10 ? '0' + dt.getMinutes() : dt.getMinutes()) + ':' + (dt.getSeconds() < 10 ? '0' + dt.getSeconds() : dt.getSeconds()));
|
||||
document.getElementById('spanRefreshCountDown').innerHTML = (dt.getMinutes() < 10 ? '0' + dt.getMinutes() : dt.getMinutes()) + ':' + (dt.getSeconds() < 10 ? '0' + dt.getSeconds() : dt.getSeconds());
|
||||
|
||||
// Time has elapsed.
|
||||
if (_AutoRefreshCountMs >= _AutoRefreshTotalIntervalMs) LoadTwcData();
|
||||
|
@ -535,7 +474,7 @@ const index = (() => {
|
|||
const StopAutoRefreshTimer = () => {
|
||||
if (_AutoRefreshIntervalId) {
|
||||
window.clearInterval(_AutoRefreshIntervalId);
|
||||
$('#spanRefreshCountDown').html('--:--');
|
||||
document.getElementById('spanRefreshCountDown').innerHTML = '--:--';
|
||||
_AutoRefreshIntervalId = null;
|
||||
}
|
||||
};
|
||||
|
@ -553,8 +492,7 @@ const index = (() => {
|
|||
|
||||
let data;
|
||||
try {
|
||||
data = await $.ajax({
|
||||
url: location.protocol + '//geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode',
|
||||
data = await utils.fetch.json(location.protocol + '//geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode', {
|
||||
data: {
|
||||
location: longitude + ',' + latitude,
|
||||
distance: 1000, // Find location up to 1 KM.
|
||||
|
@ -571,9 +509,10 @@ const index = (() => {
|
|||
const Country = data.address.CountryCode;
|
||||
const TwcQuery = `${ZipCode}, ${City}, ${State}, ${Country}`;
|
||||
|
||||
$('#txtAddress').val(TwcQuery)
|
||||
.blur()
|
||||
.focus();
|
||||
const txtAddress = document.getElementById('txtAddress');
|
||||
txtAddress.value = TwcQuery;
|
||||
txtAddress.blur();
|
||||
txtAddress.focus();
|
||||
|
||||
// Save the query
|
||||
localStorage.setItem('TwcQuery', TwcQuery);
|
||||
|
@ -581,11 +520,11 @@ const index = (() => {
|
|||
|
||||
const populateWeatherParameters = (weatherParameters) => {
|
||||
|
||||
$('#spanCity').text(weatherParameters.city + ', ');
|
||||
$('#spanState').text(weatherParameters.state);
|
||||
$('#spanStationId').text(weatherParameters.stationId);
|
||||
$('#spanRadarId').text(weatherParameters.radarId);
|
||||
$('#spanZoneId').text(weatherParameters.zoneId);
|
||||
document.getElementById('spanCity').innerHTML = weatherParameters.city + ', ';
|
||||
document.getElementById('spanState').innerHTML = weatherParameters.state;
|
||||
document.getElementById('spanStationId').innerHTML = weatherParameters.stationId;
|
||||
document.getElementById('spanRadarId').innerHTML = weatherParameters.radarId;
|
||||
document.getElementById('spanZoneId').innerHTML = weatherParameters.zoneId;
|
||||
};
|
||||
|
||||
// track state of nosleep locally to avoid a null case error when nosleep.disable is called without first calling .enable
|
||||
|
|
|
@ -17,22 +17,14 @@ class CurrentWeather extends WeatherDisplay {
|
|||
let observations, station;
|
||||
try {
|
||||
// station observations
|
||||
const observationsPromise = $.ajaxCORS({
|
||||
type: 'GET',
|
||||
url: `https://api.weather.gov/stations/${weatherParameters.stationId}/observations`,
|
||||
const observationsPromise = utils.fetch.json(`https://api.weather.gov/stations/${weatherParameters.stationId}/observations`,{
|
||||
cors: true,
|
||||
data: {
|
||||
limit: 2,
|
||||
},
|
||||
dataType: 'json',
|
||||
crossDomain: true,
|
||||
});
|
||||
// station info
|
||||
const stationPromise = $.ajax({
|
||||
type: 'GET',
|
||||
url: `https://api.weather.gov/stations/${weatherParameters.stationId}`,
|
||||
dataType: 'json',
|
||||
crossDomain: true,
|
||||
});
|
||||
const stationPromise = utils.fetch.json(`https://api.weather.gov/stations/${weatherParameters.stationId}`);
|
||||
|
||||
// wait for the promises to resolve
|
||||
[observations, station] = await Promise.all([observationsPromise, stationPromise]);
|
||||
|
@ -40,7 +32,7 @@ class CurrentWeather extends WeatherDisplay {
|
|||
// TODO: add retry for further stations if observations are unavailable
|
||||
} catch (e) {
|
||||
console.error('Unable to get current observations');
|
||||
console.error(e.status, e.responseJSON);
|
||||
console.error(e);
|
||||
this.setStatus(STATUS.failed);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -80,9 +80,9 @@ const currentWeatherScroll = (() => {
|
|||
// temperature
|
||||
(data) => {
|
||||
let text = `Temp: ${data.Temperature}${degree} ${data.TemperatureUnit}`;
|
||||
if (data.HeatIndex !== data.Temperature) {
|
||||
if (data.observations.heatIndex.value) {
|
||||
text += ` Heat Index: ${data.HeatIndex}${degree} ${data.TemperatureUnit}`;
|
||||
} else if (data.WindChill !== '' && data.WindChill < data.Temperature) {
|
||||
} else if (data.observations.windChill.value) {
|
||||
text += ` Wind Chill: ${data.WindChill}${degree} ${data.TemperatureUnit}`;
|
||||
}
|
||||
return text;
|
||||
|
|
|
@ -25,14 +25,10 @@ class ExtendedForecast extends WeatherDisplay {
|
|||
if (navigation.units() === UNITS.metric) units = 'si';
|
||||
let forecast;
|
||||
try {
|
||||
forecast = await $.ajax({
|
||||
type: 'GET',
|
||||
url: weatherParameters.forecast,
|
||||
forecast = await utils.fetch.json(weatherParameters.forecast,{
|
||||
data: {
|
||||
units,
|
||||
},
|
||||
dataType: 'json',
|
||||
crossDomain: true,
|
||||
});
|
||||
} catch (e) {
|
||||
console.error('Unable to get extended forecast');
|
||||
|
|
|
@ -31,12 +31,7 @@ class LatestObservations extends WeatherDisplay {
|
|||
// get data for regional stations
|
||||
const allConditions = await Promise.all(regionalStations.map(async station => {
|
||||
try {
|
||||
const data = await $.ajax({
|
||||
type: 'GET',
|
||||
url: `https://api.weather.gov/stations/${station.id}/observations/latest`,
|
||||
dataType: 'json',
|
||||
crossDomain: true,
|
||||
});
|
||||
const data = await utils.fetch.json(`https://api.weather.gov/stations/${station.id}/observations/latest`);
|
||||
// format the return values
|
||||
return Object.assign({}, data.properties, {
|
||||
StationId: station.id,
|
||||
|
|
|
@ -94,14 +94,10 @@ class LocalForecast extends WeatherDisplay {
|
|||
let units = 'us';
|
||||
if (navigation.units() === UNITS.metric) units = 'si';
|
||||
try {
|
||||
return await $.ajax({
|
||||
type: 'GET',
|
||||
url: weatherParameters.forecast,
|
||||
return await utils.fetch.json(weatherParameters.forecast, {
|
||||
data: {
|
||||
units,
|
||||
},
|
||||
dataType: 'json',
|
||||
crossDomain: true,
|
||||
});
|
||||
|
||||
} catch (e) {
|
||||
|
|
|
@ -57,12 +57,7 @@ const navigation = (() => {
|
|||
const point = await utils.weather.getPoint(latLon.lat, latLon.lon);
|
||||
|
||||
// get stations
|
||||
const stations = await $.ajax({
|
||||
type: 'GET',
|
||||
url: point.properties.observationStations,
|
||||
dataType: 'json',
|
||||
crossDomain: true,
|
||||
});
|
||||
const stations = await utils.fetch.json(point.properties.observationStations);
|
||||
|
||||
const StationId = stations.features[0].properties.stationIdentifier;
|
||||
|
||||
|
@ -73,7 +68,6 @@ const navigation = (() => {
|
|||
city = city.split('/')[0];
|
||||
}
|
||||
|
||||
|
||||
// populate the weather parameters
|
||||
weatherParameters.latitude = latLon.lat;
|
||||
weatherParameters.longitude = latLon.lon;
|
||||
|
@ -92,6 +86,7 @@ const navigation = (() => {
|
|||
|
||||
// draw the progress canvas and hide others
|
||||
hideAllCanvases();
|
||||
document.getElementById('loading').style.display = 'none';
|
||||
progress = new Progress(-1,'progress');
|
||||
await progress.drawCanvas();
|
||||
progress.showCanvas();
|
||||
|
|
|
@ -59,15 +59,10 @@ class Radar extends WeatherDisplay {
|
|||
let radarHtml;
|
||||
try {
|
||||
// get a list of available radars
|
||||
radarHtml = await $.ajaxCORS({
|
||||
type: 'GET',
|
||||
url: baseUrl,
|
||||
dataType: 'text',
|
||||
crossDomain: true,
|
||||
});
|
||||
radarHtml = await utils.fetch.text(baseUrl, {cors: true});
|
||||
} catch (e) {
|
||||
console.error('Unable to get list of radars');
|
||||
console.error(e.status, e.responseJSON);
|
||||
console.log('Unable to get list of radars');
|
||||
console.error(e);
|
||||
this.setStatus(STATUS.failed);
|
||||
return;
|
||||
}
|
||||
|
@ -143,19 +138,13 @@ class Radar extends WeatherDisplay {
|
|||
context.imageSmoothingEnabled = false;
|
||||
|
||||
// get the image
|
||||
const [blob, status, xhr] = await (()=>new Promise((resolve, reject) => {
|
||||
$.ajaxCORS({
|
||||
type: 'GET',
|
||||
url: baseUrl + url,
|
||||
xhrFields: {
|
||||
responseType: 'blob',
|
||||
},
|
||||
crossDomain: true,
|
||||
success: (blob, status, xhr) => resolve([blob,status,xhr]),
|
||||
error: (xhr, status, e) => reject(e),
|
||||
});
|
||||
const response = await fetch(utils.cors.rewriteUrl(baseUrl + url));
|
||||
|
||||
}))();
|
||||
// test response
|
||||
if (!response.ok) throw new Error(`Unable to fetch radar error ${response.status} ${response.statusText} from ${response.url}`);
|
||||
|
||||
// get the blob
|
||||
const blob = await response.blob();
|
||||
|
||||
// store the time
|
||||
const timeMatch = url.match(/_(\d{4})(\d\d)(\d\d)_(\d\d)(\d\d)_/);
|
||||
|
@ -171,7 +160,7 @@ class Radar extends WeatherDisplay {
|
|||
zone: 'UTC',
|
||||
}).setZone();
|
||||
} else {
|
||||
time = DateTime.fromHTTP(xhr.getResponseHeader('Last-Modified')).setZone();
|
||||
time = DateTime.fromHTTP(response.headers.get('last-modified')).setZone();
|
||||
}
|
||||
|
||||
// assign to an html image element
|
||||
|
|
|
@ -74,11 +74,7 @@ class RegionalForecast extends WeatherDisplay {
|
|||
// start off the observation task
|
||||
const observationPromise = this.getRegionalObservation(point, city);
|
||||
|
||||
const forecast = await $.ajax({
|
||||
url: point.properties.forecast,
|
||||
dataType: 'json',
|
||||
crossDomain: true,
|
||||
});
|
||||
const forecast = await utils.fetch.json(point.properties.forecast);
|
||||
|
||||
// get XY on map for city
|
||||
const cityXY = this.getXYForCity(city, minMaxLatLon.maxLat, minMaxLatLon.minLon, weatherParameters.state);
|
||||
|
@ -109,8 +105,8 @@ class RegionalForecast extends WeatherDisplay {
|
|||
this.buildForecast(forecast.properties.periods[2], city, cityXY),
|
||||
];
|
||||
} catch (e) {
|
||||
console.log(`No regional forecast data for '${city.Name}'`);
|
||||
console.error(e.status, e.responseJSON);
|
||||
console.log(`No regional forecast data for '${city.name}'`);
|
||||
console.log(e);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
@ -151,22 +147,12 @@ class RegionalForecast extends WeatherDisplay {
|
|||
async getRegionalObservation (point, city) {
|
||||
try {
|
||||
// get stations
|
||||
const stations = await $.ajax({
|
||||
type: 'GET',
|
||||
url: point.properties.observationStations,
|
||||
dataType: 'json',
|
||||
crossDomain: true,
|
||||
});
|
||||
const stations = await utils.fetch.json(point.properties.observationStations);
|
||||
|
||||
// get the first station
|
||||
const station = stations.features[0].id;
|
||||
// get the observation data
|
||||
const observation = await $.ajax({
|
||||
type: 'GET',
|
||||
url: `${station}/observations/latest`,
|
||||
dataType: 'json',
|
||||
crossDomain: true,
|
||||
});
|
||||
const observation = await utils.fetch.json(`${station}/observations/latest`);
|
||||
// preload the image
|
||||
utils.image.preload(icons.getWeatherRegionalIconFromIconLink(observation.properties.icon, !observation.properties.daytime));
|
||||
// return the observation
|
||||
|
|
|
@ -35,11 +35,7 @@ class TravelForecast extends WeatherDisplay {
|
|||
try {
|
||||
// get point then forecast
|
||||
const point = await utils.weather.getPoint(city.Latitude, city.Longitude);
|
||||
const forecast = await $.ajax({
|
||||
url: point.properties.forecast,
|
||||
dataType: 'json',
|
||||
crossDomain: true,
|
||||
});
|
||||
const forecast = await utils.fetch.json(point.properties.forecast);
|
||||
// determine today or tomorrow (shift periods by 1 if tomorrow)
|
||||
const todayShift = forecast.properties.periods[0].isDaytime? 0:1;
|
||||
// return a pared-down forecast
|
||||
|
|
|
@ -7,16 +7,10 @@ const utils = (() => {
|
|||
// ****************************** weather data ********************************
|
||||
const getPoint = async (lat, lon) => {
|
||||
try {
|
||||
return await $.ajax({
|
||||
type: 'GET',
|
||||
url: `https://api.weather.gov/points/${lat},${lon}`,
|
||||
dataType: 'json',
|
||||
crossDomain: true,
|
||||
});
|
||||
return await json(`https://api.weather.gov/points/${lat},${lon}`);
|
||||
} catch (e) {
|
||||
console.error('Unable to get point');
|
||||
console.error(lat,lon);
|
||||
console.error(e.status, e.responseJSON);
|
||||
console.log(`Unable to get point ${lat}, ${lon}`);
|
||||
console.error(e);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
@ -176,12 +170,58 @@ const utils = (() => {
|
|||
// ********************************* cors ********************************************
|
||||
// rewrite some urls for local server
|
||||
const rewriteUrl = (url) => {
|
||||
url = url.replace('https://api.weather.gov/', '');
|
||||
url = url.replace('https://radar.weather.gov/', '');
|
||||
url = url.replace('https://www.cpc.ncep.noaa.gov/', '');
|
||||
url = url.replace('https://api.weather.gov/', window.location.href);
|
||||
url = url.replace('https://radar.weather.gov/', window.location.href);
|
||||
url = url.replace('https://www.cpc.ncep.noaa.gov/', window.location.href);
|
||||
return url;
|
||||
};
|
||||
|
||||
// ********************************* fetch ********************************************
|
||||
const json = (url, params) => fetchAsync(url, 'json', params);
|
||||
const text = (url, params) => fetchAsync(url, 'text', params);
|
||||
const raw = (url, params) => fetchAsync(url, '', params);
|
||||
const blob = (url, params) => fetchAsync(url, 'blob', params);
|
||||
|
||||
const fetchAsync = async (_url, responseType, _params={}) => {
|
||||
// combine default and provided parametersutils
|
||||
const params = Object.assign({}, {
|
||||
method: 'GET',
|
||||
mode: 'cors',
|
||||
type: 'GET',
|
||||
},
|
||||
_params);
|
||||
// build a url, including the rewrite for cors if necessary
|
||||
let corsUrl = _url;
|
||||
if (params.cors === true) corsUrl = rewriteUrl(_url);
|
||||
const url = new URL(corsUrl);
|
||||
// add parameters if necessary
|
||||
if (params.data) {
|
||||
Object.keys(params.data).forEach((key) => {
|
||||
// get the value
|
||||
const value = params.data[key];
|
||||
// add to the url
|
||||
url.searchParams.append(key, value);
|
||||
});
|
||||
}
|
||||
|
||||
// make the request
|
||||
const response = await fetch(url, params);
|
||||
|
||||
// check for ok response
|
||||
if (!response.ok) throw new Error(`Fetch error ${response.status} ${response.statusText} while fetching ${response.url}`);
|
||||
// return the requested response
|
||||
switch (responseType) {
|
||||
case 'json':
|
||||
return await response.json();
|
||||
case 'text':
|
||||
return await response.text();
|
||||
case 'blob':
|
||||
return await response.blob();
|
||||
default:
|
||||
return response;
|
||||
}
|
||||
};
|
||||
|
||||
// return an orderly object
|
||||
return {
|
||||
image: {
|
||||
|
@ -219,14 +259,11 @@ const utils = (() => {
|
|||
cors: {
|
||||
rewriteUrl,
|
||||
},
|
||||
fetch: {
|
||||
json,
|
||||
text,
|
||||
raw,
|
||||
blob,
|
||||
},
|
||||
};
|
||||
})();
|
||||
|
||||
// pass data through local server as CORS workaround
|
||||
$.ajaxCORS = function (e) {
|
||||
// modify the URL
|
||||
e.url = utils.cors.rewriteUrl(e.url);
|
||||
|
||||
// call the ajax function
|
||||
return $.ajax(e);
|
||||
};
|
|
@ -58,10 +58,6 @@ input, button
|
|||
max-width: 640px;
|
||||
}
|
||||
|
||||
#divTwcMiddle
|
||||
{
|
||||
}
|
||||
|
||||
#divTwcLeft
|
||||
{
|
||||
display: none;
|
||||
|
@ -258,9 +254,31 @@ jsgif
|
|||
#container {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
max-width: 640px;
|
||||
/* max-width: 640px; */
|
||||
height: 100%;
|
||||
max-height: 480;
|
||||
background-image: url(http://localhost:8080/images/BackGround1_1.png);
|
||||
}
|
||||
|
||||
#divTwc:fullscreen #container {
|
||||
background-image: none;
|
||||
}
|
||||
#loading {
|
||||
width: 640px;
|
||||
height: 480px;
|
||||
max-width: 100%;
|
||||
text-shadow: 4px 4px black;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
text-align: center;
|
||||
justify-content: center;
|
||||
}
|
||||
#loading .title {
|
||||
font-family: Star4000 Large;
|
||||
font-size: 36px;
|
||||
color: yellow;
|
||||
margin-bottom: 40px;
|
||||
}
|
||||
#loading .instructions {font-size: 18pt;}
|
||||
#container canvas {
|
||||
/* position: absolute; */
|
||||
width: 100%;
|
||||
|
@ -284,6 +302,7 @@ jsgif
|
|||
display:flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
align-content: center;
|
||||
}
|
||||
|
||||
#divTwc:fullscreen #display {
|
||||
|
@ -306,6 +325,12 @@ jsgif
|
|||
max-width: 100vw;
|
||||
height: auto;
|
||||
}
|
||||
#divTwc:fullscreen #container {
|
||||
width: 100vw;
|
||||
height: auto;
|
||||
max-height: unset;
|
||||
max-width: unset;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (orientation: landscape) {
|
||||
|
@ -314,4 +339,26 @@ jsgif
|
|||
max-height: 100vh;
|
||||
width: auto;
|
||||
}
|
||||
#divTwc:fullscreen #container {
|
||||
height: 100vh;
|
||||
width: auto;
|
||||
max-width: 100vw;
|
||||
max-height: unset;
|
||||
}
|
||||
}
|
||||
|
||||
.navButton {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.visible {
|
||||
visibility: visible;
|
||||
opacity: 1;
|
||||
transition: opacity 1s linear;
|
||||
}
|
||||
|
||||
.hidden {
|
||||
visibility: hidden;
|
||||
opacity: 0;
|
||||
transition: visibility 0s 1s, opacity 1s linear
|
||||
}
|
|
@ -1 +1 @@
|
|||
module.exports = '3.5.0';
|
||||
module.exports = '3.6.2';
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
<% if (production) { %>
|
||||
<link rel="stylesheet" type="text/css" href="resources/ws.min.css?_=<%=production%>" />
|
||||
<script type="text/javascript" src="resources/data.min.js"></script>
|
||||
<script type="text/javascript" src="resources/data.min.js?_=<%=production%>"></script>
|
||||
<script type="text/javascript" src="resources/ws.min.js?_=<%=production%>"></script>
|
||||
<% } else { %>
|
||||
<link rel="stylesheet" type="text/css" href="styles/index.css" />
|
||||
|
@ -80,22 +80,26 @@
|
|||
<div id="version" style="display:none"><%- version %> </div>
|
||||
|
||||
<div id="divTwc">
|
||||
<div id='display'>
|
||||
<div id="container">
|
||||
<div id="loading" width="640" height="480">
|
||||
<div>
|
||||
<div class="title">WeatherStar 4000+</div>
|
||||
<div class="instructions">Enter your location above to continue</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="divTwcBottom">
|
||||
<div id="divTwcBottomLeft">
|
||||
<a id="aMenuBottom" href="#" class="NavigateMenu"><img src="images/nav/ic_menu_white_24dp_1x.png" title="Menu" /></a>
|
||||
<a id="aPreviousBottom" href="#" class="NavigatePrevious"><img src="images/nav/ic_skip_previous_white_24dp_1x.png" title="Previous" /></a>
|
||||
<a id="aNextBottom" href="#" class="NavigateNext"><img src="images/nav/ic_skip_next_white_24dp_1x.png" title="Next" /></a>
|
||||
<a id="aPlayBottom" href="#" class="NavigatePlay"><img src="images/nav/ic_play_arrow_white_24dp_1x.png" title="Play" /></a>
|
||||
<img id="NavigateMenu" class="navButton" src="images/nav/ic_menu_white_24dp_1x.png" title="Menu" />
|
||||
<img id="NavigatePrevious" class="navButton" src="images/nav/ic_skip_previous_white_24dp_1x.png" title="Previous" />
|
||||
<img id="NavigateNext" class="navButton" src="images/nav/ic_skip_next_white_24dp_1x.png" title="Next" />
|
||||
<img id="NavigatePlay" class="navButton" src="images/nav/ic_play_arrow_white_24dp_1x.png" title="Play" />
|
||||
</div>
|
||||
<div id="divTwcBottomMiddle">
|
||||
<a id="aRefreshBottom" href="#" class="NavigateRefresh"><img src="images/nav/ic_refresh_white_24dp_1x.png" title="Refresh" /></a>
|
||||
<img id="NavigateRefresh" class="navButton" src="images/nav/ic_refresh_white_24dp_1x.png" title="Refresh" />
|
||||
</div>
|
||||
<div id="divTwcBottomRight">
|
||||
<a id="aFullScreenBottom" href="#" class="ToggleFullScreen"><img src="images/nav/ic_fullscreen_exit_white_24dp_1x.png" title="Exit Fullscreen" /></a>
|
||||
<img id="ToggleFullScreen" class="navButton" src="images/nav/ic_fullscreen_exit_white_24dp_1x.png" title="Exit Fullscreen" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue