MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    1. Home
    2. Luukth
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.
    L
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 3
    • Groups 0

    Luukth

    @Luukth

    0
    Reputation
    413
    Profile views
    3
    Posts
    0
    Followers
    0
    Following
    Joined
    Last Online

    Luukth Unfollow Follow

    Latest posts made by Luukth

    • RE: Alert from inside function

      @strawberry-3.141 said in Alert from inside function:

      I suggest to outsource the data query from the render function

      Can you maybe link me to a documentation. I can’t really find a good way to learn how to make al of those functions.

      posted in Development
      L
      Luukth
    • RE: Alert from inside function

      @strawberry-3.141 Thanks that did the trick.

      posted in Development
      L
      Luukth
    • Alert from inside function

      I want to display a notification every time the interval runs. I get this error message:

      Uncaught TypeError: this.sendNotification is not a function at OV.js:40

      I think is thas something to do with where I place it because if I place it outside the interval function it does work. Maybe someone can point me in the right direction.

      Module.register("OV",{
         // Default module config.
         defaults: {
         	text: "Openbaar Vervoer!lsdksdkk"
         },
         
         // Override dom generator.
         getDom: function() {
         	var wrapper = document.createElement("div");
         	
         	function updateOV() {
         	this.sendUpdate;
         	var xhttp = new XMLHttpRequest();
         	xhttp.onreadystatechange = function() {
         		if (this.readyState == 4 && this.status == 200) {
         		var string = "";
         		//console.log(this.responseText);
         		var data = JSON.parse(this.responseText);
         		//console.log(decodeURI(data.dest));
         		string += "<table>";
         		$.each(data, function( index, value ) {
         			string += "<tr>"
         			console.log(value );
         			string += "<td>" + value.service + "</td>";
         			string += "<td>" + decodeURI(value.dest) + "</td>";
         			string += "<td>" + value.time + "</td>";
         			string += "<td>" + value.state + "</td>";
         			string += "</tr>";
         		});
         		string += "</table>";
         		wrapper.innerHTML = string;
         		}
         	  };
         	  xhttp.open("GET", "http://192.168.1.167/esp/bustijden.php");
         	  xhttp.send();
         	}
         	
         	setInterval(function() {
         		updateOV();
         		this.sendNotification("SHOW_ALERT", {title: "OV", message: "Bustijden ge-update.", timer: "1000"});
         	}, 10000);
         	updateOV();
         	
         	return wrapper;
         },
         
         getScripts: function() {
         return [
         	'https://code.jquery.com/jquery-2.2.3.min.js',  // this file will be loaded from the jquery servers.
         ]
         },
      
      });
      
      posted in Development
      L
      Luukth