mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-28 04:02:12 +00:00
Fix error when no compliments are set
This commit is contained in:
parent
e2427fe299
commit
65e1b60fb7
@ -162,19 +162,19 @@ Module.register("compliments", {
|
|||||||
// get the current time of day compliments list
|
// get the current time of day compliments list
|
||||||
var compliments = this.complimentArray();
|
var compliments = this.complimentArray();
|
||||||
// variable for index to next message to display
|
// variable for index to next message to display
|
||||||
let index=0;
|
let index = 0;
|
||||||
// are we randomizing
|
// are we randomizing
|
||||||
if(this.config.random){
|
if(this.config.random){
|
||||||
// yes
|
// yes
|
||||||
index = this.randomIndex(compliments);
|
index = this.randomIndex(compliments);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
// no, sequetial
|
// no, sequential
|
||||||
// if doing sequential, don't fall off the end
|
// if doing sequential, don't fall off the end
|
||||||
index = (this.lastIndexUsed >= (compliments.length-1))?0: ++this.lastIndexUsed;
|
index = (this.lastIndexUsed >= (compliments.length-1))?0: ++this.lastIndexUsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
return compliments[index];
|
return compliments[index] || "";
|
||||||
},
|
},
|
||||||
|
|
||||||
// Override dom generator.
|
// Override dom generator.
|
||||||
@ -184,9 +184,9 @@ Module.register("compliments", {
|
|||||||
// get the compliment text
|
// get the compliment text
|
||||||
var complimentText = this.randomCompliment();
|
var complimentText = this.randomCompliment();
|
||||||
// split it into parts on newline text
|
// split it into parts on newline text
|
||||||
var parts= complimentText.split("\n");
|
var parts = complimentText.split("\n");
|
||||||
// create a span to hold it all
|
// 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
|
// process all the parts of the compliment text
|
||||||
for (part of parts){
|
for (part of parts){
|
||||||
// create a text element for each part
|
// create a text element for each part
|
||||||
|
Loading…
x
Reference in New Issue
Block a user