Files
MMM-LiveLaughLove/MMM-LiveLaughLove.js

72 lines
2.0 KiB
JavaScript

Module.register("MMM-LiveLaughLove", {
defaults: {
preview: false,
updateInterval: 60 * 60 * 1000
},
start() {
this.scheduleUpdate();
},
isAprilFoolsDay(date = new Date()) {
return date.getMonth() === 3 && date.getDate() === 1;
},
shouldDisplay() {
return this.config.preview || this.isAprilFoolsDay();
},
getStyles() {
return ["MMM-LiveLaughLove.css"];
},
getDom() {
const wrapper = document.createElement("div");
wrapper.className = "lll-overlay";
if (!this.shouldDisplay()) {
wrapper.classList.add("lll-hidden");
return wrapper;
}
wrapper.innerHTML = `
<div class="lll-wall-texture"></div>
<div class="lll-ornament lll-ornament-top" aria-hidden="true">
<span class="lll-wing lll-wing-left">❧</span><span class="lll-heart">♡</span><span class="lll-wing lll-wing-right">❧</span>
</div>
<div class="lll-words" aria-label="Live, Laugh, Love">
<span class="lll-live">Live</span>
<span class="lll-separator">·</span>
<span class="lll-laugh">Laugh</span>
<span class="lll-separator">·</span>
<span class="lll-love">Love</span>
</div>
<div class="lll-ornament lll-ornament-bottom" aria-hidden="true">
<span class="lll-wing lll-wing-left">❧</span><span class="lll-heart">♡</span><span class="lll-wing lll-wing-right">❧</span>
</div>
<div class="lll-accent lll-accent-one" aria-hidden="true">❦</div>
<div class="lll-accent lll-accent-two" aria-hidden="true">❧</div>
<div class="lll-accent lll-accent-three" aria-hidden="true">❦</div>
<div class="lll-accent lll-accent-four" aria-hidden="true">❧</div>
<div class="lll-accent lll-accent-five" aria-hidden="true">♡</div>
<div class="lll-accent lll-accent-six" aria-hidden="true">♡</div>
`;
return wrapper;
},
scheduleUpdate() {
this.updateDom(0);
this.updateTimer = setInterval(() => this.updateDom(1000), this.config.updateInterval);
},
suspend() {
clearInterval(this.updateTimer);
},
resume() {
clearInterval(this.updateTimer);
this.scheduleUpdate();
}
});