Skip to content
This repository has been archived by the owner on Sep 24, 2024. It is now read-only.

Add umbrella reminder feature #43

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion public/js/mirror.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
;(function() {
'use strict';

var time, date, day, fcast, temp, weatherDesc, loc, weathericon;
var time, date, day, fcast, temp, weatherDesc, loc, reminder, weathericon;

var MIRROR_STATES = {
BLANK: 'blank', // Basic state. No face detected in screen. No one logged in.
Expand Down Expand Up @@ -39,6 +39,9 @@
var desc = current.conditions();
var city = current.city();
var icon = Weather.Utils.getIcon(current.icon());
var rem = current.reminder();

reminder.html(rem);

temp.html(Weather.kelvinToFahrenheit(current.temperature()).toFixed(0) + '\xB0');
weatherDesc.html(desc);
Expand Down Expand Up @@ -99,6 +102,7 @@
temp = $('.temperature');
weatherDesc = $('.conditions span');
loc = $('.weather-location');
reminder = $('.weather-reminder');
weathericon = $('#weather-icon');
updateTime();
updateWeather();
Expand Down
14 changes: 14 additions & 0 deletions public/js/weather.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,20 @@ Weather.Current = function(data) {
this.data = data;
};

Weather.Current.prototype.reminder = function() {
var conditionID = this.data.weather[0].id;
var firstDigit = conditionID.toString()[0];
var reminder;
var sunny = "Don't worry, it's gonna be a sunny day!"
var rain = "Don't forget to bring an umbrella!";
if (firstDigit != '8') {
reminder = rain;
} else {
reminder = sunny;
}
return reminder;
}

Weather.Current.prototype.temperature = function() {
return this.data.main.temp;
};
Expand Down
2 changes: 1 addition & 1 deletion views/layouts/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
</script>
{{/if}}
</body>
</html>
</html>
1 change: 1 addition & 0 deletions views/partials/weather.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
<img id="weather-icon" alt="" />
</div>
<div class="weather-location"></div>
<div class="weather-reminder"></div>
</div>