Squashed commit of the following:

commit e38dd346d9
Author: Michael Teeuw <michael@xonaymedia.nl>
Date:   Sat Apr 2 19:17:30 2016 +0200

    Add the possibility to set the maximum number of days.

commit 6f5c86775b
Author: Sam Vendittelli <sam.vendittelli@hotmail.com>
Date:   Sat Apr 2 06:27:44 2016 +0100

    Fixed cursor appearing in margin

    Cursor was appearing in the margin so moved `cursor: none` property to html.

commit 576c668d84
Author: Domi-G <lessuseguy+githubdomig@gmail.com>
Date:   Fri Apr 1 22:52:32 2016 +0200

    Huge cleanup of white space
This commit is contained in:
Michael Teeuw
2016-04-03 19:52:13 +02:00
parent e2436ad796
commit 5eed80c28e
41 changed files with 152 additions and 184 deletions

View File

@@ -1,6 +1,6 @@
# Module: Calendar
The `calendar` module is one of the default modules of the MagicMirror.
This module displays events from a public .ical calendar. It can combine multiple calendars.
This module displays events from a public .ical calendar. It can combine multiple calendars.
## Using the module
@@ -13,7 +13,7 @@ modules: [
config: {
// The config property is optional.
// If no config is set, an example calendar is shown.
// See 'Configuration options' for more information.
// See 'Configuration options' for more information.
}
}
]
@@ -40,6 +40,12 @@ The following properties can be configured:
<br><b>Default value:</b> <code>10</code>
</td>
</tr>
<tr>
<td><code>maximumNumberOfDays</code></td>
<td>The maximum number of days in the future.<br>
<br><b>Default value:</b> <code>365</code>
</td>
</tr>
<tr>
<td><code>displaySymbol</code></td>
<td>Display a symbol in front of an entry.<br>
@@ -100,7 +106,7 @@ The following properties can be configured:
<td><code>titleReplace</code></td>
<td>An object of textual replacements applied to the tile of the event. This allow to remove or replace certains words in the title.<br>
<br><b>Example:</b> <br>
<code>
titleReplace: {'Birthday of ' : '', 'foo':'bar'}
</code>
@@ -149,4 +155,4 @@ config: {
</td>
</tr>
</tbody>
</table>
</table>

View File

@@ -20,4 +20,4 @@
.calendar .time {
padding-left: 30px;
text-align: right;
}
}

View File

