update radar sequence close #5

This commit is contained in:
Matt Walsh 2020-09-12 23:41:17 -05:00
parent 58b456f69d
commit b01cf9eefc
4 changed files with 55 additions and 134 deletions

File diff suppressed because one or more lines are too long

182
dist/scripts/index.js vendored
View file

@ -17,18 +17,11 @@ let spanLastRefresh;
let chkAutoRefresh; let chkAutoRefresh;
let spanRefreshCountDown; let spanRefreshCountDown;
let spanCity;
let spanState;
let spanStationId;
let spanRadarId;
let spanZoneId;
let frmScrollText; let frmScrollText;
let chkScrollText; let chkScrollText;
let txtScrollText; let txtScrollText;
let _AutoSelectQuery = false; let _AutoSelectQuery = false;
let _TwcDataUrl = '';
let _IsPlaying = false; let _IsPlaying = false;
let _NoSleep = new NoSleep(); let _NoSleep = new NoSleep();
@ -46,33 +39,10 @@ let _WindowWidth = 0;
let latLon; let latLon;
let _canvasIds = [
'canvasProgress',
'canvasCurrentWeather',
'canvasLatestObservations',
'canvasTravelForecast',
'canvasRegionalForecast1',
'canvasRegionalForecast2',
'canvasRegionalObservations',
'canvasLocalForecast',
'canvasExtendedForecast1',
'canvasExtendedForecast2',
'canvasAlmanac',
'canvasAlmanacTides',
'canvasOutlook',
'canvasMarineForecast',
'canvasAirQuality',
'canvasLocalRadar',
'canvasHazards',
];
const FullScreenResize = () => { const FullScreenResize = () => {
const iframeDoc = $(iframeTwc[0].contentWindow.document);
const WindowWidth = $(window).width(); const WindowWidth = $(window).width();
const WindowHeight = $(window).height(); const WindowHeight = $(window).height();
const inFullScreen = InFullScreen(); const inFullScreen = InFullScreen();
let NewWidth;
let NewHeight;
let IFrameWidth; let IFrameWidth;
let IFrameHeight; let IFrameHeight;
let LeftWidth; let LeftWidth;
@ -83,8 +53,6 @@ const FullScreenResize = () => {
if (inFullScreen) { if (inFullScreen) {
if ((WindowWidth / WindowHeight) >= 1.583333333333333) { if ((WindowWidth / WindowHeight) >= 1.583333333333333) {
NewHeight = WindowHeight + 'px';
NewWidth = '';
divTwcTop.hide(); divTwcTop.hide();
divTwcBottom.hide(); divTwcBottom.hide();
divTwcLeft.show(); divTwcLeft.show();
@ -107,12 +75,9 @@ const FullScreenResize = () => {
divTwcRight.css('visibility', 'visible'); divTwcRight.css('visibility', 'visible');
IFrameWidth = WindowWidth - LeftWidth - RightWidth; IFrameWidth = WindowWidth - LeftWidth - RightWidth;
NewWidth = IFrameWidth + 'px';
iframeTwc.attr('style', 'width:' + IFrameWidth + 'px; height:100%; border:none; margin:0; padding:0; overflow:hidden; z-index:999999;'); iframeTwc.attr('style', 'width:' + IFrameWidth + 'px; height:100%; border:none; margin:0; padding:0; overflow:hidden; z-index:999999;');
} else { } else {
NewHeight = '';
NewWidth = WindowWidth + 'px';
divTwcTop.show(); divTwcTop.show();
divTwcBottom.show(); divTwcBottom.show();
divTwcLeft.hide(); divTwcLeft.hide();
@ -133,15 +98,12 @@ const FullScreenResize = () => {
divTwcBottom.css('visibility', 'visible'); divTwcBottom.css('visibility', 'visible');
IFrameHeight = WindowHeight - TopHeight - BottomHeight; IFrameHeight = WindowHeight - TopHeight - BottomHeight;
NewHeight = IFrameHeight + 'px';
iframeTwc.attr('style', 'width:100%; height:' + IFrameHeight + 'px; border:none; margin:0; padding:0; overflow:hidden; z-index:999999;'); iframeTwc.attr('style', 'width:100%; height:' + IFrameHeight + 'px; border:none; margin:0; padding:0; overflow:hidden; z-index:999999;');
divTwcMiddle.attr('style', 'width:100%; height:' + IFrameHeight + 'px; border:none; margin:0; padding:0; overflow:hidden; z-index:999999;'); divTwcMiddle.attr('style', 'width:100%; height:' + IFrameHeight + 'px; border:none; margin:0; padding:0; overflow:hidden; z-index:999999;');
} }
} }
if (!inFullScreen) { if (!inFullScreen) {
NewHeight = '';
NewWidth = '';
divTwcTop.hide(); divTwcTop.hide();
divTwcBottom.hide(); divTwcBottom.hide();
divTwcLeft.hide(); divTwcLeft.hide();
@ -154,11 +116,6 @@ const FullScreenResize = () => {
$(window).off('resize', FullScreenResize); $(window).off('resize', FullScreenResize);
} }
$(_canvasIds).each(function () {
const canvas = iframeDoc.find('#' + this.toString());
canvas.css('width', NewWidth);
canvas.css('height', NewHeight);
});
if (inFullScreen) { if (inFullScreen) {
$('body').css('overflow', 'hidden'); $('body').css('overflow', 'hidden');
@ -278,7 +235,6 @@ const LoadTwcData = () => {
postMessage('latLon', latLon); postMessage('latLon', latLon);
iframeTwc.off('load');
FullScreenResize(); FullScreenResize();
if (chkScrollText.is(':checked')) { if (chkScrollText.is(':checked')) {
@ -334,7 +290,7 @@ const AssignLastUpdate = () => {
}; };
const btnNavigateRefresh_click = () => { const btnNavigateRefresh_click = () => {
LoadTwcData(_TwcDataUrl); LoadTwcData();
UpdateFullScreenNavigate(); UpdateFullScreenNavigate();
return false; return false;
@ -507,30 +463,21 @@ $(() => {
frmGetLatLng = $('#frmGetLatLng'); frmGetLatLng = $('#frmGetLatLng');
txtAddress = $('#txtAddress'); txtAddress = $('#txtAddress');
btnGetLatLng = $('#btnGetLatLng');
btnClearQuery = $('#btnClearQuery'); btnClearQuery = $('#btnClearQuery');
btnGetGps = $('#btnGetGps'); btnGetGps = $('#btnGetGps');
divLat = $('#divLat');
spanLat = $('#spanLat');
divLng = $('#divLng');
spanLng = $('#spanLng');
iframeTwc = $('#iframeTwc'); iframeTwc = $('#iframeTwc');
btnFullScreen = $('#btnFullScreen');
divTwc = $('#divTwc'); divTwc = $('#divTwc');
divTwcTop = $('#divTwcTop'); divTwcTop = $('#divTwcTop');
divTwcMiddle = $('#divTwcMiddle'); divTwcMiddle = $('#divTwcMiddle');
divTwcBottom = $('#divTwcBottom'); divTwcBottom = $('#divTwcBottom');
divTwcLeft = $('#divTwcLeft'); divTwcLeft = $('#divTwcLeft');
divTwcRight = $('#divTwcRight'); divTwcRight = $('#divTwcRight');
divTwcNav = $('#divTwcNav');
divTwcNavContainer = $('#divTwcNavContainer'); divTwcNavContainer = $('#divTwcNavContainer');
frmScrollText = $('#frmScrollText'); frmScrollText = $('#frmScrollText');
chkScrollText = $('#chkScrollText'); chkScrollText = $('#chkScrollText');
txtScrollText = $('#txtScrollText'); txtScrollText = $('#txtScrollText');
btnScrollText = $('#btnScrollText');
frmScrollText.on('submit', frmScrollText_submit); frmScrollText.on('submit', frmScrollText_submit);
txtScrollText.on('focus', function () { txtScrollText.on('focus', function () {
@ -578,20 +525,7 @@ $(() => {
const cats = categories.join(','); const cats = categories.join(',');
const overrides = { const overrides = {
'08736, Manasquan, New Jersey, USA': { x: -74.037, y: 40.1128 }, // '32899, Orlando, Florida, USA': { x: -80.6774, y: 28.6143 },
'32899, Orlando, Florida, USA': { x: -80.6774, y: 28.6143 },
'97003, Beaverton, Oregon, USA': { x: -122.8752489, y: 45.5050916 },
'99734, Prudhoe Bay, Alaska, USA': { x: -148.3372, y: 70.2552 },
'Guam, Oceania': { x: 144.74, y: 13.46 },
'Andover, Maine, United States': { x: -70.7525, y: 44.634167 },
'Bear Creek, Pennsylvania, United States': { x: -75.772809, y: 41.204074 },
'Bear Creek Village, Pennsylvania, United States': { x: -75.772809, y: 41.204074 },
'New York City, New York, United States': { x: -74.0059, y: 40.7142 },
'Pinnacles National Monument, San Benito County,California, United States': { x: -121.147278, y: 36.47075 },
'Pinnacles National Park, CA-146, Paicines, California': { x: -121.147278, y: 36.47075 },
'Welcome, Maryland, United States': { x: -77.081212, y: 38.4692469 },
'Tampa, Florida, United States (City)': { x: -82.5329, y: 27.9756 },
'San Francisco, California, United States': { x: -122.3758, y: 37.6188 },
}; };
const roundToPlaces = function (num, decimals) { const roundToPlaces = function (num, decimals) {
@ -606,15 +540,15 @@ $(() => {
localStorage.setItem('TwcQuery', txtAddress.val()); localStorage.setItem('TwcQuery', txtAddress.val());
}; };
let PreviousSeggestionValue = null; let PreviousSuggestionValue = null;
let PreviousSeggestion = null; let PreviousSuggestion = null;
const OnSelect = (suggestion) => { const OnSelect = (suggestion) => {
let request; let request;
// Do not auto get the same city twice. // Do not auto get the same city twice.
if (PreviousSeggestionValue === suggestion.value) return; if (PreviousSuggestionValue === suggestion.value) return;
PreviousSeggestionValue = suggestion.value; PreviousSuggestionValue = suggestion.value;
PreviousSeggestion = suggestion; PreviousSuggestion = suggestion;
if (overrides[suggestion.value]) { if (overrides[suggestion.value]) {
doRedirectToGeometry(overrides[suggestion.value]); doRedirectToGeometry(overrides[suggestion.value]);
@ -681,9 +615,9 @@ $(() => {
$(ac.suggestionsContainer.children[0]).click(); $(ac.suggestionsContainer.children[0]).click();
return false; return false;
} }
if (PreviousSeggestion) { if (PreviousSuggestion) {
PreviousSeggestionValue = null; PreviousSuggestionValue = null;
OnSelect(PreviousSeggestion); OnSelect(PreviousSuggestion);
} }
return false; return false;
@ -715,11 +649,11 @@ $(() => {
} }
btnClearQuery.on('click', () => { btnClearQuery.on('click', () => {
spanCity.text(''); $('#spanCity').text('');
spanState.text(''); $('#spanState').text('');
spanStationId.text(''); $('#spanStationId').text('');
spanRadarId.text(''); $('#spanRadarId').text('');
spanZoneId.text(''); $('#spanZoneId').text('');
chkScrollText.prop('checked', ''); chkScrollText.prop('checked', '');
txtScrollText.val(''); txtScrollText.val('');
@ -732,13 +666,12 @@ $(() => {
$('#radEnglish').prop('checked', 'checked'); $('#radEnglish').prop('checked', 'checked');
localStorage.removeItem('TwcUnits'); localStorage.removeItem('TwcUnits');
TwcCallBack({ Status: 'ISPLAYING', Value: false });
localStorage.removeItem('TwcPlay'); localStorage.removeItem('TwcPlay');
_IsPlaying = true; _IsPlaying = true;
localStorage.removeItem('TwcQuery'); localStorage.removeItem('TwcQuery');
PreviousSeggestionValue = null; PreviousSuggestionValue = null;
PreviousSeggestion = null; PreviousSuggestion = null;
LoadTwcData(''); LoadTwcData('');
}); });
@ -759,10 +692,8 @@ $(() => {
}); });
divRefresh = $('#divRefresh');
spanLastRefresh = $('#spanLastRefresh'); spanLastRefresh = $('#spanLastRefresh');
chkAutoRefresh = $('#chkAutoRefresh'); chkAutoRefresh = $('#chkAutoRefresh');
lblRefreshCountDown = $('#lblRefreshCountDown');
spanRefreshCountDown = $('#spanRefreshCountDown'); spanRefreshCountDown = $('#spanRefreshCountDown');
chkAutoRefresh.on('change', (e) => { chkAutoRefresh.on('change', (e) => {
@ -786,13 +717,6 @@ $(() => {
chkAutoRefresh.prop('checked', ''); chkAutoRefresh.prop('checked', '');
} }
spanCity = $('#spanCity');
spanState = $('#spanState');
spanStationId = $('#spanStationId');
spanRadarId = $('#spanRadarId');
spanZoneId = $('#spanZoneId');
}); });
// read and dispatch an event from the iframe // read and dispatch an event from the iframe
const messageHandler = (event) => { const messageHandler = (event) => {
@ -847,7 +771,7 @@ const postMessage = (type, message = {}) => {
}; };
const StartAutoRefreshTimer = () => { const StartAutoRefreshTimer = () => {
// Esnure that any previous timer has already stopped. // Ensure that any previous timer has already stopped.
//StopAutoRefreshTimer(); //StopAutoRefreshTimer();
if (_AutoRefreshIntervalId) { if (_AutoRefreshIntervalId) {
// Timer is already running. // Timer is already running.
@ -870,7 +794,7 @@ const StartAutoRefreshTimer = () => {
spanRefreshCountDown.html((dt.getMinutes() < 10 ? '0' + dt.getMinutes() : dt.getMinutes()) + ':' + (dt.getSeconds() < 10 ? '0' + dt.getSeconds() : dt.getSeconds())); spanRefreshCountDown.html((dt.getMinutes() < 10 ? '0' + dt.getMinutes() : dt.getMinutes()) + ':' + (dt.getSeconds() < 10 ? '0' + dt.getSeconds() : dt.getSeconds()));
// Time has elapsed. // Time has elapsed.
if (_AutoRefreshCountMs >= _AutoRefreshTotalIntervalMs) LoadTwcData(_TwcDataUrl); if (_AutoRefreshCountMs >= _AutoRefreshTotalIntervalMs) LoadTwcData();
}; };
_AutoRefreshIntervalId = window.setInterval(AutoRefreshTimer, _AutoRefreshIntervalMs); _AutoRefreshIntervalId = window.setInterval(AutoRefreshTimer, _AutoRefreshIntervalMs);
AutoRefreshTimer(); AutoRefreshTimer();
@ -883,60 +807,56 @@ const StopAutoRefreshTimer = () => {
} }
}; };
const btnGetGps_click = () => { const btnGetGps_click = async () => {
if (!navigator.geolocation) return; if (!navigator.geolocation) return;
const CurrentPosition = (position) => { const position = await (() => {
const latitude = position.coords.latitude; return new Promise(resolve => {
const longitude = position.coords.longitude; navigator.geolocation.getCurrentPosition(resolve);
});
})();
const latitude = position.coords.latitude;
const longitude = position.coords.longitude;
console.log('Latitude: ' + latitude + '; Longitude: ' + longitude); let data;
try {
//http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode?location=-72.971293%2C+40.850043&f=pjson data = await $.ajax({
const request = $.ajax({
url: location.protocol + '//geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode', url: location.protocol + '//geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode',
data: { data: {
location: longitude + ',' + latitude, location: longitude + ',' + latitude,
distance: 1000, // Find location upto 1 KM. distance: 1000, // Find location up to 1 KM.
f: 'json', f: 'json',
}, },
jsonp: 'callback',
dataType: 'jsonp',
}); });
request.done((data) => { } catch (e) {
console.log(data); console.error('Unable to fetch reverse geocode');
console.error(e);
}
const ZipCode = data.address.Postal;
const City = data.address.City;
const State = states.getTwoDigitCode(data.address.Region);
const Country = data.address.CountryCode;
const TwcQuery = `${ZipCode}, ${City}, ${State}, ${Country}`;
const ZipCode = data.address.Postal; txtAddress.val(TwcQuery);
const City = data.address.City; txtAddress.blur();
const State = states.getTwoDigitCode(data.address.Region); txtAddress.focus();
const Country = data.address.CountryCode;
const TwcQuery = `${ZipCode}, ${City}, ${State}, ${Country}`;
txtAddress.val(TwcQuery); // Save the query
txtAddress.blur(); localStorage.setItem('TwcQuery', TwcQuery);
txtAddress.focus();
// Save the query
localStorage.setItem('TwcQuery', TwcQuery);
});
};
navigator.geolocation.getCurrentPosition(CurrentPosition);
}; };
const populateWeatherParameters = (weatherParameters) => { const populateWeatherParameters = (weatherParameters) => {
spanCity.text(weatherParameters.city + ', ');
spanState.text(weatherParameters.state); $('#spanCity').text(weatherParameters.city + ', ');
spanStationId.text(weatherParameters.stationId); $('#spanState').text(weatherParameters.state);
spanRadarId.text(weatherParameters.radarId); $('#spanStationId').text(weatherParameters.stationId);
spanZoneId.text(weatherParameters.zoneId); $('#spanRadarId').text(weatherParameters.radarId);
$('#spanZoneId').text(weatherParameters.zoneId);
}; };
const frmScrollText_submit = () => { const frmScrollText_submit = () => {
chkScrollText_change(); chkScrollText_change();
return false; return false;
}; };

View file

@ -11,7 +11,8 @@ class Radar extends WeatherDisplay {
// update timing // update timing
this.timing.baseDelay = 350; this.timing.baseDelay = 350;
this.timing.delay = [ this.timing.delay = [
{time: 4, si: 0}, {time: 4, si: 5},
{time: 1, si: 0},
{time: 1, si: 1}, {time: 1, si: 1},
{time: 1, si: 2}, {time: 1, si: 2},
{time: 1, si: 3}, {time: 1, si: 3},

View file

@ -1 +1 @@
module.exports = '2.4.0'; module.exports = '2.4.1';