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.

    Config option with array of multiple values?

    Scheduled Pinned Locked Moved Development
    25 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 @UncleRoger
      last edited by sdetweil

      @UncleRoger array.filter() returns an array with the items that the matching function returned true
      so there is only one. no need for the index. it returned the entire object, item in the list

      sender is the name of the parameter passed to the matching function, the element of the array

      Sam

      How to add modules

      learning how to use browser developers window for css changes

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

        @UncleRoger >I really kinda wish I had a spare RPi laying

        MagicMirror will run on windows. you don’t need a pi

        Sam

        How to add modules

        learning how to use browser developers window for css changes

        1 Reply Last reply Reply Quote 0
        • UncleRogerU Offline
          UncleRoger @sdetweil
          last edited by

          @sdetweil
          I got it working with the .filter function:

          let selSender = that.config.validSenders.filter(mySender => {
          	if (mySender.addr.toLowerCase() == mailObj.sender[0].address.toLowerCase()) 
          		return true
          	 else 
          		return false
          });
          

          but now I’m having a problem trying to use the returned array. In this code the adding the color element to the subject works fine (that’s there for testing), as does the setting the style.color, but if I uncomment the if statement, it crashes:

          subject = subject + selSender[0].color;
          //		if (selSender[0].color != undefined) {
          			subjectWrapper.style.color = selSender[0].color;
          //		} else {
          

          Is there a reason it doesn’t like that in the IF statement? Note: I also tried it as just “if (selSender[0].color) {” and assigning the value of selSender[0].color to another variable and using that other variable in the IF statement. In at least one test case there is a value in color.

          UncleRogerU 1 Reply Last reply Reply Quote 0
          • UncleRogerU Offline
            UncleRoger @UncleRoger
            last edited by

            @UncleRoger said in Config option with array of multiple values?:

            subject = subject + selSender[0].color;
            // if (selSender[0].color != undefined) {
            subjectWrapper.style.color = selSender[0].color;
            // } else {

            Is there a reason it doesn’t like that in the IF statement? Note: I also tried it as just “if (selSender[0].color) {” and assigning the value of selSender[0].color to another variable and using that other variable in the IF statement. In at least one test case there is a value in color.

            Okay, so it looks like Javascript wants “!==”, not “!=”. Ugh.

            Anyway, I got it working using a “switch (true)” block.

            Thanks for all the help!

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

              @UncleRoger yes the compares

              !=
              !==
              !===
              

              are different

              Screenshot_20231027_125711_Chrome.jpg

              one compare s the data type too
              2 is a number
              “2” is a string

              Sam

              How to add modules

              learning how to use browser developers window for css changes

              UncleRogerU 1 Reply Last reply Reply Quote 1
              • MZ-BERM Offline
                MZ-BER
                last edited by

                Hello @UncleRoger - are you planning to publish your module? And can I may ask you what this module will do?

                UncleRogerU 2 Replies Last reply Reply Quote 1
                • UncleRogerU Offline
                  UncleRoger @MZ-BER
                  last edited by

                  @MZ-BER said in Config option with array of multiple values?:

                  Hello @UncleRoger - are you planning to publish your module? And can I may ask you what this module will do?

                  Yes, I am planning to publish it, once I’ve tested it reasonably well. Mostly, it seems to work thus far. I’m doing more testing and working on documentation.

                  The module checks an e-mail address and then shows the subject of any e-mails on the MM. Basically, I wanted a way for my wife and I to post messages for the whole family to see. This is an idea I’ve had for a long time (going back to the days of pagers) and is kinda obsolete – we use text messages and instagram messages a lot these days – but I still wanted to make this happen.

                  Probably next week I’ll be posting a message “how do I put a module in github for everyone to use?” as I’m totally new to all of this. 8^)

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

                    @sdetweil said in Config option with array of multiple values?:

                    yes the compares
                    !=
                    !==
                    !===

                    are different

                    Heh. Back in my day, we got one equality operator and one inequality operator and we were dang thankful for that. Now git off my lawn! 8^)

                    Seriously, though, thanks for all your help!

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

                      @UncleRoger I agree. I came in before these fancy new languages. before web.

                      Sam

                      How to add modules

                      learning how to use browser developers window for css changes

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

                        @UncleRoger logon to GitHub, click repositories , new, make the name match your module name, create.

                        it will give you a set of commands to execute in your module folder to upload it to that repo…

                        easy peasy

                        note that you need to create an access key thru the GitHub profile menu to be able to upload.(aka push)
                        this replaces the requested password now

                        Sam

                        How to add modules

                        learning how to use browser developers window for css changes

                        UncleRogerU S 2 Replies Last reply Reply Quote 1
                        • 1
                        • 2
                        • 3
                        • 1 / 3
                        • 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