Commit f098c67b authored by Zach Knox's avatar Zach Knox

fixed precip stats in hourly table

parent 11ec6d9c
......@@ -10,9 +10,9 @@
<!-- Tab Bar Container , and Tab links -->
<div class="mdl-layout__tab-bar mdl-js-ripple-effect header-bg" style="background: #006633;">
<a id="fairfax-tab-button" href="#fairfax" class="mdl-layout__tab is-active">Fairfax</a>
<a href="#arlington" class="mdl-layout__tab">Arlington</a>
<!--a href="#arlington" class="mdl-layout__tab">Arlington</a>
<a href="#scitech" class="mdl-layout__tab">SciTech</a>
<a href="#korea" class="mdl-layout__tab">Mason Korea</a>
<a href="#korea" class="mdl-layout__tab">Mason Korea</a -->
</div>
</header>
<!-- MDL Layout Header -->
......@@ -23,27 +23,25 @@
<div class="page-content">{{> weather}}</div>
</div>
</section>
<!-- Tab No 2-->
<!--
<section class="mdl-layout__tab-panel" id="arlington">
<div class="page-content">
<div class="page-content">{{> weather}}</div>
</div>
</section>
<!-- Tab No 3-->
<section class="mdl-layout__tab-panel" id="scitech">
<div class="page-content">
<div class="page-content">{{> weather}}</div>
</div>
</section>
<!-- Tab No 4-->
<section class="mdl-layout__tab-panel" id="korea">
<div class="page-content">
<div class="page-content">{{> weather}}</div>
</div>
</section>
-->
{{> footer}}
</main>
</div>
......
......@@ -27,7 +27,7 @@
Feels like {{roundNumber weatherData.data.currently.apparentTemperature}}<i class="wi wi-fahrenheit"></i>
<br /><br /><i class="wi wi-{{precipitationIcons weatherData.data.currently.precipProbability}}"></i> {{precipitationWords weatherData.data.currently.precipProbability}} &nbsp;&nbsp;&nbsp;<i class="wi wi-wind wi-towards-{{windDirectionClass}}"></i> {{roundNumber weatherData.data.currently.windSpeed}}mph {{windDirection}}
<!-- TODO: Change the icon based on time -->
<br /><br /><i class="wi wi-sunset"></i> {{formatTimestamp weatherData.data.currently.time}}
<br /><br /><!--i class="wi wi-sunset"></i> {{formatTimestamp weatherData.data.currently.time}}-->
</div>
</div>
</div>
......@@ -49,7 +49,7 @@
<td class="mdl-data-table__cell--non-numeric">{{formatTimestampToHour hourWeather.time}}</td>
<td class="mdl-data-table__cell--non-numeric"><i class="wi {{convertIconName hourWeather.icon}} wi-fw"></i> {{hourWeather.summary}}</td>
<td>{{roundNumber hourWeather.temperature}}<i class="wi wi-fahrenheit"></i></td>
<td>{{roundNumber hourWeather.precipProbability}}%</td>
<td>{{precipitationReadable hourWeather.precipProbability}}%</td>
<td>{{roundNumber hourWeather.windSpeed}}mph</td>
</tr>
{{/each}}
......
......@@ -5,18 +5,19 @@ Template.weather.helpers({
return weatherData;
},
//Convert precipitation percentage to words
precipitationWords: function(precipProb) {
precipitationWords: function(rawPrecipProb) {
weatherDataDependency.depend();
var precipProb = rawPrecipProb * 100;
if(weatherData === undefined) return "...";
if(precipProb === 0) return "No Rain Expected";
if(precipProb > 50 && precipProb < 95) return "Potential for Rain";
if(precipProb > 95) return "Bring an Umbrella";
if(precipProb === 0) return "No Precipitation";
if(precipProb >= 90) return "Bring an Umbrella ("+precipProb+"% chance)";
if(precipProb > 100) return "Wat."; //Wait.
return precipProb+"% Precipitation"; // Otherwise, return the percentage
return precipProb+"% Chance of Precipitation"; // Otherwise, return the percentage
},
//Convert precipitation percentage to icons
precipitationIcons: function(precipProb) {
precipitationIcons: function(rawPrecipProb) {
weatherDataDependency.depend();
var precipProb = rawPrecipProb * 100;
if(weatherData === undefined) return "...";
if(precipProb === 0) return "cloud";
if(precipProb > 50 && precipProb < 95) return "showers";
......@@ -24,6 +25,11 @@ Template.weather.helpers({
if(precipProb > 100) return "alien"; //Wait.
return precipProb+"% Precipitation"; // Otherwise, return the percentage
},
precipitationReadable: function(rawPrecipProb) {
weatherDataDependency.depend();
var precipProb = Math.round(rawPrecipProb * 100);
return precipProb;
},
//Converts degrees to words
windDirection: function() {
weatherDataDependency.depend();
......@@ -45,14 +51,14 @@ Template.weather.helpers({
formatTimestamp: function(timestamp) {
if(timestamp === undefined) return "...";
var d = new Date(timestamp*1000);
console.log("GOT: "+timestamp)
//console.log("GOT: "+timestamp)
return d.toLocaleString("en-us", { hour: 'numeric', minute: 'numeric', timeZoneName:'short'});
},
//Formats unix time to just a 12 hour time
formatTimestampToHour: function(timestamp) {
if(timestamp === undefined) return "...";
var d = new Date(timestamp*1000);
console.log("GOT: "+timestamp)
//console.log("GOT: "+timestamp)
return d.toLocaleString("en-us", { hour: 'numeric'});
},
//Converts icon names from darksky to those that can be used by our css library
......@@ -91,13 +97,11 @@ Template.weather.helpers({
break;
}
}
debugger;
return hourDataArray.slice(startIndex, startIndex+12)
},
getDayNameFromTime: function(timestamp) {
var given = new Date(timestamp);
var days = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'];
return days[ given.getDay() ];
},
getColorStyle: function(temp) {
......@@ -135,7 +139,6 @@ Template.weather.helpers({
return "degree100";
}
else {
Console.log(temp);
return temp;
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment