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
    14 Posts 3 Posters 5.6k Views 3 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.
    • S Offline
      sdetweil @_V_
      last edited by sdetweil

      @_V_

      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 name

      You are writing code here
      The filter routine sees every event, one at a time

      You can have more than one if stmt
      Can use if else if else, use a switch /case logic block

      Sam

      How to add modules

      learning how to use browser developers window for css changes

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

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

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

          @_V_

          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; 
          },

          Sam

          How to add modules

          learning how to use browser developers window for css changes

          R 1 Reply Last reply Reply Quote 2
          • R Offline
            rkorell @sdetweil
            last edited by rkorell

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

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

              @rkorell his issue is not knowing JavaScript language and syntax

              Sam

              How to add modules

              learning how to use browser developers window for css changes

              R 1 Reply Last reply Reply Quote 0
              • R Offline
                rkorell @sdetweil
                last edited by

                @sdetweil Yes :-)
                therefore I thought a detailed example would be beneficial …
                Warmest regards,
                Ralf

                1 Reply Last reply Reply Quote 0
                • 1
                • 2
                • 1 / 2
                • 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