@@ -12,12 +12,13 @@ Module.register('calendar',{
// Define module defaults
defaults: {
maximumEntries: 10, // Total Maximum Entries
maximumNumberOfDays: 365,
displaySymbol: true,
defaultSymbol: 'calendar', // Fontawsome Symbol see http://fontawesome.io/cheatsheet/
maxTitleLength: 25,
maxTitleLength: 25,
fetchInterval: 5 * 60 * 1000, // Update every 5 minutes.
animationSpeed: 2000,
fade: true,
fade: true,
fadePoint: 0.25, // Start on 1/4th of the list.
calendars: [
{
@@ -58,7 +59,7 @@ Module.register('calendar',{
// Override socket notification handler.
socketNotificationReceived: function(notification, payload) {
if (notification === 'CALENDAR_EVENTS') {
if (notification === 'CALENDAR_EVENTS') {
if (this.hasCalendarURL(payload.url)) {
this.calendarData[payload.url] = payload.events;
}
@@ -180,6 +181,7 @@ Module.register('calendar',{
this.sendSocketNotification('ADD_CALENDAR', {
url: url,
maximumEntries: this.config.maximumEntries,
maximumNumberOfDays: this.config.maximumNumberOfDays,
fetchInterval: this.config.fetchInterval
});
},
@@ -237,4 +239,4 @@ Module.register('calendar',{
title = this.shorten(title, this.config.maxTitleLength);
return title;
}
});
});

View File

@@ -10,7 +10,7 @@ var ical = require('ical');
var moment = require('moment');
var validUrl = require('valid-url');
var CalendarFetcher = function(url, reloadInterval, maximumEntries) {
var CalendarFetcher = function(url, reloadInterval, maximumEntries, maximumNumberOfDays) {
var self = this;
var reloadTimer = null;
@@ -42,7 +42,8 @@ var CalendarFetcher = function(url, reloadInterval, maximumEntries) {
for (var e in data) {
var event = data[e];
var today = moment().startOf('day');
if (event.type === 'VEVENT') {
var startDate = (event.start.length === 8) ? moment(event.start, 'YYYYMMDD') : moment(new Date(event.start));
@@ -54,6 +55,7 @@ var CalendarFetcher = function(url, reloadInterval, maximumEntries) {
// This causes the times of the recurring event to be incorrect.
// By adjusting the timeset property, this issue is solved.
var now = new Date();
if (rule.timeset[0].hour == now.getHours(),
rule.timeset[0].minute == now.getMinutes(),
rule.timeset[0].second == now.getSeconds()) {
@@ -62,11 +64,8 @@ var CalendarFetcher = function(url, reloadInterval, maximumEntries) {
rule.timeset[0].minute = startDate.format('m');
rule.timeset[0].second = startDate.format('s');
}
var oneYear = new Date();
oneYear.setFullYear(oneYear.getFullYear() + 1);
var dates = rule.between(new Date(), oneYear, true, limitFunction);
var dates = rule.between(new Date(), today.add(maximumNumberOfDays, 'days') , true, limitFunction);
//console.log(dates);
for (var d in dates) {
startDate = moment(new Date(dates[d]));
@@ -78,8 +77,8 @@ var CalendarFetcher = function(url, reloadInterval, maximumEntries) {
} else {
// Single event.
var today = moment().startOf('day');
if (startDate > today) {
if (startDate > today && startDate <= today.add(maximumNumberOfDays, 'days')) {
newEvents.push({
title: event.summary,
startDate: startDate.format('x')
@@ -92,7 +91,7 @@ var CalendarFetcher = function(url, reloadInterval, maximumEntries) {
newEvents.sort(function(a,b) {
return a.startDate - b.startDate;
});
events = newEvents.slice(0, maximumEntries);
self.broadcastEvents();
@@ -180,14 +179,14 @@ module.exports = NodeHelper.create({
console.log('Starting node helper for: ' + this.name);
},
// Override socketNotificationReceived method.
socketNotificationReceived: function(notification, payload) {
if (notification === 'ADD_CALENDAR') {
//console.log('ADD_CALENDAR: ');
this.createFetcher(payload.url, payload.fetchInterval, payload.maximumEntries);
this.createFetcher(payload.url, payload.fetchInterval, payload.maximumEntries, payload.maximumNumberOfDays);
}
},
@@ -199,7 +198,7 @@ module.exports = NodeHelper.create({
* attribute reloadInterval number - Reload interval in milliseconds.
*/
createFetcher: function(url, fetchInterval, maximumEntries) {
createFetcher: function(url, fetchInterval, maximumEntries, maximumNumberOfDays) {
var self = this;
if (!validUrl.isUri(url)){
@@ -210,8 +209,8 @@ module.exports = NodeHelper.create({
var fetcher;
if (typeof self.fetchers[url] === 'undefined') {
console.log('Create new calendar fetcher for url: ' + url + ' - Interval: ' + fetchInterval);
fetcher = new CalendarFetcher(url, fetchInterval, maximumEntries);
fetcher = new CalendarFetcher(url, fetchInterval, maximumEntries, maximumNumberOfDays);
fetcher.onReceive(function(fetcher) {
//console.log('Broadcast events.');
//console.log(fetcher.events());
@@ -239,4 +238,3 @@ module.exports = NodeHelper.create({
fetcher.startFetch();
}
});

View File

@@ -12,7 +12,7 @@ modules: [
position: 'top_left', // This can be any of the regions.
config: {
// The config property is optional.
// See 'Configuration options' for more information.
// See 'Configuration options' for more information.
}
}
]

View File

@@ -33,7 +33,7 @@ Module.register('clock',{
// Set locale.
moment.locale(config.language);
},
// Override dom generator.
getDom: function() {
@@ -52,16 +52,15 @@ Module.register('clock',{
dateWrapper.innerHTML = moment().format('dddd, LL');
timeWrapper.innerHTML = moment().format((this.config.timeFormat === 24) ? 'HH:mm' : ('hh:mm'));
secondsWrapper.innerHTML = moment().format('ss');
// Combine wrappers.
wrapper.appendChild(dateWrapper);
wrapper.appendChild(timeWrapper);
if (this.config.displaySeconds) {
timeWrapper.appendChild(secondsWrapper);
}
// Return the wrapper to the dom.
return wrapper;
}
});

View File

@@ -1,6 +1,6 @@
# Module: Compliments
The `compliments` module is one of the default modules of the MagicMirror.
This module displays a random compliment.
This module displays a random compliment.
## Using the module
@@ -14,7 +14,7 @@ modules: [
config: {
// The config property is optional.
// If no config is set, an example calendar is shown.
// See 'Configuration options' for more information.
// See 'Configuration options' for more information.
}
}
]
@@ -84,4 +84,4 @@ config: {
]
}
}
````
````

View File

@@ -40,7 +40,7 @@ Module.register('compliments',{
// Define start sequence.
start: function() {
Log.info('Starting module: ' + this.name);
this.lastComplimentIndex = -1;
// Schedule update timer.
@@ -105,19 +105,18 @@ Module.register('compliments',{
var index = this.randomIndex(compliments);
return compliments[index];
},
},
// Override dom generator.
getDom: function() {
var complimentText = this.randomCompliment();
var compliment = document.createTextNode(complimentText);
var compliment = document.createTextNode(complimentText);
var wrapper = document.createElement("div");
wrapper.className = 'thin xlarge bright';
wrapper.appendChild(compliment);
return wrapper;
return wrapper;
}
});
});

View File

@@ -12,7 +12,7 @@ modules: [
position: 'top_right', // This can be any of the regions.
// Best results in left or right regions.
config: {
// See 'Configuration options' for more information.
// See 'Configuration options' for more information.
location: 'Amsterdam,Netherlands',
appid: 'abcde12345abcde12345abcde12345ab' //openweathermap.org API key.
}
@@ -140,6 +140,6 @@ The following properties can be configured:
}</code>
</td>
</tr>
</tbody>
</table>
</table>

View File

@@ -6,4 +6,4 @@
-ms-transform: translate(0px,-3px); /* IE 9 */
-webkit-transform: translate(0px,-3px); /* Safari */
transform: translate(0px,-3px);
}
}

View File

@@ -65,7 +65,7 @@ Module.register('currentweather',{
// Set locale.
moment.locale(config.language);
this.windSpeed = null;
this.sunriseSunsetTime = null;
this.sunriseSunsetIcon = null;
@@ -76,7 +76,7 @@ Module.register('currentweather',{
this.scheduleUpdate(this.config.initialLoadDelay);
this.updateTimer = null;
},
// Override dom generator.
@@ -110,7 +110,7 @@ Module.register('currentweather',{
small.appendChild(windIcon);
var windSpeed = document.createElement("span");
windSpeed.innerHTML = " " + this.windSpeed;
windSpeed.innerHTML = " " + this.windSpeed;
small.appendChild(windSpeed);
var spacer = document.createElement("span");
@@ -122,7 +122,7 @@ Module.register('currentweather',{
small.appendChild(sunriseSunsetIcon);
var sunriseSunsetTime = document.createElement("span");
sunriseSunsetTime.innerHTML = " " + this.sunriseSunsetTime;
sunriseSunsetTime.innerHTML = " " + this.sunriseSunsetTime;
small.appendChild(sunriseSunsetTime);
var large = document.createElement("div");
@@ -134,7 +134,7 @@ Module.register('currentweather',{
var temperature = document.createElement("span");
temperature.className = "bright";
temperature.innerHTML = " " + this.temperature + '&deg;';
temperature.innerHTML = " " + this.temperature + '&deg;';
large.appendChild(temperature);
wrapper.appendChild(small);
@@ -206,7 +206,7 @@ Module.register('currentweather',{
var now = moment().format('x');
var sunrise = moment(data.sys.sunrise*1000).format('x');
var sunset = moment(data.sys.sunset*1000).format('x');
if (sunrise < now && sunset > now) {
this.sunriseSunsetTime = moment(data.sys.sunset*1000).format((this.config.timeFormat === 24) ? 'HH:mm' : 'hh:mm a');
@@ -230,7 +230,7 @@ Module.register('currentweather',{
var nextLoad = this.config.updateInterval;
if (typeof delay !== 'undefined' && delay >= 0) {
nextLoad = delay;
}
}
var self = this;
setTimeout(function() {
@@ -268,4 +268,3 @@ Module.register('currentweather',{
return parseFloat(temperature).toFixed(1);
}
});

View File

@@ -20,4 +20,4 @@ var defaultModules = [
/*************** DO NOT EDIT THE LINE BELOW ***************/
if (typeof module !== 'undefined') {module.exports = defaultModules;}
if (typeof module !== 'undefined') {module.exports = defaultModules;}

View File

@@ -9,7 +9,7 @@ modules: [
module: 'helloworld',
position: 'bottom_bar', // This can be any of the regions.
config: {
// See 'Configuration options' for more information.
// See 'Configuration options' for more information.
text: 'Hello world!',
}
}
@@ -46,6 +46,6 @@ The following properties can be configured:
</td>
</tr>
</tbody>
</table>
</table>

View File

@@ -19,9 +19,8 @@ Module.register('helloworld',{
getDom: function() {
var wrapper = document.createElement("div");
wrapper.className = this.config.classes;
wrapper.innerHTML = this.config.text;
wrapper.innerHTML = this.config.text;
return wrapper;
}
});

View File

@@ -13,7 +13,7 @@ modules: [
config: {
// The config property is optional.
// If no config is set, an example calendar is shown.
// See 'Configuration options' for more information.
// See 'Configuration options' for more information.
}
}
]
@@ -40,7 +40,7 @@ The following properties can be configured:
<br><b>Default value:</b> <code>'http://www.nytimes.com/services/xml/rss/nyt/HomePage.xml'</code>
</td>
</tr>
<tr>
<td><code>showPublishDate</code></td>
<td>Display the publish date of an headline.<br>
@@ -48,7 +48,7 @@ The following properties can be configured:
<br><b>Default value:</b> <code>true</code> or <code>false</code>
</td>
</tr>
<tr>
<td><code>reloadInterval</code></td>
<td>How often does the content needs to be fetched? (Milliseconds)<br>
@@ -70,7 +70,6 @@ The following properties can be configured:
<br><b>Default value:</b> <code>2000</code> (2.5 seconds)
</td>
</tr>
</tbody>
</table>

View File

@@ -5,7 +5,7 @@
* MIT Licensed.
*/
var NewsFetcher = require('./newsfetcher.js');
var NewsFetcher = require('./newsfetcher.js');
/* Fetcher
* Responsible for requesting an update on the set interval and broadcasting the data.
@@ -20,7 +20,7 @@ var Fetcher = function(url, reloadInterval) {
if (reloadInterval < 1000) {
reloadInterval = 1000;
}
var reloadTimer = null;
var items = [];

View File

@@ -14,8 +14,8 @@ Module.register('newsfeed',{
feedUrl: 'http://www.nytimes.com/services/xml/rss/nyt/HomePage.xml',
showPublishDate: true,
reloadInterval: 5 * 60 * 1000, // every 5 minutes
updateInterval: 7.5 * 1000,
animationSpeed: 2.5 * 1000,
updateInterval: 7.5 * 1000,
animationSpeed: 2.5 * 1000,
},
// Define required scripts.
@@ -29,7 +29,7 @@ Module.register('newsfeed',{
// Set locale.
moment.locale(config.language);
this.newsItems = [];
this.loaded = false;
this.activeItem = 0;
@@ -61,7 +61,7 @@ Module.register('newsfeed',{
}
if (this.newsItems.length > 0) {
if (this.config.showPublishDate) {
var timestamp = document.createElement("div");
timestamp.className = "light small dimmed";
@@ -119,5 +119,3 @@ Module.register('newsfeed',{
return string.charAt(0).toUpperCase() + string.slice(1);
}
});

View File

@@ -6,7 +6,7 @@
*/
var FeedMe = require('feedme');
var request = require('request');
var request = require('request');
var NewsFetcher = function() {
var self = this;
@@ -40,8 +40,8 @@ var NewsFetcher = function() {
* Fetch the new news items.
*
* attribute url string - The url to fetch.
* attribute success function(items) - Callback on succes.
* attribute error function(error) - Callback on error.
* attribute success function(items) - Callback on succes.
* attribute error function(error) - Callback on error.
*/
self.fetchNews = function(url, success, error) {
self.successCallback = success;
@@ -50,4 +50,4 @@ var NewsFetcher = function() {
};
};
module.exports = NewsFetcher;
module.exports = NewsFetcher;

View File

@@ -7,7 +7,7 @@
var NodeHelper = require('node_helper');
var validUrl = require('valid-url');
var Fetcher = require('./fetcher.js');
var Fetcher = require('./fetcher.js');
module.exports = NodeHelper.create({
// Subclass start method.
@@ -44,7 +44,7 @@ module.exports = NodeHelper.create({
if (typeof self.fetchers[url] === 'undefined') {
console.log('Create new news fetcher for url: ' + url + ' - Interval: ' + reloadInterval);
fetcher = new Fetcher(url, reloadInterval);
fetcher.onReceive(function(fetcher) {
self.sendSocketNotification('NEWS_ITEMS', {
url: fetcher.url(),
@@ -70,7 +70,3 @@ module.exports = NodeHelper.create({
fetcher.startFetch();
}
});

View File

@@ -12,7 +12,7 @@ modules: [
position: 'top_right', // This can be any of the regions.
// Best results in left or right regions.
config: {
// See 'Configuration options' for more information.
// See 'Configuration options' for more information.
location: 'Amsterdam,Netherlands',
appid: 'abcde12345abcde12345abcde12345ab' //openweathermap.org API key.
}
@@ -148,6 +148,6 @@ The following properties can be configured:
}</code>
</td>
</tr>
</tbody>
</table>
</table>

View File

@@ -11,4 +11,4 @@
.weatherforecast .min-temp {
padding-left: 20px;
padding-right: 0px;
}
}

View File

@@ -18,7 +18,7 @@ Module.register('weatherforecast',{
animationSpeed: 1000,
timeFormat: config.timeFormat,
lang: config.language,
fade: true,
fade: true,
fadePoint: 0.25, // Start on 1/4th of the list.
initialLoadDelay: 2500, // 2.5 seconds delay. This delay is used to keep the OpenWeather API happy.
@@ -67,7 +67,7 @@ Module.register('weatherforecast',{
// Set locale.
moment.locale(config.language);
this.forecast = [];
this.loaded = false;
this.scheduleUpdate(this.config.initialLoadDelay);
@@ -144,10 +144,10 @@ Module.register('weatherforecast',{
}
}
}
return table;
@@ -238,7 +238,7 @@ Module.register('weatherforecast',{
var nextLoad = this.config.updateInterval;
if (typeof delay !== 'undefined' && delay >= 0) {
nextLoad = delay;
}
}
var self = this;
clearTimeout(this.updateTimer);
@@ -277,4 +277,3 @@ Module.register('weatherforecast',{
return parseFloat(temperature).toFixed(1);
}
});