Gainesvile International Airport
@@ -726,6 +1373,9 @@
now
+
no report
+
+
@@ -746,6 +1396,7 @@
Retrieving forecast data...
+
Temporarily Unavailable
diff --git a/webroot/js/audio.js b/webroot/js/audio.js
index 545bbb2..3dbf638 100644
--- a/webroot/js/audio.js
+++ b/webroot/js/audio.js
@@ -1,3 +1,4 @@
+
function WeatherAudio() {
var musicarr = [],
@@ -188,7 +189,6 @@ function WeatherAudio() {
}
var weatherAudio = new WeatherAudio();
-
//ID3 Reader
//https://github.com/aadsm/JavaScript-ID3-Reader
(function(A){if("object"===typeof exports&&"undefined"!==typeof module)module.f=A();else if("function"===typeof define&&define.M)define([],A);else{var g;"undefined"!==typeof window?g=window:"undefined"!==typeof global?g=global:"undefined"!==typeof self?g=self:g=this;g.ID3=A()}})(function(){return function g(l,h,f){function c(b,d){if(!h[b]){if(!l[b]){var e="function"==typeof require&&require;if(!d&&e)return e(b,!0);if(a)return a(b,!0);e=Error("Cannot find module '"+b+"'");throw e.code="MODULE_NOT_FOUND",
diff --git a/webroot/js/data-manager.js b/webroot/js/data-manager.js
deleted file mode 100644
index f9a34aa..0000000
--- a/webroot/js/data-manager.js
+++ /dev/null
@@ -1,111 +0,0 @@
-function DataManager(pointSearch){
- var $this = $(this),
- that = this,
- excludeRadiusMiles=10;
- includeRadiusMiles=30;
-
- var _locations = [];
-
- this.locations = _locations;
-
- this.location = function(woeid) {
- return _locations.find(x => x.woeid === woeid);
- }
-
- this.init = function (searchString) {
- _locations[0] = new Location();
-
- $(_locations[0])
-
- .on('refresh', function(){ $this.trigger('refresh') })
- .on('ready', function(){
- $this.trigger('ready:main');
- })
- .on('init', initLocations);
- _locations[0].first = true;
- _locations[0].init(searchString);
-
- };
-
- // kicks off after main location is returned.
- // create the list of neighboring cities
- function initLocations(){
-
- // find reporting stations
- var observationData = _locations[0].observations(0),
- lat = observationData.latitude,
- lon = observationData.longitude,
- locList = [];
-
- // begin the forcast pull
- _locations[0].initForecasts();
-
- // get a list of observation stations info //https://api.weather.com/v3/location/near?geocode=33.74,-84.39&product=observation&format=json&apiKey=yourApiKey
- $.getJSON('https://api.weather.com/v3/location/near?geocode=' + lat + ',' + lon + '&product=observation&format=json&apiKey=' + api_key, function(data) {
-
- var feature, geo, station, dist;
- for (var i=0; i < data.location.stationName.length || i <= 3; i++) {
- feature = data.location;
- latgeo = feature.latitude[i];
- longeo = feature.longitude[i];
- dist = feature.distanceMi[i];
-
- if (dist < includeRadiusMiles && dist > excludeRadiusMiles) {
- locList.push({lat: latgeo, long:longeo, distance:dist, stationUrl:feature.stationId[i]});
- }
- }
- if (locList.length===0) {
- $this.trigger('allinit');
- return
- }
-
- // sort list by distance
- locList.sort(function(a, b) {
- return parseInt(a.distance) - parseInt(b.distance);
- });
-
- // set the station for location 0
- _locations[0].stationUrl = locList[0].stationUrl
-
- // create location objects, get inital pull
- for(var loc of locList) {
- loc.location = new Location();
- $(loc.location).on('init',onLocationInit);
- loc.location.init(loc.lat+','+loc.long, loc.location.stationName);
- loc.location.stationUrl = loc.stationUrl;
- }
-
- });
-
- var initCount=0;
- function onLocationInit() {
- initCount++;
- if (initCount===locList.length) {
- allLocationsInit();
- }
- }
-
-
-
-
- function allLocationsInit() {
-
- var location, cities=[], city;
-
- // add locations removing any duplicate cities by name
- for(var loc of locList) {
-
- if (_locations.filter(e => e.city == loc.location.city).length === 0) {
- _locations.push(loc.location);
- //loc.location.initForecasts();
- }
-
- }
-
- $this.trigger('allinit');
-
- }
-
- }
-
-}
diff --git a/webroot/js/groupull.js b/webroot/js/groupull.js
index 6887e9e..16fa055 100644
--- a/webroot/js/groupull.js
+++ b/webroot/js/groupull.js
@@ -1,88 +1,121 @@
-var foreMarqueeDay = ""
-function GroupDataManager() {
- var locationx = {};
- var locations =
- [
- {name:'Chicago', n2:'IL'},
- {name:'Minneapolis', n2:'MN'},
- {name:'Tempe', n2:'AZ'},
- {name:'Fargo', n2:'ND'},
- {name:'North Hollywood', n2:'CA'},
- {name:'Los Angeles', n2:'CA'},
- {name:'Huntington Beach'},
- {name:'Las Vegas', n2:'NV'},
- {name:'Honolulu', n2:'HI'},
- {name:'Orlando', n2:'FL'},
- {name:'New York', n2:'NY'},
- {name:'Napa', n2:'CA'},
- {name:'Montego Bay', n2:''},
- {name:'Kona', n2:'HI'},
- {name:'Kalipaki Beach', n2:''},
- {name:'Ixtapa', n2:'MX'}
- ]
- ;
+var noreportmode = false;
+var marqueeforecasttype = 'forecast'
+//do audio thing and second marquee
+$(function(){
+ weatherAudio.playCallback = function(tags) {
+ $('.track-info').text('playing "' + tags.title + '" by ' + tags.artist);
+ }
+ $('#marquee2').text(weatherInfo.ad)
+ $('#marquee2').marquee({
+ speed: 170, pauseOnHover: true
+ });
+});
+function MarqueeMan() {
+ function switchToWarningMarquee(sidx) {
+ if (weatherInfo.bulletin.severewarnings.length != 0) {
+ $('#marqueeSevere').css("background","linear-gradient(to right, #510d08 0, #b41a08 100%)")
+ $('.marqueeheadersevere').css("background","linear-gradient(to right, #d51e08 0, #b41a08 100%)")
+ $('.marqueeheadersevere').css("color","#fff")
+ $('.marqueeheadersevere').css("text-shadow","2px 2px 4px #000")
- checkRefresh();
- setInterval(checkRefresh, 300000);
-
-
- // check to see if data needs to be refreshed
- function checkRefresh() {
-
-
-
- // check the expiration
- var url = 'https://api.weather.com/v3/aggcommon/v3-wx-forecast-daily-5day;v3-wx-observations-current;v3-location-point?geocodes='
- woeid = location.hasOwnProperty('woeid') ? location.woeid : '';
- $.getJSON("https://examples.opendatasoft.com/api/records/1.0/search/?dataset=largest-us-cities&q=&sort=population&facet=city&facet=state&refine.state=" + mainstate, function(data) {
- if (data !== undefined && data.records.length != 0) {
- data.records.forEach((city, i) => {
- url += (city.fields.coordinates).replace(';',',');
- url += ';'
+ $('.marqueeheadersevere').text((weatherInfo.bulletin.severewarnings[sidx].name).toUpperCase() + ' ' + weatherInfo.bulletin.severewarnings[sidx].status);
+ $('#arrow-img').fadeOut(0)
+ $('#marqueeSevere').fadeIn(0)
+ $('.marqueeheadersevere').fadeIn(0) //#868686
+ $('#marqueeSevere').text(weatherInfo.bulletin.severewarnings[sidx].desc)
+ $('#marqueeSevere')
+ .marquee('destroy')
+ .marquee({speed: 170, delayBeforeStart: 1000, pauseOnHover: true, pauseOnCycle: true})
+ .on('finished', function(){
+ switchSevereMarquee((sidx < weatherInfo.bulletin.severewarnings.length) ? sdix + 1 : 0)
});
+ weatherAudio.playwarningbeep()
+ } else if (weatherInfo.bulletin.marqueewarnings.length != 0){
+ if (weatherInfo.bulletin.marqueewarnings[0].significance == "Y" ||weatherInfo.bulletin.marqueewarnings[0].significance == "S") {
+ $('#marqueeSevere').css('background','linear-gradient(to right, #853302 0, #a84503 100%)')
+ $('.marqueeheadersevere').css("background","linear-gradient(to right, #e86d08 0, #a84403 100%)")
+ $('.marqueeheadersevere').css("color","#000")
+ $('.marqueeheadersevere').css("text-shadow", "0px 0px 0px #000")
+ } else if (weatherInfo.bulletin.marqueewarnings[0].significance == "A") {
+ $('#marqueeSevere').css("background", "linear-gradient(to right, #846811 0, #9b7d0e 100%)");
+ $('.marqueeheadersevere').css('background', 'linear-gradient(to right, #e5dd20 0, #9b7d0e 100%)');
+ $('.marqueeheadersevere').css("color", "#000");
+ $('.marqueeheadersevere').css("text-shadow", "0px 0px 0px #000");
+ } else if (weatherInfo.bulletin.marqueewarnings[0].significance == "W") {
+ $('#marqueeSevere').css("background","linear-gradient(to right, #510d08 0, #b41a08 100%)")
+ $('.marqueeheadersevere').css("background","linear-gradient(to right, #d51e08 0, #b41a08 100%)")
+ $('.marqueeheadersevere').css("color","#fff")
+ $('.marqueeheadersevere').css("text-shadow","2px 2px 4px #000")
+ }
+ $('.marqueeheadersevere').text((weatherInfo.bulletin.marqueewarnings[0].name).toUpperCase() + ' ' + weatherInfo.bulletin.marqueewarnings[0].status)
+ $('#arrow-img').fadeOut(0)
+ $('#marqueeSevere').fadeIn(0)
+ $('.marqueeheadersevere').fadeIn(0)
+ $('#marqueeSevere').text(weatherInfo.bulletin.marqueewarnings[0].desc)
+ $('#marqueeSevere')
+ .marquee({speed: 170, delayBeforeStart: 1000, pauseOnHover: true, pauseOnCycle: true})
+ } else {
+ $('#marqueeSevere')
+ .marquee('destroy')
+ $('#marqueeSevere').fadeOut(0)
+ $('.marqueeheadersevere').fadeOut(0)
+ $('#arrow-img').fadeIn(0)
+ }
- url += '&language=en-US&units=e&format=json&apiKey='+ api_key
- } else {
- url = 'https://api.weather.com/v3/aggcommon/v3-wx-forecast-daily-5day;v3-wx-observations-current;v3-location-point?geocodes=41.881832,-87.623177;44.986656,-93.258133;33.427204,-111.939896;46.877186,-96.789803;34.187042,-118.381256;33.660057,-117.998970;36.114647,-115.172813;21.315603,-157.858093;28.538336,-81.379234;43.0,-75.0;&language=en-US&units=e&format=json&apiKey='+ api_key
- }
- pullData(url);
+ }
+ // for ccticker
+ function displayCCTickerData() {
+ var $span,$spanfor;
+ // ajax the latest observation
+ $(".marquee-current").remove()
+ $(".marquee-fore").remove()
+ if (weatherInfo.ccticker.noReport == true) {
+ noreportmode = true
+ $('#arrow-img').attr("src",'/images/arrow.png');
+ } else {noreportmode == false}
+ weatherInfo.ccticker.ccLocs.forEach((ccLoc, i) => {
+ $span = $("
").appendTo('#marquee-now');
+ $spanfor = $("
").appendTo('#marquee-now');
+ $span.text(ccLoc.displayname + ((noreportmode == true) ? "" : ccLoc.currentCond.temp + ' ' + ccLoc.currentCond.cond));
+ $spanfor.css('display','none')
+ $spanfor.text(ccLoc.displayname + ((noreportmode == true) ? "" : ccLoc.forecast.temp + ' ' + ccLoc.forecast.cond));
});
+ };
- }
-
- function pullData(url) {
- var $span;
-
- // ajax the latest observation
- $.getJSON(url, function(data) {
- data.forEach((locationdata, i) => {
- locationx.data = locationdata;
-
- if ( !location.hasOwnProperty('woeid') ) {
- locationx.woeid = locationx.data.id;
- $span = $("
").appendTo('#marquee-now');
- $spanfor = $("
").appendTo('#marquee-now');
- } else {
- $span = $('#marquee-now>span#' + locationx.woeid);
- }
- var marqueeidx = 1;
- if (locationx.data['v3-wx-forecast-daily-5day'].daypart[0].daypartName[0] == undefined) {marqueeidx = 2;};
- if (locationx.data['v3-wx-forecast-daily-5day'].daypart[0].daypartName[marqueeidx] == "Tonight") {foreMarqueeDay = 'tonight';} else {foreMarqueeDay = (locationx.data['v3-wx-forecast-daily-5day'].dayOfWeek[1].substring(0,3)).toLowerCase()};
- // display the current info
- $span.text(locationx.data['v3-location-point'].location.displayName + ': ' + Math.round(parseInt(locationx.data['v3-wx-observations-current'].temperature)) + ' ' + (locationx.data['v3-wx-observations-current'].wxPhraseLong).toLowerCase());
- $spanfor.css('display','none')
- $spanfor.text(locationx.data['v3-location-point'].location.displayName + ': ' + Math.round(parseInt(locationx.data['v3-wx-forecast-daily-5day'].daypart[0].temperature[marqueeidx])) + ' ' + (locationx.data['v3-wx-forecast-daily-5day'].daypart[0].wxPhraseLong[marqueeidx]).toLowerCase());
-
-
- // set the expiration date/time
- //location.xdate = dateFns.addMinutes(location.data.lastBuildDate, location.data.ttl);
-
+ function refreshMarquee () {
+ if (marqueeforecasttype == 'now') {
+ marqueeforecasttype = 'forecast'
+ if (noreportmode == false) {
+ $('#arrow-img').attr("src",'/images/' + weatherInfo.ccticker.arrow + 'arrow.png');
+ }
+ $('.marquee-fore').each(function(i, item) {
+ item.style.display = ''
+ });$('.marquee-current').each(function(i, item) {
+ item.style.display = 'none'
});
-
- });
- };
-
-
-
-
+ } else {
+ marqueeforecasttype = 'now'
+ if (noreportmode == false) {
+ $('#arrow-img').attr("src",'/images/now.png');
+ }
+ $('.marquee-fore').each(function(i, item) {
+ item.style.display = 'none'
+ });
+ $('.marquee-current').each(function(i, item) {
+ item.style.display = ''
+ });
+ }
+ $('#marquee-container')
+ .marquee('destroy')
+ .marquee({speed: 200, pauseOnHover:true, delayBeforeStart:3000})
+ .on('finished', refreshMarquee);
+ }
+ //init and loop the things
+ refreshMarquee();
+ switchToWarningMarquee();
+ displayCCTickerData();
+ setInterval(function(){
+ displayCCTickerData();
+ switchToWarningMarquee();
+ }, 300000)
}
diff --git a/webroot/js/location.js b/webroot/js/location.js
deleted file mode 100644
index 91ed60b..0000000
--- a/webroot/js/location.js
+++ /dev/null
@@ -1,179 +0,0 @@
-function Location() { // onReady, onRefresh, onAllComplete
-
- var that = this,
- $this = $(this),
- _forecastmgr,
- _observations=[];
-
- this.temperature = function() {
- if (_observations[1]!=null && _observations[1].temperature.value) {
- return C2F(_observations[1].temperature.value);
- } else {
- return Math.round( _observations[0].temperature );
- }
- }
-
- this.observations = function(i) {
- return _observations[i];
- };
-
- this.forecasts=function(type){return _forecastmgr.forecast(type)};
-
- this.init = function(searchString){
- checkRefresh(searchString);
- };
-
- this.initForecasts = function() {
- // start the forecast data pull
- if (_observations[0] != undefined){
- _forecastmgr = new ForecastManager(_observations[0].latitude, _observations[0].longitude, function() {
- $this.trigger('ready');
- });
- }
- };
-
-
-
- // check to see if data needs to be refreshed
- function checkRefresh(location) {
-
- // check the expiration
- if ( _observations[0]!=undefined && dateFns.isFuture( _observations[0].xdate ) ) {
- setTimeout(checkRefresh, getRandom(5000, 10000));
- return;
- }
-
- // woeid is the id for the location to pull data for
- console.log(location);
- if (location != undefined) {
- var loclat = location.split(",")[0]
- var loclong = location.split(",")[1]
- //old var url = 'https://api.openweathermap.org/data/2.5/onecall?lat=' + loclat + '&lon=' + loclong + '&appid=0cb279a98124446dd16dba02fbfb60ee&units=imperial'
- https://api.weather.com/v3/aggcommon/v3-wx-observations-current;v3-location-point?geocode=33.74,-84.39&language=en-US&units=e&format=json&apiKey=yourApiKey
-
- var url = 'https://api.weather.com/v3/aggcommon/v3-wx-observations-current;v3-location-point?geocode=' + loclat + ',' + loclong + '&language=en-US&units=e&format=json&apiKey=' + api_key
-
- // ajax the latest observation
- $.getJSON(url, function(data) {
- if (data['v3-location-point'] != null) {
- _observations[0] = json = data['v3-wx-observations-current'];
- _observations[0].latitude = loclat;
- _observations[0].longitude = loclong;
- _observations[0].cityname = data['v3-location-point'].location.displayName;
- $this.trigger('refresh');
-
- // the following block only runs on init
- if (that.woeid===undefined) {
-
- that.woeid = loclat;
-
- that.lat = loclat;
- that.long = loclong;
-
- that.city = data['v3-location-point'].location.displayName;
-
-
- $this.trigger('init');
- }
- // set the expiration date/time
- _observations[0].xdate = dateFns.addMinutes(json.lastBuildDate, json.ttl);
-
- setTimeout(function() {checkRefresh(loclat + "," + loclong)}, 100000);
- } else {
- $this.trigger('init');
- }
- });
-
-}
-
-}
-
- // pull observations from the location observation station
-
-
-
-
-
-function ForecastManager (latitude, longitude, readyCallback) {
- var _forecasts = {},
- keys =['alert','daily','hourly','almanac','pollen','achesindex','breathindex','airquality','forecastuvindex', 'uvindex'],
- key,
- readycount = 0;
-
- for(key of keys) {
- _forecasts[key] = new Forecast(key, latitude, longitude, count);
- }
-
-
- function count() {
- // count up completed forecast pulls
- readycount++;
- if (readycount===keys.length) {
- readyCallback();
- }
- }
-
- this.forecast = function(type) {
- try{
- return _forecasts[type].data;
- } catch(err){}
- }
-
-}
-
-function Forecast(type, lat, lon, readyCallback) {
-
- var that = this;
- var url;
- if (type == 'hourly') {
- url = 'https://api.weather.com/v3/wx/forecast/hourly/2day?geocode=' + lat + ',' + lon + "&format=json&units=e&language=en-US&apiKey=" + api_key
- } else if (type == 'daily') {
- url = 'https://api.weather.com/v3/wx/forecast/daily/5day?geocode=' + lat + ',' + lon + "&format=json&units=e&language=en-US&apiKey=" + api_key
- } else if (type == 'alert') {
- url = 'https://api.weather.com/v3/alerts/headlines?geocode=' + lat + ',' + lon + "&format=json&language=en-US&apiKey=" + api_key
- } else if (type == 'almanac') {
- url = 'https://api.weather.com/v3/wx/almanac/daily/1day?geocode=' + lat + ',' + lon + "&format=json&units=e" + "&day=" + dateFns.format(new Date(), "D") + "&month=" + dateFns.format(new Date(),"M") + "&apiKey=" + api_key
- } else if (type == 'pollen') {
- url = 'https://api.weather.com/v1/geocode/'+ lat + '/' + lon + '/observations/pollen.json?language=en-US&apiKey=' + api_key
- } else if (type == 'achesindex') {
- url = 'https://api.weather.com/v2/indices/achePain/daypart/3day?geocode=' + lat + ',' + lon + "&language=en-US&format=json&apiKey=" + api_key
- } else if (type == 'breathindex') {
- url = 'https://api.weather.com/v2/indices/breathing/daypart/3day?geocode=' + lat + ',' + lon + "&language=en-US&format=json&apiKey=" + api_key
- } else if (type == 'airquality') {
- url = 'https://api.weather.com/v3/wx/globalAirQuality?geocode=' + lat + ',' + lon + "&language=en-US&scale=EPA&format=json&apiKey=" + api_key
- } else if (type == 'forecastuvindex') {
- url = 'https://api.weather.com/v2/indices/uv/hourly/48hour?geocode=' + lat + ',' + lon + "&language=en-US&format=json&apiKey=" + api_key
- }else if (type == 'uvindex') {
- url = 'https://api.weather.com/v2/indices/uv/current?geocode=' + lat + ',' + lon + "&language=en-US&format=json&apiKey=" + api_key
- }
-
- this.data = {};
-
- checkRefresh();
-
- function checkRefresh() {
-
- // check the expiration
- if ( that.data!={} && dateFns.isFuture( that.data.xdate ) ) {
- setTimeout(function() {checkRefresh}, 100000);
- return;
- }
-
- // ajax the forecast
- $.getJSON(url, function(data) {
-
- that.data = data
-
- // trigger ready callback on first data pull
-
- // set the expiration date/time
- })
- .always(function() {
- if (readyCallback){
- readyCallback();
- }
- });
- }
-
-}
-}
diff --git a/webroot/js/loops.js b/webroot/js/loops.js
index 6f89a4c..2890363 100644
--- a/webroot/js/loops.js
+++ b/webroot/js/loops.js
@@ -1,164 +1,245 @@
-var severemode
-function Loops(bindDataManager) {
- var //dataManager,
- obsData,
- foreDataDaily,
- foreDataHourly;
-
- obsData = bindDataManager.observations;
- foreDataDaily = bindDataManager.forecasts('daily');
- foreDataHourly = bindDataManager.forecasts('hourly');
-
+var loopssevereweathermode = false;
+var displayingAtmospheric = false;
+var miniMap;
+function Loops() {
// init the display loops
- displayAtmospheric(0);
+
displayForecast(0);
+ refreshObservationDisplay()
+ setInterval(refreshObservationDisplay,300000);
+
+}
+ function refreshObservationDisplay() {
+ var cond = weatherInfo.currentCond.sidebar.cond;
+ $('#city').text(maincitycoords.displayname);
+ $('#forecast-city').text(maincitycoords.displayname + ':');
+ if (weatherInfo.radarTempUnavialable == false) {
+ if (loopssevereweathermode == false){
+ $('#minimap').fadeIn(0)
+ $('#minimap-title').fadeIn(0)
+ if (miniMap===undefined) {
+ miniMap = new Radar("minimap", 3, 7, maincitycoords.lat, maincitycoords.lon);
+ }
+ }
+ } else {
+ $('#minimap').fadeOut(0)
+ $('#minimap-title').fadeOut(0)
+ }
+ if (weatherInfo.currentCond.sidebar.noReport == true) {
+ $('#now').fadeOut(0)
+ $('#current-temp').fadeOut(0)
+ $('#current-info').fadeOut(0)
+ $('#conditions-icon').fadeOut(0)
+ $('#current-info-severe').fadeOut(0)
+ $('#current-info-details').fadeOut(0)
+ $('#current-noreport').fadeIn(0)
+ } else {
+ if (displayingAtmospheric == false) {
+ if (loopssevereweathermode == false) { displayAtmospheric(0) } else { displaySevereAtmospheric(0) }
+ }
+ $('#now').fadeIn(0)
+ $('#current-temp').fadeIn(0)
+ if (loopssevereweathermode == false) { $('#current-info').fadeIn(0) } else {
+ $('#current-info-severe').fadeIn(0);
+ $('#current-info-details').fadeIn(0);
+ }
+ $('#current-noreport').fadeOut(0)
+ $('#conditions-icon').fadeIn(0)
+ $('#current-temp').text( weatherInfo.currentCond.sidebar.temp ) ;
+ $('#conditions-icon').css('background-image', 'url("' + getCCicon(+weatherInfo.currentCond.sidebar.icon, weatherInfo.currentCond.sidebar.windspeed) + '")');
+ }
+ }
+
function displayAtmospheric(idx) {
-
+ if (weatherInfo.currentCond.sidebar.noReport == false){
+ displayingAtmospheric = true;
var displays = {
conditions() {
- return (obsData(0).wxPhraseLong).toLowerCase();
+ return (weatherInfo.currentCond.sidebar.cond).toLowerCase();
},
- wind(){ return 'wind ' + ((obsData(0).windDirectionCardinal == "CALM") ? 'calm' : obsData(0).windDirectionCardinal) + ' ' + ((obsData(0).windSpeed === 0) ? '' : obsData(0).windSpeed); },
+ wind(){ return 'wind ' + weatherInfo.currentCond.sidebar.wind; },
gusts(){
- if ( obsData(1)!=undefined ) {
- return obsData(1).windGust.value!=null ? 'gusts ' + obsData(1).windGust.value : '';
+ if ( weatherInfo.currentCond.sidebar.gust!=undefined ) {
+ return (weatherInfo.currentCond.sidebar.gust!="none") ? 'gusts ' + weatherInfo.currentCond.sidebar.gust : '';
}
},
- humidity(){ return 'humidity ' + obsData(0).relativeHumidity + '%'; },
+ humidity(){ return 'humidity ' + weatherInfo.currentCond.sidebar.humid + '%'; },
- dewpoint(){ return 'dew point ' + obsData(0).temperatureDewPoint + '°'; },
+ dewpoint(){ return 'dew point ' + weatherInfo.currentCond.sidebar.dewpt + '°'; },
heatindex_windchill(){
- var windchill = Math.round(35.74 + 0.6215 * parseInt(obsData(0).temperature) - 35.75 * Math.pow(parseInt(obsData(0).windSpeed),0.16) + 0.4275 * parseInt(obsData(0).temperature) * Math.pow(parseInt(obsData(0).windSpeed),0.16) -1);
- if (parseInt(obsData(0).temperature)<80 && windchill < parseInt(obsData(0).temperature)) {
-
- return 'wind chill ' + windchill + '°';
- } else if (parseInt(obsData(0).temperature)>=80 && parseInt(obsData(0).relativeHumidity)>=40 ){
- return 'heat index ' + heatIndex(obsData(0).temperature, obsData(0).relativeHumidity) + '°';
+ if (weatherInfo.currentCond.sidebar.feelslike.type != "dontdisplay") {
+ return weatherInfo.currentCond.sidebar.feelslike.type + " " + weatherInfo.currentCond.sidebar.feelslike.val + '°'
}
- else return '';
},
- pressure(){ return 'pressure ' + obsData(0).pressureAltimeter },
-//+ ['S','R','F'][obsData(0).current.rising];
- visibility() { return 'visibility ' + obsData(0).visibility + ' mile' + (obsData(0).visibility != 1 ? 's' : ''); },
+ pressure(){ return 'pressure ' + weatherInfo.currentCond.sidebar.pressure + ' ' + weatherInfo.currentCond.sidebar.pressureTrend},
- uvindex() { return 'UV index ' + obsData(0).uvDescription; },
+ visibility() { return 'visibility ' + weatherInfo.currentCond.sidebar.visibility + ' mile' + (weatherInfo.currentCond.sidebar.visibility != 1 ? 's' : ''); },
+
+ uvindex() { return 'UV index ' + weatherInfo.currentCond.sidebar.uvidx; },
},
keys = Object.keys(displays),
text = displays[ keys[idx] ]();
// increment the pointer
- if (severemode == true) {
- var si = 0;
- function resetInfo() {
- if (si == 0) {
- stext = (obsData(0).wxPhraseLong).toLowerCase() + '
' + 'wind ' + ((obsData(0).windDirectionCardinal == "CALM") ? 'calm' : obsData(0).windDirectionCardinal) + ' ' + ((obsData(0).windSpeed === 0) ? '' : obsData(0).windSpeed) + '
' + 'humidity ' + obsData(0).relativeHumidity + '%' + '
' + 'dew point ' + obsData(0).temperatureDewPoint + '°'
- $('#current-info').html(stext);
- si = 1;
- } else {
- $('#current-info').html((obsData(0).wxPhraseLong).toLowerCase() + '
' + 'pressure ' + obsData(0).pressureAltimeter + '
' + 'visibility ' + obsData(0).visibility + ((obsData(0).visibility != 1 ) ? 'miles' : 'mile') + '
' + 'ceiling' + ((obsData(0).cloudCeiling != null) ? ((obsData(0).cloudCeiling).toString() + 'ft') : ''));
- si = 0;
- }
- setTimeout(function(){resetInfo()}, 6000);
- }
- resetInfo()
- } else {
- idx = (++idx===keys.length ? 0 : idx);
+ if (loopssevereweathermode == false) {
+ idx = (++idx===keys.length ? 0 : idx);
- if (text) {
- $('#current-info').html(text);
- setTimeout(function(){ displayAtmospheric(idx) }, 6000); // 6 second increment loop
- } else {
- // nothing to display - skip to the next one
- setTimeout(function(){ displayAtmospheric(idx) }, 0);
+ if (text) {
+ $('#current-info').html(text);
+ setTimeout(function(){ displayAtmospheric(idx) }, 6000); // 6 second increment loop
+ } else {
+ // nothing to display - skip to the next one
+ setTimeout(function(){ displayAtmospheric(idx) }, 0);
+ }
}
- }
+ } else {displayingAtmospheric = false}
} // end function
+ function displaySevereAtmospheric(idx) {
+ if (weatherInfo.currentCond.sidebar.noReport == false) {
+ displayingAtmospheric = true
+ $('#current-info-severe').text((weatherInfo.currentCond.sidebar.cond).toLowerCase());
+ var displays = {
+ display1() {
+ return 'wind ' + weatherInfo.currentCond.sidebar.wind + '
' + ((weatherInfo.currentCond.sidebar.gust!="none") ? 'gusts ' + weatherInfo.currentCond.sidebar.gust + '
' : '' ) + 'humidity ' + weatherInfo.currentCond.sidebar.humid + '%' + '
' + 'dew point ' + weatherInfo.currentCond.sidebar.dewpt + '°'
+ },
+ display2() {
+ return (((weatherInfo.currentCond.sidebar.feelslike.type != "dontdisplay") ? weatherInfo.currentCond.sidebar.feelslike.type + " " + weatherInfo.currentCond.sidebar.feelslike.val + '°' + '
' : '' ) + 'pressure ' + weatherInfo.currentCond.sidebar.pressure + weatherInfo.currentCond.sidebar.pressureTrend + '
' + 'visibility ' + weatherInfo.currentCond.sidebar.visibility + ((weatherInfo.currentCond.sidebar.visibility != 1 ) ? ' miles' : ' mile') + '
' + 'ceiling ' + ((weatherInfo.currentCond.sidebar.ceiling != null) ? ((weatherInfo.currentCond.sidebar.ceiling).toString() + ' ft') : ''))
+ }
+ },
+ keys = Object.keys(displays),
+ text = displays[ keys[idx] ]();
+
+ idx = (++idx===keys.length ? 0 : idx);
+ if (loopssevereweathermode == true) {
+ if (text) {
+ $('#current-info-details').html(text);
+ setTimeout(function(){ displaySevereAtmospheric(idx) }, 6000); // 6 second increment loop
+ } else {
+ // nothing to display - skip to the next one
+ setTimeout(function(){ displaySevereAtmospheric(idx) }, 0);
+ }
+ }
+ } else {displayingAtmospheric = false}
+ } //end function
function displayForecast(idx) {
var displays = {
text1() {
- if (foreDataDaily.daypart[0].daypartName[0] != null) {
- $('#forecast-title').text(foreDataDaily.daypart[0].daypartName[0] + "'S" + " FORECAST");
- resizeText(foreDataDaily.daypart[0].narrative[0] + ((foreDataDaily.daypart[0].qualifierPhrase[0] != null && foreDataDaily.daypart[0].narrative[0].includes(foreDataDaily.daypart[0].qualifierPhrase[0]) === false) ? foreDataDaily.daypart[0].qualifierPhrase[0] : '') + ((foreDataDaily.daypart[0].windPhrase[0] != null && foreDataDaily.daypart[0].narrative[0].includes(foreDataDaily.daypart[0].windPhrase[0]) === false) ? foreDataDaily.daypart[0].windPhrase[0] : ''));
- } else {
- $('#forecast-title').text(foreDataDaily.daypart[0].daypartName[1] + "'S" + " FORECAST");
- resizeText(foreDataDaily.daypart[0].narrative[1] + ((foreDataDaily.daypart[0].qualifierPhrase[1] != null && foreDataDaily.daypart[0].narrative[1].includes(foreDataDaily.daypart[0].qualifierPhrase[1]) === false) ? foreDataDaily.daypart[0].qualifierPhrase[1] : '') + ((foreDataDaily.daypart[0].windPhrase[1] != null && foreDataDaily.daypart[0].narrative[1].includes(foreDataDaily.daypart[0].windPhrase[1]) === false) ? foreDataDaily.daypart[0].windPhrase[1] : ''));
- }
+ if (weatherInfo.dayDesc.lowerbar.noReport == true) {
+ $('#forecast-title').fadeOut(0)
+ $('#forecast-text').fadeOut(0)
+ $('#forecast-shadow').css('box-shadow','0 3px 10px 0 rgba(0, 0, 0, 0)')
+ $('#forecast-shadow').css('background','rgba(0,0,0,0)')
+ $('#forecast-tiles').fadeOut(0)
+ $('#forecast-noreport').fadeIn(0)
+ } else {
+ $('#forecast-noreport').fadeOut(0)
+ $('#forecast-shadow').css('background','#8cadd1')
+ $('#forecast-shadow').css('box-shadow','0 3px 10px 0 rgba(0, 0, 0, .35)')
+ $('#forecast-text').fadeIn(0)
+ $('#forecast-title').fadeIn(0)
+ $('#forecast-title').text(weatherInfo.dayDesc.lowerbar.day[0].name + "'S" + " FORECAST");
+ resizeText(weatherInfo.dayDesc.lowerbar.day[0].desc);
+ }
},
text2() {
- if (foreDataDaily.daypart[0].daypartName[0] != null) {
- $('#forecast-title').text( foreDataDaily.daypart[0].daypartName[1] + "'S" + " FORECAST" );
- resizeText(foreDataDaily.daypart[0].narrative[1] + ((foreDataDaily.daypart[0].qualifierPhrase[1] != null && foreDataDaily.daypart[0].narrative[1].includes(foreDataDaily.daypart[0].qualifierPhrase[1]) === false) ? foreDataDaily.daypart[0].qualifierPhrase[1] : '') + ((foreDataDaily.daypart[0].windPhrase[1] != null && foreDataDaily.daypart[0].narrative[1].includes(foreDataDaily.daypart[0].windPhrase[1]) === false) ? foreDataDaily.daypart[0].windPhrase[1] : ''));
- } else {
- $('#forecast-title').text(foreDataDaily.dayOfWeek[1] + "'S" + " FORECAST");
- resizeText(foreDataDaily.daypart[0].narrative[2] + ((foreDataDaily.daypart[0].qualifierPhrase[2] != null && foreDataDaily.daypart[0].narrative[2].includes(foreDataDaily.daypart[0].qualifierPhrase[2]) === false) ? foreDataDaily.daypart[0].qualifierPhrase[2] : '') + ((foreDataDaily.daypart[0].windPhrase[2] != null && foreDataDaily.daypart[0].narrative[2].includes(foreDataDaily.daypart[0].windPhrase[2]) === false) ? foreDataDaily.daypart[0].windPhrase[2] : ''));
- }
+ if (weatherInfo.dayDesc.lowerbar.noReport == true) {
+ $('#forecast-shadow').css('background','rgba(0,0,0,0)')
+ $('#forecast-shadow').css('box-shadow','0 3px 10px 0 rgba(0, 0, 0, 0)')
+ $('#forecast-title').fadeOut(0)
+ $('#forecast-text').fadeOut(0)
+ $('#forecast-tiles').fadeOut(0)
+ $('#forecast-noreport').fadeIn(0)
+ } else {
+ $('#forecast-noreport').fadeOut(0)
+ $('#forecast-shadow').css('background','#8cadd1')
+ $('#forecast-shadow').css('box-shadow','0 3px 10px 0 rgba(0, 0, 0, .35)')
+ $('#forecast-text').fadeIn(0)
+ $('#forecast-title').fadeIn(0)
+ $('#forecast-title').text(weatherInfo.dayDesc.lowerbar.day[1].name + "'S" + " FORECAST");
+ resizeText(weatherInfo.dayDesc.lowerbar.day[1].desc);
+ }
},
fiveday() {
- var newtile, weekend, icons,
- startidx = (foreDataDaily.daypart[0].daypartName[0] != null ? 0 : 2);
+ if (weatherInfo.fiveDay.lowerbar.noReport == true) {
+ $('#forecast-shadow').css('box-shadow','0 3px 10px 0 rgba(0, 0, 0, 0)')
+ $('#forecast-shadow').css('background','rgba(0,0,0,0)')
+ $('#forecast-title').fadeOut(0)
+ $('#forecast-text').fadeOut(0)
+ $('#forecast-tiles').fadeOut(0)
+ $('#forecast-noreport').fadeIn(0)
+ } else {
+ $('#forecast-shadow').css('box-shadow','0 3px 10px 0 rgba(0, 0, 0, .35)')
+ $('#forecast-title').fadeIn(0)
+ $('#forecast-noreport').fadeOut(0)
+ var newtile, weekend, icons;
$('#forecast-title').text("5 DAY FORECAST");
$('#forecast-tiles').empty();
- for (var i=startidx; i<=(startidx + 8); i+=2 ) {
+ for (var i=0; i<5; i++ ) {
+ newtile = $("
");
- weekend = ( dateFns.isWeekend(foreDataDaily.validTimeLocal[i/2]) ? ' weekend' : '');
- newtile = $("
");
+ $("") .appendTo(newtile) .text(weatherInfo.fiveDay.lowerbar.day[i].name);
- $("") .appendTo(newtile) .text((foreDataDaily.dayOfWeek[i/2]).substring(0,3));
-
- icons = getCCicon(+foreDataDaily.daypart[0].iconCode[i], foreDataDaily.daypart[0].windSpeed[i]);
+ icons = getCCicon(+weatherInfo.fiveDay.lowerbar.day[i].icon, weatherInfo.fiveDay.lowerbar.day[i].windspeed);
$("
") .appendTo(newtile) .attr('src', icons);
- $("
") .appendTo(newtile) .text(foreDataDaily.temperatureMax[i/2]);
- $("
") .appendTo(newtile) .text(foreDataDaily.temperatureMin[i/2]);
+ $("
") .appendTo(newtile) .text(weatherInfo.fiveDay.lowerbar.day[i].high);
+ $("
") .appendTo(newtile) .text(weatherInfo.fiveDay.lowerbar.day[i].low);
$('#forecast-tiles').append(newtile);
}
$('#forecast-tiles').css('display','flex');
+ }
},
hourly() {
- var newtile, icons, sizer, highbar,
- indexes = calcHourlyReport(foreDataHourly),
- data, label, temps=[];
-
- $('#forecast-title').text( buildHourlyHeaderTitle(foreDataHourly.validTimeLocal[indexes[0]]) );
+ if (weatherInfo.dayPart.lowerbar.noReport == true) {
+ $('#forecast-shadow').css('box-shadow','0 3px 10px 0 rgba(0, 0, 0, 0)')
+ $('#forecast-shadow').css('background','rgba(0,0,0,0)')
+ $('#forecast-title').fadeOut(0)
+ $('#forecast-text').fadeOut(0)
+ $('#forecast-tiles').fadeOut(0)
+ $('#forecast-noreport').fadeIn(0)
+ } else {
+ $('#forecast-title').fadeIn(0)
+ $('#forecast-noreport').fadeOut(0)
+ var newtile, icons, sizer, highbar, data, label, temps=[];
+ $('#forecast-shadow').css('box-shadow','0 3px 10px 0 rgba(0, 0, 0, .35)')
+ $('#forecast-title').text( weatherInfo.dayPart.lowerbar.daytitle );
$('#forecast-tiles').empty();
- for (var i of indexes) {
- data = foreDataHourly;
+ for (var i = 0; i < 4; i++) {
newtile = $("
");
sizer = $("
").appendTo(newtile);
- icons = getCCicon(data.iconCode[i], data.windSpeed[i]);
-
+ icons = getCCicon(weatherInfo.dayPart.lowerbar.hour[i].icon, weatherInfo.dayPart.lowerbar.hour[i].windspeed);
$("
") .appendTo(sizer) .attr('src', icons);
- $("") .appendTo(newtile) .text(buildHourlyTimeTitle(data.validTimeLocal[i]));
+ $("") .appendTo(newtile) .text(weatherInfo.dayPart.lowerbar.hour[i].time);
highbar = $("
") .appendTo(sizer);
- $("
") .appendTo(highbar) .text(data.temperature[i]);
- temps.push(data.temperature[i]);
+ $("
") .appendTo(highbar) .text(weatherInfo.dayPart.lowerbar.hour[i].temp);
+ temps.push(weatherInfo.dayPart.lowerbar.hour[i].temp);
$("
") .appendTo(highbar);
@@ -170,7 +251,7 @@ function Loops(bindDataManager) {
// animate grow and show temp
var min = Math.min(...temps), // 54
max = Math.max(...temps), // 73
- range = (max-min),
+ range = ((max-min) != 0) ? (max-min) : .001,
prange = (95-78), // percent range for bar height
temp, value;
$('.forecast-tile').each(function(){
@@ -180,10 +261,10 @@ function Loops(bindDataManager) {
$(this).find('.high').fadeTo('slow', 1);
});
})
+ }
},
dummy(){}
-
},
keys = Object.keys(displays);
@@ -214,10 +295,10 @@ function Loops(bindDataManager) {
-} // end Loops class
+ // end Loops class
-function buildHourlyHeaderTitle(time) {
+/*function buildHourlyHeaderTitle(time) {
var today = new Date(),
tomorrow = dateFns.addDays(today, 1),
sforecast = "'s Forecast";
@@ -305,75 +386,7 @@ function calcHourlyReport(data) {
}
return ret;
}
-
-function mapNWSicons(url){
- var map = {
- skc:[26,25],
- few:[28,27],
- sct:[24,23],
- bkn:[22,21],
- ovc:[20,20],
- wind_skc:[26,25,47],
- wind_few:[28,27,47],
- wind_sct:[24,23,47],
- wind_bkn:[22,21,47],
- wind_ovc:[20,20,47],
- snow:[10,10],
- rain_snow:[2,2],
- rain_sleet:[38,38],
- snow_sleet:[3,3],
- fzra:[6,6],
- rain_fzra:[6,6],
- snow_fzra:[44,44],
- sleet:[13,13],
- rain:[8,8],
- rain_showers:[7,7],
- rain_showers_hi:[5,5],
- tsra:[1,1],
- tsra_sct:[29,37],
- tsra_hi:[29,37],
- tornado:[46,46],
- hurr_warn:[45,45],
- hurr_watch:[45,45],
- ts_warn:[45,45],
- ts_watch:[45,45],
- ts_hurr_warn:[45,45],
- dust:[14,14],
- smoke:[16,16],
- haze:[16,16],
- hot:[16,16],
- cold:[42,42],
- blizzard:[11,11],
- fog:[15,15]
- },
- matches = url.match(/icons\/land\/(day|night)\/([a-z_]*)\/?([a-z_]*)/), // day or night followed by one or more condition codes
- idx = {day:0, night:1}[matches[1]],
- ret=[], match;
-
- for (i=2; i
2) {
- ret.push( match[2] );
- }
- }
- }
-
- // place word icons last so they render on top
- if (ret.length>1 && [15,47,41,42, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13, 20, 31, 33, 34, 38, 39, 40, 44].indexOf( ret[1] )>-1) {
- ret.swap(0,1);
- }
-
- return ret.map(function(num){
- return 'images/icons/' + ('0'+num).slice(-2) + '.png';
- });
-
-}
+*/
/*
@@ -388,156 +401,3 @@ uv index High
partly cloudy
*/
-
-// sample data
-/*
-
-https://query.yahooapis.com/v1/public/yql?format=json&q=select * from weather.forecast where woeid=2402292
-
-"units":{
- "distance":"mi",
- "pressure":"in",
- "speed":"mph",
- "temperature":"F"
-},
-"title":"Yahoo! Weather - Fargo, ND, US",
-"link":"http://us.rd.yahoo.com/dailynews/rss/weather/Country__Country/*https://weather.yahoo.com/country/state/city-2402292/",
-"description":"Yahoo! Weather for Fargo, ND, US",
-"language":"en-us",
-"lastBuildDate":"Thu, 12 Oct 2017 10:10 PM CDT",
-"ttl":"60",
-"location":{
- "city":"Fargo",
- "country":"United States",
- "region":" ND"
-},
-"wind":{
- "chill":"52",
- "direction":"295",
- "speed":"18"
-},
-"atmosphere":{
- "humidity":"54",
- "pressure":"978.0",
- "rising":"0",
- "visibility":"16.1"
-},
-"astronomy":{
- "sunrise":"7:41 am",
- "sunset":"6:46 pm"
-},
-"image":{
- "title":"Yahoo! Weather",
- "width":"142",
- "height":"18",
- "link":"http://weather.yahoo.com",
- "url":"http://l.yimg.com/a/i/brand/purplelogo//uh/us/news-wea.gif"
-},
-"item":{
- "title":"Conditions for Fargo, ND, US at 09:00 PM CDT",
- "lat":"46.865089",
- "long":"-96.829224",
- "link":"http://us.rd.yahoo.com/dailynews/rss/weather/Country__Country/*https://weather.yahoo.com/country/state/city-2402292/",
- "pubDate":"Thu, 12 Oct 2017 09:00 PM CDT",
- "condition":{
- "code":"27",
- "date":"Thu, 12 Oct 2017 09:00 PM CDT",
- "temp":"55",
- "text":"Mostly Cloudy"
- },
- "forecast":[
- {
- "code":"30",
- "date":"12 Oct 2017",
- "day":"Thu",
- "high":"70",
- "low":"48",
- "text":"Partly Cloudy"
- },
- {
- "code":"32",
- "date":"13 Oct 2017",
- "day":"Fri",
- "high":"58",
- "low":"37",
- "text":"Sunny"
- },
- {
- "code":"39",
- "date":"14 Oct 2017",
- "day":"Sat",
- "high":"49",
- "low":"38",
- "text":"Scattered Showers"
- },
- {
- "code":"34",
- "date":"15 Oct 2017",
- "day":"Sun",
- "high":"56",
- "low":"31",
- "text":"Mostly Sunny"
- },
- {
- "code":"34",
- "date":"16 Oct 2017",
- "day":"Mon",
- "high":"65",
- "low":"35",
- "text":"Mostly Sunny"
- },
- {
- "code":"34",
- "date":"17 Oct 2017",
- "day":"Tue",
- "high":"65",
- "low":"39",
- "text":"Mostly Sunny"
- },
- {
- "code":"30",
- "date":"18 Oct 2017",
- "day":"Wed",
- "high":"64",
- "low":"48",
- "text":"Partly Cloudy"
- },
- {
- "code":"30",
- "date":"19 Oct 2017",
- "day":"Thu",
- "high":"65",
- "low":"44",
- "text":"Partly Cloudy"
- },
- {
- "code":"30",
- "date":"20 Oct 2017",
- "day":"Fri",
- "high":"66",
- "low":"49",
- "text":"Partly Cloudy"
- },
- {
- "code":"28",
- "date":"21 Oct 2017",
- "day":"Sat",
- "high":"61",
- "low":"49",
- "text":"Mostly Cloudy"
- }
- ],
- "description":"\n
\nCurrent Conditions:\n
Mostly Cloudy\n
\n
\nForecast:\n
Thu - Partly Cloudy. High: 70Low: 48\n
Fri - Sunny. High: 58Low: 37\n
Sat - Scattered Showers. High: 49Low: 38\n
Sun - Mostly Sunny. High: 56Low: 31\n
Mon - Mostly Sunny. High: 65Low: 35\n
\n
\nFull Forecast at Yahoo! Weather\n
\n
\n
\n]]>",
- "guid":{
- "isPermaLink":"false"
- }
-
-}
-
-
-Current Conditions:\n
Mostly Cloudy\n
\n
\n
-Forecast:\n
Thu - Partly Cloudy. High: 70Low: 48\n
Fri - Sunny. High: 58Low: 37\n
Sat - Scattered Showers. High: 49Low: 38\n
Sun - Mostly Sunny. High: 56Low: 31\n
-Mon - Mostly Sunny. High: 65Low: 35\n
\n
\nFull Forecast at Yahoo! Weather\n
\n
\n
\n]]>",
- "guid":{
-
-*/
diff --git a/webroot/js/main.js b/webroot/js/main.js
index 13d19bb..56abe0c 100644
--- a/webroot/js/main.js
+++ b/webroot/js/main.js
@@ -6,7 +6,7 @@ $(function(){
mainAspect = 4/3,
resizeTimer;
-
+//calls rescale when window resizes
$(window).resize( function(e) {
clearTimeout(resizeTimer);
resizeTimer = setTimeout(scaleWindow, 100);
@@ -26,6 +26,9 @@ $(function(){
$main.css({
transform: "translate(-50%, -50%) " + "scale(" + scale + ")"
});
+ $("#startup").css({
+ transform: "translate(-50%, -50%) " + "scale(" + scale + ")"
+ });
}
scaleWindow(); // init
diff --git a/webroot/js/newweathermanager.js b/webroot/js/newweathermanager.js
new file mode 100644
index 0000000..f7781f8
--- /dev/null
+++ b/webroot/js/newweathermanager.js
@@ -0,0 +1,873 @@
+function Intro() {
+let animationtime, rotatex, rotatey, rotatez;
+function spinything() {
+ animationtime = Math.floor(Math.random() * (12 - 3 + 1)) + 3
+ rotatex = (Math.floor(-100 + Math.random()*(100 + 1 - -100)))/100
+ rotatey = (Math.floor(-100 + Math.random()*(100 + 1 - -100)))/100
+ rotatez = (Math.floor(-100 + Math.random()*(100 + 1 - -100)))/100
+ $("#headendid").text("headend id: 0"+Math.round(Math.random()*100000))
+ $("#serialnumber").text("serial number: TWCS"+"0"+Math.round(Math.random()*100000000))
+ $("#affilatename").text("affiliatename: Midco")
+ $(".intellistarlogo").css( { transition: `transform 5s linear`,
+ transform: `rotate3d(${rotatex}, ${rotatey}, ${rotatez}, ${.25 + Math.random()}turn)` } );
+ setTimeout(function () {
+ $("#startup").fadeOut(0);
+ }, 5000)
+
+ };
+ spinything()
+};
+$(function(){
+ Intro()
+})
+
+//time manager
+setInterval(
+ function () {
+ var today = new Date();
+
+ $('#date').text( today.toString().slice(4,10).trimRight() );
+ $('#time').text( today.toLocaleTimeString('en-US', { hour: 'numeric', hour12: true, minute: 'numeric', second: 'numeric' }).replace(/ /g,'') );
+ }
+, 1000);
+//location pull
+var maincitycoords = {name:"",lat:"",lon:""}, marinelocation,
+locList = [], citySlideList = [], state, ccTickerCitiesList = [];
+
+
+ //If there is a location inputted, use that.
+
+queryString = window.location.search;
+
+function getMainLoc(onInit) {
+ if (queryString) {
+ $.getJSON("https://api.weather.com/v3/location/search?query="+queryString.split("?")[1]+"&language=en-US&format=json&apiKey=" + api_key, function(data) {
+ if (onInit==true){
+ getExtraLocs(data.location.latitude[0],data.location.longitude[0],true);
+ maincitycoords.lat = data.location.latitude[0]
+ maincitycoords.lon = data.location.longitude[0]
+ maincitycoords.name = data.location.displayName[0]
+ $("#locationname").text("location name: "+data.location.displayName[0])
+ maincitycoords.displayname = data.location.displayName[0]
+ state = data.location.adminDistrict[0];
+ //init data
+ getStatePopularCities(state, true)
+ grabAlamanacSlidesData()
+ grabHealthData()
+ grabSideandLowerBarData()
+ } else {
+ //for settings
+ mainlocationdata = {name:data.location[0].displayName,displayname:data.location[0].displayName,lat:data.location[0].latitude,lon:data.location[0].longitude,state:data.location.adminDistrict[0]};
+ updateonResetMainLoc()
+ }
+ });
+ } else {
+ // get lat lon from user's ip
+ $.getJSON("http://ip-api.com/json/?callback=?", function(data) {
+ if (onInit==true){
+ getExtraLocs(data.lat,data.lon,true);
+ maincitycoords.name = data.city
+ $("#locationname").text("location name: "+data.city)
+ maincitycoords.displayname = data.city
+ maincitycoords.lat = data.lat
+ maincitycoords.lon = data.lon
+ state = data.regionName
+ //init data
+ getStatePopularCities(state, true)
+ grabAlamanacSlidesData()
+ grabHealthData()
+ grabSideandLowerBarData()
+ } else {
+ //for settings
+ mainlocationdata = {name:data.city,displayname:data.city,lat:data.lat,lon:data.lon,state:data.regionName};
+ updateonResetMainLoc()
+ }
+ });
+
+ }
+}
+getMainLoc(true);
+
+function getExtraLocs(lat,lon, onInit, whichReset) {
+ $.getJSON('https://api.weather.com/v3/location/near?geocode=' + lat + ',' + lon + '&product=observation&format=json&apiKey=' + api_key, function(data) {
+
+ var feature = data.location, geo, station, dist, ti=0;
+ var minRadiusMiles = 0, maxRadiusMiles = 45;
+ getLocLoop(0);
+ function getLocLoop(i) {
+ $.getJSON("https://api.weather.com/v3/location/point?geocode="+ feature.latitude[i] + "," + feature.longitude[i] + "&language=en-US&format=json&apiKey=" + api_key, function(dataii){
+ latgeo = feature.latitude[i];
+ longeo = feature.longitude[i];
+ dist = feature.distanceMi[i];
+ displayname = dataii.location.displayName
+ if (displayname == maincitycoords.displayname || displayname == state) {
+ if ((dataii.location.locale.locale3 != maincitycoords.displayname && dataii.location.locale.locale3) || (dataii.location.locale.locale4 != maincitycoords.displayname && dataii.location.locale.locale4)) {
+ displayname = (dataii.location.locale.locale3 != maincitycoords.displayname && dataii.location.locale.locale3) ? dataii.location.locale.locale3 : dataii.location.locale.locale4
+ } else {
+ if (feature.latitude.length == (i + 1)) {onExtraAjaxFinish()} else {getLocLoop(i + 1)}
+ return
+ }
+ }
+ for (var li = 0; li < citySlideList.length; li++) {
+ if (displayname == citySlideList[li].displayname) {
+ if ((dataii.location.locale.locale3 != citySlideList[li].displayname && dataii.location.locale.locale3) || (dataii.location.locale.locale4 != citySlideList[li].displayname && dataii.location.locale.locale4)) {
+ displayname = (dataii.location.locale.locale3 != citySlideList[li].displayname && dataii.location.locale.locale3) ? dataii.location.locale.locale3 : dataii.location.locale.locale4
+ } else {
+ if (feature.latitude.length == (i + 1)) {onExtraAjaxFinish()} else {getLocLoop(i + 1)}
+ return
+ }
+ }
+ }
+ if (i!=0) {
+ if (onInit==true) {
+ citySlideList.push({lat: latgeo, lon:longeo, distance:dist, stationUrl:feature.stationId[i], name:displayname, displayname:displayname});
+ } else {
+ //for settings
+ if (whichReset=="8slide"){
+ city8slidedata.push({lat: latgeo, lon:longeo, distance:dist, stationUrl:feature.stationId[i], name:displayname, displayname:displayname});
+ }
+ }
+ };
+ displayname = dataii.location.displayName
+ if (displayname == maincitycoords.displayname || displayname == state) {
+ if (feature.latitude.length == (i + 1)) {onExtraAjaxFinish()} else {getLocLoop(i + 1)}
+ return
+ }
+ for (var li = 0; li < locList.length; li++) {
+ if (displayname == locList[li].displayname) {
+ if (feature.latitude.length == (i + 1)) {onExtraAjaxFinish()} else {getLocLoop(i + 1)}
+ return
+ }
+ }
+
+ if (dist >= minRadiusMiles && dist <= maxRadiusMiles) {
+ if (ti < 3) {
+ if (onInit==true) {
+ locList.push({lat: latgeo, lon:longeo, distance:dist, stationUrl:feature.stationId[i], name:displayname, displayname:displayname});
+ } else {
+ //for settinngs
+ if (whichReset=="extralocation") {
+ extralocsdata.push({lat: latgeo, lon:longeo, distance:dist, stationUrl:feature.stationId[i], name:displayname, displayname:displayname});
+ }
+ }
+ }
+ } else {
+ ti = ti - 1
+ }
+ //for the 8 city slide
+ if (i < data.location.stationName.length && (citySlideList.length < 8 || locList.length < 3)) {
+ ti = ti + 1
+ i = i + 1
+ getLocLoop(i)
+ } else {onExtraAjaxFinish()};
+
+ }).fail(function(){
+ if (feature.latitude.length >= (i + 1) || i >= 9) {onExtraAjaxFinish()} else {getLocLoop(i + 1)}
+ })
+ }
+
+ // sort list by distance
+ function onExtraAjaxFinish () {
+ if (onInit==true) {
+ locList.sort(function(a, b) {
+ return parseInt(a.distance) - parseInt(b.distance);
+ });
+ grabCitySlidesData()
+ } else {
+ //for settings
+ if (whichReset=="extralocation") {
+ extralocsdata.sort(function(a, b) {
+ return parseInt(a.distance) - parseInt(b.distance);
+ });
+ }
+ updateLocs(whichReset)
+ }
+ // set the station for location 0
+ //_locations[0].stationUrl = locList[0].stationUrl
+ //start datapull
+ }
+ });
+ }
+
+ function getStatePopularCities(state, onInit) {
+ $.getJSON("https://examples.opendatasoft.com/api/records/1.0/search/?dataset=largest-us-cities&q=&sort=population&facet=city&facet=state&refine.state=" + state, function(data) {
+ if (data !== undefined && data.records.length != 0) {
+ data.records.forEach((city, i) => {
+ if (onInit==true) {
+ ccTickerCitiesList.push({name:city.fields.city,displayname:city.fields.city,lat:(city.fields.coordinates).split(';')[0],lon:(city.fields.coordinates).split(';')[1]})
+ } else {
+ cctickerdata.push({name:city.fields.city,displayname:city.fields.city,lat:(city.fields.coordinates).split(';')[0],lon:(city.fields.coordinates).split(';')[1]})
+ updateLocs("cctickerloc")
+ };
+ if (i == (data.records.length - 1)) {pullCCTickerData()};
+ });
+ } else {
+ //if nothing just run the function and use placeholder locs
+ pullCCTickerData();
+ }
+ });
+ }
+
+
+var weatherInfo = { currentCond: {
+ sidebar: {noReport:false,displayname:"",temp:"",cond:"",icon:"",humid:"",dewpt:"",pressure:"",wind:"",windspeed:"",gust:"",feelslike:{type:"",val:""},visibility:"",uvidx:"",ceiling:""},
+ //loc:{noReport:"",displayname:"",temp:"",cond:"",icon:"",humid:"",dewpt:"",pressure:"",pressureTrend:"",wind:"",windspeed:"",gust:"",feelslike:{type:"",val:""},},
+ weatherLocs:[],
+}, dayPart: {
+ lowerbar:{noReport:false,displayname:"",daytitle:"",hour:[{time:"",cond:"",icon:"",temp:"",wind:"",windspeed:""},{time:"",cond:"",icon:"",temp:"",wind:"",windspeed:""},{time:"",cond:"",icon:"",temp:"",wind:"",windspeed:""},{time:"",cond:"",icon:"",temp:"",wind:"",windspeed:""},]},
+ /*loc:{noReport:"",displayname:"",daytitle:"",hour:[
+ {time:"",cond:"",icon:"",temp:"",wind:"",windspeed:""},
+ {time:"",cond:"",icon:"",temp:"",wind:"",windspeed:""},
+ {time:"",cond:"",icon:"",temp:"",wind:"",windspeed:""},
+ {time:"",cond:"",icon:"",temp:"",wind:"",windspeed:""},
+ ]},*/
+ weatherLocs:[],
+}, dayDesc: {
+ lowerbar: {noReport:false,displayname:"",day:[{name:"",desc:""},{name:"",desc:""},{name:"",desc:""},{name:"",desc:""}]},
+ /*loc:{noReport:"",displayname:"",day:[
+ {name:"",desc:""},
+ {name:"",desc:""},
+ {name:"",desc:""},
+ {name:"",desc:""}
+ ]},*/
+ weatherLocs:[]
+}, fiveDay: {
+ lowerbar: {noReport:false,displayname:"",day:[{name:"",cond:"",icon:"",high:"",low:"",windspeed:"",weekend:""},{name:"",cond:"",icon:"",high:"",low:"",windspeed:"",weekend:""},{name:"",cond:"",icon:"",high:"",low:"",windspeed:"",weekend:""},{name:"",cond:"",icon:"",high:"",low:"",windspeed:"",weekend:""},{name:"",cond:"",icon:"",high:"",low:"",windspeed:"",weekend:""}]},
+ /*loc:{noReport:"",displayname:"",day:[
+ {name:"",cond:"",icon:"",high:"",low:"",windspeed:""},
+ {name:"",cond:"",icon:"",high:"",low:"",windspeed:""},
+ {name:"",cond:"",icon:"",high:"",low:"",windspeed:""},
+ {name:"",cond:"",icon:"",high:"",low:"",windspeed:""},
+ {name:"",cond:"",icon:"",high:"",low:"",windspeed:""}
+ ]},*/
+ weatherLocs:[]
+ }, alamanac: {displayname:"",date:"",avghigh:"",avglow:"",rechigh:"",reclow:"",rechighyear:"",reclowyear:"",sunrise:"",sunset:"",moonphases:[
+ {name:"NEW",date:"Feb 10"},
+ {name:"FIRST",date:"Feb 16"},
+ {name:"FULL",date:"Feb 21"},
+ {name:"LAST",date:"Feb 27"},
+ ]}, bulletin: {
+ //loc:{displayname:"",pages:[]},
+ weatherLocs:[],
+ severewarnings:[],
+ //{name:"", desc:"", status:""}
+ marqueewarnings:[],
+ severeweathermode: false
+ //{name:"", desc:"", status:"", significance:""}
+ }, healthforecast: { displayname:"",dayidx:0, day:"", high:"", low:"", precipChance:"", humid:"", wind:"",windspeed:"", icon:""
+ }, healthPollen: {displayname:"", total:"", totalcat:"", date:"", types:[
+ {type:"tree", treetype:"", pollenidx:""},
+ {type:"grass", pollenidx:""},
+ {type:"weed", pollenidx:""},
+ {type:"mold", pollenidx:""},
+ ]}, healthAcheBreath: {date:"",achesindex:"",achescat:"",breathindex:"",breathcat:""
+ }, airquality: {date:"",ozoneactin: false, primarypolute:"", airqualityindex:""
+ }, uvindex: {currentuv:{index:"",desc:""},forecast:[
+ {day:"",time:"",index:"",desc:""},
+ {day:"",time:"",index:"",desc:""},
+ {day:"",time:"",index:"",desc:""}
+ ]},
+ ccticker: {noReport:false,arrow:"",ccLocs:[]},
+ radarTempUnavialable: false,
+ ad: "You are watching an emulation of the Weatherscan IntelliStar system. Weatherscan is a digital cable and satellite television network that is owned by a consortium owned in turn by NBCUniversal and investment firms The Blackstone Group and Bain Capital. A spinoff of The Weather Channel, Weatherscan features uninterrupted local weather information in graphical format on a continuous loop that is generated by an IntelliStar unit installed at the cable provider's headend; unlike The Weather Channel, Weatherscan does not feature on-air talent of any kind."
+}
+
+//start data functions. these are run after their respective location functions finish
+function grabCitySlidesData() {
+ console.log("grabbed city data")
+ var url = "https://api.weather.com/v3/aggcommon/v3alertsHeadlines;v3-wx-forecast-daily-5day;v3-wx-observations-current;v3-wx-forecast-hourly-2day?geocodes="
+ url += `${maincitycoords.lat},${maincitycoords.lon};`
+ locList.forEach((loc, i) => {
+ url += `${loc.lat},${loc.lon};`
+ });
+ url += "&language=en-US&units=e&format=json&apiKey=" + api_key
+
+ $.getJSON(url, function(data) {
+ data.forEach((ajaxedLoc, i) => {
+ //Extra locations
+
+ var weatherLocscc = {noReport:false,displayname:"",temp:"",cond:"",icon:"",humid:"",dewpt:"",pressure:"",pressureTrend:"",wind:"",windspeed:"",gust:"",feelslike:{type:"",val:""}}
+ weatherLocscc.temp = ajaxedLoc["v3-wx-observations-current"].temperature
+ weatherLocscc.cond = ajaxedLoc["v3-wx-observations-current"].wxPhraseLong
+ weatherLocscc.icon = ajaxedLoc["v3-wx-observations-current"].iconCode
+ weatherLocscc.humid = ajaxedLoc["v3-wx-observations-current"].relativeHumidity
+ weatherLocscc.dewpt = ajaxedLoc["v3-wx-observations-current"].temperatureDewPoint
+ weatherLocscc.pressure = ajaxedLoc["v3-wx-observations-current"].pressureAltimeter
+ weatherLocscc.pressureTrend = ((ajaxedLoc["v3-wx-observations-current"].pressureTendencyCode === 1 || ajaxedLoc["v3-wx-observations-current"].pressureTendencyCode === 3) ? '↑' : (ajaxedLoc["v3-wx-observations-current"].pressureTendencyCode === 2 || ajaxedLoc["v3-wx-observations-current"].pressureTendencyCode === 4) ? '↓' : ' S')
+ weatherLocscc.wind = ((ajaxedLoc["v3-wx-observations-current"].windDirectionCardinal == "CALM" || ajaxedLoc["v3-wx-observations-current"].windSpeed == 0) ? 'calm' : ajaxedLoc["v3-wx-observations-current"].windDirectionCardinal) + ' ' + ((ajaxedLoc["v3-wx-observations-current"].windSpeed === 0) ? '' : ajaxedLoc["v3-wx-observations-current"].windSpeed)
+ weatherLocscc.windspeed = ajaxedLoc["v3-wx-observations-current"].windSpeed
+ weatherLocscc.gust = ((ajaxedLoc["v3-wx-observations-current"].windGust!=undefined) ? ajaxedLoc["v3-wx-observations-current"].windGust + " mph": "none")
+ weatherLocscc.feelslike.type = ((ajaxedLoc["v3-wx-observations-current"].temperature != ajaxedLoc["v3-wx-observations-current"].temperatureHeatIndex) ? "Heat Index" : ((ajaxedLoc["v3-wx-observations-current"].temperatureWindChill != ajaxedLoc["v3-wx-observations-current"].temperature) ? "Wind Chill" : "dontdisplay"))
+ weatherLocscc.feelslike.val = ajaxedLoc["v3-wx-observations-current"].temperatureFeelsLike
+ weatherLocscc.displayname = ((i ==0 ) ? maincitycoords.displayname : locList[i-1].displayname)
+ weatherInfo.currentCond.weatherLocs.push(weatherLocscc)
+ //day part
+ //functions converting hourly data into daypart
+ var indexes = calcHourlyReport(ajaxedLoc["v3-wx-forecast-hourly-2day"]);
+ function buildHourlyTimeTitle(time){
+ var hour=dateFns.getHours(time);
+ if (hour===0) {
+ return 'Midnight';
+ } else if (hour===12){
+ return 'Noon';
+ }
+ return (dateFns.format(time,'h a')).replace(" ", "");
+ }
+ //get reporting hours: 12am, 6am, 12pm, 3pm, 5pm, 8pm...
+ function calcHourlyReport(data) {
+ var ret = [],
+ targets = [0, 6, 12, 15, 17, 20], // hours that we report
+ current = dateFns.getHours(new Date()),
+ now = new Date(),
+ //firsthour = targets[ getNextHighestIndex(targets, current) ],
+ start,
+ hour, hi=0;
+
+ switch (true) {
+ case (current < 3):
+ start = 6; //before 3:00
+ case (current < 9):
+ start = 12; break; //before 9:00 after 3:00
+ case (current < 12):
+ start = 15; break; //before 12:00 after 9:00
+ case (current < 14):
+ start = 17; break; //before 2:00 after 12:00
+ case (current < 17):
+ start = 6; break; //before 5:00 after 2:00
+ case (current < 20):
+ start = 6; break; //before 8:00 after 5:00
+ default:
+ start = 6;
+ }
+ while(ret.length<4){
+ // hour must be equal or greater than current
+ hour = dateFns.getHours(data.validTimeLocal[hi] );
+ if ( dateFns.isAfter(data.validTimeLocal[hi], now) && (hour==start || ret.length>0) ) {
+ if ( targets.indexOf(hour)>=0 ) { // it is in our target list so record its index
+ ret.push(hi);
+ }
+ }
+ hi++;
+ }
+ return ret;
+ }
+ function buildHourlyHeaderTitle(time) {
+ var today = new Date(),
+ tomorrow = dateFns.addDays(today, 1);
+
+ // title based on the first hour reported
+ switch (dateFns.getHours(time)) {
+
+ case 6: // 6 - Nextday's Forecast / Today's Forecast
+ // if 6am today
+ if (dateFns.isToday(time)) {
+ return "Today's Forecast";
+ }
+ case 0: // 0 - Nextday's Forecast
+ return "Tomorrow's Forecast";
+
+ case 12:
+ return "Today's Forecast";
+
+ case 15:
+ return "Today's Forecast";
+
+ case 17:
+ return "Tonight's Forecast";
+
+ case 20:
+ return "Tonight's Forecast"
+ }
+ }
+
+ var weatherLocsDP = {noReport:false,displayname:"",daytitle:"",hour:[{time:"",cond:"",icon:"",temp:"",wind:"",windspeed:""},{time:"",cond:"",icon:"",temp:"",wind:"",windspeed:""},{time:"",cond:"",icon:"",temp:"",wind:"",windspeed:""},{time:"",cond:"",icon:"",temp:"",wind:"",windspeed:""},]};
+ weatherLocsDP.daytitle = buildHourlyHeaderTitle(ajaxedLoc["v3-wx-forecast-hourly-2day"].validTimeLocal[indexes[0]])
+ for (var hi = 0; hi < 4; hi++) {
+ weatherLocsDP.hour[hi].time = buildHourlyTimeTitle(ajaxedLoc["v3-wx-forecast-hourly-2day"].validTimeLocal[indexes[hi]])
+ weatherLocsDP.hour[hi].cond = ajaxedLoc["v3-wx-forecast-hourly-2day"].wxPhraseShort[indexes[hi]].replace('M ', 'Mostly ').replace('P ','Partly ').replace('PMostly ', 'PM').replace('AMostly ', 'AM')
+ weatherLocsDP.hour[hi].icon = ajaxedLoc["v3-wx-forecast-hourly-2day"].iconCode[indexes[hi]]
+ weatherLocsDP.hour[hi].temp = ajaxedLoc["v3-wx-forecast-hourly-2day"].temperature[indexes[hi]]
+ weatherLocsDP.hour[hi].wind = ajaxedLoc["v3-wx-forecast-hourly-2day"].windDirectionCardinal[indexes[hi]] + ' ' + ajaxedLoc["v3-wx-forecast-hourly-2day"].windSpeed[indexes[hi]]
+ weatherLocsDP.hour[hi].windspeed= ajaxedLoc["v3-wx-forecast-hourly-2day"].windSpeed[indexes[hi]]
+ }
+ weatherLocsDP.displayname = ((i ==0 ) ? maincitycoords.displayname : locList[i-1].displayname)
+ weatherInfo.dayPart.weatherLocs.push(weatherLocsDP)
+ //daydesc
+ var weatherLocsDD = {noReport:false,displayname:"",day:[{name:"",desc:""},{name:"",desc:""},{name:"",desc:""},{name:"",desc:""}]}
+ var daycorrection = 0;
+ if (ajaxedLoc["v3-wx-forecast-daily-5day"].daypart[0].daypartName[0] == null) {
+ daycorrection = 1;
+ }
+ for (var hi = (ajaxedLoc["v3-wx-forecast-daily-5day"].daypart[0].daypartName[0] == null) ? 1 : 0; hi < 4 + daycorrection; hi++) {
+ weatherLocsDD.day[hi - daycorrection].name = (ajaxedLoc["v3-wx-forecast-daily-5day"].daypart[0].daypartName[hi].replace('Tomorrow', ajaxedLoc["v3-wx-forecast-daily-5day"].dayOfWeek[1]))
+ weatherLocsDD.day[hi - daycorrection].desc = ajaxedLoc["v3-wx-forecast-daily-5day"].daypart[0].narrative[hi] + ((ajaxedLoc["v3-wx-forecast-daily-5day"].daypart[0].qualifierPhrase[hi] != null && ajaxedLoc["v3-wx-forecast-daily-5day"].daypart[0].narrative[hi].includes(ajaxedLoc["v3-wx-forecast-daily-5day"].daypart[0].qualifierPhrase[hi]) === false) ? ajaxedLoc["v3-wx-forecast-daily-5day"].daypart[0].qualifierPhrase[hi] : '') + ((ajaxedLoc["v3-wx-forecast-daily-5day"].daypart[0].windPhrase[hi - daycorrection] != null && ajaxedLoc["v3-wx-forecast-daily-5day"].daypart[0].narrative[hi].includes(ajaxedLoc["v3-wx-forecast-daily-5day"].daypart[0].windPhrase[hi]) === false) ? ajaxedLoc["v3-wx-forecast-daily-5day"].daypart[0].windPhrase[hi] : '')
+ }
+ weatherLocsDD.displayname = ((i ==0 ) ? maincitycoords.displayname : locList[i-1].displayname)
+ weatherInfo.dayDesc.weatherLocs.push(weatherLocsDD)
+ //fiveday
+ var weatherLocsFD = {noReport:false,displayname:"",day:[{name:"",cond:"",icon:"",high:"",low:"",windspeed:""},{name:"",cond:"",icon:"",high:"",low:"",windspeed:""},{name:"",cond:"",icon:"",high:"",low:"",windspeed:""},{name:"",cond:"",icon:"",high:"",low:"",windspeed:""},{name:"",cond:"",icon:"",high:"",low:"",windspeed:""}]};
+ for (var hi = (ajaxedLoc["v3-wx-forecast-daily-5day"].daypart[0].daypartName[0] == null) ? 1 : 0, hidp = (ajaxedLoc["v3-wx-forecast-daily-5day"].daypart[0].daypartName[0] == null) ? 2 : 0; hi < 5 + daycorrection; hi++, hidp = hidp + 2) {
+ weatherLocsFD.day[hi - daycorrection].name = ajaxedLoc["v3-wx-forecast-daily-5day"].dayOfWeek[hi].substring(0,3)
+ weatherLocsFD.day[hi - daycorrection].icon = ajaxedLoc["v3-wx-forecast-daily-5day"].daypart[0].iconCode[hidp]
+ weatherLocsFD.day[hi - daycorrection].cond = ajaxedLoc["v3-wx-forecast-daily-5day"].daypart[0].wxPhraseShort[hidp].replace('M ', 'Mostly ').replace('P ','Partly ').replace('M ', 'Mostly ').replace('P ','Partly ').replace('PMostly ', 'PM').replace('AMostly ', 'AM');
+ weatherLocsFD.day[hi - daycorrection].high = ajaxedLoc["v3-wx-forecast-daily-5day"].temperatureMax[hi]
+ weatherLocsFD.day[hi - daycorrection].windspeed = ajaxedLoc["v3-wx-forecast-daily-5day"].daypart[0].windSpeed[hidp]
+ weatherLocsFD.day[hi - daycorrection].low = ajaxedLoc["v3-wx-forecast-daily-5day"].temperatureMin[hi]
+ }
+ weatherLocsFD.displayname = ((i ==0 ) ? maincitycoords.displayname : locList[i-1].displayname)
+ weatherInfo.fiveDay.weatherLocs.push(weatherLocsFD)
+ //bulletin
+ var weatherLocsWA = {displayname:"",pages:[]};
+ weatherLocsWA.displayname = ((i ==0 ) ? maincitycoords.displayname : locList[i-1].displayname)
+ if (ajaxedLoc["v3alertsHeadlines"] != undefined){
+ var displayday;
+ var bulletintext = "";
+ var ret = [];
+ var ai=0;
+ //info
+ //get only weather alers
+ for (ai=0; ai<=ajaxedLoc["v3alertsHeadlines"].alerts.length - 1; ai++) {
+ warning = ajaxedLoc["v3alertsHeadlines"].alerts[ai].categories[0].category;
+ if (warning == "Met") {
+ ret.push({idx:ai, priority: getWarningPosition(ajaxedLoc["v3alertsHeadlines"].alerts[ai].eventDescription)})
+ }
+ };
+ if (ret.length != 0) {
+ ret.sort(function(a,b) {return a.priority - b.priority;});
+
+ for (ai of ret) {
+ var icount = 0;
+ getexpiredate = function(expiretime) {
+ dateFns.format(new Date(expiretime), "h:mm");
+ if (dateFns.isToday(expiretime) != true) {
+ var numday = dateFns.getDay(expiretime);
+ displayday = {"0":"SUN","1":"MON","2":"TUE","3":"WED","4":"THU","5":"FRI","6":"SAT"}[numday] + ".";
+ } else {
+ displayday = "Today."
+ }
+ return dateFns.format(new Date(expiretime), "h:mm A ") + displayday
+ }
+ if (icount != ret.length - 1) {
+ bulletintext += ajaxedLoc["v3alertsHeadlines"].alerts[ai.idx].eventDescription + " in effect until " + (getexpiredate(ajaxedLoc["v3alertsHeadlines"].alerts[ai.idx].expireTimeLocal) + "\n \n")
+ } else {
+ bulletintext += ajaxedLoc["v3alertsHeadlines"].alerts[ai.idx].eventDescription + " in effect until " + (getexpiredate(ajaxedLoc["v3alertsHeadlines"].alerts[ai.idx].expireTimeLocal) + "\n \n")
+ }
+ var icount = icount + 1;
+ }
+
+ function splitLines() {
+
+ var warningsplitstr = bulletintext.split(/(?![^\n]{1,40}$)([^\n]{1,40})\s/g)
+ warningsplitstr.pop()
+ warningsplitstr.pop()
+ var warningpageidx = 0;
+ var warninglineidx = 0;
+ warningsplitstr.forEach(warningline => {
+ if (warningline != "") {
+ if (warninglineidx == 0) {
+ weatherLocsWA.pages[warningpageidx] = ""
+ }
+ weatherLocsWA.pages[warningpageidx] += (warningline + '
')
+ warninglineidx += 1;
+ if (warninglineidx == 7) {
+ warningpageidx += 1
+ warninglineidx = 0
+ }
+ }
+ });
+ }
+ splitLines()
+ weatherInfo.bulletin.weatherLocs.push(weatherLocsWA)
+ }
+ }
+ });
+ })
+}
+
+function grabSideandLowerBarData() {
+ var url = "https://api.weather.com/v3/aggcommon/v3alertsHeadlines;v3-wx-forecast-daily-5day;v3-wx-observations-current;v3-wx-forecast-hourly-2day?geocodes="
+ url += `${maincitycoords.lat},${maincitycoords.lon};`
+ url += "&language=en-US&units=e&format=json&apiKey=" + api_key
+
+ $.getJSON(url, function(data) {
+ //Extra locations
+ var ajaxedLoc = data[0]
+ weatherInfo.currentCond.sidebar.temp = ajaxedLoc["v3-wx-observations-current"].temperature
+ weatherInfo.currentCond.sidebar.cond = ajaxedLoc["v3-wx-observations-current"].wxPhraseLong
+ weatherInfo.currentCond.sidebar.icon = ajaxedLoc["v3-wx-observations-current"].iconCode
+ weatherInfo.currentCond.sidebar.humid = ajaxedLoc["v3-wx-observations-current"].relativeHumidity
+ weatherInfo.currentCond.sidebar.dewpt = ajaxedLoc["v3-wx-observations-current"].temperatureDewPoint
+ weatherInfo.currentCond.sidebar.pressure = ajaxedLoc["v3-wx-observations-current"].pressureAltimeter
+ weatherInfo.currentCond.sidebar.pressureTrend = ((ajaxedLoc["v3-wx-observations-current"].pressureTendencyCode === 1 || ajaxedLoc["v3-wx-observations-current"].pressureTendencyCode === 3) ? '↑' : (ajaxedLoc["v3-wx-observations-current"].pressureTendencyCode === 2 || ajaxedLoc["v3-wx-observations-current"].pressureTendencyCode === 4) ? '↓' : ' S')
+ weatherInfo.currentCond.sidebar.wind = ((ajaxedLoc["v3-wx-observations-current"].windDirectionCardinal == "CALM" || ajaxedLoc["v3-wx-observations-current"].windSpeed == 0) ? 'calm' : ajaxedLoc["v3-wx-observations-current"].windDirectionCardinal) + ' ' + ((ajaxedLoc["v3-wx-observations-current"].windSpeed === 0) ? '' : ajaxedLoc["v3-wx-observations-current"].windSpeed)
+ weatherInfo.currentCond.sidebar.windspeed = ajaxedLoc["v3-wx-observations-current"].windSpeed
+ weatherInfo.currentCond.sidebar.gust = ((ajaxedLoc["v3-wx-observations-current"].windGust!=undefined) ? ajaxedLoc["v3-wx-observations-current"].windGust + " mph" : "none")
+ weatherInfo.currentCond.sidebar.visibility = ajaxedLoc["v3-wx-observations-current"].visibility
+ weatherInfo.currentCond.sidebar.uvidx = ajaxedLoc["v3-wx-observations-current"].uvDescription
+ weatherInfo.currentCond.sidebar.ceiling = ajaxedLoc["v3-wx-observations-current"].cloudCeiling
+ weatherInfo.currentCond.sidebar.feelslike.type = ((ajaxedLoc["v3-wx-observations-current"].temperature != ajaxedLoc["v3-wx-observations-current"].temperatureHeatIndex) ? "heat index" : ((ajaxedLoc["v3-wx-observations-current"].temperatureWindChill != ajaxedLoc["v3-wx-observations-current"].temperature) ? "wind chill" : "dontdisplay"))
+ weatherInfo.currentCond.sidebar.feelslike.val = ajaxedLoc["v3-wx-observations-current"].temperatureFeelsLike
+ weatherInfo.currentCond.sidebar.displayname = maincitycoords.displayname
+ //day part
+ //functions converting hourly data into daypart
+ var indexes = calcHourlyReport(ajaxedLoc["v3-wx-forecast-hourly-2day"]);
+ function buildHourlyTimeTitle(time){
+ var hour=dateFns.getHours(time);
+ if (hour===0) {
+ return 'Midnight';
+ } else if (hour===12){
+ return 'Noon';
+ }
+ return (dateFns.format(time,'h a')).replace(" ", "");
+ }
+ //get reporting hours: 12am, 6am, 12pm, 3pm, 5pm, 8pm...
+ function calcHourlyReport(data) {
+ var ret = [],
+ targets = [0, 6, 12, 15, 17, 20], // hours that we report
+ current = dateFns.getHours(new Date()),
+ now = new Date(),
+ //firsthour = targets[ getNextHighestIndex(targets, current) ],
+ start,
+ hour, hi=0;
+
+ switch (true) {
+ case (current < 3):
+ start = 6; //before 3:00
+ case (current < 9):
+ start = 12; break; //before 9:00 after 3:00
+ case (current < 12):
+ start = 15; break; //before 12:00 after 9:00
+ case (current < 14):
+ start = 17; break; //before 2:00 after 12:00
+ case (current < 17):
+ start = 20; break; //before 5:00 after 2:00
+ case (current < 20):
+ start = 0; break; //before 8:00 after 5:00
+ default:
+ start = 6;
+ }
+ while(ret.length<4){
+ // hour must be equal or greater than current
+ hour = dateFns.getHours(data.validTimeLocal[hi] );
+ if ( dateFns.isAfter(data.validTimeLocal[hi], now) && (hour==start || ret.length>0) ) {
+ if ( targets.indexOf(hour)>=0 ) { // it is in our target list so record its index
+ ret.push(hi);
+ }
+ }
+ hi++;
+ }
+ return ret;
+ }
+ function buildHourlyHeaderTitle(time) {
+ var today = new Date(),
+ tomorrow = dateFns.addDays(today, 1);
+ sforecast = "'s Forecast";
+
+ // title based on the first hour reported
+ switch (dateFns.getHours(time)) {
+
+ case 6: // 6 - Nextday's Forecast / Today's Forecast
+ // if 6am today
+ if (dateFns.isToday(time)) {
+ return dateFns.format(today, 'dddd') + sforecast;
+ }
+ case 0: // 0 - Nextday's Forecast
+ return dateFns.format(tomorrow, 'dddd') + sforecast;
+
+ case 12:
+ return 'This Afternoon';
+
+ case 15:
+ return "Today's Forecast";
+
+ case 17:
+ return "Tonight's Forecast";
+
+ case 20:
+ return dateFns.format(today, 'ddd') + ' Night/' + dateFns.format(tomorrow, 'ddd');
+
+ }
+ }
+
+ weatherInfo.dayPart.lowerbar.daytitle = buildHourlyHeaderTitle(ajaxedLoc["v3-wx-forecast-hourly-2day"].validTimeLocal[indexes[0]])
+ for (var hi = 0; hi < 4; hi++) {
+ weatherInfo.dayPart.lowerbar.hour[hi].time = buildHourlyTimeTitle(ajaxedLoc["v3-wx-forecast-hourly-2day"].validTimeLocal[indexes[hi]])
+ weatherInfo.dayPart.lowerbar.hour[hi].cond = ajaxedLoc["v3-wx-forecast-hourly-2day"].wxPhraseShort[indexes[hi]].replace('M ', 'Mostly ').replace('P ','Partly ').replace('PMostly ', 'PM').replace('AMostly ', 'AM')
+ weatherInfo.dayPart.lowerbar.hour[hi].icon = ajaxedLoc["v3-wx-forecast-hourly-2day"].iconCode[indexes[hi]]
+ weatherInfo.dayPart.lowerbar.hour[hi].temp = ajaxedLoc["v3-wx-forecast-hourly-2day"].temperature[indexes[hi]]
+ weatherInfo.dayPart.lowerbar.hour[hi].wind = ajaxedLoc["v3-wx-forecast-hourly-2day"].windDirectionCardinal[indexes[hi]] + ' ' + ajaxedLoc["v3-wx-forecast-hourly-2day"].windSpeed[indexes[hi]]
+ weatherInfo.dayPart.lowerbar.hour[hi].windspeed= ajaxedLoc["v3-wx-forecast-hourly-2day"].windSpeed[indexes[hi]]
+ }
+ weatherInfo.dayPart.lowerbar.displayname = maincitycoords.displayname
+ //daydesc
+ var daycorrection = 0;
+ if (ajaxedLoc["v3-wx-forecast-daily-5day"].daypart[0].daypartName[0] == null) {
+ daycorrection = 1;
+ }
+ for (var hi = (ajaxedLoc["v3-wx-forecast-daily-5day"].daypart[0].daypartName[0] == null) ? 1 : 0; hi < 4 + daycorrection; hi++) {
+ weatherInfo.dayDesc.lowerbar.day[hi - daycorrection].name = (ajaxedLoc["v3-wx-forecast-daily-5day"].daypart[0].daypartName[hi].replace('Tomorrow', ajaxedLoc["v3-wx-forecast-daily-5day"].dayOfWeek[1]))
+ weatherInfo.dayDesc.lowerbar.day[hi - daycorrection].desc = ajaxedLoc["v3-wx-forecast-daily-5day"].daypart[0].narrative[hi] + ((ajaxedLoc["v3-wx-forecast-daily-5day"].daypart[0].qualifierPhrase[hi] != null && ajaxedLoc["v3-wx-forecast-daily-5day"].daypart[0].narrative[hi].includes(ajaxedLoc["v3-wx-forecast-daily-5day"].daypart[0].qualifierPhrase[hi]) === false) ? ajaxedLoc["v3-wx-forecast-daily-5day"].daypart[0].qualifierPhrase[hi] : '') + ((ajaxedLoc["v3-wx-forecast-daily-5day"].daypart[0].windPhrase[hi - daycorrection] != null && ajaxedLoc["v3-wx-forecast-daily-5day"].daypart[0].narrative[hi].includes(ajaxedLoc["v3-wx-forecast-daily-5day"].daypart[0].windPhrase[hi]) === false) ? ajaxedLoc["v3-wx-forecast-daily-5day"].daypart[0].windPhrase[hi] : '')
+ }
+ weatherInfo.dayDesc.lowerbar.displayname = maincitycoords.displayname
+ //fiveday
+ var weatherLocsFD = {displayname:"",day:[{name:"",cond:"",icon:"",high:"",low:""},{name:"",cond:"",icon:"",high:"",low:""},{name:"",cond:"",icon:"",high:"",low:""},{name:"",cond:"",icon:"",high:"",low:""},{name:"",cond:"",icon:"",high:"",low:""}]};
+ for (var hi = (ajaxedLoc["v3-wx-forecast-daily-5day"].daypart[0].daypartName[0] == null) ? 1 : 0, hidp = (ajaxedLoc["v3-wx-forecast-daily-5day"].daypart[0].daypartName[0] == null) ? 2 : 0; hi < 5 + daycorrection; hi++, hidp = hidp + 2) {
+ weatherInfo.fiveDay.lowerbar.day[hi - daycorrection].name = ajaxedLoc["v3-wx-forecast-daily-5day"].dayOfWeek[hi].substring(0,3)
+ weatherInfo.fiveDay.lowerbar.day[hi - daycorrection].windspeed = ajaxedLoc["v3-wx-forecast-daily-5day"].daypart[0].windSpeed[hidp]
+ weatherInfo.fiveDay.lowerbar.day[hi - daycorrection].icon = ajaxedLoc["v3-wx-forecast-daily-5day"].daypart[0].iconCode[hidp]
+ weatherInfo.fiveDay.lowerbar.day[hi - daycorrection].cond = ajaxedLoc["v3-wx-forecast-daily-5day"].daypart[0].wxPhraseShort[hidp].replace('M ', 'Mostly ').replace('P ','Partly ').replace('M ', 'Mostly ').replace('P ','Partly ').replace('PMostly ', 'PM').replace('AMostly ', 'AM');
+ weatherInfo.fiveDay.lowerbar.day[hi - daycorrection].high = ajaxedLoc["v3-wx-forecast-daily-5day"].temperatureMax[hi]
+ weatherInfo.fiveDay.lowerbar.day[hi - daycorrection].low = ajaxedLoc["v3-wx-forecast-daily-5day"].temperatureMin[hi]
+ weatherInfo.fiveDay.lowerbar.day[hi - daycorrection].weekend = ((dateFns.isWeekend(ajaxedLoc["v3-wx-forecast-daily-5day"].validTimeLocal[hi])) ? ' weekend' : '')
+ }
+ weatherInfo.fiveDay.lowerbar.displayname = maincitycoords.displayname
+
+ //bulletin
+ if (ajaxedLoc["v3alertsHeadlines"] != undefined){
+ var displayday;
+ var bulletintext = "";
+ var ret = [], sret = [];
+ var ai=0;
+ //info
+ //get only weather alers
+ for (ai=0; ai<=ajaxedLoc["v3alertsHeadlines"].alerts.length - 1; ai++) {
+ warning = ajaxedLoc["v3alertsHeadlines"].alerts[ai].categories[0].category;
+ if (warning == "Met") {
+ ret.push({idx:ai, priority: getWarningPosition(ajaxedLoc["v3alertsHeadlines"].alerts[ai].eventDescription)})
+ if (ajaxedLoc["v3alertsHeadlines"].alerts[ai].eventDescription == "Severe Thunderstorm Warning" || ajaxedLoc["v3alertsHeadlines"].alerts[ai].eventDescription == "Flash Flood Warning" || ajaxedLoc["v3alertsHeadlines"].alerts[ai].eventDescription == "Tornado Warning") {
+ sret.push({idx:ai, priority:ajaxedLoc["v3alertsHeadlines"].alerts[ai].eventDescription})
+ }
+ }
+ };
+ if (ret.length != 0) {
+ ret.sort(function(a,b) {return a.priority - b.priority;});
+ function pushAlert(aai) {
+ $.getJSON('https://api.weather.com/v3/alerts/detail?alertId='+ ajaxedLoc["v3alertsHeadlines"].alerts[ret[aai].idx].detailKey +'&format=json&language=en-US&apiKey=' + api_key, function(adata) {
+ var alertt = {name:"", desc:"", status:"", significance:""}
+ alertt.name = ajaxedLoc["v3alertsHeadlines"].alerts[ret[aai].idx].eventDescription
+ alertt.significance = ajaxedLoc["v3alertsHeadlines"].alerts[ret[aai].idx].significance
+ alertt.status = ((ajaxedLoc["v3alertsHeadlines"].alerts[ret[aai].idx].messageType == " Update") ? 'UPDATE' : (ajaxedLoc["v3alertsHeadlines"].alerts[ret[aai].idx].messageType == "Cancel") ? " CANCELLATION" : "")
+ alertt.desc = adata.alertDetail.texts[0].description
+ weatherInfo.bulletin.marqueewarnings.push(alertt)
+ if (aai < (ret.length - 1)) {pushAlert(aai = aai + 1)};
+ });
+ };
+ pushAlert(0)
+ }
+
+ if (sret.length != 0) {
+ weatherInfo.bulletin.severeweathermode = true;
+ sret.sort(function(a,b) {return a.priority - b.priority;});
+ function pushSevereAlert(aai) {
+ $.getJSON('https://api.weather.com/v3/alerts/detail?alertId='+ ajaxedLoc["v3alertsHeadlines"].alerts[sret[i]].detailKey +'&format=json&language=en-US&apiKey=' + api_key, function(sdata) {
+ var severewarn = {warningname:"", warningdesc:"", warningstatus:""}
+ severewarn.warningname = ajaxedLoc["v3alertsHeadlines"].alerts[sret[aai].idx].eventDescription
+ severewarn.warningstatus = ((ajaxedLoc["v3alertsHeadlines"].alerts[sret[aai].idx].messageType == " Update") ? 'UPDATE' : (ajaxedLoc["v3alertsHeadlines"].alerts[sret[aii].idx].messageType == "Cancel") ? " CANCELLATION" : "")
+ severewarn.warningdesc = sdata.alertDetail.texts[0].description
+ weatherInfo.bulletin.severewarnings.push(severewarn)
+ if (aai < (sret.length - 1)) {pushAlert(aai = aai + 1)};
+ });
+ };
+ pushSevereAlert(0)
+ }
+ };
+
+});
+}
+function grabAlamanacSlidesData() {
+ url = 'https://api.weather.com/v3/aggcommon/v3-wx-almanac-daily-1day;v3-wx-observations-current?geocode=' + maincitycoords.lat + ',' + maincitycoords.lon + "&format=json&language=en-US&units=e" + "&day=" + dateFns.format(new Date(), "D") + "&month=" + dateFns.format(new Date(),"M") + "&apiKey=" + api_key
+ $.getJSON(url, function(data) {
+ weatherInfo.alamanac.displayname = maincitycoords.displayname
+ weatherInfo.alamanac.date = dateFns.format(new Date(),"MMMM D")
+ weatherInfo.alamanac.avghigh = data["v3-wx-almanac-daily-1day"].temperatureAverageMax[0]
+ weatherInfo.alamanac.avglow = data["v3-wx-almanac-daily-1day"].temperatureAverageMin[0]
+ weatherInfo.alamanac.rechigh = data["v3-wx-almanac-daily-1day"].temperatureRecordMax[0]
+ weatherInfo.alamanac.reclow = data["v3-wx-almanac-daily-1day"].temperatureRecordMin[0]
+ weatherInfo.alamanac.rechighyear = data["v3-wx-almanac-daily-1day"].almanacRecordYearMax[0]
+ weatherInfo.alamanac.reclowyear = data["v3-wx-almanac-daily-1day"].almanacRecordYearMin[0]
+ weatherInfo.alamanac.sunset = dateFns.format(new Date(data["v3-wx-observations-current"].sunsetTimeLocal),"h:mm a")
+ weatherInfo.alamanac.sunrise = dateFns.format(new Date(data["v3-wx-observations-current"].sunriseTimeLocal),"h:mm a")
+ });
+}
+function grabHealthData() {
+ $.getJSON('https://api.weather.com/v3/wx/forecast/daily/5day?geocode='+ maincitycoords.lat + ',' + maincitycoords.lon +"&format=json&language=en-US&units=e&apiKey=" + api_key, function(data) {
+ var healthforecastdata = data
+ var starthidx = 0;
+ var starthidxdayonly = 0;
+ if (healthforecastdata.daypart[0].daypartName[0] == undefined) {
+ starthidx = 2;
+ starthidxdayonly = 1;
+ weatherInfo.healthforecast.dayidx = 2;
+ }
+ weatherInfo.healthforecast.displayname = maincitycoords.displayname
+ weatherInfo.healthforecast.day = healthforecastdata.dayOfWeek[starthidxdayonly];
+ weatherInfo.healthforecast.icon = healthforecastdata.daypart[0].iconCode[starthidx]
+ weatherInfo.healthforecast.high = healthforecastdata.temperatureMax[starthidxdayonly]
+ weatherInfo.healthforecast.low = healthforecastdata.temperatureMin[starthidxdayonly]
+ weatherInfo.healthforecast.precipChance = healthforecastdata.daypart[0].precipChance[starthidx] + '%'
+ weatherInfo.healthforecast.humid = healthforecastdata.daypart[0].relativeHumidity[starthidx] + '%'
+ weatherInfo.healthforecast.wind = (((healthforecastdata.daypart[0].windDirectionCardinal[starthidx] == "CALM") ? 'calm' : healthforecastdata.daypart[0].windDirectionCardinal[starthidx]) + ' ' + ((healthforecastdata.daypart[0].windSpeed[starthidx] === 0) ? '' : healthforecastdata.daypart[0].windSpeed[starthidx]))
+ weatherInfo.healthforecast.windspeed = healthforecastdata.daypart[0].windSpeed[starthidx]
+ });
+ $.getJSON('https://api.weather.com/v1/geocode/'+ maincitycoords.lat + '/' + maincitycoords.lon + '/observations/pollen.json?language=en-US&apiKey=' + api_key, function(pollendata) {
+ if (pollendata.pollenobservations !== undefined) {
+ if (pollendata.pollenobservations[0].stn_cmnt != "No Report" && pollendata.pollenobservations[0].stn_cmnt != "Equipment Failure" && pollendata.pollenobservations[0].stn_cmnt != "Reports only during weed pollen season" && pollendata.pollenobservations[0].stn_cmnt != "Does not report year round" && pollendata.pollenobservations[0].stn_cmnt != "Reports Suspended") {
+ if (pollendata.pollenobservations[0].total_pollen_cnt <= 9) {
+ weatherInfo.healthPollen.totalcat = 'Low'
+ } else if (pollendata.pollenobservations[0].total_pollen_cnt >= 10 && pollendata.pollenobservations[0].total_pollen_cnt <= 49) {
+ weatherInfo.healthPollen.totalcat = 'Moderate'
+ } else if (pollendata.pollenobservations[0].total_pollen_cnt >= 50 && pollendata.pollenobservations[0].total_pollen_cnt <= 499) {
+ weatherInfo.healthPollen.totalcat = 'High'
+ } else if (pollendata.pollenobservations[0].total_pollen_cnt >= 500) {
+ weatherInfo.healthPollen.totalcat = 'Very High'
+ };
+ weatherInfo.healthPollen.total = pollendata.pollenobservations[0].total_pollen_cnt
+ weatherInfo.healthPollen.types[0].treetype = 'Tree Pollen
' + ((pollendata.pollenobservations[0].treenames[0].tree_nm != "No Report") ? pollendata.pollenobservations[0].treenames[0].tree_nm : "")
+ weatherInfo.healthPollen.date = dateFns.format(new Date(pollendata.pollenobservations[0].rpt_dt), "MMMM D")
+ var pollentypes = ['tree', 'grass', 'weed', 'mold'];
+ pollentypes.forEach((pollentype, i) => {
+ weatherInfo.healthPollen.types[i].pollenidx = pollendata.pollenobservations[0].pollenobservation[i].pollen_idx
+ });
+ }
+ }
+ });
+ $.getJSON('https://api.weather.com/v2/indices/achePain/daypart/3day?geocode=' + maincitycoords.lat + ',' + maincitycoords.lon + "&language=en-US&format=json&apiKey=" + api_key, function(data) {
+ var achesindexdata = data
+ var startidx = 0;
+ if (achesindexdata.achesPainsIndex12hour.dayInd[0] == 'N') {
+ startidx = 1;
+ }
+ weatherInfo.healthAcheBreath.achesindex = achesindexdata.achesPainsIndex12hour.achesPainsIndex[startidx]
+ weatherInfo.healthAcheBreath.achescat = achesindexdata.achesPainsIndex12hour.achesPainsCategory[startidx]
+ weatherInfo.healthAcheBreath.date = dateFns.format(new Date(achesindexdata.achesPainsIndex12hour.fcstValidLocal[0]), "dddd")
+ });
+ $.getJSON('https://api.weather.com/v2/indices/breathing/daypart/3day?geocode=' + maincitycoords.lat + ',' + maincitycoords.lon + "&language=en-US&format=json&apiKey=" + api_key, function(data) {
+ var breathindexdata = data
+ var startidx = 0;
+ if (breathindexdata.breathingIndex12hour.dayInd[0] == 'N') {
+ startidx = 1;
+ }
+ weatherInfo.healthAcheBreath.breathindex = breathindexdata.breathingIndex12hour.breathingIndex[startidx]
+ weatherInfo.healthAcheBreath.breathcat = breathindexdata.breathingIndex12hour.breathingCategory[startidx]
+ });
+ $.getJSON('https://api.weather.com/v3/wx/globalAirQuality?geocode=' + maincitycoords.lat + ',' + maincitycoords.lon + "&language=en-US&scale=EPA&format=json&apiKey=" + api_key, function(data) {
+ var airqualitydata = data
+ weatherInfo.airquality.airqualityindex = airqualitydata.globalairquality.airQualityCategoryIndex
+ if (airqualitydata.globalairquality.primaryPollutant == "PM2.5" || airqualitydata.globalairquality.primaryPollutant == "PM10") {
+ weatherInfo.airquality.primarypolute = 'Fine Particulate'
+ } else {weatherInfo.airquality.primarypolute = airqualitydata.globalairquality.primaryPollutant};
+ weatherInfo.airquality.date = dateFns.format(new Date(airqualitydata.globalairquality.expireTimeGmt * 1000), "dddd")
+ });
+ $.getJSON('https://api.weather.com/v2/indices/uv/current?geocode=' + maincitycoords.lat + ',' + maincitycoords.lon + "&language=en-US&format=json&apiKey=" + api_key, function(data) {
+ var uvData = data
+ weatherInfo.uvindex.currentuv.index = uvData.uvIndexCurrent.uvIndex
+ weatherInfo.uvindex.currentuv.desc = uvData.uvIndexCurrent.uvDesc
+ });
+ $.getJSON('https://api.weather.com/v2/indices/uv/hourly/48hour?geocode=' + maincitycoords.lat + ',' + maincitycoords.lon + "&language=en-US&format=json&apiKey=" + api_key, function(data) {
+ var uvData = data
+ var indexes = calcHourlyReport(uvData.uvIndex1hour);
+ var i;
+ for (var i = 0; i < 3; i++) {
+ weatherInfo.uvindex.forecast[i].day = dateFns.format(new Date(uvData.uvIndex1hour.fcstValidLocal[indexes[i]]), 'ddd')
+ weatherInfo.uvindex.forecast[i].time = buildHourlyTimeTitle(uvData.uvIndex1hour.fcstValidLocal[indexes[i]])
+ weatherInfo.uvindex.forecast[i].index = uvData.uvIndex1hour.uvIndex[indexes[i]]
+ weatherInfo.uvindex.forecast[i].desc = uvData.uvIndex1hour.uvDesc[indexes[i]]
+ }
+
+ //get reporting hours: 6am, 12pm, 3pm
+ function buildHourlyTimeTitle(time){
+ var hour=dateFns.getHours(time);
+ return (dateFns.format(time,'h a')).replace(" ", "");
+ }
+ function calcHourlyReport(data) {
+ var hret = [],
+ targets = [9, 12, 15], // hours that we report
+ current = dateFns.getHours(new Date()),
+ now = new Date(),
+ //firsthour = targets[ getNextHighestIndex(targets, current) ],
+ start,
+ hour, i=0;
+ switch (true) {
+ case (current < 6):
+ start = 9;
+ case (current < 9):
+ start = 12; break;
+ case (current < 12):
+ start = 15; break;
+ case (current < 13):
+ start = 9; break;
+ default:
+ start = 9;
+ }
+ while(hret.length<3){
+
+ // hour must be equal or greater than current
+ hour = dateFns.getHours(data.fcstValidLocal[i] );
+ if ( dateFns.isAfter(data.fcstValidLocal[i], now) && (hour==start || hret.length>0) ) {
+
+ if ( targets.indexOf(hour)>=0 ) { // it is in our target list so record its index
+ hret.push(i);
+ }
+
+ }
+ i++;
+ }
+ return hret;
+ }
+ })
+}
+function pullCCTickerData() {
+ var ccurl = 'https://api.weather.com/v3/aggcommon/v3-wx-forecast-daily-5day;v3-wx-observations-current;v3-location-point?geocodes=';
+ // ajax the latest observation
+ if (ccTickerCitiesList.length != 0) {
+ ccTickerCitiesList.forEach((loc, i) => {
+ ccurl += `${loc.lat},${loc.lon};`
+ });
+ ccurl += '&language=en-US&units=e&format=json&apiKey='+ api_key
+ } else {
+ ccurl = 'https://api.weather.com/v3/aggcommon/v3-wx-forecast-daily-5day;v3-wx-observations-current;v3-location-point?geocodes=41.881832,-87.623177;44.986656,-93.258133;33.427204,-111.939896;46.877186,-96.789803;34.187042,-118.381256;33.660057,-117.998970;36.114647,-115.172813;21.315603,-157.858093;28.538336,-81.379234;43.0,-75.0;&language=en-US&units=e&format=json&apiKey='+ api_key
+ }
+ $.getJSON(ccurl, function(data) {
+ data.forEach((locationdata, i) => {
+ var ccLoc = {displayname:"",currentCond:{cond:"",temp:""},forecast:{cond:"",temp:""}}
+ var marqueeidx = 1;
+ if (locationdata['v3-wx-forecast-daily-5day'].daypart[0].daypartName[0] == undefined) {marqueeidx = 2;};
+ if (locationdata['v3-wx-forecast-daily-5day'].daypart[0].daypartName[marqueeidx] == "Tonight") {weatherInfo.ccticker.arrow = 'tonight';} else {weatherInfo.ccticker.arrow = (locationdata['v3-wx-forecast-daily-5day'].dayOfWeek[1].substring(0,3)).toLowerCase()};
+ ccLoc.displayname = locationdata['v3-location-point'].location.displayName + ': '
+ ccLoc.currentCond.temp = locationdata['v3-wx-observations-current'].temperature
+ ccLoc.currentCond.cond = (locationdata['v3-wx-observations-current'].wxPhraseLong).toLowerCase()
+ ccLoc.forecast.temp = locationdata['v3-wx-forecast-daily-5day'].daypart[0].temperature[marqueeidx]
+ ccLoc.forecast.cond = (locationdata['v3-wx-forecast-daily-5day'].daypart[0].wxPhraseLong[marqueeidx]).toLowerCase()
+ weatherInfo.ccticker.ccLocs.push(ccLoc)
+ });
+
+ });
+ };
+//loop data collection, slide loops data functions is done based on full cycle
+setInterval(function(){
+ grabSideandLowerBarData();
+ pullCCTickerData();
+}, 300000)
+
+//init 1 second before intro stops
+setTimeout(function() {
+ Loops();
+ Slides();
+ MarqueeMan();
+}, 4000)
+/*var weatherlinks;
+function grabData() {
+ var citySlidesUrl = "&language=en-US&units=e&format=json&apiKey='+ api_key"
+ locList.forEach((item, i) => {
+ "https://api.weather.com/v3/aggcommon/v3-wx-forecast-daily-5day;v3-wx-observations-current;v3-location-point?geocodes=41.881832,-87.623177;44.986656,-93.258133;33.427204,-111.939896;46.877186,-96.789803;34.187042,-118.381256;33.660057,-117.998970;36.114647,-115.172813;21.315603,-157.858093;28.538336,-81.379234;43.0,-75.0;&language=en-US&units=e&format=json&apiKey='+ api_key
+ });
+
+
+};
+function updateData() {
+
+};
+
+function InitLoops() {
+
+};*/
diff --git a/webroot/js/radar.js b/webroot/js/radar.js
index ac9d3aa..48c8853 100644
--- a/webroot/js/radar.js
+++ b/webroot/js/radar.js
@@ -46,6 +46,9 @@ function Radar(divIDin, intervalHoursIn, zoomIn, latitudeIn, longitudeIn, withSa
tileSize: 512,
zoomOffset: -1
}).addTo(map);
+ if (weatherInfo.radarTempUnavialable == true) {
+
+ } else {
if (withSat == true) {
$.getJSON("https://api.weather.com/v3/TileServer/series/productSet/PPAcore?filter=satrad&apiKey=" + api_key, function(data) {
for (var i = 0; i < data.seriesInfo.satrad.series.length; i++) {
@@ -93,7 +96,7 @@ function Radar(divIDin, intervalHoursIn, zoomIn, latitudeIn, longitudeIn, withSa
animationLoop()
}, 1000);
-
+ }
}
}
diff --git a/webroot/js/slides-loop.js b/webroot/js/slides-loop.js
index 96d7864..185a008 100644
--- a/webroot/js/slides-loop.js
+++ b/webroot/js/slides-loop.js
@@ -3,100 +3,17 @@
headings:
RADAR < MAIN CITY < CITY 1 < CITY 2
*/
-
+var showsevercityslides = false;
+var mainMap
// load slide data
- function Slides(dataMan) {
+ function Slides() {
severemode = false;
var radarSlideDuration = 60000,
slideDelay = 10000;
// for later
var selectval = 0;
- var ret = [];
- //severe weather mode / marquee management
- var foreDataAlert = dataMan.locations[0].forecasts('alert');
- if (foreDataAlert !== undefined){
- ret = []
- sret = []
- var ai=0;
- //info
- //get only weather alers
- for (ai=0; ai<=foreDataAlert.alerts.length - 1; ai++) {
- warning = foreDataAlert.alerts[ai].categories[0].category;
- if (warning == "Met") {
- ret.push(ai)
- if (foreDataAlert.alerts[ai].eventDescription == "Severe Thunderstorm Warning" || foreDataAlert.alerts[ai].eventDescription == "Flash Flood Warning" || foreDataAlert.alerts[ai].eventDescription == "Tornado Warning") {
- sret.push(ai)
- }
- }
- };
- if (ret.length != 0) {
- ret.sort(function(a, b){
- if (foreDataAlert.alerts[a].eventDescription < foreDataAlert.alerts[b].eventDescription) {
- return -1;
- }
- if (foreDataAlert.alerts[a].eventDescription > foreDataAlert.alerts[b].eventDescription) {
- return 1;
- }
- return 0
- });
- if (sret.length != 0) {
- severemode = true;
- $('#marqueeSevere').css("background","linear-gradient(to right, #510d08 0, #b41a08 100%)")
- $('.marqueeheadersevere').css("background","linear-gradient(to right, #d51e08 0, #b41a08 100%)")
- $('.marqueeheadersevere').css("color","#fff")
- $('.marqueeheadersevere').css("text-shadow","2px 2px 4px #000")
- var severeidx = 0;
- function switchSevereMarquee() {
- $.getJSON('https://api.weather.com/v3/alerts/detail?alertId='+ foreDataAlert.alerts[sret[severeidx]].detailKey +'&format=json&language=en-US&apiKey=' + api_key, function(data) {
- $('.marqueeheadersevere').text((foreDataAlert.alerts[sret[severeidx]].eventDescription + ((foreDataAlert.alerts[sret[severeidx]].messageType == " Update") ? 'UPDATE' : (foreDataAlert.alerts[sret[severeidx]].messageType == "Cancel") ? " CANCELLATION" : "")).toUpperCase());
- $('#arrow-img').fadeOut(0)
- $('#marqueeSevere').fadeIn(0)
- $('.marqueeheadersevere').fadeIn(0) //#868686
- $('#marqueeSevere').text(data.alertDetail.texts[0].description)
- $('#marqueeSevere')
- .marquee('destroy')
- .marquee({speed: 170, delayBeforeStart: 1000, pauseOnHover: true, pauseOnCycle: true})
- .on('finished', function(){
- switchSevereMarquee()
- });
- weatherAudio.playwarningbeep()
- });
- }
- switchSevereMarquee()
- } else {
- var warningdata;
- $.getJSON('https://api.weather.com/v3/alerts/detail?alertId='+ foreDataAlert.alerts[ret[0]].detailKey +'&format=json&language=en-US&apiKey=' + api_key, function(data) {
- $('.marqueeheadersevere').text((foreDataAlert.alerts[ret[0]].eventDescription + ((foreDataAlert.alerts[ret[0]].messageType == " Update") ? 'UPDATE' : (foreDataAlert.alerts[ret[0]].messageType == "Cancel") ? " CANCELLATION" : "")).toUpperCase());
- if (foreDataAlert.alerts[ret[0]].significance == "Y" || foreDataAlert.alerts[ret[0]].significance == "S") {
- $('#marqueeSevere').css('background','linear-gradient(to right, #853302 0, #a84503 100%)')
- $('.marqueeheadersevere').css("background","linear-gradient(to right, #e86d08 0, #a84403 100%)")
- $('.marqueeheadersevere').css("color","#000")
- $('.marqueeheadersevere').css("text-shadow", "0px 0px 0px #000")
- } else if (foreDataAlert.alerts[ret[0]].significance == "A") {
- $('#marqueeSevere').css("background", "linear-gradient(to right, #846811 0, #9b7d0e 100%)");
- $('.marqueeheadersevere').css('background', 'linear-gradient(to right, #e5dd20 0, #9b7d0e 100%)');
- $('.marqueeheadersevere').css("color", "#000");
- $('.marqueeheadersevere').css("text-shadow", "0px 0px 0px #000");
- } else if (foreDataAlert.alerts[ret[0]].significance == "W") {
- $('#marqueeSevere').css("background","linear-gradient(to right, #510d08 0, #b41a08 100%)")
- $('.marqueeheadersevere').css("background","linear-gradient(to right, #d51e08 0, #b41a08 100%)")
- $('.marqueeheadersevere').css("color","#fff")
- $('.marqueeheadersevere').css("text-shadow","2px 2px 4px #000")
- }
- $('#arrow-img').fadeOut(0)
- $('#marqueeSevere').fadeIn(0)
- $('.marqueeheadersevere').fadeIn(0) //#868686
- $('#marqueeSevere').text(data.alertDetail.texts[0].description)
- $('#marqueeSevere')
- .marquee({speed: 170, delayBeforeStart: 1000, pauseOnHover: true, pauseOnCycle: true})
- });
- }
- }
- }
- buildHeader();
- //if (dataMan.location[0].observations[0].alerts != undefined) {
- //}
+ buildHeader();
setTimeout(function() {
$('.radar-content').fadeOut(500);
$('.radar-color-legend').fadeOut(500, function() {
@@ -107,105 +24,430 @@ RADAR < MAIN CITY < CITY 1 < CITY 2
// loop cities
function nextCity(){
//severe weather mode
- if (severemode == true) {
-
- $('#minimap-cover').fadeIn(0)
+ if (weatherInfo.bulletin.severeweathermode == true) {
$('.city-slide-intro .segment').text(location.city);
$('#info-slides-header .hscroller').empty();
$('#info-slides-header .hscroller').append("SEVERE WEATHER UPDATE");
+ $('#current-info').fadeOut(0)
+ $('#current-info-severe').fadeIn(0)
+ $('#current-info-details').fadeIn(0)
+ loopssevereweathermode = true
+ $('#minimap').fadeOut(0)
+ $('#minimap-title').fadeOut(0)
$('.radar-slide .info-subheader').css('background', 'linear-gradient(to top, #868686 0, #868686 100%)')
- showBulletin();
- function showRadarS(lat, long, zoom, time) {
+ displaySevereAtmospheric(0)
+ showSevereSlides(0);
+ } else {
+ //non severe
+ advanceHeader();
+ var city = $('#info-slides-header .city.current');
- // fade out info, fade in radar
- weatherAudio.playLocalRadar();
- $('.radar-slide').fadeIn(0);
- $('.radar-content').fadeIn(500);
- weatherMan.mainMap = Radar("radar-1", 3, zoom, lat, long, false);
- $('.radar-color-legend').fadeIn(500);
- setTimeout(function() {
- $('.radar-content').fadeOut(500);
- $('.radar-color-legend').fadeOut(500, function() {
- $('.radar-slide').fadeOut(0);
- if (severemode == true) {
- showBulletin()
- } else {
- $('#info-slides-header .hscroller').empty();
- $('#marqueeSevere').fadeOut(0)
- $('.marqueeheadersevere').fadeOut(0)
- $('#arrow-img').fadeIn(0)
- $('.radar-slide .infosubheader').css('background','linear-gradient(to top, #fffe21 0, #db5a14 100%);')
- buildHeader();
- nextCity();
- }
- });
- }, 60500);
+ // is radar or city?
+ if (city[0].dataset.dname) {
+ // show slide deck for the current city
+ showCitySlides(city[0].dataset.dname, 0 );
+ } else {
+ if (city[0].classList.contains("radar")) {
+ showRadar(maincitycoords.lat, maincitycoords.lon, 8, 60000, false);
+ setTimeout(nextCity, 60500);
+ } else if (city[0].classList.contains("airport")) {
+ showAirport(0);
+ } else if (city[0].classList.contains("healthh")) {
+ showHealth(0);
+ } else if (city[0].classList.contains("beach")) {
+ showMarine(0);
}
- function showBulletin() {
- var foreDataAlert = dataMan.locations[0].forecasts('alert');
- var pages = [""];
- if (foreDataAlert !== undefined){
- $('.bulletin .frost-pane .warnings').empty()
- var displayday;
- //info
- //get only weather alers
+ }
+ }
+ }
- if (ret.length != 0) {
+ function showSevereSlides(idx) {
+ if (showsevercityslides == true) {
+ var currentDisplay,
+ displays = {
+ showBulletin() {
+ if (weatherInfo.bulletin.weatherLocs[0]) {
+ $('.bulletin .frost-pane .cityname').text(weatherInfo.bulletin.weatherLocs[0].displayname + " Area");
+ //fade in
+ $('.bulletin').fadeIn(0);
+ $('.bulletin .frost-pane').fadeIn(500);
- for (i of ret) {
- getexpiredate = function(expiretime) {
- dateFns.format(new Date(expiretime), "h:mm");
- if (dateFns.isToday(expiretime) != true) {
- var numday = dateFns.getDay(expiretime);
- displayday = {"0":"SUN","1":"MON","2":"TUE","3":"WED","4":"THU","5":"FRI","6":"SAT"}[numday] + ".";
- } else {
- displayday = "Today."
+ $('#subhead-noaa').fadeIn(500);
+ pages = weatherInfo.bulletin.weatherLocs[0].pages
+ makewarningPage(0)
+ function makewarningPage(warningpagenum) {
+ if (warningpagenum > 0) {
+ $('.bulletin .frost-pane').fadeOut(500, function() {
+ $('.bulletin .frost-pane .warnings').html(pages[warningpagenum])
+ $('.bulletin .frost-pane').fadeIn(500);
+ });
+ } else {
+ $('.bulletin .frost-pane .warnings').html(pages[warningpagenum])
+ $('.bulletin .frost-pane').fadeIn(500);
+ }
+ setTimeout(function() {
+ if (warningpagenum < (pages.length - 1)) {
+ makewarningPage(warningpagenum + 1)
+ } else {
+ $('.bulletin').fadeIn(0);
+ $('.bulletin .frost-pane').fadeOut(500);
+ $('#subhead-noaa').fadeOut(500, function() {
+ $('.bulletin').fadeOut(0);
+ wait(0)
+ });
+ }
+ }, slideDelay);
+ }
+ } else {wait(0)};
}
- return dateFns.format(new Date(expiretime), "h:mm A ") + displayday
- }
- if (i != ret.length - 1) {
- $('.bulletin .frost-pane .warnings').append(foreDataAlert.alerts[i].eventDescription + " in effect until " + getexpiredate(foreDataAlert.alerts[ret[i]].expireTimeLocal) + "\n \n")
- } else {
- $('.bulletin .frost-pane .warnings').append(foreDataAlert.alerts[i].eventDescription + " in effect until " + getexpiredate(foreDataAlert.alerts[ret[i]].expireTimeLocal) + "\n \n")
- }
- }
- function splitLines() {
- var warningsplitstr = $('.bulletin .frost-pane .warnings').text().split(/(?![^\n]{1,45}$)([^\n]{1,45})\s/g)
- warningsplitstr.pop()
- warningsplitstr.pop()
- var warningpageidx = 0;
- var warninglineidx = 0;
- console.log(pages)
- console.log(warningsplitstr)
- warningsplitstr.forEach(warningline => {
- if (warningline != "") {
- if (warninglineidx == 0) {
- pages[warningpageidx] = ""
+ // Currently (10 sec)
+ ,currentConditions() {
+ $('.severe-city-info-slide #subhead-title').text('Currently');
+ $('.severe-city-info-slide #subhead-city').text(weatherInfo.currentCond.weatherLocs[0].displayname);
+ if (weatherInfo.currentCond.weatherLocs[0].noReport == true) {
+ $('.severe-city-info-slide .noreport').fadeIn(500)
+ $('.severe-city-info-slide').fadeIn(0);
+ setTimeout(function() {
+ $('.severe-city-info-slide .noreport').fadeOut(500, function(){
+ $('.severe-city-info-slide').fadeOut(0);
+ wait(0);
+ });
+ }, slideDelay);
+ } else {
+ var strLabels = 'Humidity
Dew Point
Pressure
Wind
',
+ strData = weatherInfo.currentCond.weatherLocs[0].humid + '%
' + weatherInfo.currentCond.weatherLocs[0].dewpt + '
' + weatherInfo.currentCond.weatherLocs[0].pressure + " " + weatherInfo.currentCond.weatherLocs[0].pressureTrend + '
' + weatherInfo.currentCond.weatherLocs[0].wind + '
';
+ strLabels+='Gusts
';
+ strData+=weatherInfo.currentCond.weatherLocs[0].gust + '
';
+ if (weatherInfo.currentCond.weatherLocs[0].feelslike.type != "dontdisplay") {
+ strLabels+=weatherInfo.currentCond.weatherLocs[0].feelslike.type
+ strData+=weatherInfo.currentCond.weatherLocs[0].feelslike.val
}
- console.log(warningline)
- pages[warningpageidx] += (warningline + '
')
- warninglineidx += 1;
- if (warninglineidx == 7) {
- warningpageidx += 1
- warninglineidx = 0
- }
- }
- });
- //$('.bulletin .frost-pane .warnings').text($('.bulletin .frost-pane .warnings').text().replace(/(?![^\n]{1,40}$)([^\n]{1,40})\s/g, '$1\n'))
- //console.log($('.bulletin .frost-pane .warnings').html())
- makewarningPage(0)
- }
- splitLines()
+ $('.severe-city-info .frost-pane .labels').html(strLabels);
+ $('.severe-city-info .frost-pane .data').html(strData);
+
+ // right pane
+ $('.severe-city-info .icon').css('background-image', 'url("' + getCCicon(+weatherInfo.currentCond.weatherLocs[0].icon, weatherInfo.currentCond.weatherLocs[0].windspeed) + '")');
+ //$('.info-slide-content.airport .frost-pane.right .icon').css('background-image', 'url("' + getCCicon(+obsData(0).iconCode, obsData(0).current.wind_speed) + '")');
+ $('.severe-city-info .conditions').text(weatherInfo.currentCond.weatherLocs[0].cond);
+ $('.severe-city-info .temp').text(weatherInfo.currentCond.weatherLocs[0].temp);
+ weatherAudio.playCurrentConditions();
+
+ //fadein
+ $('.severe-city-info-slide').fadeIn(0);
+ $('.severe-city-info').fadeIn(500);
+ //fadeout and switch
+ setTimeout(function() {
+ $('.severe-city-info').fadeOut(500, function(){
+ $('.severe-city-info-slide').fadeOut(0);
+ wait(0);
+ });
+ }, slideDelay);
+ }
+ }
+ // Local Doppler Radar or Radar/Satellite (15 sec, zoomed out with cloud cover)
+ ,localDoppler(){
+ var showsat = Math.random()
+ if (showsat <= .5) {
+ showRadar(maincitycoords.lat, maincitycoords.lon, 6, slideDelay, true);
+ } else {
+ showRadar(maincitycoords.lat, maincitycoords.lon, 8, slideDelay, false);
+ }
+ wait(slideDelay + 500);
+ }
+
+ // daypart / hourly
+ ,forecast(fidx) {
+ //pick between day part or local forecast
+ if (selectval === 2 || selectval === 3) {
+ // reset tempbar animation
+ if (weatherInfo.dayPart.weatherLocs[0].noReport == true) {
+ $('.severe-city-info-slide #subhead-title').text(weatherInfo.dayPart.weatherLocs[0].daytitle);
+ $('.severe-city-info-slide').fadeIn(0);
+ $('.severe-city-info-slide .tempunavailable').fadeIn(500)
+ setTimeout(function() {
+ $('.severe-city-info-slide .tempunavailable').fadeOut(500, function(){
+ wait(0);
+ });
+ }, slideDelay);
+ } else {
+ $('.info-slide-content.severe-daypart .hour').each(function(){
+ $('.info-slide-content.severe-daypart .hour .tempbar').css("height", "0px")
+ $('.info-slide-content.severe-daypart .hour .tempbar .temp').css("opacity", "0%");
+ $('.info-slide-content.severe-daypart .hour .tempbar .wind').css("opacity", "0%");
+ i = i + 1
+ });
+ //hour title
+ $('.info-slide-content.severe-daypart .hour.i .thing .thingtext').text(weatherInfo.dayPart.weatherLocs[0].hour[0].time);
+ $('.info-slide-content.severe-daypart .hour.ii .thing .thingtext').text(weatherInfo.dayPart.weatherLocs[0].hour[1].time);
+ $('.info-slide-content.severe-daypart .hour.iii .thing .thingtext').text(weatherInfo.dayPart.weatherLocs[0].hour[2].time);
+ $('.info-slide-content.severe-daypart .hour.iv .thing .thingtext').text(weatherInfo.dayPart.weatherLocs[0].hour[3].time);
+
+ //temp
+ $('.info-slide-content.severe-daypart .hour.i .tempbar .temp').text(weatherInfo.dayPart.weatherLocs[0].hour[0].temp);
+ $('.info-slide-content.severe-daypart .hour.ii .tempbar .temp').text(weatherInfo.dayPart.weatherLocs[0].hour[1].temp);
+ $('.info-slide-content.severe-daypart .hour.iii .tempbar .temp').text(weatherInfo.dayPart.weatherLocs[0].hour[2].temp);
+ $('.info-slide-content.severe-daypart .hour.iv .tempbar .temp').text(weatherInfo.dayPart.weatherLocs[0].hour[3].temp);
+
+ //wind
+ $('.info-slide-content.severe-daypart .hour.i .tempbar .wind').text(weatherInfo.dayPart.weatherLocs[0].hour[0].wind);
+ $('.info-slide-content.severe-daypart .hour.ii .tempbar .wind').text(weatherInfo.dayPart.weatherLocs[0].hour[1].wind);
+ $('.info-slide-content.severe-daypart .hour.iii .tempbar .wind').text(weatherInfo.dayPart.weatherLocs[0].hour[2].wind);
+ $('.info-slide-content.severe-daypart .hour.iv .tempbar .wind').text(weatherInfo.dayPart.weatherLocs[0].hour[3].wind);
+
+ $('.info-slide-content.severe-daypart .hour.i .condition').text(weatherInfo.dayPart.weatherLocs[0].hour[0].cond);
+ $('.info-slide-content.severe-daypart .hour.ii .condition').text(weatherInfo.dayPart.weatherLocs[0].hour[1].cond);
+ $('.info-slide-content.severe-daypart .hour.iii .condition').text(weatherInfo.dayPart.weatherLocs[0].hour[2].cond);
+ $('.info-slide-content.severe-daypart .hour.iv .condition').text(weatherInfo.dayPart.weatherLocs[0].hour[3].cond);
+
+ //icon
+ $('.info-slide-content.severe-daypart .hour.i .icon').css('background-image', 'url("' + getCCicon(+weatherInfo.dayPart.weatherLocs[0].hour[0].icon, weatherInfo.dayPart.weatherLocs[0].hour[0].windspeed) + '")');
+ $('.info-slide-content.severe-daypart .hour.ii .icon').css('background-image', 'url("' + getCCicon(+weatherInfo.dayPart.weatherLocs[0].hour[1].icon, weatherInfo.dayPart.weatherLocs[0].hour[1].windspeed) + '")');
+ $('.info-slide-content.severe-daypart .hour.iii .icon').css('background-image', 'url("' + getCCicon(+weatherInfo.dayPart.weatherLocs[0].hour[2].icon, weatherInfo.dayPart.weatherLocs[0].hour[2].windspeed) + '")');
+ $('.info-slide-content.severe-daypart .hour.iv .icon').css('background-image', 'url("' + getCCicon(+weatherInfo.dayPart.weatherLocs[0].hour[3].icon, weatherInfo.dayPart.weatherLocs[0].hour[3].windspeed) + '")');
+
+ // calculate height of tempbars
+ $('.severe-city-info-slide #subhead-title').text(weatherInfo.dayPart.weatherLocs[0].daytitle);
+ var temps = [];
+ for (var i = 0; i < 4; i++) {
+ temps.push(weatherInfo.dayPart.weatherLocs[0].hour[i].temp);
+ }
+ var min = Math.min(...temps), // 54
+ max = Math.max(...temps), // 73
+ range = ((max-min) != 0) ? (max-min) : .001,
+ prange = (100-78), // percent range for bar height
+ hourlable = ['i', 'ii', 'iii', 'iv'],
+ temp, value, i = 0;
+ $('.info-slide-content.severe-daypart .hour').each(function(){
+ temp = weatherInfo.dayPart.weatherLocs[0].hour[i].temp
+ value = ((temp-min)/range) * prange + 78; // find percentage of range and translate to percent and add that to the starting css % height number
+ valueii = (value/100) * 165 // multiply percentage by max height
+ $('.info-slide-content.severe-daypart .hour.' + hourlable[i] + ' .tempbar').animate({height:valueii+"px"}, 1500,function(){
+ $('.info-slide-content.severe-daypart .hour .tempbar .temp').fadeTo('slow', 1);
+ $('.info-slide-content.severe-daypart .hour .tempbar .wind').fadeTo('slow', 1);
+ });
+ i = i + 1
+ })
+ //play narration
+ weatherAudio.playLocalforecastii();
+ //fade in
+ $('.severe-city-info-slide').fadeIn(0);
+ $('.info-slide-content.severe-daypart').fadeIn(500);
+ //for calculating when to show daypart
+ selectval = selectval + 1
+ //fadeout
+ setTimeout(function() {
+ $('.info-slide-content.severe-daypart').fadeOut(500, function() {
+ wait(0)
+ });
+ }, slideDelay);
+ }
+ } else {
+ // Local Forecast -Today (10 sec)
+ var div = '.info-slide-content.severe-forecast '
+ if (weatherInfo.dayDesc.weatherLocs[0].noReport == true) {
+ $('.severe-city-info-slide #subhead-title').text('Local Forecast');
+ $('.severe-city-info-slide').fadeIn(0);
+ $('.severe-city-info-slide .tempunavailable').fadeIn(500)
+ $('.info-slide-content.severe-forecast').fadeIn(500);
+ $(div + '.title').empty()
+ $(div + '.content').empty()
+ setTimeout(function() {
+ $('.info-slide-content.severe-forecast').fadeOut(500);
+ $('.severe-city-info-slide .tempunavailable').fadeOut(500, function(){
+ wait(0);
+ });
+ }, slideDelay);
+ } else {
+ function fillinfo() {
+
+ fidx = (fidx===undefined ? 0 : fidx);
+
+ $('.severe-city-info-slide #subhead-title').text('Local Forecast');
+ //replace tomorrow
+
+ $(div + '.title').text(weatherInfo.dayDesc.weatherLocs[0].day[fidx].name);
+
+ // content
+ resizeText(weatherInfo.dayDesc.weatherLocs[0].day[fidx].desc);
+ $(div + '.content').text(weatherInfo.dayDesc.weatherLocs[0].day[fidx].desc);
+
+ }
+ if (fidx === 0) {
+ weatherAudio.playLocalforecasti();
+ }
+
+ $('.severe-city-info-slide').fadeIn(0);
+ fillinfo();
+ $('.info-slide-content.severe-forecast').fadeIn(500);
+
+ setTimeout( function() {
+
+ if (fidx<3) {
+ $('.info-slide-content.severe-forecast').fadeOut(500, function() {
+ currentDisplay(fidx+1);
+ //fillinfo();
+ });
+ } else {
+ $('.info-slide-content.severe-forecast').fadeOut(500, function() {
+ selectval = selectval + 1
+ if (selectval === 4) {selectval = 0}
+ wait(0);
+ });
+ }
+
+ }, slideDelay)
+ }
+ }
+ }
+
+
+
+ // Extended Forecast(5 day columns)
+ ,extendedForecast() {
+ $('.severe-city-info-slide #subhead-title').text('Extended Forecast');
+ if (weatherInfo.fiveDay.weatherLocs[0].noReport == true) {
+ $('.severe-city-info-slide .tempunavailable').fadeIn(500)
+ setTimeout(function() {
+ $('.severe-city-info-slide .tempunavailable').fadeOut(500, function(){
+ $('.severe-city-info-slide').fadeOut(0);
+ wait(0);
+ });
+ }, slideDelay);
+ } else {
+ //days
+ $('.info-slide-content.severe-extended-forecast .thingday.i').text(weatherInfo.fiveDay.weatherLocs[0].day[0].name)
+ $('.info-slide-content.severe-extended-forecast .thingday.iiw').text(weatherInfo.fiveDay.weatherLocs[0].day[1].name)
+ $('.info-slide-content.severe-extended-forecast .thingday.iiiw').text(weatherInfo.fiveDay.weatherLocs[0].day[2].name)
+ $('.info-slide-content.severe-extended-forecast .thingday.ivw').text(weatherInfo.fiveDay.weatherLocs[0].day[3].name)
+ $('.info-slide-content.severe-extended-forecast .thingday.vw').text(weatherInfo.fiveDay.weatherLocs[0].day[4].name)
+
+ //icons
+ $('.info-slide-content.severe-extended-forecast .frost-pane.iw .icon').css('background-image', 'url("' + getCCicon(+weatherInfo.fiveDay.weatherLocs[0].day[0].icon, weatherInfo.fiveDay.weatherLocs[0].day[0].windspeed) + '")');
+ $('.info-slide-content.severe-extended-forecast .frost-pane.iiw .icon').css('background-image', 'url("' + getCCicon(+weatherInfo.fiveDay.weatherLocs[0].day[1].icon, weatherInfo.fiveDay.weatherLocs[0].day[1].windspeed) + '")');
+ $('.info-slide-content.severe-extended-forecast .frost-pane.iiiw .icon').css('background-image', 'url("' + getCCicon(+weatherInfo.fiveDay.weatherLocs[0].day[2].icon, weatherInfo.fiveDay.weatherLocs[0].day[2].windspeed) + '")');
+ $('.info-slide-content.severe-extended-forecast .frost-pane.ivw .icon').css('background-image', 'url("' + getCCicon(+weatherInfo.fiveDay.weatherLocs[0].day[3].icon, weatherInfo.fiveDay.weatherLocs[0].day[3].windspeed) + '")');
+ $('.info-slide-content.severe-extended-forecast .lfrost-pane.vw .icon').css('background-image', 'url("' + getCCicon(+weatherInfo.fiveDay.weatherLocs[0].day[4].icon, weatherInfo.fiveDay.weatherLocs[0].day[4].windspeed) + '")');
+
+ //conditions
+ $('.info-slide-content.severe-extended-forecast .frost-pane.iw .conditions').text(weatherInfo.fiveDay.weatherLocs[0].day[0].cond);
+ $('.info-slide-content.severe-extended-forecast .frost-pane.iiw .conditions').text(weatherInfo.fiveDay.weatherLocs[0].day[1].cond);
+ $('.info-slide-content.severe-extended-forecast .frost-pane.iiiw .conditions').text(weatherInfo.fiveDay.weatherLocs[0].day[2].cond);
+ $('.info-slide-content.severe-extended-forecast .frost-pane.ivw .conditions').text(weatherInfo.fiveDay.weatherLocs[0].day[3].cond);
+ $('.info-slide-content.severe-extended-forecast .lfrost-pane.vw .conditions').text(weatherInfo.fiveDay.weatherLocs[0].day[4].cond);
+
+ //high
+ $('.info-slide-content.severe-extended-forecast .frost-pane.iw .temphigh').text(weatherInfo.fiveDay.weatherLocs[0].day[0].high)
+ $('.info-slide-content.severe-extended-forecast .frost-pane.iiw .temphigh').text(weatherInfo.fiveDay.weatherLocs[0].day[1].high)
+ $('.info-slide-content.severe-extended-forecast .frost-pane.iiiw .temphigh').text(weatherInfo.fiveDay.weatherLocs[0].day[2].high)
+ $('.info-slide-content.severe-extended-forecast .frost-pane.ivw .temphigh').text(weatherInfo.fiveDay.weatherLocs[0].day[3].high)
+ $('.info-slide-content.severe-extended-forecast .lfrost-pane.vw .temphigh .temphightext').text(weatherInfo.fiveDay.weatherLocs[0].day[4].high)
+
+ //low
+ $('.info-slide-content.severe-extended-forecast .frost-pane.iw .templow').text(weatherInfo.fiveDay.weatherLocs[0].day[0].low)
+ $('.info-slide-content.severe-extended-forecast .frost-pane.iiw .templow').text(weatherInfo.fiveDay.weatherLocs[0].day[1].low)
+ $('.info-slide-content.severe-extended-forecast .frost-pane.iiiw .templow').text(weatherInfo.fiveDay.weatherLocs[0].day[2].low)
+ $('.info-slide-content.severe-extended-forecast .frost-pane.ivw .templow').text(weatherInfo.fiveDay.weatherLocs[0].day[3].low)
+ $('.info-slide-content.severe-extended-forecast .lfrost-pane.vw .templow').text(weatherInfo.fiveDay.weatherLocs[0].day[4].low)
+
+ $('.info-slide-content.severe-extended-forecast').fadeIn(500);
+ //buildailycalculating when to show daypart
+ //fadeout
+ setTimeout(function() {
+ $('.info-slide-content.severe-extended-forecast').fadeOut(500, function() {
+ $('.city-info-slide').fadeOut(0);
+ wait(0)
+ });
+ }, slideDelay);
+ }
+ }
+ }
+ keys = Object.keys(displays);
+ if (idx ') .appendTo($container) .css('font-size', s + 'px') .css('line-height', '125%') .html(text);
+
+ // have to display parent so we can get measurements
+ $container.closest('.info-slide-content').show();
+
+ $test.width($container.width() );
+ while ($test.outerHeight(true) >= (400) ) {
+ s -= 1;
+ $test.css('font-size', s + 'px');
+ }
+ $container.closest('.info-slide-content').hide();
+ $container .text(text) .css('font-size', s + 'px');
+ $test.remove();
+ };
+
+ } else {
+ var currentDisplay,
+ displays = {
+ bulletin() {
+ if (weatherInfo.bulletin.weatherLocs[0]) {
+ $('.bulletin .frost-pane .cityname').text(weatherInfo.bulletin.weatherLocs[0].displayname + " Area");
+ //fade in
$('.bulletin').fadeIn(0);
$('.bulletin .frost-pane').fadeIn(500);
+
$('#subhead-noaa').fadeIn(500);
+ pages = weatherInfo.bulletin.weatherLocs[0].pages
+ makewarningPage(0)
function makewarningPage(warningpagenum) {
if (warningpagenum > 0) {
$('.bulletin .frost-pane').fadeOut(500, function() {
@@ -222,103 +464,95 @@ RADAR < MAIN CITY < CITY 1 < CITY 2
} else {
$('.bulletin').fadeIn(0);
$('.bulletin .frost-pane').fadeOut(500);
- $('#subhead-noaa').fadeOut(500, function() {
- $('.bulletin').fadeOut(0);
- if (severemode == true) {
- showRadarS(dataMan.locations[0].lat, dataMan.locations[0].long, 8, 60000)
- } else {
- $('#minimap-cover').fadeOut(0)
- $('#info-slides-header .hscroller').empty();
- $('#marqueeSevere').fadeOut(0)
- $('.marqueeheadersevere').fadeOut(0)
- $('#arrow-img').fadeIn(0)
- $('.radar-slide .infosubheader').css('background','linear-gradient(to top, #fffe21 0, #db5a14 100%);')
- buildHeader();
- nextCity();
- }
- });
+ $('#subhead-noaa').fadeOut(500, function() {
+ $('.bulletin').fadeOut(0);
+ wait(0)
+ });
}
}, slideDelay);
}
- } else {
- if (severemode == true) {
- showRadarS(dataMan.locations[0].lat, dataMan.locations[0].long, 8, 60000)
- } else {
- $('#info-slides-header .hscroller').empty();
- $('#marqueeSevere').fadeOut(0)
- $('.marqueeheadersevere').fadeOut(0)
- $('#arrow-img').fadeIn(0)
- $('.radar-slide .infosubheader').css('background','linear-gradient(to top, #fffe21 0, #db5a14 100%);')
- buildHeader();
- nextCity();
- }
+ } else {wait(0)}
}
- } else {
- if (severemode == true) {
- showRadarS(dataMan.locations[0].lat, dataMan.locations[0].long, 8, 60000)
+ ,radar() {
+ weatherAudio.playLocalRadar();
+ $('.radar-slide').fadeIn(0);
+ if (weatherInfo.radarTempUnavialable == true) {
+ $('.radar-slide .tempunavailable').fadeIn(500);
+ }
+ $('.radar-content').fadeIn(500);
+ mainMap = new Radar("radar-1", 3, 8, maincitycoords.lat, maincitycoords.lon, false);
+ $('.radar-color-legend').fadeIn(500);
+ wait(60500)
+ }
+ }
+ };
+ keys = Object.keys(displays);
+ if (idx