mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-08-21 21:00:57 +00:00
Added clock notifications for elapsed time.
Added notifications to default `clock` module to broadcast: - `CLOCK_SECOND` for a clock second, and - `CLOCK_MINUTE` for a clock minute having elapsed. Each notification is broadcasted with the corresponding value i.e. `CLOCK_SECOND` -> `30` and `CLOCK_MINUTE` -> `5` .
This commit is contained in:
@@ -41,11 +41,25 @@ Module.register("clock",{
|
||||
|
||||
// Schedule update interval.
|
||||
var self = this;
|
||||
self.second = 0;
|
||||
self.minute = 0;
|
||||
self.lastDisplayedMinute = null;
|
||||
setInterval(function() {
|
||||
if (self.config.displaySeconds || self.lastDisplayedMinute !== moment().minute()) {
|
||||
self.updateDom();
|
||||
}
|
||||
if (self.second === 59) {
|
||||
self.second = 0;
|
||||
if (self.minute === 59){
|
||||
self.minute = 0;
|
||||
} else {
|
||||
self.minute++;
|
||||
}
|
||||
self.sendNotification("CLOCK_MINUTE", self.minute);
|
||||
} else {
|
||||
self.second++;
|
||||
self.sendNotification("CLOCK_SECOND", self.second);
|
||||
}
|
||||
}, 1000);
|
||||
|
||||
// Set locale.
|
||||
|
Reference in New Issue
Block a user