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: Develop module with API

      @sdetweil I don’t understand what you mean.

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

      Don’t I do this with this?

      var callWrapper = document.createElement("tr");
      callWrapper.appendChild(FajrTextCell);
      
      posted in Development
      htilburgsH
      htilburgs
    • RE: Develop module with API

      Strugling with formatting. When I use the basic code, I got the result I like but it’s not displayed nice. I like to have 3 columns.

      		var MPT = this.MPT;
      		
      		// Creating the div's for your data items
      		var top = document.createElement("div");
      		top.classList.add("list-row");
      
      		// Fajr from data
      		var mptFajr = document.createElement("div");
      		mptFajr.classList.add("small", "bright", "Fajr");
      		mptFajr.innerHTML = "Fajr : " + MPT.Fajr + " الفجر";
      		wrapper.appendChild(mptFajr);			
      			
      		// Sunrise from data
      		if (this.config.showSunrise != false) {
      		    var mptSunrise = document.createElement("div");
      		    mptSunrise.classList.add("small", "bright", "Sunrise");
      		    mptSunrise.innerHTML = "Sunrise : " + MPT.Sunrise + " شروق الشمس";
      		    wrapper.appendChild(mptSunrise);
      		}
      		// Dhuhr from data
      		var mptDhuhr = document.createElement("div");
      		mptDhuhr.classList.add("small", "bright", "Dhuhr");
      		mptDhuhr.innerHTML = "Duhr : " + MPT.Dhuhr + " الظهر";
      		wrapper.appendChild(mptDhuhr);
      
      		// Asr from data
      		var mptAsr = document.createElement("div");
      		mptAsr.classList.add("small", "bright", "Asr");
      		mptAsr.innerHTML = "Asr : " + MPT.Asr + " العصر";
      		wrapper.appendChild(mptAsr);
      			
      		// Sunset from data
      		if (this.config.showSunset != false) {
      		    var mptSunset = document.createElement("div");
      		    mptSunset.classList.add("small", "bright", "Sunset");
      		    mptSunset.innerHTML = "Sunset : " + MPT.Sunset + " غروب الشمس";
      		    wrapper.appendChild(mptSunset);
      		}
      			
      		// Maghrib from data
      		var mptMaghrib = document.createElement("div");
      		mptMaghrib.classList.add("small", "bright", "Maghrib");
      		mptMaghrib.innerHTML = "Maghrib : " + MPT.Maghrib + " المغرب";
      		wrapper.appendChild(mptMaghrib);
      		
      		// Isha from data
      		var mptIsha = document.createElement("div");
      		mptIsha.classList.add("small", "bright", "Isha");
      		mptIsha.innerHTML = "Isha : " + MPT.Isha + " العشاء";
      		wrapper.appendChild(mptIsha);
      			
      		// Midnight from data
      		if (this.config.showMidnight != false) {
      		    var mptMidnight = document.createElement("div");
      		    mptMidnight.classList.add("small", "bright", "Midnight");
      		    mptMidnigh
      

      alt text

      Now I trying for several hours to figure out how to create table, columns, rows…
      I’ve changed the code part to

      		var MPT = this.MPT;
      
      		var logs = document.createElement("table");
      		var callWrapper = document.createElement("tr");
      		callWrapper.classList.add("small");
      		
      		// Fajr
      		var FajrTextCell = document.createElement("td");
      		FajrTextCell.className.add = "xsmall bright fajrtext";
      		FajrTextCell.innerHTML = "Fajr";
      		callWrapper.appendChild(FajrTextCell);
      		
      		var FajrTimeCell = document.createElement("td");
      		FajrTimeCell.className = "xsmall bright fajrtime";
      		FajrTimeCell.innerHTML = MPT.Fajr;
      		callWrapper.appendChild(FajrTimeCell);
      		
      		var FajrArabCell = document.createElement("td");
      		FajrArabCell.className = "xsmall bright fajrarab";
      		FajrArabCell.innerHTML = "الفجر";
      		callWrapper.appendChild(FajrArabCell);
      
      		logs.appendChild(callWrapper);
      		wrapper.appendChild(logs);
      		return wrapper;
      

      The result for 1 item is nice

      alt text

      But when I repeat this for the other items, no rows are created and everything is on the same row.

      		var MPT = this.MPT;
      
      //Table Test
      
      		var logs = document.createElement("table");
      		var callWrapper = document.createElement("tr");
      		callWrapper.classList.add("small");
      		
      		// Fajr
      		var FajrTextCell = document.createElement("td");
      		FajrTextCell.className.add = "xsmall bright fajrtext";
      		FajrTextCell.innerHTML = "Fajr";
      		callWrapper.appendChild(FajrTextCell);
      		
      		var FajrTimeCell = document.createElement("td");
      		FajrTimeCell.className = "xsmall bright fajrtime";
      		FajrTimeCell.innerHTML = MPT.Fajr;
      		callWrapper.appendChild(FajrTimeCell);
      		
      		var FajrArabCell = document.createElement("td");
      		FajrArabCell.className = "xsmall bright fajrarab";
      		FajrArabCell.innerHTML = "الفجر";
      		callWrapper.appendChild(FajrArabCell);
      		
      		// Sunrise
      		var SunriseTextCell = document.createElement("td");
      		SunriseTextCell.className.add = "xsmall bright sunrisetext";
      		SunriseTextCell.innerHTML = "Sunrise";
      		callWrapper.appendChild(FajrTextCell);
      		
      		var SunriseTimeCell = document.createElement("td");
      		SunriseTimeCell.className = "xsmall bright fajrtime";
      		SunriseTimeCell.innerHTML = MPT.Sunrise;
      		callWrapper.appendChild(SunriseTimeCell);
      		
      		var SunriseArabCell = document.createElement("td");
      		SunriseArabCell.className = "xsmall bright sunrisearab";
      		SunriseArabCell.innerHTML = "شروق الشمس";
      		callWrapper.appendChild(SunriseArabCell);		
      
      		logs.appendChild(callWrapper);
      		wrapper.appendChild(logs);
      		return wrapper;
      

      alt text

      Any help to get me on the right track again?

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

      @Sean,
      Thank you for explaining and pointing me out.
      I understand what was the issue. I’ve cleaned up the code and removed the caroussel part (and unneeded variables), because I don’t use that.

      Added the possibility for showing or not showing some items.
      Up to the next part… HTML Markup

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

      @Sean,
      This is what I want. Thanx for the quick reply!

      Can you tell me what is the difference in the code?

      This was an example from the MMM-UFO where information is rotated.
      Because I don’t need it, I’m going to cleanup.

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

      @Mykle1, @sdetweil ,
      Looking at the website from the API Prayer Times API, the result are all displayed in JSON

      The API has several endpoints to assist developers. Note that all the endpoints return JSON and are available over http and https.
      

      I’ve looked at the code again and it should be MPT.Fajr.
      I’ve made the module public on github, so you can take a look if you like.
      MMM-MyPrayerTime

      Meanwhile I’m trying to solve it…

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

      @Mykle1 I’m using MMM-UFO as example and trying to figure out. I’m getting somewhere but… The data is retrieved through the api and this is the result:

      Asr: "16:01"
      Dhuhr: "12:46"
      Fajr: "05:12"
      Imsak: "05:02"
      Isha: "20:21"
      Maghrib: "18:49"
      Midnight: "00:46"
      Sunrise: "06:44"
      Sunset: "18:49"
      

      The module is generated on the MM

      alt text

      But as you can see, it cannot read or display the data in the correct way.
      This is the code that I use to get the data from the resultset.

      // Fajr from data
      var mptFajr = document.createElement("div");
      mptFajr.classList.add("small", "bright", "fajr");
      mptFajr.innerHTML = "Fajr : " + MPT.Fajr;
      wrapper.appendChild(mptFajr);
      

      I can’t figure out what the problem is. It seems have something to do with the time-string that is returned. But whatever I try, no luck. Any idea?

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

      Oke, got it. I had to add some console.log settings…:flushed_face:

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

      I used the example from MMM-UFO, and started the module.
      How can I check if there is data from the API URL?

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

      @Mykle1 @Sean
      Both thanks for the quick reply.
      For now I’ve information that I can use to start.
      If there are any questions, I know where to be ;-)

      posted in Development
      htilburgsH
      htilburgs
    • 1
    • 2
    • 13
    • 14
    • 15
    • 16
    • 17
    • 15 / 17