mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-08-22 13:09:26 +00:00
Add eventClass for customEvents in calendar (#3193)
Hello, This pull request allows you to add a class to the tr of the event sought in customEvents. You must enter the class with the "eventClass" option. --------- Co-authored-by: TeddyStarinvest <teddy.payet@starinvest.com>
This commit is contained in:
@@ -42,7 +42,7 @@ Module.register("calendar", {
|
||||
hideDuplicates: true,
|
||||
showTimeToday: false,
|
||||
colored: false,
|
||||
customEvents: [], // Array of {keyword: "", symbol: "", color: ""} where Keyword is a regexp and symbol/color are to be applied for matched
|
||||
customEvents: [], // Array of {keyword: "", symbol: "", color: "", eventClass: ""} where Keyword is a regexp and symbol/color/eventClass are to be applied for matched
|
||||
tableClass: "small",
|
||||
calendars: [
|
||||
{
|
||||
@@ -321,12 +321,12 @@ Module.register("calendar", {
|
||||
}
|
||||
}
|
||||
|
||||
// Color events if custom color is specified
|
||||
// Color events if custom color or eventClass are specified
|
||||
if (this.config.customEvents.length > 0) {
|
||||
for (let ev in this.config.customEvents) {
|
||||
if (typeof this.config.customEvents[ev].color !== "undefined" && this.config.customEvents[ev].color !== "") {
|
||||
let needle = new RegExp(this.config.customEvents[ev].keyword, "gi");
|
||||
if (needle.test(event.title)) {
|
||||
let needle = new RegExp(this.config.customEvents[ev].keyword, "gi");
|
||||
if (needle.test(event.title)) {
|
||||
if (typeof this.config.customEvents[ev].color !== "undefined" && this.config.customEvents[ev].color !== "") {
|
||||
// Respect parameter ColoredSymbolOnly also for custom events
|
||||
if (this.config.coloredText) {
|
||||
eventWrapper.style.cssText = `color:${this.config.customEvents[ev].color}`;
|
||||
@@ -337,6 +337,9 @@ Module.register("calendar", {
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (typeof this.config.customEvents[ev].eventClass !== "undefined" && this.config.customEvents[ev].eventClass !== "") {
|
||||
eventWrapper.className += ` ${this.config.customEvents[ev].eventClass}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user