Read the statement by Michael Teeuw here.
Exact matches for phrases in config.js?
-
I recently updated my default calendar module to use colours and symbols for repeating events, using the customEvents option from here:
https://docs.magicmirror.builders/modules/calendar.html#configuration-options
but I’ve since found out that if the keyword is part of another word, the second word triggers the custom colour and symbol too. As an example, I’ve used ‘live’ for live music events, but ‘delivery’ triggers the same colour and symbol.
Does anyone know the correct term for this so that I can try to figure it out please? I can only find answers for creating the Javascript in the first place, but I want a way to limit the term from my config.js, if that’s possible.
-
@tippon The reason is that the
.indexOf()
function searches a string for a character pattern, not for a word.
You could try to include spaces, have it search for'live '
and/or' live'
-
@lavolp3 indexOf searches for string patterns too… but as u note adding a space to distinguish keyword from word contents might still be required
-
@lavolp3 @sdetweil Thanks for the replies, it worked perfectly! :)
I tried a space before and after ‘live’, and both at once. I made a separate entry for ‘delivery’ too, and put it after the ‘live’ line. The ‘delivery’ line wasn’t necessary, but I tried it as an override (which didn’t work), and liked the way it looked :D
{keyword: 'live ', symbol: 'music', color: 'Aqua'}, {keyword: 'delivery', symbol: 'truck', color: 'GreenYellow'},