mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 11:50:00 +00:00
Show text when event is still running.
This commit is contained in:
parent
614e5e62af
commit
27a47d4e4a
@ -130,6 +130,12 @@ The following properties can be configured:
|
||||
<br><b>Default value:</b> <code>'Today'</code>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>runningText</code></td>
|
||||
<td>Text to display when an event is still running.<br>
|
||||
<br><b>Default value:</b> <code>'Ends in'</code>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
@ -33,7 +33,8 @@ Module.register("calendar",{
|
||||
emptyCalendarText: "No upcoming events.",
|
||||
|
||||
// TODO: It would be nice if there is a way to get this from the Moment.js locale.
|
||||
todayText: "Today"
|
||||
todayText: "Today",
|
||||
runningText: "Ends in"
|
||||
},
|
||||
|
||||
// Define required scripts.
|
||||
@ -119,7 +120,11 @@ Module.register("calendar",{
|
||||
if (event.fullDayEvent) {
|
||||
timeWrapper.innerHTML = (event.today) ? this.config.todayText : moment(event.startDate,"x").fromNow();
|
||||
} else {
|
||||
timeWrapper.innerHTML = moment(event.startDate,"x").fromNow();
|
||||
if (event.startDate >= new Date()) {
|
||||
timeWrapper.innerHTML = moment(event.startDate,"x").fromNow();
|
||||
} else {
|
||||
timeWrapper.innerHTML = this.config.runningText + ' ' + moment(event.endDate,"x").fromNow(true);
|
||||
}
|
||||
}
|
||||
// timeWrapper.innerHTML = moment(event.startDate,'x').format('lll');
|
||||
timeWrapper.className = "time light";
|
||||
|
@ -58,6 +58,7 @@ var CalendarFetcher = function(url, reloadInterval, maximumEntries, maximumNumbe
|
||||
if (event.type === "VEVENT") {
|
||||
|
||||
var startDate = (event.start.length === 8) ? moment(event.start, "YYYYMMDD") : moment(new Date(event.start));
|
||||
var endDate = (event.end.length === 8) ? moment(event.end, "YYYYMMDD") : moment(new Date(event.end));
|
||||
if (event.start.length === 8) {
|
||||
startDate = startDate.startOf("day");
|
||||
}
|
||||
@ -88,8 +89,8 @@ var CalendarFetcher = function(url, reloadInterval, maximumEntries, maximumNumbe
|
||||
newEvents.push({
|
||||
title: (typeof event.summary.val !== "undefined") ? event.summary.val : event.summary,
|
||||
startDate: startDate.format("x"),
|
||||
endDate: endDate.format("x"),
|
||||
fullDayEvent: (event.start.length === 8)
|
||||
|
||||
});
|
||||
}
|
||||
} else {
|
||||
@ -98,13 +99,13 @@ var CalendarFetcher = function(url, reloadInterval, maximumEntries, maximumNumbe
|
||||
var fullDayEvent = (event.start.length === 8);
|
||||
var title = (typeof event.summary.val !== "undefined") ? event.summary.val : event.summary;
|
||||
|
||||
if (!fullDayEvent && startDate < new Date()) {
|
||||
if (!fullDayEvent && endDate < new Date()) {
|
||||
// it's not a fullday event, and it is in the past. So skip.
|
||||
console.log("It's not a fullday event, and it is in the past. So skip: " + title);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (fullDayEvent && startDate < today) {
|
||||
if (fullDayEvent && endDate < today) {
|
||||
// it's a fullday event, and it is before today. So skip.
|
||||
console.log("It's a fullday event, and it is before today. So skip: " + title);
|
||||
continue;
|
||||
@ -120,6 +121,7 @@ var CalendarFetcher = function(url, reloadInterval, maximumEntries, maximumNumbe
|
||||
newEvents.push({
|
||||
title: title,
|
||||
startDate: startDate.format("x"),
|
||||
endDate: endDate.format("x"),
|
||||
fullDayEvent: fullDayEvent
|
||||
});
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
var CalendarFetcher = require("./calendarfetcher.js");
|
||||
|
||||
var url = 'https://github.com/MichMich/MagicMirror/files/217285/reachcalendar.txt';
|
||||
var url = 'http://p35-calendars.icloud.com/published/2/qsud2R2XlRhT3puEVfrzkeSd3X_QSfCMBmpgTsjVqOD2W_fyy0Y-5QskbvWw2jOQB_cPsmcjpGtcg1a3jBQ_QIS2H0XWSxjqCa8LX0dznpE';
|
||||
var fetchInterval = 60 * 60 * 1000;
|
||||
var maximumEntries = 10;
|
||||
var maximumNumberOfDays = 365;
|
||||
|
Loading…
x
Reference in New Issue
Block a user