Snille / MMM-Modulebar

A module for the MagicMirror 2 that adds touch buttons for showing/hiding other modules.
MIT License
14 stars 10 forks source link

can I control other pages or url #15

Open mmycjguo opened 3 years ago

mmycjguo commented 3 years ago

I use MMM-SmartWebDisplay,Can I use this module's gotourl to control smartwebdisplay's url? or change mmm-pages page

        if (typeof data.gotoUrl !== 'undefined') {
            if (data.gotoUrl === "back") {
                window.history.back();
            } else {

                this.sendNotification("SWD_URL", "http://10.227.10.56:9000/material/?page=now-playing");

                //window.location.assign(data.gotoUrl);
            }

I don’t know how to write code. I spent a lot of time and tried a lot of methods, but I couldn’t get enough results.

Snille commented 3 years ago

Hmm... No, not really, with the "gotourl" you will load another page instead of the mirror in the same webbrowser-window... But, maybe you could use the "showurl" and "hideurl"-button function...

In the button array, add a button that shows or hides (any) module. (for example, a "picture module" or any other then just use a picture of just 1 black pixel :))... And use the "showurl" and "hideurl" arguments in the button to trigger something... That should work... :) Don't know if it achieves what you want...

The button:

    },
    "1": {
      // A button to show and hide the clock in this example, and is uses the "bell" icon.
      module: "clock",
      idnum: 1,
      text: "Clock",
      symbol: "bell",
      symbol2: "bell-slash",
      showUrl: "http://10.227.10.56:9000/material/?page=now-playing",
      hideUrl: "http://10.227.10.56:9000/material/?page=stop-playing"
    },
mmycjguo commented 3 years ago

Thank you very, very much for your quick reply, I just want to show this module: "MMM-SmartWebDisplay", //idnum: 1, symbol: "fas fa-laptop-house", symbol2: "fas fa-home", showUrl: 'http://10.227.10.70:8080/remote?action=NOTIFICATION&notification=SWD_URL&payload={"url":["http://10.227.10.56:9000/material/?page=now-playing"], "update":"0", "NextURL":"0"}', hideUrl: 'http://10.227.10.70:8080/remote?action=NOTIFICATION&notification=SWD_URL&payload={"url":[""], "update":"0", "NextURL":"0"}'

mmycjguo commented 3 years ago

if I want to use gotourl to load page 2,Is this the configuration parameter? "1": { module: "MMM-SmartWebDisplay", //idnum: 1, symbol: "fas fa-laptop-house", symbol2: "fas fa-home", showUrl: 'http://10.227.10.70:8080/remote?action=NOTIFICATION&notification=SWD_URL&payload={"url":["https://home.mygogo.win:8123/lovelace-magicmirror/0"], "update":"0", "NextURL":"0"}', hideUrl: 'http://10.227.10.70:8080/remote?action=NOTIFICATION&notification=SWD_URL&payload={"url":[""], "update":"0", "NextURL":"0"}' gotoUrl: 2 },

Snille commented 3 years ago

I'm not sure I understand what you want to do... The "gotourl" can not be used in the same button as the "showurl" and "hideurl", at least have I not tried it that way. :) The "gotourl" needs to have the full URL defined. The "gotourl" will navigate away from the mirror it self and will load the page you have defined.

The "showurl" and "hideurl" will be visited in the "background", it will not show anywhere. I made that function to be able to "start" and "stop" a stream for MotionEye. So when the camera is "displayed" (by pressing the button) the "showurl" triggers MotionEye to start the stream for the camera. And when the camera is hidden again, the "hideurl" triggers MotionEye to stop the stream. Otherwise the hidden camera would stream all the time and a lot of bandwidth would be waisted. :)

However I don't know if this helps you. :) But that was the thinking behind the functions... :)