mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-08-21 21:00:57 +00:00
New option "limitDays" that will limit the number of days displayed.
This commit is contained in:
@@ -11,6 +11,7 @@ Module.register("calendar", {
|
|||||||
defaults: {
|
defaults: {
|
||||||
maximumEntries: 10, // Total Maximum Entries
|
maximumEntries: 10, // Total Maximum Entries
|
||||||
maximumNumberOfDays: 365,
|
maximumNumberOfDays: 365,
|
||||||
|
limitDays: 0, // Limit the number of days shown, 0 = no limit
|
||||||
displaySymbol: true,
|
displaySymbol: true,
|
||||||
defaultSymbol: "calendar", // Fontawesome Symbol see https://fontawesome.com/cheatsheet?from=io
|
defaultSymbol: "calendar", // Fontawesome Symbol see https://fontawesome.com/cheatsheet?from=io
|
||||||
showLocation: false,
|
showLocation: false,
|
||||||
@@ -98,6 +99,7 @@ Module.register("calendar", {
|
|||||||
var calendarConfig = {
|
var calendarConfig = {
|
||||||
maximumEntries: calendar.maximumEntries,
|
maximumEntries: calendar.maximumEntries,
|
||||||
maximumNumberOfDays: calendar.maximumNumberOfDays,
|
maximumNumberOfDays: calendar.maximumNumberOfDays,
|
||||||
|
limitDays: calendar.limitDays,
|
||||||
broadcastPastEvents: calendar.broadcastPastEvents
|
broadcastPastEvents: calendar.broadcastPastEvents
|
||||||
};
|
};
|
||||||
if (calendar.symbolClass === "undefined" || calendar.symbolClass === null) {
|
if (calendar.symbolClass === "undefined" || calendar.symbolClass === null) {
|
||||||
@@ -521,6 +523,16 @@ Module.register("calendar", {
|
|||||||
events.sort(function (a, b) {
|
events.sort(function (a, b) {
|
||||||
return a.startDate - b.startDate;
|
return a.startDate - b.startDate;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// If limitDays is set > 0, limit display to that number of days
|
||||||
|
if (this.config.limitDays > 0) {
|
||||||
|
var lastDate = today.clone().subtract(1, "days").format("YYYYMMDD");
|
||||||
|
var days = 0;
|
||||||
|
var newevents = [];
|
||||||
|
for (var e in events) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return events.slice(0, this.config.maximumEntries);
|
return events.slice(0, this.config.maximumEntries);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user