Read the statement by Michael Teeuw here.
Text per week
-
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.
-
@retroflex
As far as I know, there is nothing like that. :D
But I think it could be easily developed.
withmoment.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.
-
@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) } })
-
@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.
-
So a lot later I finally managed to make a module out of this:
https://github.com/retroflex/MMM-TextPerWeekThanks again @Sean !