mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-08-21 12:55:22 +00:00
Merge branch 'date' of https://github.com/rejas/MagicMirror into rejas-date
This commit is contained in:
@@ -28,6 +28,9 @@ Module.register("compliments", {
|
||||
"Wow, you look hot!",
|
||||
"You look nice!",
|
||||
"Hi, sexy!"
|
||||
],
|
||||
"....-01-01": [
|
||||
"Happy new year!"
|
||||
]
|
||||
},
|
||||
updateInterval: 30000,
|
||||
@@ -102,6 +105,7 @@ Module.register("compliments", {
|
||||
*/
|
||||
complimentArray: function() {
|
||||
var hour = moment().hour();
|
||||
var date = moment().format("YYYY-MM-DD");
|
||||
var compliments;
|
||||
|
||||
if (hour >= this.config.morningStartTime && hour < this.config.morningEndTime && this.config.compliments.hasOwnProperty("morning")) {
|
||||
@@ -122,6 +126,12 @@ Module.register("compliments", {
|
||||
|
||||
compliments.push.apply(compliments, this.config.compliments.anytime);
|
||||
|
||||
for (entry in this.config.compliments) {
|
||||
if (new RegExp(entry).test(date)) {
|
||||
compliments.push.apply(compliments, this.config.compliments[entry]);
|
||||
}
|
||||
}
|
||||
|
||||
return compliments;
|
||||
},
|
||||
|
||||
@@ -151,19 +161,19 @@ Module.register("compliments", {
|
||||
// get the current time of day compliments list
|
||||
var compliments = this.complimentArray();
|
||||
// variable for index to next message to display
|
||||
let index=0;
|
||||
let index = 0;
|
||||
// are we randomizing
|
||||
if(this.config.random){
|
||||
// yes
|
||||
index = this.randomIndex(compliments);
|
||||
}
|
||||
else{
|
||||
// no, sequetial
|
||||
// if doing sequential, don't fall off the end
|
||||
// no, sequential
|
||||
// if doing sequential, don't fall off the end
|
||||
index = (this.lastIndexUsed >= (compliments.length-1))?0: ++this.lastIndexUsed;
|
||||
}
|
||||
|
||||
return compliments[index];
|
||||
return compliments[index] || "";
|
||||
},
|
||||
|
||||
// Override dom generator.
|
||||
@@ -173,9 +183,9 @@ Module.register("compliments", {
|
||||
// get the compliment text
|
||||
var complimentText = this.randomCompliment();
|
||||
// split it into parts on newline text
|
||||
var parts= complimentText.split("\n");
|
||||
var parts = complimentText.split("\n");
|
||||
// create a span to hold it all
|
||||
var compliment=document.createElement("span");
|
||||
var compliment = document.createElement("span");
|
||||
// process all the parts of the compliment text
|
||||
for (part of parts){
|
||||
// create a text element for each part
|
||||
|
Reference in New Issue
Block a user