diff --git a/webroot/index.html b/webroot/index.html index 3df6e9d..39c041f 100644 --- a/webroot/index.html +++ b/webroot/index.html @@ -58,6 +58,26 @@ + + + + + + -
+
@@ -225,6 +685,11 @@
+
PAST 3 HOURS
@@ -255,7 +720,26 @@ 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. - + + diff --git a/webroot/js/audio.js b/webroot/js/audio.js index bc23254..545bbb2 100644 --- a/webroot/js/audio.js +++ b/webroot/js/audio.js @@ -6,49 +6,49 @@ function WeatherAudio() { mobilePlaying = false; (function() { - + $('body').append($players); // start the music buildMusicArray(musicarr); - shuffle(musicarr); + shuffle(musicarr); startPlaying(musicarr, true); - + function buildMusicArray(arr) { var musicpath = "music/"; // insert track names - for (var i = 1; i<66; i++) { + for (var i = 32; i<66; i++) { arr.push(musicpath + "Track " + String('0'+i).slice(-2) + '.mp3'); - } + } - } + } })(); - + function startPlaying(arrPlayList, bLoop) { - - + + // only allow one set of players to be created var myclass = (bLoop ? 'music' : 'voice'); if ($players.find('.' + myclass).length>0) {return} - var current=-1, + var current=-1, len = arrPlayList.length, - $player = initPlayer('p1'), + $player = initPlayer('p1'), $preloader = initPlayer('p2'), $myplayers = $players.find('.' + myclass); // init the event to output ID3 track info if this is a music play if (myclass=='music') { - $players.find('.music').bind($.jPlayer.event.play, + $players.find('.music').bind($.jPlayer.event.play, function() { // event.jPlayer.status.media - - if (that.playCallback) { - + + if (that.playCallback) { + var mp3url = $(this).data('jPlayer').status.src, relativeUrl = mp3url.replace('%20',' ').slice(-arrPlayList[current].length); @@ -62,27 +62,27 @@ function WeatherAudio() { } } } - ); + ); } else { // duck the music if we're going to play a vocal $players.find('.music').jPlayer('volume', 0.30); } // prime the preloader - $preloader.jPlayer("setMedia", {mp3:arrPlayList[0]}); + $preloader.jPlayer("setMedia", {mp3:arrPlayList[0]}); + + playNext(); - playNext(); - function playNext() { - current = nextIndex(); + current = nextIndex(); if (nextIndex()===null) { // nothing to preload so don't fire off a playNext after this play $preloader.unbind($.jPlayer.event.ended); - $preloader.bind($.jPlayer.event.ended, - function() { + $preloader.bind($.jPlayer.event.ended, + function() { $players.find('.music').jPlayer('volume', 0.80); // bring music volume back up $player.remove(); $preloader.remove(); @@ -95,12 +95,12 @@ function WeatherAudio() { // preload the next track function doPreload(trackname) { try { - $preloader.jPlayer("setMedia", {mp3:arrPlayList[nextIndex()]}).jPlayer("play").jPlayer("stop"); + $preloader.jPlayer("setMedia", {mp3:arrPlayList[nextIndex()]}).jPlayer("play").jPlayer("stop"); } catch(e) { setTimeout( function() {doPreload(trackname)}, 500); - } + } } - doPreload( arrPlayList[nextIndex()] ); + doPreload( arrPlayList[nextIndex()] ); } @@ -115,8 +115,8 @@ function WeatherAudio() { } - - + + function initPlayer(id){ var $div; $div = $('
'); @@ -134,63 +134,57 @@ function WeatherAudio() { function swapAndPlay() { // who would think swapping two vars would be so hard? var $temp1 = $player, - $temp2 = $preloader; + $temp2 = $preloader; $player = null; $preloader = null; $player=$temp2; $preloader=$temp1; - $player.jPlayer("play"); - + $player.jPlayer("play"); + $(document).mousedown( function() { if (!mobilePlaying) { $player.jPlayer("play"); mobilePlaying = true; } - }); + }); } - + } - - - // click for debugging or whater you want + + + // click for debugging or whater you want $('body').on('click', function(){ //$player.jPlayer("playHead", 100); //getWeatherbyLocation(); }); - - + + this.playCallback = {}; - - + + // plays the vocal current conditions announcement - this.playCurrentConditions = function (currentConditions) { - - var array2play = ['CC_INTRO' + (Math.floor(Math.random()*2)+1), currentConditions.temp.replace('-', 'M')], - condfile = mapCurrentConditions(currentConditions.code); - - if (condfile) { array2play.push(condfile); } - - $.each(array2play, function(i,v){ - array2play[i] = '/localvocals/' + v + '.mp3'; - }); - - startPlaying(array2play, false); - - function mapCurrentConditions(ccCode){ - return "CC" + {0:"422",1:"EF300",2:"EF300",3:"422",4:"400",5:"500",6:"600",7:"700",8:"800",9:"901",10:"1000",11:"1100",12:"2680",13:"1601",14:"1312",15:"1500",16:"1600",17:"1730",18:"1800",19:"1939",20:"2000",21:"2000",22:"2200",23:"2410",24:"2410",26:"2600",27:"2700",28:"2700",29:"2900",30:"2900",31:"3100",32:"3200",33:"3400",34:"3400",35:"1730",37:"429",38:"429",39:"429",40:"2680",41:"1402",42:"1312",43:"1402",44:"2900",45:"1100",46:"1312",47:"EF3900"}[ccCode]; - } - + this.playCurrentConditions = function () { + startPlaying(['/localvocals/narrations/Your_current_conditions.mp3'], false); } - - + this.playwarningbeep = function () { + startPlaying(['/localvocals/narrations/warningbeep.mp3'], false); + } + + this.playLocalRadar = function() { - startPlaying(['/localvocals/RADAR.mp3'], false); + startPlaying(['/localvocals/narrations/The_local_Doppler_radar.mp3'], false); + } + this.playLocalforecasti = function() { + startPlaying(['/localvocals/narrations/Your_local_forecast_1.mp3'], false); + } + this.playLocalforecastii = function() { + startPlaying(['/localvocals/narrations/Your_local_forecast_2.mp3'], false); } - + } var weatherAudio = new WeatherAudio(); @@ -228,4 +222,4 @@ b,c){return c.S(a)};f.b.CNT=f.b.PCNT;f.b["T*"]=function(a,b,c){var d=h(c.a(a));r q,"UTF-8");break;case "uint8":k=b.F(v);break;case "jpeg":case "png":k={format:"image/"+w,data:b.s(v,q)}}a[x[0]]="comment"===x[0]?{text:k}:k}}g+=l}}var c={types:{0:"uint8",1:"text",13:"jpeg",14:"png",21:"uint8"},o:{"\u00a9alb":["album"],"\u00a9art":["artist"],"\u00a9ART":["artist"],aART:["artist"],"\u00a9day":["year"],"\u00a9nam":["title"],"\u00a9gen":["genre"],trkn:["track"],"\u00a9wrt":["composer"],"\u00a9too":["encoder"],cprt:["copyright"],covr:["picture"],"\u00a9grp":["grouping"],keyw:["keyword"], "\u00a9lyr":["lyrics"],"\u00a9cmt":["comment"],tmpo:["tempo"],cpil:["compilation"],disk:["disc"]},u:function(a,b){a.i([0,7],function(){h(a,0,a.l(),b)})},v:function(a){var b={};f(b,a,0,a.l());return b}};l.f=c},{}],9:[function(g,l){l.f={J:function(h,f,c){var a=0,b=1,g=0;c=Math.min(c||h.length,h.length);254==h[0]&&255==h[1]?(f=!0,a=2):255==h[0]&&254==h[1]&&(f=!1,a=2);f&&(b=0,g=1);f=[];for(var d=0;ae||224<=e?f[d]=String.fromCharCode(l): (e=(h[a+b]<<8)+h[a+g],a+=2,f[d]=String.fromCharCode(l,e))}h=new String(f.join(""));h.j=a;return h},K:function(h,f){var c=0;f=Math.min(f||h.length,h.length);239==h[0]&&187==h[1]&&191==h[2]&&(c=3);for(var a=[],b=0;cg)a[b]=String.fromCharCode(g);else if(194<=g&&224>g){var d=h[c++];a[b]=String.fromCharCode(((g&31)<<6)+(d&63))}else if(224<=g&&240>g){var d=h[c++],e=h[c++];a[b]=String.fromCharCode(((g&255)<<12)+((d&63)<<6)+(e&63))}else if(240<=g&&245>g){var d= -h[c++],e=h[c++],l=h[c++],g=((g&7)<<18)+((d&63)<<12)+((e&63)<<6)+(l&63)-65536;a[b]=String.fromCharCode((g>>10)+55296,(g&1023)+56320)}}a=new String(a.join(""));a.j=c;return a},I:function(g,f){var c=[];f=f||g.length;for(var a=0;a>10)+55296,(g&1023)+56320)}}a=new String(a.join(""));a.j=c;return a},I:function(g,f){var c=[];f=f||g.length;for(var a=0;a excludeRadiusMiles) { - locList.push({lat: geo[1], long:geo[0], distance:dist, stationUrl:feature.id}); + locList.push({lat: latgeo, long:longeo, distance:dist, stationUrl:feature.stationId[i]}); } } @@ -67,13 +67,12 @@ function DataManager(pointSearch){ // set the station for location 0 _locations[0].stationUrl = locList[0].stationUrl - _locations[0].initNWSObservations(); // 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.init(loc.lat+','+loc.long, loc.location.stationName); loc.location.stationUrl = loc.stationUrl; } @@ -99,8 +98,7 @@ function DataManager(pointSearch){ if (_locations.filter(e => e.city == loc.location.city).length === 0) { _locations.push(loc.location); - loc.location.initForecasts(); - loc.location.initNWSObservations(); + //loc.location.initForecasts(); } } diff --git a/webroot/js/groupull.js b/webroot/js/groupull.js index e8938b0..23d6483 100644 --- a/webroot/js/groupull.js +++ b/webroot/js/groupull.js @@ -37,7 +37,7 @@ function GroupDataManager() { // woeid is the id for the location to pull data for - var url = 'https://api.openweathermap.org/data/2.5/weather?q='+ location.name + '&appid=putapikeyhere&units=imperial' + var url = 'https://api.openweathermap.org/data/2.5/weather?q='+ location.name + '&appid=0cb279a98124446dd16dba02fbfb60ee&units=imperial' pullData(url, location); @@ -60,7 +60,7 @@ function GroupDataManager() { } // display the current info - $span.text(location.name + ': ' + Math.round(parseInt(location.data.main.temp)) + ' ' + location.data.weather[0].description.toLowerCase()); + $span.text(location.name + ': ' + Math.round(parseInt(location.data.main.temp)) + ' ' + (getCC(location.data.weather[0].id + location.data.weather[0].icon, location.data.wind.speed)).toLowerCase()); // set the expiration date/time diff --git a/webroot/js/location.js b/webroot/js/location.js index 804b80f..0871d00 100644 --- a/webroot/js/location.js +++ b/webroot/js/location.js @@ -9,7 +9,7 @@ function Location() { // onReady, onRefresh, onAllComplete if (_observations[1]!=null && _observations[1].temperature.value) { return C2F(_observations[1].temperature.value); } else { - return Math.round( _observations[0].current.temp ); + return Math.round( _observations[0].temperature ); } } @@ -26,15 +26,12 @@ function Location() { // onReady, onRefresh, onAllComplete this.initForecasts = function() { // start the forecast data pull if (_observations[0] != undefined){ - _forecastmgr = new ForecastManager(_observations[0].lat, _observations[0].lon, function() { + _forecastmgr = new ForecastManager(_observations[0].latitude, _observations[0].longitude, function() { $this.trigger('ready'); }); } }; - this.initNWSObservations = function(){ - stationObservations(); - }; // check to see if data needs to be refreshed @@ -51,24 +48,28 @@ function Location() { // onReady, onRefresh, onAllComplete if (location != undefined) { var loclat = location.split(",")[0] var loclong = location.split(",")[1] - var url = 'https://api.openweathermap.org/data/2.5/onecall?lat=' + loclat + '&lon=' + loclong + '&appid=putkeyhere&units=imperial' + //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=e1f10a1e78da46f5b10a1e78da96f525' // ajax the latest observation $.getJSON(url, function(data) { - _observations[0] = json = data; - + _observations[0] = json = data['v3-wx-observations-current']; + _observations[0].latitude = loclat; + _observations[0].longitude = loclong; + _observations[0].cityname = data['v3-location-point'].location.city; $this.trigger('refresh'); // the following block only runs on init if (that.woeid===undefined) { - that.woeid = loclat + that.woeid = loclat; - that.lat = data.lat - that.long = data.lon; + that.lat = loclat; + that.long = loclong; - //that.city = data.query.results.channel.location.city; + that.city = data['v3-location-point'].location.city; $this.trigger('init'); @@ -79,42 +80,20 @@ function Location() { // onReady, onRefresh, onAllComplete setTimeout(checkRefresh, getRandom(5000, 10000)); }); - $.getJSON('http://api.openweathermap.org/geo/1.0/reverse?lat=' + loclat + '&lon=' + loclong + '&limit=1&appid=0cb279a98124446dd16dba02fbfb60ee', function(sloc) { - that.city = (sloc[0].name); - }); } } // pull observations from the location observation station - function stationObservations() { - var url = that.stationUrl + '/observations/current'; - - // check the expiration - if ( _observations[1]!=undefined && dateFns.isFuture( _observations[1].xdate ) ) { - setTimeout(checkRefresh, getRandom(5000, 10000)); - return; - } - - // ajax the current conditions - $.getJSON(url, function(data) { - _observations[1] = data.properties; - - // set the expiration date/time - _observations[1].xdate = dateFns.addMinutes(data.properties.timestamp, 60); - setTimeout(stationObservations, getRandom(5000, 10000)); - - }); - } function ForecastManager (latitude, longitude, readyCallback) { var _forecasts = {}, - keys =['daily','hourly'], + keys =['alert','daily','hourly','almanac','pollen','achesindex','breathindex','airquality','forecastuvindex', 'uvindex'], key, readycount = 0; @@ -141,8 +120,29 @@ function ForecastManager (latitude, longitude, readyCallback) { function Forecast(type, lat, lon, readyCallback) { - var that = this, - url = 'https://api.weather.gov/points/' + lat + ',' + lon + "/forecast/" + (type==='hourly' ? type : ''); + 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=e1f10a1e78da46f5b10a1e78da96f525" + } 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=e1f10a1e78da46f5b10a1e78da96f525" + } else if (type == 'alert') { + url = 'https://api.weather.com/v3/alerts/headlines?geocode=' + lat + ',' + lon + "&format=json&language=en-US&apiKey=e1f10a1e78da46f5b10a1e78da96f525" + } 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=e1f10a1e78da46f5b10a1e78da96f525" + } else if (type == 'pollen') { + url = 'https://api.weather.com/v1/geocode/'+ lat + '/' + lon + '/observations/pollen.json?language=en-US&apiKey=e1f10a1e78da46f5b10a1e78da96f525' + } else if (type == 'achesindex') { + url = 'https://api.weather.com/v2/indices/achePain/daypart/3day?geocode=' + lat + ',' + lon + "&language=en-US&format=json&apiKey=e1f10a1e78da46f5b10a1e78da96f525" + } else if (type == 'breathindex') { + url = 'https://api.weather.com/v2/indices/breathing/daypart/3day?geocode=' + lat + ',' + lon + "&language=en-US&format=json&apiKey=e1f10a1e78da46f5b10a1e78da96f525" + } else if (type == 'airquality') { + url = 'https://api.weather.com/v3/wx/globalAirQuality?geocode=' + lat + ',' + lon + "&language=en-US&scale=EPA&format=json&apiKey=e1f10a1e78da46f5b10a1e78da96f525" + } else if (type == 'forecastuvindex') { + url = 'https://api.weather.com/v2/indices/uv/hourly/48hour?geocode=' + lat + ',' + lon + "&language=en-US&format=json&apiKey=e1f10a1e78da46f5b10a1e78da96f525" + }else if (type == 'uvindex') { + url = 'https://api.weather.com/v2/indices/uv/current?geocode=' + lat + ',' + lon + "&language=en-US&format=json&apiKey=e1f10a1e78da46f5b10a1e78da96f525" + } this.data = {}; @@ -159,20 +159,17 @@ function Forecast(type, lat, lon, readyCallback) { // ajax the forecast $.getJSON(url, function(data) { - that.data = data.properties.periods; + that.data = data // trigger ready callback on first data pull + + // set the expiration date/time + }) + .always(function() { if (readyCallback){ readyCallback(); } - - // set the expiration date/time - that.data.xdate = dateFns.addMinutes(data.properties.updated, 60); - that.data.xdate = dateFns.addMinutes(new Date(), 5); - setTimeout(checkRefresh, getRandom(5000, 10000)); - - }); - + }); } } diff --git a/webroot/js/loops.js b/webroot/js/loops.js index 79bd5f9..6f89a4c 100644 --- a/webroot/js/loops.js +++ b/webroot/js/loops.js @@ -1,4 +1,4 @@ - +var severemode function Loops(bindDataManager) { var //dataManager, obsData, @@ -17,45 +17,59 @@ function Loops(bindDataManager) { function displayAtmospheric(idx) { var displays = { + conditions() { + return (obsData(0).wxPhraseLong).toLowerCase(); + }, - conditions() { - return (getCC(obsData(0).current.weather[0].id + obsData(0).current.weather[0].icon, obsData(0).current.wind_speed)).toLowerCase(); - }, - - wind(){ return 'wind ' + degToCompass(obsData(0).current.wind_deg) + ' ' + Math.round(parseInt(obsData(0).current.wind_speed)); }, + wind(){ return 'wind ' + ((obsData(0).windDirectionCardinal == "CALM") ? 'calm' : obsData(0).windDirectionCardinal) + ' ' + ((obsData(0).windSpeed === 0) ? '' : obsData(0).windSpeed); }, gusts(){ if ( obsData(1)!=undefined ) { - return obsData(1).windGust.value!=null ? 'gusts ' + mps2mph( obsData(1).windGust.value ) : ''; + return obsData(1).windGust.value!=null ? 'gusts ' + obsData(1).windGust.value : ''; } }, - humidity(){ return 'humidity ' + obsData(0).current.humidity + '%'; }, + humidity(){ return 'humidity ' + obsData(0).relativeHumidity + '%'; }, - dewpoint(){ return 'dew point ' + dewPoint(obsData(0).current.temp, obsData(0).current.humidity ) + '°'; }, + dewpoint(){ return 'dew point ' + obsData(0).temperatureDewPoint + '°'; }, heatindex_windchill(){ - var windchill = 35.74 + (0.6215 * parseInt(obsData(0).current.temp)) + (0.4275 * parseInt(obsData(0).current.temp) - 35.75) * parseInt(obsData(0).current.wind_speed) ^ 0.16; - if (parseInt(obsData(0).current.temp)<80 && windchill < parseInt(obsData(0).current.temp)) { + 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).current.temp)>=80 && parseInt(obsData(0).current.humidity)>=40 ){ - return 'heat index ' + heatIndex(obsData(0).current.temp, obsData(0).current.humidity) + '°'; + } else if (parseInt(obsData(0).temperature)>=80 && parseInt(obsData(0).relativeHumidity)>=40 ){ + return 'heat index ' + heatIndex(obsData(0).temperature, obsData(0).relativeHumidity) + '°'; } else return ''; }, - pressure(){ return 'pressure ' + (obsData(0).current.pressure*0.0295301).toFixed(2) }, + pressure(){ return 'pressure ' + obsData(0).pressureAltimeter }, //+ ['S','R','F'][obsData(0).current.rising]; - visibility() { return 'visibility ' + (parseInt(obsData(0).current.visibility) / 1000) + ' mile' + (obsData(0).current.visibility != 1 ? 's' : ''); }, + visibility() { return 'visibility ' + obsData(0).visibility + ' mile' + (obsData(0).visibility != 1 ? 's' : ''); }, - uvindex() { return 'UV index ' + obsData(0).current.uvi; }, + uvindex() { return 'UV index ' + obsData(0).uvDescription; }, }, 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 (text) { @@ -65,7 +79,7 @@ function Loops(bindDataManager) { // nothing to display - skip to the next one setTimeout(function(){ displayAtmospheric(idx) }, 0); } - + } } // end function @@ -74,36 +88,45 @@ function Loops(bindDataManager) { var displays = { text1() { - $('#forecast-title').text( possessiveForecast(foreDataDaily[0].name) ); - resizeText(foreDataDaily[0].detailedForecast); + 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] : '')); + } }, text2() { - $('#forecast-title').text( possessiveForecast(foreDataDaily[1].name) ); - resizeText(foreDataDaily[1].detailedForecast); + 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] : '')); + } }, fiveday() { var newtile, weekend, icons, - startidx = (foreDataDaily[0].name==='Tonight' ? 1 : 2), - days = ['SUN','MON','TUE','WED','THU','FRI','SAT']; + startidx = (foreDataDaily.daypart[0].daypartName[0] != null ? 0 : 2); $('#forecast-title').text("5 DAY FORECAST"); $('#forecast-tiles').empty(); - for (var i=startidx; i<=10; i+=2 ) { + for (var i=startidx; i<=(startidx + 8); i+=2 ) { - weekend = ( dateFns.isWeekend(foreDataDaily[i].startTime) ? ' weekend' : ''); + weekend = ( dateFns.isWeekend(foreDataDaily.validTimeLocal[i/2]) ? ' weekend' : ''); newtile = $("
"); - $("
") .appendTo(newtile) .text(days[ dateFns.getDay(foreDataDaily[i].startTime) ]); + $("
") .appendTo(newtile) .text((foreDataDaily.dayOfWeek[i/2]).substring(0,3)); - icons = mapNWSicons(foreDataDaily[i].icon); - for (x=icons.length-1; x>=0; x--){ - $("") .appendTo(newtile) .attr('src', icons[x]); - } + icons = getCCicon(+foreDataDaily.daypart[0].iconCode[i], foreDataDaily.daypart[0].windSpeed[i]); - $("
") .appendTo(newtile) .text(foreDataDaily[i].temperature); - $("
") .appendTo(newtile) .text(foreDataDaily[i+1].temperature); + $("") .appendTo(newtile) .attr('src', icons); + + + $("
") .appendTo(newtile) .text(foreDataDaily.temperatureMax[i/2]); + $("
") .appendTo(newtile) .text(foreDataDaily.temperatureMin[i/2]); $('#forecast-tiles').append(newtile); } @@ -116,26 +139,26 @@ function Loops(bindDataManager) { indexes = calcHourlyReport(foreDataHourly), data, label, temps=[]; - $('#forecast-title').text( buildHourlyHeaderTitle(foreDataHourly[indexes[0]].startTime) ); + $('#forecast-title').text( buildHourlyHeaderTitle(foreDataHourly.validTimeLocal[indexes[0]]) ); $('#forecast-tiles').empty(); for (var i of indexes) { - data = foreDataHourly[i]; + data = foreDataHourly; newtile = $("
"); sizer = $("
").appendTo(newtile); - icons = mapNWSicons(data.icon); - for (var x=icons.length-1; x>=0; x--){ - $("") .appendTo(sizer) .attr('src', icons[x]); - } + icons = getCCicon(data.iconCode[i], data.windSpeed[i]); - $("") .appendTo(newtile) .text(buildHourlyTimeTitle(data.startTime)); + $("") .appendTo(sizer) .attr('src', icons); + + + $("") .appendTo(newtile) .text(buildHourlyTimeTitle(data.validTimeLocal[i])); highbar = $("
") .appendTo(sizer); - $("
") .appendTo(highbar) .text(data.temperature); - temps.push(data.temperature); + $("
") .appendTo(highbar) .text(data.temperature[i]); + temps.push(data.temperature[i]); $("
") .appendTo(highbar); @@ -188,9 +211,7 @@ function Loops(bindDataManager) { //},100); // delay is a workaround for Interstate font not updating display } - function possessiveForecast(text){ - return text + (text.toUpperCase() != 'OVERNIGHT' ? "'S" : '') + ' FORECAST'; - } + } // end Loops class @@ -272,8 +293,8 @@ function calcHourlyReport(data) { while(ret.length<4){ // hour must be equal or greater than current - hour = dateFns.getHours( data[i].startTime ); - if ( dateFns.isAfter(data[i].startTime, now) && (hour==start || ret.length>0) ) { + hour = dateFns.getHours( data.validTimeLocal[i] ); + if ( dateFns.isAfter(data.validTimeLocal[i], now) && (hour==start || ret.length>0) ) { if ( targets.indexOf(hour)>=0 ) { // it is in our target list so record its index ret.push(i); diff --git a/webroot/js/radar.js b/webroot/js/radar.js index db511cb..0c1c5cf 100644 --- a/webroot/js/radar.js +++ b/webroot/js/radar.js @@ -6,7 +6,8 @@ function Radar(divIDin, intervalHoursIn, zoomIn, latitudeIn, longitudeIn, withSa intervalHours = intervalHoursIn, zoom = zoomIn, latitude = latitudeIn, - longitude = longitudeIn; + longitude = longitudeIn, + timeLayers = []; this.setView = function(lat, long, zoomLevel){ map.setView(L.latLng(lat, long), zoomLevel) @@ -14,16 +15,6 @@ function Radar(divIDin, intervalHoursIn, zoomIn, latitudeIn, longitudeIn, withSa startAnimation(); - setInterval(updatePeriod, 300000); - - function updatePeriod() { - var endDate = roundDate(new Date()), - startDate = dateFns.subHours(endDate, 3), - newAvailableTimes = L.TimeDimension.Util.explodeTimeRange(startDate, endDate, 'PT5M'); - - map.timeDimension.setAvailableTimes(newAvailableTimes, 'replace'); - map.timeDimension.setCurrentTime(startDate); - } // snap date to 5 minute intervals function roundDate(date) { @@ -40,31 +31,8 @@ function Radar(divIDin, intervalHoursIn, zoomIn, latitudeIn, longitudeIn, withSa map = L.map(divID, { zoom: zoom, fullscreenControl: false, - timeDimension: true, - timeDimensionControl: true, - timeDimensionOptions:{ - timeInterval: "PT" + intervalHours + "H/" + endDate.toISOString(), - period: "PT5M", - currentTime: endDate - }, - - timeDimensionControlOptions: { - autoPlay: true, - playerOptions: { - buffer: 36, - transitionTime: 100, - loop: false, - startOver:true - } - }, - center: [latitude, longitude] // 31.205482,-82.4331197 test coordinates - }); - map.timeDimensionControl._player.on('stop', function(){ - setTimeout( function() { - map.timeDimensionControl._player.setLooped(true); - map.timeDimensionControl._player.start(); - setTimeout(function(){map.timeDimensionControl._player.setLooped(false)}, 1000); - }, 1000) + center: [latitude, longitude] + // 31.205482,-82.4331197 test coordinates }); @@ -73,19 +41,44 @@ function Radar(divIDin, intervalHoursIn, zoomIn, latitudeIn, longitudeIn, withSa // satellite streets cj8p1qym6976p2rqut8oo6vxr // weatherscan green cj8owq50n926g2smvagdxg9t8 // mapbox://styles/goldbblazez/ckgc7fwvr4qmn19pevtvhyabl - L.tileLayer('https://api.mapbox.com/styles/v1/goldbblazez/ckgc8lzdz4lzh19qt7q9wbbr9/tiles/{z}/{x}/{y}?access_token=putapikeyhere', { + // https://api.mapbox.com/styles/v1/goldbblazez/ckgc8lzdz4lzh19qt7q9wbbr9.html?fresh=true&title=copy&access_token=pk.eyJ1IjoiZ29sZGJibGF6ZXoiLCJhIjoiY2tiZTRnb2Q2MGkxajJwbzV2bWd5dXI5MyJ9.jU-2DqGCBI14K-acyN9RCw + L.tileLayer('https://api.mapbox.com/styles/v1/goldbblazez/ckgc8lzdz4lzh19qt7q9wbbr9/tiles/{z}/{x}/{y}?access_token=pk.eyJ1IjoiZ29sZGJibGF6ZXoiLCJhIjoiY2ttbTRyYjlsMGMwdDJvbnh6ZDd3b3l4ZyJ9.AcR8BHOrQGjoISQfC-dNFw', { tileSize: 512, zoomOffset: -1 }).addTo(map); + $.getJSON("https://api.weather.com/v3/TileServer/series/productSet/PPAcore?filter=radar&apiKey=e1f10a1e78da46f5b10a1e78da96f525", function(data) { + for (var i = 0; i < data.seriesInfo.radar.series.length; i++) { + timeLayers.push( + L.tileLayer("https://api.weather.com/v3/TileServer/tile/radar?ts="+ data.seriesInfo.radar.series[i].ts +"&xyz={x}:{y}:{z}&apiKey=e1f10a1e78da46f5b10a1e78da96f525", { + opacity: 0 + })) + } + timeLayers.forEach(timeLayers => { - var radarWMS = L.nonTiledLayer.wms("https://nowcoast.noaa.gov/arcgis/services/nowcoast/radar_meteo_imagery_nexrad_time/MapServer/WMSServer", { - layers: '1', - format: 'image/png', - transparent: true, - opacity: 0.8 + timeLayers.addTo(map); + }); }); + const sleepNow = (delay) => new Promise((resolve) => setTimeout(resolve, delay)) + + async function animationLoop() { + for (let i = timeLayers.length; i > 0; i--) { + timeLayers[i - 1].setOpacity(1) + await sleepNow(100) + timeLayers[i - 1].setOpacity(0) + if (i === 1) { + timeLayers[i - 1].setOpacity(1) + await sleepNow(1750) + timeLayers[i - 1].setOpacity(0) + animationLoop() + } + } + } + setTimeout(function() { + animationLoop() + }, 1000); + if (withSat) { var goes_visible_sat = L.nonTiledLayer.wms('https://nowcoast.noaa.gov/arcgis/services/nowcoast/sat_meteo_imagery_time/MapServer/WMSServer', { @@ -149,15 +142,6 @@ function Radar(divIDin, intervalHoursIn, zoomIn, latitudeIn, longitudeIn, withSa } - var proxy = 'js/leaflet/proxy.php'; - var radarTimeLayer = L.timeDimension.layer.wms(radarWMS, { - proxy: proxy, - updateTimeDimension: false - }); - - radarTimeLayer.addTo(map); - - } } diff --git a/webroot/js/slides-loop.js b/webroot/js/slides-loop.js index a2a6bf0..dfc81eb 100644 --- a/webroot/js/slides-loop.js +++ b/webroot/js/slides-loop.js @@ -5,19 +5,255 @@ RADAR < MAIN CITY < CITY 1 < CITY 2 */ // load slide data - function Slides(dataMan) { + function Slides(dataMan) { [ + severemode = false; var radarSlideDuration = 60000, slideDelay = 10000; - // for later + // 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=e1f10a1e78da46f5b10a1e78da96f525', 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=e1f10a1e78da46f5b10a1e78da96f525', 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) { - setTimeout(nextCity, 5000); - - + //} + setTimeout(function() { + $('.radar-content').fadeOut(500); + $('.radar-color-legend').fadeOut(500, function() { + $('.radar-slide').fadeOut(0); + nextCity() + }); + }, 5500); // loop cities function nextCity(){ + //severe weather mode + if (severemode == true) { + $('#minimap-cover').fadeIn(0) + $('.city-slide-intro .segment').text(location.city); + $('#info-slides-header .hscroller').empty(); + $('#info-slides-header .hscroller').append("SEVERE WEATHER UPDATE"); + + $('.radar-slide .info-subheader').css('background', 'linear-gradient(to top, #868686 0, #868686 100%)') + showBulletin(); + function showRadarS(lat, long, zoom, time) { + + weatherMan.mainMap.setView(lat, long, zoom); + // fade out info, fade in radar + weatherAudio.playLocalRadar(); + $('.radar-slide').fadeIn(0); + $('.radar-content').fadeIn(500); + $('.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); + + + } + function showBulletin() { + var foreDataAlert = dataMan.locations[0].forecasts('alert'); + var page2 = []; + if (foreDataAlert !== undefined){ + $('.bulletin .frost-pane .warnings').empty() + var displayday; + //info + //get only weather alers + + + if (ret.length != 0) { + + 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." + } + return dateFns.format(new Date(expiretime), "h:mm A ") + displayday + } + if (i < 3) { + $('.bulletin .frost-pane .warnings').append(foreDataAlert.alerts[i].eventDescription + " in effect until " + getexpiredate(foreDataAlert.alerts[ret[i]].expireTimeLocal) + "

") + } else { + page2.push(foreDataAlert.alerts[i].eventDescription + " in effect until " + getexpiredate(foreDataAlert.alerts[ret[i]].expireTimeLocal) + "

") + } + } + $('.bulletin').fadeIn(0); + $('.bulletin .frost-pane').fadeIn(500); + $('#subhead-noaa').fadeIn(500); + setTimeout(function() { + if (page2.length !== 0) { + $('.bulletin .frost-pane').fadeOut(500, function(){ + $('.bulletin .frost-pane .warnings').empty() + for (i=0; i<=foreDataAlert.alerts.length; i++){ + $('.bulletin .frost-pane .warnings').append(page2[i]) + } + }); + $('.bulletin .frost-pane').fadeIn(500); + setTimeout(function() { + $('.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(); + } + }); + }, slideDelay); + } 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(); + } + }); + } + }, 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 { + 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 { + //non severe advanceHeader(); var city = $('#info-slides-header .city.current'); @@ -28,38 +264,375 @@ RADAR < MAIN CITY < CITY 1 < CITY 2 showCitySlides( dataMan.location(city[0].dataset.woeid), 0 ); } else { - - + if (city[0].classList.contains("radar")) { + showRadar(dataMan.locations[0].lat, dataMan.locations[0].long, 8, 60000); + setTimeout(nextCity, 60500); + } else if (city[0].classList.contains("airport")) { + showAirport(0); + } else if (city[0].classList.contains("healthh")) { + showHealth(0); + } // radar - showRadar(dataMan.locations[0].lat, dataMan.locations[0].long, 8); + //showRadar(dataMan.locations[0].lat, dataMan.locations[0].long, 8); //setTimeout(function() { weatherAudio.playLocalRadar() }, 2000 ); // show for how long? - setTimeout(nextCity, 60000); + //setTimeout(nextCity, 60000); } - + } } - function showRadar(lat, long, zoom) { + function showRadar(lat, long, zoom, time) { weatherMan.mainMap.setView(lat, long, zoom); - - setTimeout(function() { - // fade out info, fade in radar - $('.info-slide-content:visible').fadeOut(250, function(){ - $('.info-slide').fadeOut(250, function() { - $('.radar-slide').fadeIn(500); + weatherAudio.playLocalRadar(); + $('.radar-slide').fadeIn(0); + $('.radar-content').fadeIn(500); + $('.radar-color-legend').fadeIn(500); + setTimeout(function() { + $('.radar-content').fadeOut(500); + $('.radar-color-legend').fadeOut(500, function() { + $('.radar-slide').fadeOut(0); }); - }); + }, time); - }, 1500); // give it time to load } + function showAirport(idx) { + var currentDisplay, + displays = { + intro() { + $('.airport-slide-intro').fadeIn(0); + $('.airport-slide-intro .accent').fadeIn(500); + $('.airport-slide-intro .weatherscanmarquee').fadeIn(500); + $('.airport-slide-intro .weatherscanmarquee').css('animation', 'marqueeweatherscan 5.5s linear normal forwards') + setTimeout(function() { + $('.airport-slide-intro .segment').fadeIn(500); + }, 1000); + setTimeout(function() { + $('.airport-slide-intro .segment').fadeOut(500) + $('.airport-slide-intro .accent').fadeOut(500); + $('.airport-slide-intro .weatherscanmarquee').fadeOut(500, function() { + $('.airport-slide-intro').fadeOut(0); + wait(0); + }); + }, 5000); + } + ,airportconditions() { + $('.airport-slide').fadeIn(0); + $('.airportpanel').fadeIn(500); + setTimeout(function() { + $('.airportpanel').fadeOut(500, function(){ + $('.airport-slide').fadeOut(0); + wait(0); + }); + }, slideDelay); + } + }, + keys = Object.keys(displays); + + var daypart; + if (idx= 4) { + $('.info-slide-content.health-forecast .mainforecast .hightext').css("right","85px"); + $('.info-slide-content.health-forecast .mainforecast .hightext').css("top","220px"); + $('.info-slide-content.health-forecast .mainforecast .high').css("left","91px"); + $('.info-slide-content.health-forecast .mainforecast .high').css("top","265px"); + $('.info-slide-content.health-forecast .mainforecast .lowtext').fadeOut(0) + $('.info-slide-content.health-forecast .mainforecast .low').fadeOut(0) + } + $('.info-slide-content.health-forecast .thing').text("Forecast for " + healthforecastdata.dayOfWeek[startidxdayonly]) + $('.info-slide-content.health-forecast .mainforecast .hightext').text(healthforecastdata.temperatureMax[startidxdayonly]) + $('.info-slide-content.health-forecast .mainforecast .lowtext').text(healthforecastdata.temperatureMin[startidxdayonly]) + $('.info-slide-content.health-forecast .forecastdetails .chancepreciptext').text(healthforecastdata.daypart[0].precipChance[startidx] + '%') + $('.info-slide-content.health-forecast .forecastdetails .humidtext').text(healthforecastdata.daypart[0].relativeHumidity[startidx] + '%') + $('.info-slide-content.health-forecast .forecastdetails .windtext').text(((healthforecastdata.daypart[0].windDirectionCardinal[startidx] == "CALM") ? 'calm' : healthforecastdata.daypart[0].windDirectionCardinal[startidx]) + ' ' + ((healthforecastdata.daypart[0].windSpeed[startidx] === 0) ? '' : healthforecastdata.daypart[0].windSpeed[startidx])) + $('.info-slide-content.health-forecast .mainforecast .icon').css('background-image', 'url("' + getCCicon(+healthforecastdata.daypart[0].iconCode[startidx], healthforecastdata.daypart[0].windSpeed[startidx]) + '")'); + $('.info-slide.health #subhead-title').text('Outdoor Activity'); + $('.info-slide.health #subhead-city').text(dataMan.locations[0].city); + $('.info-slide.health').fadeIn(0); + $('.info-slide-content.health-forecast').fadeIn(500); + setTimeout(function() { + $('.info-slide-content.health-forecast').fadeOut(500, function(){ + wait(0); + }); + }, slideDelay); + } + ,pollen() { + var pollendata = dataMan.locations[0].forecasts("pollen"); + 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) { + $('.info-slide-content.allergy .totalpollen .desc').text('Low') + } else if (pollendata.pollenobservations[0].total_pollen_cnt >= 10 && pollendata.pollenobservations[0].total_pollen_cnt <= 49) { + $('.info-slide-content.allergy .totalpollen .desc').text('Moderate') + } else if (pollendata.pollenobservations[0].total_pollen_cnt >= 50 && pollendata.pollenobservations[0].total_pollen_cnt <= 499) { + $('.info-slide-content.allergy .totalpollen .desc').text('High') + } else if (pollendata.pollenobservations[0].total_pollen_cnt >= 500) { + $('.info-slide-content.allergy .totalpollen .desc').text('Very High') + }; + $('.info-slide-content.allergy .pollen .pollenbar.tree .type').html('Tree Pollen
' + ((pollendata.pollenobservations[0].treenames[0].tree_nm != "No Report") ? pollendata.pollenobservations[0].treenames[0].tree_nm : "")) + $('.info-slide-content.allergy .pollen .thing').text("As of " + dateFns.format(new Date(pollendata.pollenobservations[0].rpt_dt), "MMMM D")) + $('.info-slide-content.allergy .totalpollen .cat').text(pollendata.pollenobservations[0].total_pollen_cnt) + $('.info-slide.health #subhead-title').text('Allergy Report'); + $('.info-slide-content.allergy').fadeIn(500); + setTimeout(function () { + i = 0 + var pollentypes = ['tree', 'grass', 'weed', 'mold']; + pollentypes.forEach(pollentype => { + var plength = {"0":"-10", "1":"55", "2":"115", "3":"175", "4":"235", "5":"295", "9":"-10"}[pollendata.pollenobservations[0].pollenobservation[i].pollen_idx] + var ptime = {"0":0, "1":500, "2":1000, "3":1500, "4":2000, "5":2500, "9":0}[pollendata.pollenobservations[0].pollenobservation[i].pollen_idx] + $('.info-slide-content.allergy .pollen .pollenbar.' + pollentype + ' .bar .bararrow').animate({left: plength + "px"}, ptime) + }); + }, 500) + setTimeout(function() { + $('.info-slide-content.allergy').fadeOut(500, function(){ + wait(0); + }); + }, slideDelay); + } else {wait(0)} + } else {wait(0)} + } + ,achesbreath() { + achesindexdata = dataMan.locations[0].forecasts("achesindex"); + breathindexdata = dataMan.locations[0].forecasts("breathindex"); + var startidx = 0; + if (achesindexdata.achesPainsIndex12hour.dayInd[0] == 'N') { + startidx = 1; + } + var alength = {"0":"-10", "1":"22", "2":"55", "3":"88", "4":"121", "5":"154", "6":"187", "7":"220", "8":"253", "9":"286", "10":"-300"}[achesindexdata.achesPainsIndex12hour.achesPainsIndex[startidx]] + var atime = {"0":0, "1":250, "2":500, "3":750, "4":1000, "5":1250, "6":1500, "7":1750, "8":2000, "9":2250, "10":2500}[achesindexdata.achesPainsIndex12hour.achesPainsIndex[startidx]] + var blength = {"10":"-10", "9":"22", "8":"55", "7":"88", "6":"121", "5":"154", "5":"187", "4":"220", "3":"253", "2":"286", "1":"-300"}[breathindexdata.breathingIndex12hour.breathingIndex[startidx]] + var btime = {"10":0, "9":250, "8":500, "7":750, "6":1000, "5":1250, "4":1500, "3":1750, "2":2000, "1":2250, "10":2500}[breathindexdata.breathingIndex12hour.breathingIndex[startidx]] + $('.info-slide-content.Aches-Breath .thing').text(dateFns.format(new Date(achesindexdata.achesPainsIndex12hour.fcstValidLocal[0]), "dddd")) + $('.info-slide.health #subhead-title').text('Health Forecast'); + $('.info-slide-content.Aches-Breath').fadeIn(500); + setTimeout(function () { + $('.info-slide-content.Aches-Breath .aches .bar .bararrow').animate({left: alength + "px"}, atime, 'linear', function() { + $('.info-slide-content.Aches-Breath .aches .bar .bararrow .bararrowtext').text(achesindexdata.achesPainsIndex12hour.achesPainsCategory[startidx]); + $('.info-slide-content.Aches-Breath .aches .bar .bararrow .bararrowtext').fadeIn(500); + + }) + $('.info-slide-content.Aches-Breath .breath .bar .bararrow').animate({left: blength + "px"}, btime, 'linear' ,function() { + $('.info-slide-content.Aches-Breath .breath .bar .bararrow .bararrowtext').text(breathindexdata.breathingIndex12hour.breathingCategory[0]); + $('.info-slide-content.Aches-Breath .breath .bar .bararrow .bararrowtext').fadeIn(500); + + }) + }, 500); + setTimeout(function() { + $('.info-slide-content.Aches-Breath').fadeOut(500, function(){ + wait(0); + }); + }, slideDelay); + } + ,airquality() { + var foreDataAlert = dataMan.locations[0].forecasts('alert'); + var airqualitydata = dataMan.locations[0].forecasts('airquality'); + var ozone = false; + + if (foreDataAlert !== undefined){ + for (var i=0; i0) ) { + + if ( targets.indexOf(hour)>=0 ) { // it is in our target list so record its index + hret.push(i); + } + + } + i++; + } + return hret; + } + var hourlable = ['i', 'ii', 'iii'], + uvi, value, i = 0; + var ulength = {"-2":"25", "-1":"25", 0:"25", 1:"25", 2:"40", 3:"55", 4:"70", 5:"85", 6:"100", 7:"115", 8:"130", 9:"145", 10:"160", 11:"175"}[uvData.uvIndexCurrent.uvIndex] + var utime = {"-2":0, "-1":0, 0:0, 1:125, 2:250, 3:375, 4:500, 5:625, 6:750, 7:1000, 8:1250, 9:1325, 10:1500, 11:1625}[uvData.uvIndexCurrent.uvIndex] + $('.info-slide-content.uvindex .currentuv .bar .cat').text(uvData.uvIndexCurrent.uvDesc) + $('.info-slide-content.uvindex .currentuv .bar .num').text(uvData.uvIndexCurrent.uvIndex) + if (uvData.uvIndexCurrent.uvIndex == "0" || uvData.uvIndexCurrent.uvIndex == "-1" || uvData.uvIndexCurrent.uvIndex == "-2") { + $('.info-slide-content.uvindex .currentuv .bar').css("background", "rgba(0,0,0,0)") + } + $('.info-slide-content.uvindex .currentuv .bar').animate({height:ulength+"px"}, utime,function(){ + $('.info-slide-content.uvindex .currentuv .bar .cat').fadeTo('slow', 1); + $('.info-slide-content.uvindex .currentuv .bar .num').fadeTo('slow', 1); + }); + $('.info-slide-content.uvindex .forecastuv .bar').each(function(){ + var ulength = {"-2":0, "-1":0, 0:"1", 1:"25", 2:"40", 3:"55", 4:"70", 5:"85", 6:"100", 7:"115", 8:"130", 9:"145", 10:"160", 11:"175"}[foreUvData.uvIndex1hour.uvIndex[indexes[i]]] + var utime = {"-2":0, "-1":0, 0:0, 1:125, 2:250, 3:375, 4:500, 5:625, 6:750, 7:1000, 8:1250, 9:1325, 10:1500, 11:1625}[foreUvData.uvIndex1hour.uvIndex[indexes[i]]] + $('.info-slide-content.uvindex .forecastuv .bar.' + hourlable[i] + ' .cat').text(foreUvData.uvIndex1hour.uvDesc[indexes[i]]) + $('.info-slide-content.uvindex .forecastuv .bar.' + hourlable[i] + ' .num').text(foreUvData.uvIndex1hour.uvIndex[indexes[i]]) + if (foreUvData.uvIndex1hour.uvIndex[indexes[i]] == "0" || foreUvData.uvIndex1hour.uvIndex[indexes[i]] == "-1" || foreUvData.uvIndex1hour.uvIndex[indexes[i]] == "-2") { + $('.info-slide-content.uvindex .currentuv .bar.' + hourlable[i]).css("background", "rgba(0,0,0,0)") + } + $('.info-slide-content.uvindex .forecastuv .bar.' + hourlable[i]).animate({height:ulength+"px"}, utime,function(){ + $('.info-slide-content.uvindex .forecastuv .bar .cat').fadeTo('slow', 1); + $('.info-slide-content.uvindex .forecastuv .bar .num').fadeTo('slow', 1); + }); + i = i + 1 + }) + setTimeout(function() { + $('.info-slide-content.uvindex').fadeOut(500, function(){ + wait(0); + }); + }, slideDelay); + } + ,healthtip() { + $('.info-slide.health #subhead-title').text('Weather Safety Tips'); + $('.info-slide-content.healthtip').fadeIn(500); + setTimeout(function() { + $('.info-slide-content.healthtip').fadeOut(500, function(){ + wait(0); + }); + }, slideDelay); + } + ,moreinfoimage() { + $('.info-slide.health #subhead-title').text(''); + $('.info-slide-content.moreinfoimage').fadeIn(500); + setTimeout(function() { + $('.info-slide-content.moreinfoimage').fadeOut(500, function(){ + $('.info-slide.health').fadeOut(0); + wait(0); + }); + }, slideDelay); + } + }, + keys = Object.keys(displays); + + var daypart; + if (idx
") + } else { + page2.push(foreDataAlert.alerts[i].eventDescription + "in effect until " + getexpiredate(foreDataAlert.alerts[ret[i]].expireTimeLocal) + "

") + } + } + $('.bulletin .frost-pane .cityname').text(location.city + " Area"); + //fade in + $('.bulletin').fadeIn(0); + $('.bulletin .frost-pane').fadeIn(500); + $('#subhead-noaa').fadeIn(500); + setTimeout(function() { + if (page2.length !== 0) { + $('.bulletin .frost-pane').fadeOut(500); + $('.bulletin .frost-pane .warnings').empty() + for (i=0; i<=foreDataAlert.alerts.length; i++){ + $('.bulletin .frost-pane .warnings').append(page2[i]) + } + $('.bulletin .frost-pane').fadeIn(500); + setTimeout(function() { + $('.bulletin').fadeIn(0); + $('.bulletin .frost-pane').fadeOut(500); + $('#subhead-noaa').fadeOut(500, function() { + $('.bulletin').fadeOut(0); + wait(0) + }); + }, slideDelay); + } else { + $('.bulletin').fadeIn(0); + $('.bulletin .frost-pane').fadeOut(500); + $('#subhead-noaa').fadeOut(500, function() { + $('.bulletin').fadeOut(0); + wait(0) + }); + } + }, slideDelay); + } else {wait(0)} + } else {wait(0)}; + } // Currently (10 sec) - currentConditions() { + ,currentConditions() { $('.city-info-slide #subhead-title').text('Currently'); $('.city-info-slide #subhead-city').text(location.city); var obsData = location.observations, strLabels = 'Humidity
Dew Point
Pressure
Wind
', - strData = - obsData(0).current.humidity + '%
' + dewPoint(parseInt(obsData(0).current.temp), parseInt(obsData(0).current.humidity)) + '
' + (obsData(0).current.pressure*0.0295301).toFixed(2) + '
' + degToCompass(obsData(0).current.wind_deg) + ' ' + Math.round(parseInt(obsData(0).current.wind_speed)) + '
'; - if (obsData(0).current.wind_gust!=undefined) { + strData = obsData(0).relativeHumidity + '%
' + obsData(0).temperatureDewPoint + '
' + obsData(0).pressureAltimeter + ((obsData(0).pressureTendencyCode === 1 || obsData(0).pressureTendencyCode === 3) ? '↑' : (obsData(0).pressureTendencyCode === 2 || obsData(0).pressureTendencyCode === 4) ? '↓' : ' S') + '
' + ((obsData(0).windDirectionCardinal == "CALM") ? 'calm' : obsData(0).windDirectionCardinal) + ' ' + ((obsData(0).windSpeed === 0) ? '' : obsData(0).windSpeed) + '
'; + if (obsData(0).windGust!=undefined) { strLabels+='Gusts
'; - strData+=obsData(0).current.wind_gust + '
'; + strData+=obsData(0).windGust + '
'; } else { strLabels+='Gusts
'; strData+='none
'; } - var windchill = 35.74 + (0.6215 * parseInt(obsData(0).current.temp)) + (0.4275 * parseInt(obsData(0).current.temp) - 35.75) * parseInt(obsData(0).current.wind_speed) ^ 0.16; - if (windchill < parseInt(obsData(0).current.temp)) { + if (parseInt(obsData(0).temperature)<70 && parseInt(obsData(0).windSpeed)>=3) { + 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) strLabels+='Wind Chill'; strData+= windchill; - } else if (parseInt(obsData(0).current.temp)>=80 && parseInt(obsData(0).current.humidity)>=40 ){ + } else if (parseInt(obsData(0).temperature)>=80 && parseInt(obsData(0).relativeHumidity)>=40 ){ + strLabels+='Heat Index'; - return 'heat index ' + heatIndex(obsData(0).current.temp, obsData(0).current.humidity) + '°'; + var heatindexx = heatIndex(obsData(0).temperature, obsData(0).relativeHumidity) + '°'; + strData+=heatindexx }; $('.city-info .frost-pane .labels').html(strLabels); $('.city-info .frost-pane .data').html(strData); // right pane - $('.city-info .icon').css('background-image', 'url("' + getCCicon(+obsData(0).current.weather[0].id + obsData(0).current.weather[0].icon, obsData(0).current.wind_speed) + '")'); - $('.city-info .conditions').text(getCC(obsData(0).current.weather[0].id + obsData(0).current.weather[0].icon, obsData(0).current.wind_speed)); - $('.city-info .temp').text( Math.round(parseInt(obsData(0).current.temp)) ); + $('.city-info .icon').css('background-image', 'url("' + getCCicon(+obsData(0).iconCode, obsData(0).windSpeed) + '")'); + //$('.info-slide-content.airport .frost-pane.right .icon').css('background-image', 'url("' + getCCicon(+obsData(0).iconCode, obsData(0).current.wind_speed) + '")'); + $('.city-info .conditions').text(obsData(0).wxPhraseLong); + $('.city-info .temp').text( Math.round(parseInt(obsData(0).temperature)) ); + weatherAudio.playCurrentConditions(); - fadeToContent('.city-info'); - wait(slideDelay); + //fadein + $('.city-info-slide').fadeIn(0); + $('.city-info').fadeIn(500); + //fadeout and switch + setTimeout(function() { + $('.city-info').fadeOut(500, function(){ + $('.city-info-slide').fadeOut(0); + wait(0); + }); + }, slideDelay); } - // Local Doppler Radar or Radar/Satellite (15 sec, zoomed out with cloud cover) ,localDoppler(){ - showRadar(location.lat, location.long, 8); - wait(slideDelay + 1500); + showRadar(location.lat, location.long, 8, slideDelay); + wait(slideDelay + 500); } // daypart / hourly @@ -127,42 +800,34 @@ RADAR < MAIN CITY < CITY 1 < CITY 2 i = i + 1 }); //hour title - $('.info-slide-content.daypart .hour.i .thing .thingtext').text(buildHourlyTimeTitle(foreDataHourly[indexes[0]].startTime)); - $('.info-slide-content.daypart .hour.ii .thing .thingtext').text(buildHourlyTimeTitle(foreDataHourly[indexes[1]].startTime)); - $('.info-slide-content.daypart .hour.iii .thing .thingtext').text(buildHourlyTimeTitle(foreDataHourly[indexes[2]].startTime)); - $('.info-slide-content.daypart .hour.iv .thing .thingtext').text(buildHourlyTimeTitle(foreDataHourly[indexes[3]].startTime)); + $('.info-slide-content.daypart .hour.i .thing .thingtext').text(buildHourlyTimeTitle(foreDataHourly.validTimeLocal[indexes[0]])); + $('.info-slide-content.daypart .hour.ii .thing .thingtext').text(buildHourlyTimeTitle(foreDataHourly.validTimeLocal[indexes[1]])); + $('.info-slide-content.daypart .hour.iii .thing .thingtext').text(buildHourlyTimeTitle(foreDataHourly.validTimeLocal[indexes[2]])); + $('.info-slide-content.daypart .hour.iv .thing .thingtext').text(buildHourlyTimeTitle(foreDataHourly.validTimeLocal[indexes[3]])); for (var i of indexes) { - var data = foreDataHourly[i]; - temps.push(data.temperature); + temps.push(foreDataHourly.temperature[i]); } - $('.info-slide-content.daypart .hour.i .tempbar .temp').text(foreDataHourly[indexes[0]].temperature); - $('.info-slide-content.daypart .hour.ii .tempbar .temp').text(foreDataHourly[indexes[1]].temperature); - $('.info-slide-content.daypart .hour.iii .tempbar .temp').text(foreDataHourly[indexes[2]].temperature); - $('.info-slide-content.daypart .hour.iv .tempbar .temp').text(foreDataHourly[indexes[3]].temperature); + $('.info-slide-content.daypart .hour.i .tempbar .temp').text(foreDataHourly.temperature[indexes[0]]); + $('.info-slide-content.daypart .hour.ii .tempbar .temp').text(foreDataHourly.temperature[indexes[1]]); + $('.info-slide-content.daypart .hour.iii .tempbar .temp').text(foreDataHourly.temperature[indexes[2]]); + $('.info-slide-content.daypart .hour.iv .tempbar .temp').text(foreDataHourly.temperature[indexes[3]]); - $('.info-slide-content.daypart .hour.i .tempbar .wind').text(foreDataHourly[indexes[0]].windDirection + ' ' + (foreDataHourly[indexes[0]].windSpeed).replace(" mph", "")); - $('.info-slide-content.daypart .hour.ii .tempbar .wind').text(foreDataHourly[indexes[1]].windDirection + ' ' + (foreDataHourly[indexes[1]].windSpeed).replace(" mph", "")); - $('.info-slide-content.daypart .hour.iii .tempbar .wind').text(foreDataHourly[indexes[2]].windDirection + ' ' + (foreDataHourly[indexes[2]].windSpeed).replace(" mph", "")); - $('.info-slide-content.daypart .hour.iv .tempbar .wind').text(foreDataHourly[indexes[3]].windDirection + ' ' + (foreDataHourly[indexes[3]].windSpeed).replace(" mph", "")); + $('.info-slide-content.daypart .hour.i .tempbar .wind').text(foreDataHourly.windDirectionCardinal[indexes[0]] + ' ' + foreDataHourly.windSpeed[indexes[0]]); + $('.info-slide-content.daypart .hour.ii .tempbar .wind').text(foreDataHourly.windDirectionCardinal[indexes[1]] + ' ' + foreDataHourly.windSpeed[indexes[1]]); + $('.info-slide-content.daypart .hour.iii .tempbar .wind').text(foreDataHourly.windDirectionCardinal[indexes[2]] + ' ' + foreDataHourly.windSpeed[indexes[2]]); + $('.info-slide-content.daypart .hour.iv .tempbar .wind').text(foreDataHourly.windDirectionCardinal[indexes[3]] + ' ' + foreDataHourly.windSpeed[indexes[3]]); - $('.info-slide-content.daypart .hour.i .condition').text(buildConditions(foreDataHourly[indexes[0]].shortForecast)); - $('.info-slide-content.daypart .hour.ii .condition').text(buildConditions(foreDataHourly[indexes[1]].shortForecast)); - $('.info-slide-content.daypart .hour.iii .condition').text(buildConditions(foreDataHourly[indexes[2]].shortForecast)); - $('.info-slide-content.daypart .hour.iv .condition').text(buildConditions(foreDataHourly[indexes[3]].shortForecast)); + $('.info-slide-content.daypart .hour.i .condition').text((foreDataHourly.wxPhraseShort[indexes[0]]).replace('M ', 'Mostly ').replace('P ','Partly ')); + $('.info-slide-content.daypart .hour.ii .condition').text((foreDataHourly.wxPhraseShort[indexes[1]]).replace('M ', 'Mostly ').replace('P ','Partly ')); + $('.info-slide-content.daypart .hour.iii .condition').text((foreDataHourly.wxPhraseShort[indexes[2]]).replace('M ', 'Mostly ').replace('P ','Partly ')); + $('.info-slide-content.daypart .hour.iv .condition').text((foreDataHourly.wxPhraseShort[indexes[3]]).replace('M ', 'Mostly ').replace('P ','Partly ')); - $('.info-slide-content.daypart .hour.i .icon').css('background-image', 'url("' + mapNWSicons(foreDataHourly[indexes[0]].icon) + '")'); - $('.info-slide-content.daypart .hour.ii .icon').css('background-image', 'url("' + mapNWSicons(foreDataHourly[indexes[1]].icon) + '")'); - $('.info-slide-content.daypart .hour.iii .icon').css('background-image', 'url("' + mapNWSicons(foreDataHourly[indexes[2]].icon) + '")'); - $('.info-slide-content.daypart .hour.iv .icon').css('background-image', 'url("' + mapNWSicons(foreDataHourly[indexes[3]].icon) + '")'); + $('.info-slide-content.daypart .hour.i .icon').css('background-image', 'url("' + getCCicon(+foreDataHourly.iconCode[indexes[0]], foreDataHourly.windSpeed[indexes[0]]) + '")'); + $('.info-slide-content.daypart .hour.ii .icon').css('background-image', 'url("' + getCCicon(+foreDataHourly.iconCode[indexes[1]], foreDataHourly.windSpeed[indexes[1]]) + '")'); + $('.info-slide-content.daypart .hour.iii .icon').css('background-image', 'url("' + getCCicon(+foreDataHourly.iconCode[indexes[2]], foreDataHourly.windSpeed[indexes[2]]) + '")'); + $('.info-slide-content.daypart .hour.iv .icon').css('background-image', 'url("' + getCCicon(+foreDataHourly.iconCode[indexes[3]], foreDataHourly.windSpeed[indexes[3]]) + '")'); - function buildConditions(forecasttext) { - if (forecasttext.includes("Thunderstorms") === true) { - return forecasttext.replace(/Slight Chance/g,"Isolated").replace(/Chance/g,"Sct'd").replace(/Thunderstorms/g,"T'storms").replace(/Partly Sunny/g,"Partly Cloudy").replace(/Showers and Thunderstorms/g,"T'Storms") - } else { - return forecasttext.replace(/Slight Chance/g,"Few").replace(/Chance/g,"").replace(/Partly Sunny/g,"Partly Cloudy").replace(/Isolated/g,"Few") - } - } function buildHourlyTimeTitle(time){ var hour=dateFns.getHours(time); @@ -171,7 +836,7 @@ RADAR < MAIN CITY < CITY 1 < CITY 2 } else if (hour===12){ return 'Noon'; } - return (dateFns.format(time,'h a')).replace(" ", ""); + return (dateFns.format(time,'h a')).replace(" ", ""); } //get reporting hours: 12am, 6am, 12pm, 3pm, 5pm, 8pm... function calcHourlyReport(data) { @@ -202,8 +867,8 @@ RADAR < MAIN CITY < CITY 1 < CITY 2 while(ret.length<4){ // hour must be equal or greater than current - hour = dateFns.getHours( data[i].startTime ); - if ( dateFns.isAfter(data[i].startTime, now) && (hour==start || ret.length>0) ) { + hour = dateFns.getHours(data.validTimeLocal[i] ); + if ( dateFns.isAfter(data.validTimeLocal[i], now) && (hour==start || ret.length>0) ) { if ( targets.indexOf(hour)>=0 ) { // it is in our target list so record its index ret.push(i); @@ -245,8 +910,7 @@ RADAR < MAIN CITY < CITY 1 < CITY 2 } // calculate height of tempbars - $('.city-info-slide #subhead-title').text(buildHourlyHeaderTitle(foreDataHourly[indexes[0]].startTime)); - fadeToContent('.info-slide-content.daypart') + $('.city-info-slide #subhead-title').text(buildHourlyHeaderTitle(foreDataHourly.validTimeLocal[indexes[0]])); var min = Math.min(...temps), // 54 max = Math.max(...temps), // 73 range = (max-min), @@ -254,7 +918,7 @@ RADAR < MAIN CITY < CITY 1 < CITY 2 hourlable = ['i', 'ii', 'iii', 'iv'], temp, value, i = 0; $('.info-slide-content.daypart .hour').each(function(){ - temp = foreDataHourly[indexes[i]].temperature + temp = foreDataHourly.temperature[indexes[i]] 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.daypart .hour.' + hourlable[i] + ' .tempbar').animate({height:valueii+"px"}, 1500,function(){ @@ -263,41 +927,70 @@ RADAR < MAIN CITY < CITY 1 < CITY 2 }); i = i + 1 }) - wait(slideDelay) + //play narration + weatherAudio.playLocalforecastii(); + //fade in + $('.city-info-slide').fadeIn(0); + $('.info-slide-content.daypart').fadeIn(500); + //for calculating when to show daypart + selectval = selectval + 1 + //fadeout + setTimeout(function() { + $('.info-slide-content.daypart').fadeOut(500, function() { + wait(0) + }); + }, slideDelay); + } else { // Local Forecast -Today (10 sec) var div = '.info-slide-content.forecast ', - forecasts = location.forecasts('daily'); + forecasts = dataMan.locations[0].forecasts('daily'); + var correct = 0; function fillinfo() { fidx = (fidx===undefined ? 0 : fidx); - $('.city-info-slide #subhead-title').text('Local Forecast'); + if (forecasts.daypart[0].daypartName[0] == null && fidx == 0) { + correct = 1; + fidx = 1; + } - // title - $(div + '.title').text( forecasts[fidx].name ); + $('.city-info-slide #subhead-title').text('Local Forecast'); + //replace tomorrow + + $(div + '.title').text(forecasts.daypart[0].daypartName[fidx].replace('Tomorrow', forecasts.dayOfWeek[fidx])); // content - resizeText( forecasts[fidx].detailedForecast ); - $(div + '.content').text( forecasts[fidx].detailedForecast ); + resizeText(forecasts.daypart[0].narrative[fidx] + ((forecasts.daypart[0].qualifierPhrase[fidx] != null && forecasts.daypart[0].narrative[fidx].includes(forecasts.daypart[0].qualifierPhrase[fidx]) === false) ? forecasts.daypart[0].qualifierPhrase[fidx] : '') + ((forecasts.daypart[0].windPhrase[fidx] != null && forecasts.daypart[0].narrative[fidx].includes(forecasts.daypart[0].windPhrase[fidx]) === false) ? forecasts.daypart[0].windPhrase[fidx] : '')); + $(div + '.content').text(forecasts.daypart[0].narrative[fidx] + ((forecasts.daypart[0].qualifierPhrase[fidx] != null && forecasts.daypart[0].narrative[fidx].includes(forecasts.daypart[0].qualifierPhrase[fidx]) === false) ? forecasts.daypart[0].qualifierPhrase[fidx] : '') + ((forecasts.daypart[0].windPhrase[fidx] != null && forecasts.daypart[0].narrative[fidx].includes(forecasts.daypart[0].windPhrase[fidx]) === false) ? forecasts.daypart[0].windPhrase[fidx] : '')); } + if (fidx === 0) { + weatherAudio.playLocalforecasti(); + } - fadeToContent(div, fillinfo) + $('.city-info-slide').fadeIn(0); + fillinfo(); + $('.info-slide-content.forecast').fadeIn(500); setTimeout( function() { - if (fidx<3) { - currentDisplay(++fidx); + if (fidx<3 + correct) { + $('.info-slide-content.forecast').fadeOut(500, function() { + currentDisplay(++fidx); + fillinfo(); + }); } else { - wait(0); + $('.info-slide-content.forecast').fadeOut(500, function() { + selectval = selectval + 1 + if (selectval === 4) {selectval = 0} + wait(0); + }); } }, slideDelay) } - selectval = selectval + 1 - if (selectval === 4) {selectval = 1} } @@ -307,65 +1000,87 @@ RADAR < MAIN CITY < CITY 1 < CITY 2 $('.city-info-slide #subhead-title').text('Extended Forecast'); var foreDataDaily = dataMan.locations[0].forecasts('daily'); - var icons, weekend - startidx = (foreDataDaily[0].name==='Tonight' ? 1 : 2), - days = ['Sun','Mon','Tue','Wed','Thu','Fri','Sat']; + var icons, weekend, + startidx = 0, + startidxdayonly = 0; + if (foreDataDaily.daypart[0].daypartName[0] == null) { + startidx = 2; + startidxdayonly = 1; + } + //days - $('.info-slide-content.extended-forecast .frost-pane.iw .thing').text(days[ dateFns.getDay(foreDataDaily[startidx].startTime) ]) - $('.info-slide-content.extended-forecast .frost-pane.iiw .thing').text(days[ dateFns.getDay(foreDataDaily[startidx+2].startTime) ]) - $('.info-slide-content.extended-forecast .frost-pane.iiiw .thing').text(days[ dateFns.getDay(foreDataDaily[startidx+4].startTime) ]) - $('.info-slide-content.extended-forecast .frost-pane.ivw .thing').text(days[ dateFns.getDay(foreDataDaily[startidx+6].startTime) ]) - $('.info-slide-content.extended-forecast .lfrost-pane.vw .thing .thingtext').text(days[ dateFns.getDay(foreDataDaily[startidx+8].startTime) ]) + $('.info-slide-content.extended-forecast .frost-pane.iw .thing').text(foreDataDaily.dayOfWeek[startidxdayonly].substring(0,3)) + $('.info-slide-content.extended-forecast .frost-pane.iiw .thing').text(foreDataDaily.dayOfWeek[startidxdayonly + 1].substring(0,3)) + $('.info-slide-content.extended-forecast .frost-pane.iiiw .thing').text(foreDataDaily.dayOfWeek[startidxdayonly + 2].substring(0,3)) + $('.info-slide-content.extended-forecast .frost-pane.ivw .thing').text(foreDataDaily.dayOfWeek[startidxdayonly + 3].substring(0,3)) + $('.info-slide-content.extended-forecast .lfrost-pane.vw .thing .thingtext').text(foreDataDaily.dayOfWeek[startidxdayonly + 4].substring(0,3)) //icons - $('.info-slide-content.extended-forecast .frost-pane.iw .icon').css('background-image', 'url("' + mapNWSicons(foreDataDaily[startidx].icon)[0] + '")'); - $('.info-slide-content.extended-forecast .frost-pane.iiw .icon').css('background-image', 'url("' + mapNWSicons(foreDataDaily[startidx+2].icon) + '")'); - $('.info-slide-content.extended-forecast .frost-pane.iiiw .icon').css('background-image', 'url("' + mapNWSicons(foreDataDaily[startidx+4].icon) + '")'); - $('.info-slide-content.extended-forecast .frost-pane.ivw .icon').css('background-image', 'url("' + mapNWSicons(foreDataDaily[startidx+6].icon) + '")'); - $('.info-slide-content.extended-forecast .lfrost-pane.vw .icon').css('background-image', 'url("' + mapNWSicons(foreDataDaily[startidx+8].icon) + '")'); + $('.info-slide-content.extended-forecast .frost-pane.iw .icon').css('background-image', 'url("' + getCCicon(+foreDataDaily.daypart[0].iconCode[startidx], foreDataDaily.daypart[0].windSpeed[startidx]) + '")'); + $('.info-slide-content.extended-forecast .frost-pane.iiw .icon').css('background-image', 'url("' + getCCicon(+foreDataDaily.daypart[0].iconCode[startidx + 2], foreDataDaily.daypart[0].windSpeed[startidx + 2]) + '")'); + $('.info-slide-content.extended-forecast .frost-pane.iiiw .icon').css('background-image', 'url("' + getCCicon(+foreDataDaily.daypart[0].iconCode[startidx + 4], foreDataDaily.daypart[0].windSpeed[startidx + 4]) + '")'); + $('.info-slide-content.extended-forecast .frost-pane.ivw .icon').css('background-image', 'url("' + getCCicon(+foreDataDaily.daypart[0].iconCode[startidx + 6], foreDataDaily.daypart[0].windSpeed[startidx + 6]) + '")'); + $('.info-slide-content.extended-forecast .lfrost-pane.vw .icon').css('background-image', 'url("' + getCCicon(+foreDataDaily.daypart[0].iconCode[startidx + 8], foreDataDaily.daypart[0].windSpeed[startidx + 8]) + '")'); //conditions - $('.info-slide-content.extended-forecast .frost-pane.iw .conditions').text(builddailyconditions(foreDataDaily[startidx].shortForecast)); - $('.info-slide-content.extended-forecast .frost-pane.iiw .conditions').text(builddailyconditions(foreDataDaily[startidx+2].shortForecast)); - $('.info-slide-content.extended-forecast .frost-pane.iiiw .conditions').text(builddailyconditions(foreDataDaily[startidx+4].shortForecast)); - $('.info-slide-content.extended-forecast .frost-pane.ivw .conditions').text(builddailyconditions(foreDataDaily[startidx+6].shortForecast)); - $('.info-slide-content.extended-forecast .lfrost-pane.vw .conditions').text(builddailyconditions(foreDataDaily[startidx+8].shortForecast)); + $('.info-slide-content.extended-forecast .frost-pane.iw .conditions').text((foreDataDaily.daypart[0].wxPhraseShort[startidx]).replace('M ', 'Mostly ').replace('P ','Partly ')); + $('.info-slide-content.extended-forecast .frost-pane.iiw .conditions').text((foreDataDaily.daypart[0].wxPhraseShort[startidx + 2]).replace('M ', 'Mostly ').replace('P ','Partly ')); + $('.info-slide-content.extended-forecast .frost-pane.iiiw .conditions').text((foreDataDaily.daypart[0].wxPhraseShort[startidx + 4]).replace('M ', 'Mostly ').replace('P ','Partly ')); + $('.info-slide-content.extended-forecast .frost-pane.ivw .conditions').text((foreDataDaily.daypart[0].wxPhraseShort[startidx + 6]).replace('M ', 'Mostly ').replace('P ','Partly ')); + $('.info-slide-content.extended-forecast .lfrost-pane.vw .conditions').text((foreDataDaily.daypart[0].wxPhraseShort[startidx + 8]).replace('M ', 'Mostly ').replace('P ','Partly ')); //high - $('.info-slide-content.extended-forecast .frost-pane.iw .temphigh').text(foreDataDaily[startidx].temperature) - $('.info-slide-content.extended-forecast .frost-pane.iiw .temphigh').text(foreDataDaily[startidx+2].temperature) - $('.info-slide-content.extended-forecast .frost-pane.iiiw .temphigh').text(foreDataDaily[startidx+4].temperature) - $('.info-slide-content.extended-forecast .frost-pane.ivw .temphigh').text(foreDataDaily[startidx+6].temperature) - $('.info-slide-content.extended-forecast .lfrost-pane.vw .temphigh .temphightext').text(foreDataDaily[startidx+8].temperature) + $('.info-slide-content.extended-forecast .frost-pane.iw .temphigh').text(foreDataDaily.temperatureMax[startidxdayonly]) + $('.info-slide-content.extended-forecast .frost-pane.iiw .temphigh').text(foreDataDaily.temperatureMax[startidxdayonly + 1]) + $('.info-slide-content.extended-forecast .frost-pane.iiiw .temphigh').text(foreDataDaily.temperatureMax[startidxdayonly + 2]) + $('.info-slide-content.extended-forecast .frost-pane.ivw .temphigh').text(foreDataDaily.temperatureMax[startidxdayonly + 3]) + $('.info-slide-content.extended-forecast .lfrost-pane.vw .temphigh .temphightext').text(foreDataDaily.temperatureMax[startidxdayonly + 4]) //low - $('.info-slide-content.extended-forecast .frost-pane.iw .templow').text(foreDataDaily[startidx+1].temperature) - $('.info-slide-content.extended-forecast .frost-pane.iiw .templow').text(foreDataDaily[startidx+3].temperature) - $('.info-slide-content.extended-forecast .frost-pane.iiiw .templow').text(foreDataDaily[startidx+5].temperature) - $('.info-slide-content.extended-forecast .frost-pane.ivw .templow').text(foreDataDaily[startidx+7].temperature) - $('.info-slide-content.extended-forecast .lfrost-pane.vw .templow').text(foreDataDaily[startidx+9].temperature) + $('.info-slide-content.extended-forecast .frost-pane.iw .templow').text(foreDataDaily.temperatureMin[startidxdayonly]) + $('.info-slide-content.extended-forecast .frost-pane.iiw .templow').text(foreDataDaily.temperatureMin[startidxdayonly + 1]) + $('.info-slide-content.extended-forecast .frost-pane.iiiw .templow').text(foreDataDaily.temperatureMin[startidxdayonly + 2]) + $('.info-slide-content.extended-forecast .frost-pane.ivw .templow').text(foreDataDaily.temperatureMin[startidxdayonly + 3]) + $('.info-slide-content.extended-forecast .lfrost-pane.vw .templow').text(foreDataDaily.temperatureMin[startidxdayonly + 4]) - function builddailyconditions(dailyconditiontext) { - if (dailyconditiontext.includes("then") === true){ - var splitdc = dailyconditiontext.split("then") - if (dailyconditiontext.includes("Thunderstorms") === true) { - splitdc[0] = splitdc[0].replace(/Slight Chance/g,"Isolated").replace(/Chance/g,"Sct'd").replace(/Thunderstorms/g,"T'storms").replace(/Partly Sunny/g,"Partly Cloudy").replace(/Showers and Thunderstorms/g,"T'Storms").replace(/Patchy/g,"").replace(/Cloudy/g,"Clouds").replace(/Sunny/g,"Sun") - splitdc[1] = splitdc[1].replace(/Slight Chance/g,"Isolated").replace(/Chance/g,"Sct'd").replace(/Thunderstorms/g,"T'storms").replace(/Partly Sunny/g,"Partly Cloudy").replace(/Showers and Thunderstorms/g,"T'Storms").replace(/Patchy/g,"").replace(/Cloudy/g,"Clouds").replace(/Sunny/g,"Sun") - return "AM" + splitdc[0] + ", PM" + splitdc[1] - } else { - splitdc[0] = splitdc[0].replace(/Slight Chance/g,"Few").replace(/Chance/g,"").replace(/Partly Sunny/g,"Partly Cloudy").replace(/Isolated/g,"Few").replace(/Partly Sunny/g,"Partly Cloudy").replace(/Showers and Thunderstorms/g,"T'Storms").replace(/Patchy/g,"").replace(/Cloudy/g,"Clouds").replace(/Sunny/g,"Sun") - splitdc[1] = splitdc[1].replace(/Slight Chance/g,"Few").replace(/Chance/g,"").replace(/Partly Sunny/g,"Partly Cloudy").replace(/Isolated/g,"Few").replace(/Patchy/g,"").replace(/Cloudy/g,"Clouds").replace(/Sunny/g,"Sun") - return "AM" + splitdc[0] + ", PM" + splitdc[1] - } - } else { - if (dailyconditiontext.includes("Thunderstorms") === true) {return dailyconditiontext.replace(/Slight Chance/g,"Isolated").replace(/Chance/g,"Sct'd").replace(/Thunderstorms/g,"T'storms").replace(/Partly Sunny/g,"Partly Cloudy").replace(/Showers and Thunderstorms/g,"T'Storms").replace(/Patchy/g,"")} else {return dailyconditiontext.replace(/Slight Chance/g,"Few").replace(/Chance/g,"").replace(/Partly Sunny/g,"Partly Cloudy").replace(/Isolated/g,"Few").replace(/Patchy/g,"")} - } - } - fadeToContent('.info-slide-content.extended-forecast') - wait(slideDelay) + + $('.info-slide-content.extended-forecast').fadeIn(500); + //buildailycalculating when to show daypart + //fadeout + setTimeout(function() { + $('.info-slide-content.extended-forecast').fadeOut(500, function() { + $('.city-info-slide').fadeOut(0); + wait(0) + }); + }, slideDelay); + } + ,almanac() { + var obsData = location.observations; + if (selectval === 1) { + var foreDataAlmanac = dataMan.locations[0].forecasts('almanac'); + $('.info-slide-content.almanac .frost-pane.half .thing').text(dateFns.format(new Date(),"MMMM D")); + $('.info-slide-content.almanac .frost-pane.half .ahightext').text(foreDataAlmanac.temperatureAverageMax[0]); + $('.info-slide-content.almanac .frost-pane.half .alowtext').text(foreDataAlmanac.temperatureAverageMin[0]); + $('.info-slide-content.almanac .frost-pane.half .rhightext').text(foreDataAlmanac.temperatureRecordMax[0]); + $('.info-slide-content.almanac .frost-pane.half .rlowtext').text(foreDataAlmanac.temperatureRecordMin[0]); + $('.info-slide-content.almanac .frost-pane.half .rhighyear').text(foreDataAlmanac.almanacRecordYearMax[0]); + $('.info-slide-content.almanac .frost-pane.half .rlowyear').text(foreDataAlmanac.almanacRecordYearMin[0]); + $('.info-slide-content.almanac .frost-pane.purple .sunrisetext').text(dateFns.format(new Date(obsData(0).sunriseTimeLocal),"h:m a")); + $('.info-slide-content.almanac .frost-pane.purple .sunsettext').text(dateFns.format(new Date(obsData(0).sunsetTimeLocal),"h:m a")); + $('.city-info-slide #subhead-title').text('Almanac'); + $('.city-info-slide').fadeIn(0); + $('.info-slide-content.almanac').fadeIn(500); + setTimeout(function() { + $('.info-slide-content.almanac').fadeOut(500, function() { + $('.city-info-slide').fadeOut(0); + wait(0) + }); + }, slideDelay); + } else { + wait(0) + }; } - }, keys = Object.keys(displays); @@ -387,15 +1102,15 @@ RADAR < MAIN CITY < CITY 1 < CITY 2 function resizeText(text){ - var s = 50, + var s = 52, $container = $('.info-slide-content.forecast .content'), - $test = $('
') .appendTo($container) .css('font-size', s + 'px') .html(text); + $test = $('
') .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) >= ($container.height()) ) { + while ($test.outerHeight(true) >= (400) ) { s -= 1; $test.css('font-size', s + 'px'); } @@ -406,36 +1121,6 @@ RADAR < MAIN CITY < CITY 1 < CITY 2 } - function fadeToContent(to, callfirst) { - var $to = $(to), - $parent = $to.closest('.info-slide'); - - if ( $parent.is(":hidden") ) { - // hide other visible slide then show the parent - $to.hide(); - $('.info-slide:visible').fadeOut(250, function() { - //$to.hide(); - $parent.fadeIn(250, showMe); - }); - } else { - hideOldShowMe(); - } - - function hideOldShowMe() { - if ($('.info-slide-content:visible')) { - $('.info-slide-content:visible').fadeOut(500, showMe); - } else { - showMe(); - } - } - - function showMe() { - if (callfirst) { callfirst() }; - $to.fadeIn(500); - } - - } - //doDisplay = displays[ keys[idx] ](); // increment the pointer @@ -487,6 +1172,10 @@ RADAR < MAIN CITY < CITY 1 < CITY 2 } + function fadeToContent(to, callfirst) { + } + + function advanceHeader() { @@ -514,86 +1203,22 @@ RADAR < MAIN CITY < CITY 1 < CITY 2 function buildHeader(){ var city, first, woeid, cities='', - arrow='<', - radar='LOCAL RADAR'; + arrow='<', + radar='LOCAL RADAR', + golf='GOLF', + beach='BOAT AND BEACH', + health='HEALTH', + airport='AIRPORTS'; for (var location of dataMan.locations) { city = location.city; cities += arrow+'' + city + ''; } - $('#info-slides-header .hscroller').append(cities + arrow + (radar + cities + arrow).repeat(4)); + $('#info-slides-header .hscroller').append(arrow + health + cities + arrow + (radar + arrow + airport + cities + arrow).repeat(4)); } } // end function -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; i2) { - 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'; - }); - -} diff --git a/webroot/js/utils.js b/webroot/js/utils.js index 6dad8a0..0c3a66d 100644 --- a/webroot/js/utils.js +++ b/webroot/js/utils.js @@ -90,24 +90,134 @@ function heatIndex(T, R) { // T = temp, R = relative humidity // maps current condition code to icon function getCCicon(ccCode, windData){ - var icon = "images/icons/" + ( "0" + {"20011d":1,"20011n":1,"20111d":1,"20111n":1,"20211d":1,"20211n":1,"21011d":46,"21011n":46,"21111d":46,"21111n":46,"21211d":46,"21211n":46,"22111d":1,"22111n":1,"23011d":1,"23011n":1,"23111d":1,"23111n":1,"23211d":1,"23211n":1,"30009d":5,"30009n":5,"30109d":5,"30109n":5,"30209d":5,"30209n":5,"31009d":5,"31009n":5,"31109d":5,"31109n":5,"31209d":5,"31209n":5,"31309d":5,"31309n":5,"31409d":5,"31409n":5,"32109d":5,"32109n":5,"50010d":7,"50010n":7,"50110d":8,"50110n":8,"50210d":31,"50210n":31,"50310d":31,"50310n":31,"50410d":31,"50410d":31,"51110d":6,"51110n":6,"52010d":7,"52010n":7,"52110d":8,"52110n":8,"52210d":31,"52210n":31,"53110d":29,"53110n":37,"60013d":10,"60013n":10,"60113d":12,"60113n":12,"60213d":33,"60213n":33,"61113d":13,"61113n":13,"61213d":13,"61213n":13,"61313d":13,"61313n":13,"61513d":2,"61513n":2,"61613d":2,"61613n":2,"62013d":10,"62013n":10,"62113d":12,"62113n":12,"62213d":33,"62213n":33,"70150d":15,"70150n":15,"71150d":14,"71150n":14,"72150d":16,"72150n":16,"73150d":16,"73150n":16,"74150d":15,"74150n":15,"75150d":16,"75150n":16,"76150d":14,"76150n":14,"76250d":14,"76250n":14,"77150d":18,"77150n":18,"78150d":1,"78150n":1,"80001d":26,"80001n":25,"80102d":28,"80102n":27,"80203d":22,"80203n":21,"80304d":24,"80304n":23,"80404d":20,"80404n":20}[ccCode]).slice(-2) + ".png"; + var icon = "images/icons/" + ( "0" + {"0":0,"1":0,"2":0,"3":47,"4":01,"5":02,"6":38,"7":03,"8":04,"9":05,"10":06,"11":08,"12":08,"13":09,"14":12,"15":11,"16":12,"17":48,"18":48,"19":16,"20":49,"21":16,"22":14,"23":0,"24":50,"25":34,"26":20,"27":21,"28":22,"29":23,"30":24,"31":25,"32":26,"33":27,"34":28,"35":13,"36":41,"37":29,"38":29,"39":30,"40":31,"41":32,"42":33,"43":34,"44":19,"45":35,"46":36,"47":37}[ccCode]).slice(-2) + ".png"; if (parseInt(windData) >= 20) { - if (ccCode === "50110d" || "50110n" || "52110d" || "52110d") { + if (ccCode === "11" || "12" || "40") { icon = "images/icons/45.png" } - if (ccCode === "60113d" || "60113n" || "62113d" || "62113n") { + if (ccCode === "14" || "16" || "42") { icon = "images/icons/34.png" } } return icon } -function getCC(ccCode, windData){ - var condition = {"20011d":"Light Thunderstorm","20011n":"Light Thunderstorm","20111d":"Thunderstorm","20111n":"Thunderstorm","20211d":"Heavy Thunderstorm","20211n":"Heavy Thunderstorm","21011d":"Thunder","21011n":"Thunder","21111d":"Thunder","21111n":"Thunder","21211d":"Thunder","21211n":"Thunder","22111d":"Scattered Thunderstorm","22111n":"Scattered Thunderstorm","23011d":"Light Thunderstorm","23011n":"Light Thunderstorm","23111d":"Light Thunderstorm","23111n":"Light Thunderstorm","23211d":"Light Thunderstorm","23211n":"Light Thunderstorm","30009d":"Drizzle","30009n":"Drizzle","30109d":"Drizzle","30109n":"Drizzle","30209d":"Drizzle","30209n":"Drizzle","31009d":"Drizzle","31009n":"Drizzle","31109d":"Drizzle","31109n":"Drizzle","31209d":"Drizzle","31209n":"Drizzle","31309d":"Drizzle","31309n":"Drizzle","31409d":"Drizzle","31409n":"Drizzle","32109d":"Drizzle","32109n":"Drizzle","50010d":"Light Rain","50010n":"Light Rain","50110d":"Rain","50110n":"Rain","50210d":"Heavy Rain","50210n":"Heavy Rain","50310d":"Heavy Rain","50310n":"Heavy Rain","50410d":"Heavy Rain","50410d":"Heavy Rain","51110d":"Freezing Rain","51110n":"Freezing Rain","52010d":"Light Rain Shower","52010n":"Light Rain Shower","52110d":"Rain Shower","52110n":"Rain Shower","52210d":"Heavy Rain Shower","52210n":"Heavy Rain Shower","53110d":"Scattered Rain Showers","53110n":"Scattered Rain Showers","60013d":"Light Snow","60013n":"Light snow","60113d":"Snow","60113n":"Snow","60213d":"Heavy Snow","60213n":"Heavy Snow","61113d":"Sleet","61113n":"Sleet","61213d":"Sleet","61213n":"Sleet","61313d":"Sleet","61313n":"Sleet","61513d":"Light Rain and Snow","61513n":"Light Rain and Snow","61613d":"Rain and Snow","61613n":"Rain and Snow","62013d":"Light Snow Shower","62013n":"Light Snow Shower","62113d":"Snow Shower","62113n":"Snow Shower","62213d":"Heavy Snow Shower","62213n":"Heavy Snow Shower","70150d":"Mist","70150n":"Mist","71150d":"Smoke","71150n":"Smoke","72150d":"Haze","72150n":"Haze","73150d":"Blowing Dust","73150n":"Blowing Dust","74150d":"Fog","74150n":"Fog","75150d":"Blowing Dust","75150n":"Blowing Dust","76150d":"Blowing Dust","76150n":"Blowing Dust","76250d":"Ash","76250n":"Ash","77150d":"Squalls","77150n":"Squalls","78150d":"Tornado","78150n":"Tornado","80001d":"Sunny","80001n":"Clear","80102d":"Fair","80102n":"Fair","80203d":"Partly Cloudy","80203n":"Partly Cloudy","80304d":"Mostly Cloudy","80304n":"Mostly Cloudy","80404d":"Cloudy","80404n":"Cloudy"}[ccCode] - if (parseInt(windData) >= 20) { - condition = condition + ", windy" +function getWarningPosition(warning) { +var warnpos = { "Tsunami Warning": 1, +"Tornado Warning": 2, +"Extreme Wind Warning": 3, +"Severe Thunderstorm Warning": 4, +"Flash Flood Warning": 5, +"Flash Flood Statement": 6, +"Severe Weather Statement": 7, +"Fire Warning": 14, +"Storm Surge Warning": 17, +"Hurricane Force Wind Warning": 18, +"Hurricane Warning": 19, +"Typhoon Warning": 20, +"Special Marine Warning": 21, +"Blizzard Warning": 22, +"Snow Squall Warning": 23, +"Ice Storm Warning": 24, +"Winter Storm Warning": 25, +"High Wind Warning": 26, +"Tropical Storm Warning": 27, +"Storm Warning": 28, +"Tsunami Advisory": 29, +"Tsunami Watch": 30, +"Avalanche Warning": 31, +"Earthquake Warning": 32, +"Volcano Warning": 33, +"Ashfall Warning": 34, +"Coastal Flood Warning": 35, +"Lakeshore Flood Warning": 36, +"Flood Warning": 37, +"River Flood Warning": 37.5, +"High Surf Warning": 38, +"Dust Storm Warning": 39, +"Blowing Dust Warning": 40, +"Lake Effect Snow Warning": 41, +"Excessive Heat Warning": 42, +"Tornado Watch": 43, +"Severe Thunderstorm Watch": 44, +"Flash Flood Watch": 45, +"Gale Warning": 46, +"Flood Statement": 47, +"Wind Chill Warning": 48, +"Extreme Cold Warning": 49, +"Hard Freeze Warning": 50, +"Freeze Warning": 51, +"Red Flag Warning": 52, +"Storm Surge Watch": 53, +"Hurricane Watch": 54, +"Hurricane Force Wind Watch": 55, +"Typhoon Watch": 56, +"Tropical Storm Watch": 57, +"Storm Watch": 58, +"Hurricane Local Statement": 59, +"Typhoon Local Statement": 60, +"Tropical Storm Local Statement": 61, +"Tropical Depression Local Statement": 62, +"Avalanche Advisory": 63, +"Winter Weather Advisory": 64, +"Wind Chill Advisory": 65, +"Heat Advisory": 66, +"Urban and Small Stream Flood Advisory": 67, +"Small Stream Flood Advisory": 68, +"Arroyo and Small Stream Flood Advisory": 69, +"Flood Advisory": 70, +"Hydrologic Advisory": 71, +"Lakeshore Flood Advisory": 72, +"Coastal Flood Advisory": 73, +"High Surf Advisory": 74, +"Heavy Freezing Spray Warning": 75, +"Dense Fog Advisory": 76, +"Dense Smoke Advisory": 77, +"Small Craft Advisory For Hazardous Seas": 78, +"Small Craft Advisory for Rough Bar": 79, +"Small Craft Advisory for Winds": 80, +"Small Craft Advisory": 81, +"Brisk Wind Advisory": 82, +"Hazardous Seas Warning": 83, +"Dust Advisory": 84, +"Blowing Dust Advisory": 85, +"Lake Wind Advisory": 86, +"Wind Advisory": 87, +"Frost Advisory": 88, +"Ashfall Advisory": 89, +"Freezing Fog Advisory": 90, +"Freezing Spray Advisory": 91, +"Low Water Advisory": 92, +"Avalanche Watch": 94, +"Blizzard Watch": 95, +"Rip Current Statement": 96, +"Beach Hazards Statement": 97, +"Gale Watch": 98, +"Winter Storm Watch": 99, +"Hazardous Seas Watch": 100, +"Heavy Freezing Spray Watch": 101, +"Coastal Flood Watch": 102, +"Lakeshore Flood Watch": 103, +"Flood Watch": 104, +"High Wind Watch": 105, +"Excessive Heat Watch": 106, +"Extreme Cold Watch": 107, +"Wind Chill Watch": 108, +"Lake Effect Snow Watch": 109, +"Hard Freeze Watch": 110, +"Freeze Watch": 111, +"Fire Weather Watch": 112, +"Extreme Fire Danger": 113, +"Coastal Flood Statement": 115, +"Lakeshore Flood Statement": 116, +"Special Weather Statement": 117, +"Marine Weather Statement": 118, +"Air Quality Alert": 119, +"Air Stagnation Advisory": 120, +"Hazardous Weather Outlook": 121, +}[warning] + if (warnpos !== undefined) { + return warnpos; + } else { + return 140; } - return condition - -} - -// https://date-fns.org/docs/Getting-Started +}// https://date-fns.org/docs/Getting-Started diff --git a/webroot/js/weather.js b/webroot/js/weather.js index 2770937..3dce154 100644 --- a/webroot/js/weather.js +++ b/webroot/js/weather.js @@ -3,14 +3,13 @@ function WeatherManager() { var mainloc var mainMap, miniMap, slides, - dataMan, loops, // weatherAudio, + dataMan, loops, //weatherAudio, that = this; $(function(){ // init marquees function refreshMarquee () { - $('#marquee-container') .marquee('destroy') .marquee({speed: 200, pauseOnHover:true, delayBeforeStart:3000}) @@ -53,7 +52,10 @@ function WeatherManager() { var queryString = window.location.search; if (queryString) { - dataMan = createDataManager( queryString.split("?")[1] ); + $.getJSON("https://api.weather.com/v3/location/search?query="+queryString.split("?")[1]+"&language=en-US&format=json&apiKey=e1f10a1e78da46f5b10a1e78da96f525", function(data) { + dataMan = createDataManager( data.location.latitude[0]+','+data.location.longitude[0] ); + mainloc = data.location.city[0] + }); } else { // get lat lon from user's ip @@ -89,19 +91,17 @@ function WeatherManager() { function refreshObservationDisplay() { var data = dataMan.locations[0].observations(0), - cond = data.current.weather[0]; + cond = data.wxPhraseLong; if (mainMap===undefined) { - mainMap = that.mainMap = new Radar("radar-1", 3, 8, data.lat, data.lon, false); - miniMap = new Radar("minimap", 3, 5, data.lat, data.lon); + mainMap = that.mainMap = new Radar("radar-1", 3, 8, data.latitude, data.longitude, false); + miniMap = new Radar("minimap", 3, 6, data.latitude, data.longitude); } $('#city').text(mainloc); $('#forecast-city').text(mainloc + ':'); $('#current-temp').text( dataMan.locations[0].temperature() ) ; - $('#conditions-icon').css('background-image', 'url("' + getCCicon(cond.id + cond.icon) + '")'); - - //weatherAudio.playCurrentConditions(cond); + $('#conditions-icon').css('background-image', 'url("' + getCCicon(+data.iconCode, data.windSpeed) + '")'); }