MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.

    Text per week

    Scheduled Pinned Locked Moved Unsolved Requests
    5 Posts 2 Posters 1.7k Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • R Offline
      retroflex Project Sponsor Module Developer
      last edited by

      Does anyone know if there is a module that let’s you show a different text each week? My son is learning letters in school and each week they have a certain letter, like this:

      week 38: R
      week 39: E
      week 40: P
      …

      My though was to show this week’s letter on my mirror.

      ? 2 Replies Last reply Reply Quote 0
      • ? Offline
        A Former User @retroflex
        last edited by

        @retroflex
        As far as I know, there is nothing like that. :D
        But I think it could be easily developed.
        with moment.js library, you can easily get the order of the current week.

        const letterOfWeek = ["", "", "A", ... "R", "E", "P", ...],
        var curWeekNumber = moment().week() //will return 1~52. You can use `isoWeek()` also.
        var letterOfThisWeek = letterOfWeek[curWeekNumber]
        

        This is just an idea, anyway, I believe you can make a simple module to display this.

        1 Reply Last reply Reply Quote 0
        • ? Offline
          A Former User @retroflex
          last edited by A Former User

          @retroflex
          Here. not fully tested.

          Module.register("letterOfWeek",{
            defaults: {
              letterOfWeek: {
                "default": "?",
                "38": "A",
                "39": "B",
                "40": "C",
              },
              updateInterval: 1000*60*60*3, // refresh per 3 hour.
            },
            getScripts: function() {
              return ["moment.js"]
            },
            getStyles: function() {
              return ["letterOfWeek.css"] // You need to parepare your own css.
            },
            getDom: function() {
              var getLetter = ()=> {
                var thisWeek = moment().week()
                var letter = (this.config.letterOfWeek.hasOwnProperty(thisWeek))
                  ? this.config.letterOfWeek[thisWeek]
                  : this.config.letterOfWeek["default"]
                return letter
              }
              var dom = document.createElement("div")
              dom.innerHTML = getLetter()
              dom.classList.add("letterOfWeek")
              return dom
            },
            notificationReceived: function(noti, payload) {
              if (noti == "DOM_OBJECTS_CREATED") {
                this.refresh()
              }
            },
            refresh: function() {
              this.updateDom()
              setTimeout(()=>{
                this.refresh()
              }, this.config.updateInterval)
            }
          })
          
          
          R 1 Reply Last reply Reply Quote 0
          • R Offline
            retroflex Project Sponsor Module Developer @Guest
            last edited by

            @Sean Thanks a lot! My thought was to make a module, but wanted to check first if one existed. And now you did the work for me :) I will try it out tonight. Maybe even upload it so others can download it.

            1 Reply Last reply Reply Quote 0
            • R Offline
              retroflex Project Sponsor Module Developer
              last edited by

              So a lot later I finally managed to make a module out of this:
              https://github.com/retroflex/MMM-TextPerWeek

              Thanks again @Sean !

              1 Reply Last reply Reply Quote 0
              • 1 / 1
              • First post
                Last post
              Enjoying MagicMirror? Please consider a donation!
              MagicMirror created by Michael Teeuw.
              Forum managed by Sam, technical setup by Karsten.
              This forum is using NodeBB as its core | Contributors
              Contact | Privacy Policy