mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-08-21 04:45:17 +00:00
calendar events repeating count title for birthdayd etc
This commit is contained in:
@@ -15,6 +15,8 @@ Module.register("calendar",{
|
||||
maximumNumberOfDays: 365,
|
||||
displaySymbol: true,
|
||||
defaultSymbol: "calendar", // Fontawsome Symbol see http://fontawesome.io/cheatsheet/
|
||||
displayRepeatingCountTitle: false,
|
||||
defaultRepeatingCountTitle: '',
|
||||
maxTitleLength: 25,
|
||||
fetchInterval: 5 * 60 * 1000, // Update every 5 minutes.
|
||||
animationSpeed: 2000,
|
||||
@@ -113,8 +115,24 @@ Module.register("calendar",{
|
||||
eventWrapper.appendChild(symbolWrapper);
|
||||
}
|
||||
|
||||
var titleWrapper = document.createElement("td");
|
||||
titleWrapper.innerHTML = this.titleTransform(event.title);
|
||||
var titleWrapper = document.createElement("td"),
|
||||
repeatingCountTitle = '';
|
||||
|
||||
|
||||
if (this.config.displayRepeatingCountTitle) {
|
||||
|
||||
repeatingCountTitle = this.countTitleForUrl(event.url)
|
||||
|
||||
if(repeatingCountTitle != '') {
|
||||
|
||||
var thisYear = new Date().getFullYear(),
|
||||
yearDiff = thisYear - event.firstYear;
|
||||
|
||||
repeatingCountTitle = ', '+ yearDiff + '. ' + repeatingCountTitle;
|
||||
}
|
||||
}
|
||||
|
||||
titleWrapper.innerHTML = this.titleTransform(event.title) + repeatingCountTitle;
|
||||
titleWrapper.className = "title bright";
|
||||
eventWrapper.appendChild(titleWrapper);
|
||||
|
||||
@@ -239,6 +257,23 @@ Module.register("calendar",{
|
||||
|
||||
return this.config.defaultSymbol;
|
||||
},
|
||||
/* countTitleForUrl(url)
|
||||
* Retrieves the name for a specific url.
|
||||
*
|
||||
* argument url sting - Url to look for.
|
||||
*
|
||||
* return string - The Symbol
|
||||
*/
|
||||
countTitleForUrl: function(url) {
|
||||
for (var c in this.config.calendars) {
|
||||
var calendar = this.config.calendars[c];
|
||||
if (calendar.url === url && typeof calendar.repeatingCountTitle === "string") {
|
||||
return calendar.repeatingCountTitle;
|
||||
}
|
||||
}
|
||||
|
||||
return this.config.defaultRepeatingCountTitle;
|
||||
},
|
||||
|
||||
/* shorten(string, maxLength)
|
||||
* Shortens a sting if it's longer than maxLenthg.
|
||||
|
Reference in New Issue
Block a user