mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 11:50:00 +00:00
Add the newsfeed URL to config. Add weather icons to the forecast.
This commit is contained in:
parent
b8b32a449c
commit
eb7350fb52
10
css/main.css
10
css/main.css
@ -134,6 +134,16 @@ body, html {
|
|||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.icon-small
|
||||||
|
{
|
||||||
|
position: relative;
|
||||||
|
display: inline-block;
|
||||||
|
font-size: 20px;
|
||||||
|
padding-left: 10px;
|
||||||
|
padding-right: -10px;
|
||||||
|
font-weight: 100;
|
||||||
|
}
|
||||||
|
|
||||||
.time .sec {
|
.time .sec {
|
||||||
font-size: 25px;
|
font-size: 25px;
|
||||||
color: #666;
|
color: #666;
|
||||||
|
10
js/config.js
10
js/config.js
@ -4,12 +4,18 @@ var lang = window.navigator.language;
|
|||||||
//var lang = 'en';
|
//var lang = 'en';
|
||||||
|
|
||||||
//change weather params here:
|
//change weather params here:
|
||||||
|
//units: metric or imperial
|
||||||
var weatherParams = {
|
var weatherParams = {
|
||||||
'q':'Baarn,Netherlands',
|
'q':'New York, NY',
|
||||||
'units':'metric',
|
'units':'imperial',
|
||||||
'lang':lang
|
'lang':lang
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//var feed = 'http://feeds.nos.nl/nosjournaal?format=rss';
|
||||||
|
//var feed = 'http://www.nu.nl/feeds/rss/achterklap.rss';
|
||||||
|
//var feed = 'http://www.nu.nl/feeds/rss/opmerkelijk.rss';
|
||||||
|
var feed = 'http://www.nytimes.com/services/xml/rss/nyt/HomePage.xml';
|
||||||
|
|
||||||
// compliments:
|
// compliments:
|
||||||
var compliments = [
|
var compliments = [
|
||||||
'Hey, handsome!',
|
'Hey, handsome!',
|
||||||
|
28
js/main.js
28
js/main.js
@ -249,6 +249,26 @@ jQuery(document).ready(function($) {
|
|||||||
|
|
||||||
(function updateWeatherForecast()
|
(function updateWeatherForecast()
|
||||||
{
|
{
|
||||||
|
var iconTable = {
|
||||||
|
'01d':'wi-day-sunny',
|
||||||
|
'02d':'wi-day-cloudy',
|
||||||
|
'03d':'wi-cloudy',
|
||||||
|
'04d':'wi-cloudy-windy',
|
||||||
|
'09d':'wi-showers',
|
||||||
|
'10d':'wi-rain',
|
||||||
|
'11d':'wi-thunderstorm',
|
||||||
|
'13d':'wi-snow',
|
||||||
|
'50d':'wi-fog',
|
||||||
|
'01n':'wi-night-clear',
|
||||||
|
'02n':'wi-night-cloudy',
|
||||||
|
'03n':'wi-night-cloudy',
|
||||||
|
'04n':'wi-night-cloudy',
|
||||||
|
'09n':'wi-night-showers',
|
||||||
|
'10n':'wi-night-rain',
|
||||||
|
'11n':'wi-night-thunderstorm',
|
||||||
|
'13n':'wi-night-snow',
|
||||||
|
'50n':'wi-night-alt-cloudy-windy'
|
||||||
|
}
|
||||||
$.getJSON('http://api.openweathermap.org/data/2.5/forecast', weatherParams, function(json, textStatus) {
|
$.getJSON('http://api.openweathermap.org/data/2.5/forecast', weatherParams, function(json, textStatus) {
|
||||||
|
|
||||||
var forecastData = {};
|
var forecastData = {};
|
||||||
@ -260,10 +280,12 @@ jQuery(document).ready(function($) {
|
|||||||
if (forecastData[dateKey] == undefined) {
|
if (forecastData[dateKey] == undefined) {
|
||||||
forecastData[dateKey] = {
|
forecastData[dateKey] = {
|
||||||
'timestamp':forecast.dt * 1000,
|
'timestamp':forecast.dt * 1000,
|
||||||
|
'icon':forecast.weather[0].icon,
|
||||||
'temp_min':forecast.main.temp,
|
'temp_min':forecast.main.temp,
|
||||||
'temp_max':forecast.main.temp
|
'temp_max':forecast.main.temp
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
|
forecastData[dateKey]['icon'] = forecast.weather[0].icon;
|
||||||
forecastData[dateKey]['temp_min'] = (forecast.main.temp < forecastData[dateKey]['temp_min']) ? forecast.main.temp : forecastData[dateKey]['temp_min'];
|
forecastData[dateKey]['temp_min'] = (forecast.main.temp < forecastData[dateKey]['temp_min']) ? forecast.main.temp : forecastData[dateKey]['temp_min'];
|
||||||
forecastData[dateKey]['temp_max'] = (forecast.main.temp > forecastData[dateKey]['temp_max']) ? forecast.main.temp : forecastData[dateKey]['temp_max'];
|
forecastData[dateKey]['temp_max'] = (forecast.main.temp > forecastData[dateKey]['temp_max']) ? forecast.main.temp : forecastData[dateKey]['temp_max'];
|
||||||
}
|
}
|
||||||
@ -275,10 +297,12 @@ jQuery(document).ready(function($) {
|
|||||||
var opacity = 1;
|
var opacity = 1;
|
||||||
for (var i in forecastData) {
|
for (var i in forecastData) {
|
||||||
var forecast = forecastData[i];
|
var forecast = forecastData[i];
|
||||||
|
var iconClass = iconTable[forecast.icon];
|
||||||
var dt = new Date(forecast.timestamp);
|
var dt = new Date(forecast.timestamp);
|
||||||
var row = $('<tr />').css('opacity', opacity);
|
var row = $('<tr />').css('opacity', opacity);
|
||||||
|
|
||||||
row.append($('<td/>').addClass('day').html(moment.weekdaysShort(dt.getDay())));
|
row.append($('<td/>').addClass('day').html(moment.weekdaysShort(dt.getDay())));
|
||||||
|
row.append($('<td/>').addClass('icon-small').addClass(iconClass));
|
||||||
row.append($('<td/>').addClass('temp-max').html(roundVal(forecast.temp_max)));
|
row.append($('<td/>').addClass('temp-max').html(roundVal(forecast.temp_max)));
|
||||||
row.append($('<td/>').addClass('temp-min').html(roundVal(forecast.temp_min)));
|
row.append($('<td/>').addClass('temp-min').html(roundVal(forecast.temp_min)));
|
||||||
|
|
||||||
@ -297,9 +321,7 @@ jQuery(document).ready(function($) {
|
|||||||
|
|
||||||
(function fetchNews() {
|
(function fetchNews() {
|
||||||
$.feedToJson({
|
$.feedToJson({
|
||||||
feed:'http://feeds.nos.nl/nosjournaal?format=rss',
|
feed: feed,
|
||||||
//feed:'http://www.nu.nl/feeds/rss/achterklap.rss',
|
|
||||||
//feed:'http://www.nu.nl/feeds/rss/opmerkelijk.rss',
|
|
||||||
success: function(data){
|
success: function(data){
|
||||||
news = [];
|
news = [];
|
||||||
for (var i in data.item) {
|
for (var i in data.item) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user