var loopssevereweathermode = false;
var displayingAtmospheric = false;
var miniMap;
function Loops() {
// init the display loops
displayForecast(0);
refreshObservationDisplay()
setInterval(refreshObservationDisplay,300000);
}
function refreshObservationDisplay() {
var cond = weatherInfo.currentCond.sidebar.cond;
$('#city').text(maincitycoords.displayname);
$('#forecast-city').text(maincitycoords.displayname + ':');
if (weatherInfo.radarTempUnavialable == false) {
if (loopssevereweathermode == false){
$('#minimap').fadeIn(0)
$('#minimap-title').fadeIn(0)
miniMap = new Radar("minimap", 3, 7, maincitycoords.lat, maincitycoords.lon);
}
} else {
$('#minimap').fadeOut(0)
$('#minimap-title').fadeOut(0)
}
if (weatherInfo.currentCond.sidebar.noReport == true) {
$('#now').fadeOut(0)
$('#current-temp').fadeOut(0)
$('#current-info').fadeOut(0)
$('#conditions-icon').fadeOut(0)
$('#current-info-severe').fadeOut(0)
$('#current-info-details').fadeOut(0)
$('#current-noreport').fadeIn(0)
} else {
if (displayingAtmospheric == false) {
if (loopssevereweathermode == false) { displayAtmospheric(0) } else { displaySevereAtmospheric(0) }
}
$('#now').fadeIn(0)
$('#current-temp').fadeIn(0)
if (loopssevereweathermode == false) { $('#current-info').fadeIn(0) } else {
$('#current-info-severe').fadeIn(0);
$('#current-info-details').fadeIn(0);
}
$('#current-noreport').fadeOut(0)
$('#conditions-icon').fadeIn(0)
$('#current-temp').text( weatherInfo.currentCond.sidebar.temp ) ;
$('#conditions-icon').css('background-image', 'url("' + getCCicon(+weatherInfo.currentCond.sidebar.icon, weatherInfo.currentCond.sidebar.windspeed) + '")');
}
}
function displayAtmospheric(idx) {
if (weatherInfo.currentCond.sidebar.noReport == false){
displayingAtmospheric = true;
var displays = {
conditions() {
return (weatherInfo.currentCond.sidebar.cond).toLowerCase();
},
wind(){ return 'wind ' + weatherInfo.currentCond.sidebar.wind; },
gusts(){
if ( weatherInfo.currentCond.sidebar.gust!=undefined ) {
return (weatherInfo.currentCond.sidebar.gust!="none") ? 'gusts ' + weatherInfo.currentCond.sidebar.gust : '';
}
},
humidity(){ return 'humidity ' + weatherInfo.currentCond.sidebar.humid + '%'; },
dewpoint(){ return 'dew point ' + weatherInfo.currentCond.sidebar.dewpt + '°'; },
heatindex_windchill(){
if (weatherInfo.currentCond.sidebar.feelslike.type != "dontdisplay") {
return weatherInfo.currentCond.sidebar.feelslike.type + " " + weatherInfo.currentCond.sidebar.feelslike.val + '°'
}
},
pressure(){ return 'pressure ' + weatherInfo.currentCond.sidebar.pressure + ' ' + weatherInfo.currentCond.sidebar.pressureTrend},
visibility() { return 'visibility ' + weatherInfo.currentCond.sidebar.visibility + ' mile' + (weatherInfo.currentCond.sidebar.visibility != 1 ? 's' : ''); },
uvindex() { return 'UV index ' + weatherInfo.currentCond.sidebar.uvidx; },
},
keys = Object.keys(displays),
text = displays[ keys[idx] ]();
// increment the pointer
if (weatherInfo.reboot == true) {
$('#forecast-shadow').hide()
return;
}
if (loopssevereweathermode == false) {
idx = (++idx===keys.length ? 0 : idx);
if (text) {
$('#current-info').html(text);
setTimeout(function(){ displayAtmospheric(idx) }, 6000); // 6 second increment loop
} else {
// nothing to display - skip to the next one
setTimeout(function(){ displayAtmospheric(idx) }, 0);
}
}
} else {displayingAtmospheric = false}
} // end function
function displaySevereAtmospheric(idx) {
if (weatherInfo.currentCond.sidebar.noReport == false) {
displayingAtmospheric = true
$('#current-info-severe').text((weatherInfo.currentCond.sidebar.cond).toLowerCase());
var displays = {
display1() {
return 'wind ' + weatherInfo.currentCond.sidebar.wind + '
' + ((weatherInfo.currentCond.sidebar.gust!="none") ? 'gusts ' + weatherInfo.currentCond.sidebar.gust + '
' : '' ) + 'humidity ' + weatherInfo.currentCond.sidebar.humid + '%' + '
' + 'dew point ' + weatherInfo.currentCond.sidebar.dewpt + '°'
},
display2() {
return (((weatherInfo.currentCond.sidebar.feelslike.type != "dontdisplay") ? weatherInfo.currentCond.sidebar.feelslike.type + " " + weatherInfo.currentCond.sidebar.feelslike.val + '°' + '
' : '' ) + 'pressure ' + weatherInfo.currentCond.sidebar.pressure + weatherInfo.currentCond.sidebar.pressureTrend + '
' + 'visibility ' + weatherInfo.currentCond.sidebar.visibility + ((weatherInfo.currentCond.sidebar.visibility != 1 ) ? ' miles' : ' mile') + '
' + 'ceiling ' + ((weatherInfo.currentCond.sidebar.ceiling != null) ? ((weatherInfo.currentCond.sidebar.ceiling).toString() + ' ft') : ''))
}
},
keys = Object.keys(displays),
text = displays[ keys[idx] ]();
idx = (++idx===keys.length ? 0 : idx);
if (weatherInfo.reboot == true) {
$('#forecast-shadow').hide()
return;
}
if (loopssevereweathermode == true) {
if (text) {
$('#current-info-details').html(text);
setTimeout(function(){ displaySevereAtmospheric(idx) }, 6000); // 6 second increment loop
} else {
// nothing to display - skip to the next one
setTimeout(function(){ displaySevereAtmospheric(idx) }, 0);
}
}
} else {displayingAtmospheric = false}
} //end function
function displayForecast(idx) {
var displays = {
text1() {
$('.forecast-header').prop('id', 'normalheader');
if (weatherInfo.dayDesc.lowerbar.noReport == true) {
$('#forecast-title').fadeOut(0)
$('#forecast-text').fadeOut(0)
$('#forecast-shadow').css('box-shadow','0 3px 10px 0 rgba(0, 0, 0, 0)')
$('#forecast-shadow').css('background','rgba(0,0,0,0)')
$('.forecast-tiles').fadeOut(0)
$('#forecast-noreport').fadeIn(0)
} else {
$('#forecast-noreport').fadeOut(0)
$('#forecast-shadow').css('background','#8cadd1')
$('#forecast-shadow').css('box-shadow','0 3px 10px 0 rgba(0, 0, 0, .35)')
$('#forecast-text').fadeIn(0)
$('#forecast-title').fadeIn(0)
$('#forecast-title').text(weatherInfo.dayDesc.lowerbar.day[0].name + "'S" + " FORECAST");
resizeText(weatherInfo.dayDesc.lowerbar.day[0].desc);
}
},
text2() {
$('.forecast-header').prop('id', 'normalheader');
if (weatherInfo.dayDesc.lowerbar.noReport == true) {
$('#forecast-shadow').css('background','rgba(0,0,0,0)')
$('#forecast-shadow').css('box-shadow','0 3px 10px 0 rgba(0, 0, 0, 0)')
$('#forecast-title').fadeOut(0)
$('#forecast-text').fadeOut(0)
$('.forecast-tiles').fadeOut(0)
$('#forecast-noreport').fadeIn(0)
} else {
$('#forecast-noreport').fadeOut(0)
$('#forecast-shadow').css('background','#8cadd1')
$('#forecast-shadow').css('box-shadow','0 3px 10px 0 rgba(0, 0, 0, .35)')
$('#forecast-text').fadeIn(0)
$('#forecast-title').fadeIn(0)
$('#forecast-title').text(weatherInfo.dayDesc.lowerbar.day[1].name + "'S" + " FORECAST");
resizeText(weatherInfo.dayDesc.lowerbar.day[1].desc);
}
},
fiveday() {
$('.forecast-header').prop('id', 'normaltiles');
$('.forecast-tiles').prop('id', 'normalheader');
if (weatherInfo.fiveDay.lowerbar.noReport == true) {
$('#forecast-shadow').css('box-shadow','0 3px 10px 0 rgba(0, 0, 0, 0)')
$('#forecast-shadow').css('background','rgba(0,0,0,0)')
$('#forecast-title').fadeOut(0)
$('#forecast-text').fadeOut(0)
$('.forecast-tiles').fadeOut(0)
$('#forecast-noreport').fadeIn(0)
} else {
$('#forecast-shadow').css('box-shadow','0 3px 10px 0 rgba(0, 0, 0, .35)')
$('#forecast-title').fadeIn(0)
$('#forecast-noreport').fadeOut(0)
var newtile, weekend, icons;
$('#forecast-title').text("5 DAY FORECAST");
$('.forecast-tiles').empty();
for (var i=0; i<5; i++ ) {
newtile = $("