mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 11:50:00 +00:00
add support for sequential compliments usage
This commit is contained in:
parent
5e4d25b957
commit
0cb377618e
@ -36,9 +36,10 @@ Module.register("compliments", {
|
||||
morningStartTime: 3,
|
||||
morningEndTime: 12,
|
||||
afternoonStartTime: 12,
|
||||
afternoonEndTime: 17
|
||||
afternoonEndTime: 17,
|
||||
random: true
|
||||
},
|
||||
|
||||
lastIndexUsed:-1,
|
||||
// Set currentweather from module
|
||||
currentWeatherType: "",
|
||||
|
||||
@ -147,8 +148,20 @@ Module.register("compliments", {
|
||||
* return compliment string - A compliment.
|
||||
*/
|
||||
randomCompliment: function() {
|
||||
// get the current time of day compliments list
|
||||
var compliments = this.complimentArray();
|
||||
var index = this.randomIndex(compliments);
|
||||
variable for index to next message to display
|
||||
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
|
||||
index = (this.lastIndexUsed >= (compliments.length-1))?0: ++this.lastIndexUsed
|
||||
}
|
||||
|
||||
return compliments[index];
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user