mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 03:39:55 +00:00
commit
9a5a74e153
@ -16,26 +16,30 @@ var compliments = {
|
||||
*/
|
||||
compliments.updateCompliment = function () {
|
||||
|
||||
|
||||
|
||||
var _list = [];
|
||||
|
||||
var hour = moment().hour();
|
||||
|
||||
// In the followign if statement we use .slice() on the
|
||||
// compliments array to make a copy by value.
|
||||
// This way the original array of compliments stays in tact.
|
||||
|
||||
if (hour >= 3 && hour < 12) {
|
||||
// Morning compliments
|
||||
_list = compliments.complimentList['morning'];
|
||||
_list = compliments.complimentList['morning'].slice();
|
||||
} else if (hour >= 12 && hour < 17) {
|
||||
// Afternoon compliments
|
||||
_list = compliments.complimentList['afternoon'];
|
||||
_list = compliments.complimentList['afternoon'].slice();
|
||||
} else if (hour >= 17 || hour < 3) {
|
||||
// Evening compliments
|
||||
_list = compliments.complimentList['evening'];
|
||||
_list = compliments.complimentList['evening'].slice();
|
||||
} else {
|
||||
// Edge case in case something weird happens
|
||||
// This will select a compliment from all times of day
|
||||
Object.keys(compliments.complimentList).forEach(function (_curr) {
|
||||
|
||||
_list = _list.concat(compliments.complimentList[_curr]);
|
||||
|
||||
_list = _list.concat(compliments.complimentList[_curr]).slice();
|
||||
});
|
||||
}
|
||||
|
||||
@ -44,12 +48,12 @@ compliments.updateCompliment = function () {
|
||||
|
||||
// If it exists, remove it so we don't see it again
|
||||
if (_spliceIndex !== -1) {
|
||||
_list = _list.slice(_spliceIndex, 1);
|
||||
_list.splice(_spliceIndex, 1);
|
||||
}
|
||||
|
||||
// Randomly select a location
|
||||
var _location = Math.floor(Math.random() * _list.length);
|
||||
compliments.currentCompliment = _list[_location];
|
||||
var _randomIndex = Math.floor(Math.random() * _list.length);
|
||||
compliments.currentCompliment = _list[_randomIndex];
|
||||
|
||||
$('.compliment').updateWithText(compliments.currentCompliment, compliments.fadeInterval);
|
||||
|
||||
|
@ -15,7 +15,7 @@ var config = {
|
||||
}
|
||||
},
|
||||
compliments: {
|
||||
interval: 2000,
|
||||
interval: 30000,
|
||||
fadeInterval: 4000,
|
||||
morning: [
|
||||
'Good morning, handsome!',
|
||||
|
Loading…
x
Reference in New Issue
Block a user