mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-29 12:39:45 +00:00
added possibility to give each calendar another color
This commit is contained in:
parent
09ba1e2470
commit
ce3ee909bf
@ -27,6 +27,7 @@ Module.register("calendar", {
|
|||||||
getRelative: 6,
|
getRelative: 6,
|
||||||
fadePoint: 0.25, // Start on 1/4th of the list.
|
fadePoint: 0.25, // Start on 1/4th of the list.
|
||||||
hidePrivate: false,
|
hidePrivate: false,
|
||||||
|
colored: false,
|
||||||
calendars: [
|
calendars: [
|
||||||
{
|
{
|
||||||
symbol: "calendar",
|
symbol: "calendar",
|
||||||
@ -114,6 +115,11 @@ Module.register("calendar", {
|
|||||||
var event = events[e];
|
var event = events[e];
|
||||||
|
|
||||||
var eventWrapper = document.createElement("tr");
|
var eventWrapper = document.createElement("tr");
|
||||||
|
|
||||||
|
if (this.config.colored) {
|
||||||
|
eventWrapper.style.cssText = 'color:' + this.colorForUrl(event.url);
|
||||||
|
}
|
||||||
|
|
||||||
eventWrapper.className = "normal";
|
eventWrapper.className = "normal";
|
||||||
|
|
||||||
if (this.config.displaySymbol) {
|
if (this.config.displaySymbol) {
|
||||||
@ -142,7 +148,13 @@ Module.register("calendar", {
|
|||||||
}
|
}
|
||||||
|
|
||||||
titleWrapper.innerHTML = this.titleTransform(event.title) + repeatingCountTitle;
|
titleWrapper.innerHTML = this.titleTransform(event.title) + repeatingCountTitle;
|
||||||
|
|
||||||
|
if (!this.config.colored) {
|
||||||
titleWrapper.className = "title bright";
|
titleWrapper.className = "title bright";
|
||||||
|
} else {
|
||||||
|
titleWrapper.className = "title";
|
||||||
|
}
|
||||||
|
|
||||||
eventWrapper.appendChild(titleWrapper);
|
eventWrapper.appendChild(titleWrapper);
|
||||||
|
|
||||||
var timeWrapper = document.createElement("td");
|
var timeWrapper = document.createElement("td");
|
||||||
@ -323,6 +335,24 @@ Module.register("calendar", {
|
|||||||
|
|
||||||
return this.config.defaultSymbol;
|
return this.config.defaultSymbol;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/* colorForUrl(url)
|
||||||
|
* Retrieves the color for a specific url.
|
||||||
|
*
|
||||||
|
* argument url sting - Url to look for.
|
||||||
|
*
|
||||||
|
* return string - The Color
|
||||||
|
*/
|
||||||
|
colorForUrl: function (url) {
|
||||||
|
for (var c in this.config.calendars) {
|
||||||
|
var calendar = this.config.calendars[c];
|
||||||
|
if (calendar.url === url && typeof calendar.color === "string") {
|
||||||
|
return calendar.color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return '#fff';
|
||||||
|
},
|
||||||
/* countTitleForUrl(url)
|
/* countTitleForUrl(url)
|
||||||
* Retrieves the name for a specific url.
|
* Retrieves the name for a specific url.
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user