Read the statement by Michael Teeuw here.
Cal EXT3 - understanding transforming
-
I get the idea but since Im quite new to this, I cant follow completely.
Again the exampleeventTransformer: (ev) => { if (ev.title.search("John") > -1) ev.color = "blue"; return ev; };
Now you told me, “search” is a look up in form of “if contains” - this means if it contains the value, it will give out a value bigger than -1 and the effect will be set; other wise it will return -1 and the event stays unedited, correct?
This would also mean, I have to set up every possible event title class inbefore.
If I want to change/assign a specific symbol is a thing I dont understand.
I use the Iconify function from the module - do I have to put in a link to the desired symbol now or what is it I have to enter?
I could also imagine that I have to download the symbols and put in a directory to make the module be able to access them?Thanks a lot
-
If I search this field, and find ‘John’
Then
I change the event color
ev.color=You could change to symbol the same way
ev.symbol=. Whatever symbol nameYou are writing code here
The filter routine sees every event, one at a timeYou can have more than one if stmt
Can use if else if else, use a switch /case logic block -
@sdetweil Sam good evening
I wonder how to set up multiple ev transformations in one config.
I got working
{ eventTransformer: (ev) => { if (ev.title.search("Geburtstag") > -1) {ev.color= "#ff00ff"; }; return ev; },
But putting another one to it is puzzling me. I tried different methods, but cant get it done.
When I simply put a second complete command after the first, like this:{ eventTransformer: (ev) => { if (ev.title.search("Arzt") > -1) {ev.color= "#ff0000"; }; return ev; },
it will just negate the first applied effect from birthday and uses this effect instead on the named events.
Can you help me out please? -
all in one… there is only ONE eventTransformer, it has to do ALL the work for ALL events
I used else if here… if it matched the first, there is no reason to check again
eventTransformer: (ev) => { if (ev.title.search("Geburtstag") > -1) {ev.color= "#ff00ff"; } else if (ev.title.search("Arzt") > -1) {ev.color= "#ff0000"; }; return ev; },
-
@_V_ as you might have overseen you can not only check several conditions (as Sam (@sdetweil ) suggested) - separated by else or not but you can make several changes to the same event at one check.
e.g.:
eventTransformer: (ev) => { if (ev.title.search("Restmüll & Papier & Gelber Sack") !== -1) {ev.isFullday = [true], ev.title = "Alle Tonnen", ev.symbol = [ "fa-regular fa-trash-can" ], ev.color = "fuchsia"} if (ev.title.search("Therapie") !== -1) { ev.title = "Sitzung", ev.symbol = [ "fa-solid fa-mug-hot" ], ev.color = "Forestgreen"} return ev }, // end Eventtransformer
In the above example you can see
- the modification of the color (as you already had identified,
- the change of the kind of event (from “scheduled” to “Fullday-Event”)
- the assignment of a different symbol (with font-awesome-symbols: double check their web-page, keep in mind that only the “STANDARD” (non-payed) versions will be shown in Magic Mirror) and
- the change of the title of the event.
Hope this helps.
Good luck!
Ralf -
@rkorell his issue is not knowing JavaScript language and syntax
-
@sdetweil Yes :-)
therefore I thought a detailed example would be beneficial …
Warmest regards,
Ralf