MagicMirror Forum

    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • Donate
    • Discord

    Exact matches for phrases in config.js?

    Troubleshooting
    3
    4
    201
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Tippon
      Tippon last edited by

      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.

      lavolp3 1 Reply Last reply Reply Quote 0
      • lavolp3
        lavolp3 Module Developer @Tippon last edited by lavolp3

        @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'

        How to troubleshoot modules
        MMM-soccer v2, MMM-AVStock

        S Tippon 2 Replies Last reply Reply Quote 0
        • S
          sdetweil @lavolp3 last edited by sdetweil

          @lavolp3 indexOf searches for string patterns too… but as u note adding a space to distinguish keyword from word contents might still be required

          Sam

          Create a working config
          How to add modules

          1 Reply Last reply Reply Quote 0
          • Tippon
            Tippon @lavolp3 last edited by

            @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 😃

            {keyword: 'live ', symbol: 'music', color: 'Aqua'},
            {keyword: 'delivery', symbol: 'truck', color: 'GreenYellow'},
            
            1 Reply Last reply Reply Quote 1
            • 1 / 1
            • First post
              Last post
            Enjoying MagicMirror? Please consider a donation!
            MagicMirror created by Michael Teeuw.
            Forum managed by Paul-Vincent Roll and Rodrigo Ramírez Norambuena.
            This forum is using NodeBB as its core | Contributors
            Contact | Privacy Policy