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

    Posts

    Recent Best Controversial
    • RE: Getting API data in table

      @sdetweil, so what you’re saying is continu as I’m started with table, row, cells manual?

      I was hoping something in the next style would work.

         for (i = 0; i < this.MWB.length; i++) {
      	var MWB = this.MWB[i];
      

      and combining this with the text of the result. But I can’t figure it out.

      posted in Development
      htilburgsH
      htilburgs
    • Getting API data in table

      I get data through an API, lets say:

      alarm: "0"
      d0neerslag: "4"
      d0tmax: "12"
      d0tmin: "5"
      ....
      

      Currently I’m making a table, row and cells in the getDOM function to display the data:

      var TemperatuurRow = document.createElement("tr");
      TemperatuurRow.className = "temperatuur-row";
      		
      var TempTextCell = document.createElement("td");
      TempTextCell.className = "small";
      TempTextCell.innerHTML = "Neerslag";
      TemperatuurRow.appendChild(TempTextCell);
      table.appendChild(TemperatuurRow);
      			
      var TempDataCell = document.createElement("td");
      TempDataCell.className = "small fas fa-thermometer-half";
      TempDataCell.innerHTML = "  " + MWB.d0neerslag;
      TemperatuurRow.appendChild(TempDataCell);
      table.appendChild(TemperatuurRow);
      ...
      return table;	
      

      This is a lot of type-work. I was thinking isn’t there a better way?
      I was thinking of creating a table with the names and combine this with the results from the API. Can this be done? And how?

      (still trying to learn JS, but not afraid to ask) :smiling_face:

      posted in Development
      htilburgsH
      htilburgs
    • RE: Uncaught SyntaxError: Unexpected token return

      @sdetweil Oké, thank you for the explanation.

      posted in Troubleshooting
      htilburgsH
      htilburgs
    • RE: Uncaught SyntaxError: Unexpected token return

      @sdetweil YES, that did the trick! Learning a lot these few days.
      Thanks again.

      Is this notation always like this if you’re working with numbers?

      posted in Troubleshooting
      htilburgsH
      htilburgs
    • RE: Uncaught SyntaxError: Unexpected token return

      No luck…
      I’ve tried both of the options:

      	var MWB = this.MWB;
      	var n = 0;
      
      	// creating the tablerows
      	var WoonplaatsRow = document.createElement("tr");
      	WoonplaatsRow.className = "woonplaats-row";
      	
      	var WoonplaatsCell = document.createElement("td");
      	WoonplaatsCell.className = "small";
      	WoonplaatsCell.innerHTML = MWB.n.plaats;
      	WoonplaatsRow.appendChild(WoonplaatsCell);
      	table.appendChild(WoonplaatsRow);
      

      Error: Uncaught (in promise) TypeError: Cannot read property ‘plaats’ of undefined

      	var MWB = this.MWB;
      
      	// creating the tablerows
      	var WoonplaatsRow = document.createElement("tr");
      	WoonplaatsRow.className = "woonplaats-row";
      	
      	var WoonplaatsCell = document.createElement("td");
      	WoonplaatsCell.className = "small";
      	WoonplaatsCell.innerHTML = MWB.['0'].plaats;
      	WoonplaatsRow.appendChild(WoonplaatsCell);
      	table.appendChild(WoonplaatsRow);
      

      Error: Uncaught SyntaxError: Unexpected token [

      So both of the options give an error.

      posted in Troubleshooting
      htilburgsH
      htilburgs
    • RE: Uncaught SyntaxError: Unexpected token return

      @sdetweil , thanx, missed that.
      Now that this part is running the JSON data is fetched. But when I trying to show the data I get an error:

      Uncaught SyntaxError: Unexpected number
      

      This error is created by the zero in the line:
      WoonplaatsCell.innerHTML = MWB.0.plaats;

      		var MWB = this.MWB;
      
      		// creating the tablerows
      		var WoonplaatsRow = document.createElement("tr");
      		WoonplaatsRow.className = "woonplaats-row";
      		
      		var WoonplaatsCell = document.createElement("td");
      		WoonplaatsCell.className = "small";
      		WoonplaatsCell.innerHTML = MWB.0.plaats;
      		WoonplaatsRow.appendChild(WoonplaatsCell);
      		table.appendChild(WoonplaatsRow);
      

      The problem seems that I cannot use the 0 in the command.

      This is the JSON result

      object{1}
      	liveweer[1]
      		0{49}
      			alarm: "0"
      			d0neerslag: "4"
      			d0tmax: "12"
      			plaats: "Amsterdam"
      			...
      

      I used a JSON checker and it says that it’s valid JSON.
      How do I display the data from this result, if I cannot use the 0?

      posted in Troubleshooting
      htilburgsH
      htilburgs
    • Uncaught SyntaxError: Unexpected token return

      I’m creating a new module. I’m testing and get the error “Uncaught SyntaxError: Unexpected token return” at the line where is

      return table;
      

      This is the part where it goes wrong.
      I’ve been looking for typos and other errors, but cannot find them.
      Has anybody a clue?

      
      	getDom: function() {
      		
      		// creating the table
      		var table = document.createElement("table");
      		table.className = "small";
      		
      		// creating the wrapper
      		var wrapper = document.createElement("div");
      		wrapper.className = "wrapper";
      		wrapper.style.maxWidth = this.config.maxWidth;
      	
      		// The loading sequence
              	if (!this.loaded) {
                  	    wrapper.innerHTML = "Loading....";
                  	    wrapper.classList.add("bright", "light", "small");
                  	    return wrapper;
              	}	
      		
      		var MWB = this.MWB;
      
      		// creating the tablerows
      		var WoonplaatsRow = document.createElement("tr")
      		WoonplaatsRow.className = "woonplaats-row";
      		
      		var WoonplaatsCell = document.createElement("td");
      		WoonplaatsCell.className = "small";
      		WoonplaatsCell.innerHTML = "Regel1";
      		WoonplaatsRow.appendChild(WoonplaatsCell);
      		table.appendChild(WoonplaatsRow);
      		
      		var TemperatuurRow = document.createElement("tr")
      		TemperatuurRow.className = "temperatuur-row";
      		
      		var TemperatuurCell = document.createElement("td");
      		TemperatuurCell.className = "small";
      		TemperatuurCell.innerHTML = "Regel2"
      		TemperatuurRow.appendChild(TemperatuurCell);
      		table.appendChild(TemperatuurRow);
      					
      		}		
      		return table;		
      	
      	}, // <-- closes the getDom function from above```
      posted in Troubleshooting
      htilburgsH
      htilburgs
    • RE: Develop module with API

      @Mykle1 Thanks for the MMM-UFO “templates”. This really helped me to get started.
      First one down, several to go…:winking_face:

      posted in Development
      htilburgsH
      htilburgs
    • MMM-MyPrayerTimes

      Description
      MyPrayerTimes is a simple Module, that calculate prayer times for any location around the world, based on a variety of calculation methods currently used in Muslim communities using the Aladhan API

      Screenshot
      alt text

      Download
      [card:htilburgs/MMM-MyPrayerTimes]

      Extra
      I’m not an experienced programmer and do this for fun. Feel free to suggest any ideas.

      Versions
      20-03-2019 - v1.0.0 - Initial release
      02-04-2019 - v1.1.0 - Added option for 12/24 hour clock
      03-04-2019 - v1.1.1 - Added Imsak to prayer times

      posted in Utilities
      htilburgsH
      htilburgs
    • RE: Develop module with API

      @Sean @sdetweil I finaly figured it out! Thanx for the support and pointing me in the correct direction. See the result:

      alt text

      		var MPT = this.MPT;
      
      		// creating the tablerows
      		// Fajr
      		var FajrRow = document.createElement("tr")
      		FajrRow.className = "small fajr-row";
      		
      		var FajrTextCell = document.createElement("td");
      		FajrTextCell.innerHTML = "Fajr";
      		FajrRow.appendChild(FajrTextCell);
      		table.appendChild(FajrRow);
      		
      		var FajrTimeCell = document.createElement("td");
      		FajrTimeCell.className = "bright";
      		FajrTimeCell.innerHTML = MPT.Fajr;
      		FajrRow.appendChild(FajrTimeCell);
      		table.appendChild(FajrRow);
      		
      		var FajrArabCell = document.createElement("td");
      		FajrArabCell.innerHTML = "الفجر";
      		FajrRow.appendChild(FajrArabCell);
      		table.appendChild(FajrRow);
      ......
      }		
      		return table;	
      
      posted in Development
      htilburgsH
      htilburgs
    • 1
    • 2
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 14 / 17