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

    Posts

    Recent Best Controversial
    • RE: MMM-MyCommute

      @j.e.f.f
      Managed to do it and pretty pleased with myself :)

      Here’s what it looks like:

      0_1496151228319_commute.png

      I had to edit the css file to move the destination-label slightly as you mentioned:

      margin-right: 70px;
      

      I edited your formatTime function to format the time in hours and minutes or just minutes if it’s less than an hour in total.
      Below is the code for that function with my bits added, I am sure it could be better but I think I did ok!

      formatTime: function(time, timeInTraffic) {
      
          var timeEl = document.createElement("span");
          timeEl.classList.add("travel-time");
          if (timeInTraffic != null) {
            var minutes = Math.floor(Number(timeInTraffic) /60);
            var h = Math.floor(minutes /60);
            var m = Math.floor(minutes %60);
            if (h == 0) {
              timeEl.innerHTML = m + " min";
            } else {
              timeEl.innerHTML = h + "h " + m + " min";
            }
            var variance = timeInTraffic / time;
            if (this.config.colorCodeTravelTime) {
              if (variance > this.config.poorTimeThreshold) {
                timeEl.classList.add("status-poor");
              } else if (variance > this.config.moderateTimeThreshold) {
                timeEl.classList.add("status-moderate");
              } else {
                timeEl.classList.add("status-good");
              }
            }
          } else {
            var minutes = Math.floor(Number(time) /60);
            var h = Math.floor(minutes /60);
            var m = Math.floor(minutes %60);
            if (h == 0) {
              timeEl.innerHTML = m + " min";
            } else {
              timeEl.innerHTML = h + "h " + m + " min";
            }
            timeEl.classList.add("status-good");
          }
      

      Thanks for your help Jeff, learned some more programming skills too so I’m happy! :)

      posted in Transport
      J
      jon11a
    • 1 / 1