Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SRCT
weather
Commits
f098c67b
Commit
f098c67b
authored
Jan 29, 2017
by
Zach Knox
Browse files
fixed precip stats in hourly table
parent
11ec6d9c
Changes
3
Hide whitespace changes
Inline
Side-by-side
weather/client/views/home/home.html
View file @
f098c67b
...
...
@@ -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>
...
...
weather/client/views/weather/weather.html
View file @
f098c67b
...
...
@@ -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}}
<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}}
...
...
weather/client/views/weather/weather.js
View file @
f098c67b
...
...
@@ -5,18 +5,19 @@ Template.weather.helpers({
return
weatherData
;
},
//Convert precipitation percentage to words
precipitationWords
:
function
(
p
recipProb
)
{
precipitationWords
:
function
(
rawP
recipProb
)
{
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
(
p
recipProb
)
{
precipitationIcons
:
function
(
rawP
recipProb
)
{
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
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment