MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.

    Cal EXT3 - understanding transforming

    Scheduled Pinned Locked Moved Unsolved Troubleshooting
    7 Posts 2 Posters 703 Views 2 Watching
    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.
    • _ Offline
      _V_
      last edited by

      Hello again guys

      I am using the 3rd cal-mod from @MMRIZE and try to bring it up a bit more specific regarding styling.

      So the documention says:

      Transforming
      You can manipulate or change the properties of the event.

      eventTransformer: (ev) => {
        if (ev.title.search("John") > -1) ev.color = "blue";
        return ev;
      };
      

      This example shows how you can transform the color of events when the event title has specific text.

      Would this mean, it looks up, if the events text is exact like the named text ( “John” in this example )
      OR the event starts with the word
      OR the event contains this word?

      Also I wondered, if I can specify the icon used for this event, besides defining the events color?
      Thank you very much and as always, regards from Germany

      S 3 Replies Last reply Reply Quote 0
      • S Offline
        sdetweil @_V_
        last edited by sdetweil

        @_V_ said in Cal EXT3 - understanding transforming:

        ev.title.search

        search() searches the string for the specified characters and IF those characters are found, it returns the position of the text in the string…(0= 1st char/start of string). if NOT found it returns -1

        this is a javascript string function

        there is also startsWith() and endsWith()
        search() = contains

        the code could have used includes()

        The includes() method of String values performs a case-sensitive search to determine whether a given string may be found within this string, returning true or false as appropriate.

        if you wanted case insensitive, you would do
        ev.title.toLowerCase().includes(‘john’)

        Sam

        How to add modules

        learning how to use browser developers window for css changes

        1 Reply Last reply Reply Quote 0
        • S Offline
          sdetweil @_V_
          last edited by

          @_V_ transforming, you must ALWAYS return the event, modified or not

          Sam

          How to add modules

          learning how to use browser developers window for css changes

          1 Reply Last reply Reply Quote 0
          • _ Offline
            _V_
            last edited by

            Hello Sam

            Thanks for the input.
            Ok now what would this search method mean for “title”

            Like, what is it the case of the EXT3 cal module?
            It says “title”?
            Anybody knows about my last question for icon change too?

            Thanks

            S 2 Replies Last reply Reply Quote 0
            • S Offline
              sdetweil @_V_
              last edited by

              @_V_ from his readme

              IMG_3898.png

              Sam

              How to add modules

              learning how to use browser developers window for css changes

              1 Reply Last reply Reply Quote 0
              • S Offline
                sdetweil @_V_
                last edited by

                @_V_ what do you mean for title? We just searched title
                If you want to change it. Then do that

                ev.title=‘new string’

                Same with symbol

                Sam

                How to add modules

                learning how to use browser developers window for css changes

                1 Reply Last reply Reply Quote 0
                • S Offline
                  sdetweil @_V_
                  last edited by

                  @_V_ you can change any property of the event

                  Sam

                  How to add modules

                  learning how to use browser developers window for css changes

                  1 Reply Last reply Reply Quote 0
                  • 1 / 1
                  • First post
                    Last post
                  Enjoying MagicMirror? Please consider a donation!
                  MagicMirror created by Michael Teeuw.
                  Forum managed by Sam, technical setup by Karsten.
                  This forum is using NodeBB as its core | Contributors
                  Contact | Privacy Policy