• 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.

Except a module in getModules()

Scheduled Pinned Locked Moved Troubleshooting
14 Posts 3 Posters 5.2k 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.
  • Y Offline
    yours.mukul
    last edited by Sep 9, 2017, 8:26 PM

    var i,modules = MM.getModules().exceptModule(helloworld);

    The above code throws error, while the below doesn’t work
    var i,modules = MM.getModules().exceptModule(‘helloworld’);

    S 1 Reply Last reply Sep 9, 2017, 9:07 PM Reply Quote 0
    • S Offline
      strawberry 3.141 Project Sponsor Module Developer @yours.mukul
      last edited by Sep 9, 2017, 9:07 PM

      @yours.mukul can you give some context, like the whole module code or what you ate tryng to achieve?

      Please create a github issue if you need help, so I can keep track

      1 Reply Last reply Reply Quote 0
      • Y Offline
        yours.mukul
        last edited by Sep 9, 2017, 9:24 PM

        I have a button module, which throws notification when a button is pressed. What I want is, it blacks out the whole screen except “Hello World”. So I will be using

        **var i,modules = MM.getModule();
        for(i=0;i

        S 1 Reply Last reply Sep 9, 2017, 9:42 PM Reply Quote 0
        • S Offline
          strawberry 3.141 Project Sponsor Module Developer @yours.mukul
          last edited by Sep 9, 2017, 9:42 PM

          @yours.mukul exceptModule doens’t work with strings, instead it needs a module instance. What error do you get? The example is from the developers guide

          MM.getModules().exceptModule(helloworld).enumerate(function(module) {
            module.hide(1000, function() {
              //Module hidden.
            });
          });
          

          Please create a github issue if you need help, so I can keep track

          Y 2 Replies Last reply Sep 10, 2017, 6:16 AM Reply Quote 0
          • Y Offline
            yours.mukul @strawberry 3.141
            last edited by yours.mukul Sep 10, 2017, 6:16 AM Sep 10, 2017, 6:16 AM

            This post is deleted!
            1 Reply Last reply Reply Quote 0
            • Y Offline
              yours.mukul @strawberry 3.141
              last edited by Sep 10, 2017, 6:22 AM

              @strawberry-3.141

              socketNotificationReceived: function(notification, payload) {
                              var i,modules =  MM.getModules();
                  		if (notification === "BUTTON_PRESSED"){
              			this.sendNotification(notification, payload);   
                                      for(i=0; imodules.length; i+=1){
                                             if(modules[i].hidden == true){
                                                 modules[i].show(0);
                                            }
                                             else if(modules[i].hidden == false)
                                                  {
                                                   modules[i].hide(0);
                                                               }                           
                        }
              		}
              
              

              I want to show/hide all the modules except the **hello world ** module. Please help me out with that.

              Note: I was unable to write less than sign in the for loop while writing this reply, I think its a bug, in this forum, whenever I write less than, all the text after it is is ignored.

              S 1 Reply Last reply Sep 10, 2017, 8:18 AM Reply Quote 0
              • S Offline
                strawberry 3.141 Project Sponsor Module Developer @yours.mukul
                last edited by Sep 10, 2017, 8:18 AM

                @yours.mukul i can’t test it right now. what error do you get?

                try the example from the docs

                socketNotificationReceived: function(notification, payload) {
                  if (notification === "BUTTON_PRESSED"){
                    MM.getModules().exceptModule(helloworld).enumerate(function(module) {
                      module.hide(1000, function() {
                        //Module hidden.
                      });
                    });
                  }
                }
                

                Please create a github issue if you need help, so I can keep track

                Y 2 Replies Last reply Sep 10, 2017, 8:33 AM Reply Quote 0
                • Y Offline
                  yours.mukul @strawberry 3.141
                  last edited by Sep 10, 2017, 8:33 AM

                  @strawberry-3.141 how to iterate over the modules array ?
                  I want to show/hide all modules except the “helloworld”.

                  ? S 2 Replies Last reply Sep 10, 2017, 8:56 AM Reply Quote 0
                  • ? Offline
                    A Former User @yours.mukul
                    last edited by A Former User Sep 10, 2017, 8:56 AM Sep 10, 2017, 8:56 AM

                    @yours.mukul

                    MM.getModules().enumerate((module)=>{
                      if(module.name !== "helloworld") {
                        module.hide()
                      }
                    })
                    

                    This is written by hand, so there might be error, but you can understand how it goes.

                    1 Reply Last reply Reply Quote 0
                    • S Offline
                      strawberry 3.141 Project Sponsor Module Developer @yours.mukul
                      last edited by Sep 10, 2017, 10:08 AM

                      @yours.mukul enumerate will iterate over the array and will execute the function you specify for each module in the array

                      Please create a github issue if you need help, so I can keep track

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