• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
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.

MMM-CX3A - Transform not working?

Scheduled Pinned Locked Moved Solved Troubleshooting
11 Posts 3 Posters 4.4k 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.
  • B Offline
    BKeyport Module Developer
    last edited by Jun 29, 2023, 7:29 PM

    @MMRIZE (tagged as author)

    I have 4 transforms attempting to work at the same time, the last one “busy” doesn’t work - can someone explain why?

    				eventTransformer: (ev) => {
    					if (ev.title.search("🏠") > -1) {
    						ev.title = ev.title.replace("🏠 Personal Commitment","Private (Brendan)");
    						ev.color = 'yellow';
    					}
    					if (ev.title.search("✈ Flight") > -1) {
    						ev.title = ev.title.replace("✈ Flight","Private (Brendan)");
    						ev.color = 'yellow';
    					}
    					if (ev.title.search("🚌️") > -1) {
    						ev.title = ev.title.replace("🚌️ Transit","Private (Brendan)");
    						ev.color = 'yellow';
    					}
    					if (ev.title.search("busy️") > -1) {
    						ev.title = ev.title.replace("busy","Private (Mom)");
    						ev.color = 'yellow';
    					}
    					return ev
    				},
    

    The "E" in "Javascript" stands for "Easy"

    S M 2 Replies Last reply Jun 29, 2023, 9:01 PM Reply Quote 0
    • S Offline
      sdetweil @BKeyport
      last edited by Jun 29, 2023, 9:01 PM

      @BKeyport is it lower case busy?

      Sam

      How to add modules

      learning how to use browser developers window for css changes

      1 Reply Last reply Reply Quote -1
      • M Offline
        MMRIZE @BKeyport
        last edited by MMRIZE Jun 29, 2023, 9:35 PM Jun 29, 2023, 9:35 PM

        @BKeyport
        Font seems weird. (“y” of “busy”)
        461eadf2-20c5-43ab-9125-bfc95934d396-image.jpeg

        B S 2 Replies Last reply Jun 29, 2023, 9:59 PM Reply Quote 0
        • B Offline
          BKeyport Module Developer @MMRIZE
          last edited by Jun 29, 2023, 9:59 PM

          @MMRIZE good catch, that’s what it was… Cut and paste solved it. I really hate that my calendar merger application uses weird junk like that.

          The "E" in "Javascript" stands for "Easy"

          1 Reply Last reply Reply Quote 0
          • S Offline
            sdetweil @MMRIZE
            last edited by Jun 29, 2023, 10:05 PM

            @MMRIZE interesting, it doesn’t appear like that for me

            Sam

            How to add modules

            learning how to use browser developers window for css changes

            B 1 Reply Last reply Jun 29, 2023, 10:06 PM Reply Quote 0
            • B Offline
              BKeyport Module Developer @sdetweil
              last edited by Jun 29, 2023, 10:06 PM

              @sdetweil it looks normal for me, too - however, a cut and paste into both fields from the original text does fix it, so, whatever.

              The "E" in "Javascript" stands for "Easy"

              M 1 Reply Last reply Jun 30, 2023, 10:11 AM Reply Quote 0
              • M Offline
                MMRIZE @BKeyport
                last edited by Jun 30, 2023, 10:11 AM

                @BKeyport
                Anyway, how about this code for those who need many transforming like you?

                eventTransformer: (event) => {
                  const replaceMap = {
                    'original': 'Replaced',
                    'text': 'string',
                    'foo': 'bar',
                    'baz': 'qux',
                  }
                
                  Object.keys(replaceMap).forEach((key) => {
                    const regex = new RegExp(key, 'gi')
                    event.title = event.title.replace(regex, (token) => {
                      event.color = 'red'
                      return replaceMap[ key ]
                    })
                  })
                  return event
                }
                

                5ae3c465-a5cb-4e50-8b16-35bb01462c24-image.png

                B 1 Reply Last reply Jun 30, 2023, 9:20 PM Reply Quote 0
                • B Offline
                  BKeyport Module Developer @MMRIZE
                  last edited by Jun 30, 2023, 9:20 PM

                  @MMRIZE That looks interesting… Most of my transforming is yanking out the emoji, though - because electron does partial display at best, and I so hate the boxed X showing up everywhere.

                  The "E" in "Javascript" stands for "Easy"

                  M 1 Reply Last reply Jun 30, 2023, 11:40 PM Reply Quote 0
                  • M Offline
                    MMRIZE @BKeyport
                    last edited by Jun 30, 2023, 11:40 PM

                    @BKeyport
                    You may need to install emoji fonts
                    Or you can parse out non-ASCII characters with regular expressions.

                    B 1 Reply Last reply Jul 1, 2023, 12:25 AM Reply Quote 0
                    • B Offline
                      BKeyport Module Developer @MMRIZE
                      last edited by Jul 1, 2023, 12:25 AM

                      @MMRIZE Interesting. How would one install the Emoji fonts? I’d rather have the prettyness than all text.

                      The "E" in "Javascript" stands for "Easy"

                      M 1 Reply Last reply Jul 1, 2023, 3:54 PM Reply Quote 0
                      • 1
                      • 2
                      • 1 / 2
                      1 / 2
                      • First post
                        1/11
                        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