mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-08-21 12:55:22 +00:00
Refactor code
This commit is contained in:
@@ -29,10 +29,12 @@ Module.register("compliments", {
|
|||||||
"You look nice!",
|
"You look nice!",
|
||||||
"Hi, sexy!"
|
"Hi, sexy!"
|
||||||
],
|
],
|
||||||
date: [
|
1403 : [
|
||||||
["03-14", "Happy birthday, Albert Einstein!"],
|
"Happy birthday, Albert Einstein!"
|
||||||
["12-10", "Happy birthday, Ada Lovelace!"]
|
|
||||||
],
|
],
|
||||||
|
1012: [
|
||||||
|
"Happy birthday, Ada Lovelace!"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
updateInterval: 30000,
|
updateInterval: 30000,
|
||||||
remoteFile: null,
|
remoteFile: null,
|
||||||
@@ -106,8 +108,7 @@ Module.register("compliments", {
|
|||||||
*/
|
*/
|
||||||
complimentArray: function() {
|
complimentArray: function() {
|
||||||
var hour = moment().hour();
|
var hour = moment().hour();
|
||||||
var year = moment().year();
|
var date = moment().format("DDMM");
|
||||||
var today = moment(new Date());
|
|
||||||
var compliments;
|
var compliments;
|
||||||
|
|
||||||
if (hour >= this.config.morningStartTime && hour < this.config.morningEndTime && this.config.compliments.hasOwnProperty("morning")) {
|
if (hour >= this.config.morningStartTime && hour < this.config.morningEndTime && this.config.compliments.hasOwnProperty("morning")) {
|
||||||
@@ -128,11 +129,9 @@ Module.register("compliments", {
|
|||||||
|
|
||||||
compliments.push.apply(compliments, this.config.compliments.anytime);
|
compliments.push.apply(compliments, this.config.compliments.anytime);
|
||||||
|
|
||||||
this.config.compliments.date.forEach(d => {
|
if (date in this.config.compliments) {
|
||||||
if (today.isSame(year + "-" + d[0], "month")) {
|
compliments.push.apply(compliments, this.config.compliments[date]);
|
||||||
compliments.push(d[1]);
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
return compliments;
|
return compliments;
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user