Read the statement by Michael Teeuw here.
compliments doesnt work
-
Hey , i up dated little bit the settings in the compliments.js
first it work but after u tried to add another timed compliments group its stoped working .
this is my code . thanks for helpers /ps - i am pretty sure that the problem is here :
but not sure how to fix .if (hour >= this.config.morningStartTime && hour < this.config.morningEndTime && this.config.compliments.hasOwnProperty("morning")) { compliments = this.config.compliments.morning.slice(0); } else if (hour >= this.config.afternoonStartTime && hour < this.config.afternoonEndTime && this.config.compliments.hasOwnProperty("afternoon")) { compliments = this.config.compliments.afternoon.slice(0); } else if (hour >= this.config.beforemorningStartTime && hour < this.config.beforemorningEndTime && this.config.compliments.hasOwnProperty("beforemorning")) { compliments = this.config.compliments.beforemorning.slice(0); } else if(this.config.compliments.hasOwnProperty("evening")) { compliments = this.config.compliments.evening.slice(0); }
/* global Log, Module, moment */
/* Magic Mirror
-
Module: Compliments
-
By Michael Teeuw http://michaelteeuw.nl
-
MIT Licensed.
*/
Module.register(“compliments”, {// Module config defaults.
defaults: {
compliments: {
anytime: [
“Hey there sexy !”,
“Have you been working out ?”,
“I’m lucky to be your mirror !”,
“Damn. You’re looking good!”,
“There’s no place like home”,
“Your smile is contagious”,
“You’re a smart cookie”,
“You’re more helpful than you realize”,
“You bring out the best in other people”,
“I am so proud of you.”,
“Get down and give me 20 !!”,
“Don’t underestimate me! \n I don’t quit and I don’t run.\n - Naruto -”,
“Failing doesn’t give you a reason to give up, as long as you believe.\n - Naruto -”,
“Once you question your own belief it’s over. \n - Naruto -”,
“Hard work is worthless for those that don’t believe in themselves.\n - Naruto -”,
“Somebody told me I’m a failure, I’ll prove them wrong. \n - Naruto -”,
“I don’t quit, i don’t run, i never go back on my word, THAT’S IS MY WAY !”,
“Hard work is worthless for those that don’t belive in themselves”,
"When you give up, your dreams and everything else, they’re gone ",
“While you’re alive, you need a reason for existence. Being unable to find one is the same as being dead”,
“Once you question your own belief, it’s over”,
“Do not wait , The time never be ‘just right.’ Start where you stand , and work with whateverr tolls you may have”,
“Aim for the moon . If you miss you may hit a star”,
“Keep your eyes on the stars , And your feet tn the ground”,
“Start where you are .\n Use what you have . \n Do what you can.”,
“Only I can change my life. No one can do it for me.”,
“We should not give up and we should not allow the problem to defeat us.”,
“If something is important enough, even if the odds are against you, you should still do it.”,
“If you get up in the morning and think the future is going to be better, it is a bright day. Otherwise, it’s not.”,
“The question I ask myself like almost every day is, ‘Am I doing the most important thing I could be doing?’”,
“The biggest risk is not taking any risk.”,
“Drink cup of water”,
“Drink cup of water”,
" ",
" ",
“Drink cup of water”], morning: [ "Good morning, handsome !", "Enjoy your day !", "Drink cup of water", "Good start of the day is the most important part of it", "Hope you sleep well !!", "Good morning, sunshine !", "Who needs coffee when you have your smile ?", "Go get 'em, Tiger !", "Loud song morning is better then silence morning ", "Set a goal that makes you want to jump out of bed in the morning." ], afternoon: [ "Hello, beauty !", "Drink cup of water", "You look sexy !", "Looking good today !", "so far you did a great job !", "If you want to eat something and you don't know what - it's better not to eat, \ninstead of candy", "You are making a difference !" ], evening: [ "Wow, you look hot !", "You look nice ! ", "Hi, sexy !", "Drink cup of water", "You made someone smile today, I know it", "You are making a difference", "The day was better for your efforts", "See you tomorrow !", "Sleep tight", "Remember don't drink caffeine after 19:00" ], beforemorning:[ "go to sleep , a good night sleep lead to great moring ", "no good desicion has made after 2 am " \n"ted , How I Met Your Mother ", "if you play now ,it is better to pause the game and go to sleep you can resume it tomorow " ] }, updateInterval: 900000, remoteFile: null, fadeSpeed: 500, morningStartTime: 5, morningEndTime: 13, afternoonStartTime: 13, afternoonEndTime: 17, beforemorningStartTime:1, beforemorningEndTime:4
},
// Set currentweather from module
currentWeatherType: “”,// Define required scripts.
getScripts: function() {
return [“moment.js”];
},// Define start sequence.
start: function() {
Log.info("Starting module: " + this.name);this.lastComplimentIndex = -1; var self = this; if (this.config.remoteFile != null) { this.complimentFile(function(response) { self.config.compliments = JSON.parse(response); self.updateDom(); }); } // Schedule update timer. setInterval(function() { self.updateDom(self.config.fadeSpeed); }, this.config.updateInterval);
},
/* randomIndex(compliments)
-
Generate a random index for a list of compliments.
-
argument compliments Array - Array with compliments.
-
return Number - Random index.
*/
randomIndex: function(compliments) {
if (compliments.length === 1) {
return 0;
}var generate = function() {
return Math.floor(Math.random() * compliments.length);
};var complimentIndex = generate();
while (complimentIndex === this.lastComplimentIndex) {
complimentIndex = generate();
}this.lastComplimentIndex = complimentIndex;
return complimentIndex;
},
/* complimentArray()
-
Retrieve an array of compliments for the time of the day.
-
return compliments Array - Array with compliments for the time of the day.
*/
complimentArray: function() {
var hour = moment().hour();
var compliments;if (hour >= this.config.morningStartTime && hour < this.config.morningEndTime && this.config.compliments.hasOwnProperty(“morning”)) {
compliments = this.config.compliments.morning.slice(0);
} else if (hour >= this.config.afternoonStartTime && hour < this.config.afternoonEndTime && this.config.compliments.hasOwnProperty(“afternoon”)) {
compliments = this.config.compliments.afternoon.slice(0);
} else if (hour >= this.config.beforemorningStartTime && hour < this.config.beforemorningEndTime && this.config.compliments.hasOwnProperty(“beforemorning”)) {
compliments = this.config.compliments.beforemorning.slice(0);
} else if(this.config.compliments.hasOwnProperty(“evening”)) {
compliments = this.config.compliments.evening.slice(0);
}if (typeof compliments === “undefined”) {
compliments = new Array();
}if (this.currentWeatherType in this.config.compliments) {
compliments.push.apply(compliments, this.config.compliments[this.currentWeatherType]);
}compliments.push.apply(compliments, this.config.compliments.anytime);
return compliments;
},
/* complimentFile(callback)
- Retrieve a file from the local filesystem
*/
complimentFile: function(callback) {
var xobj = new XMLHttpRequest(),
isRemote = this.config.remoteFile.indexOf(“http://”) === 0 || this.config.remoteFile.indexOf(“https://”) === 0,
path = isRemote ? this.config.remoteFile : this.file(this.config.remoteFile);
xobj.overrideMimeType(“application/json”);
xobj.open(“GET”, path, true);
xobj.onreadystatechange = function() {
if (xobj.readyState == 4 && xobj.status == “200”) {
callback(xobj.responseText);
}
};
xobj.send(null);
},
/* complimentArray()
-
Retrieve a random compliment.
-
return compliment string - A compliment.
*/
randomCompliment: function() {
var compliments = this.complimentArray();
var index = this.randomIndex(compliments);return compliments[index];
},
// Override dom generator.
getDom: function() {
var complimentText = this.randomCompliment();var compliment = document.createTextNode(complimentText); var wrapper = document.createElement("div"); wrapper.className = this.config.classes ? this.config.classes : "thin xlarge bright pre-line"; wrapper.appendChild(compliment); return wrapper;
},
// From data currentweather set weather type
setCurrentWeatherType: function(data) {
var weatherIconTable = {
“01d”: “day_sunny”,
“02d”: “day_cloudy”,
“03d”: “cloudy”,
“04d”: “cloudy_windy”,
“09d”: “showers”,
“10d”: “rain”,
“11d”: “thunderstorm”,
“13d”: “snow”,
“50d”: “fog”,
“01n”: “night_clear”,
“02n”: “night_cloudy”,
“03n”: “night_cloudy”,
“04n”: “night_cloudy”,
“09n”: “night_showers”,
“10n”: “night_rain”,
“11n”: “night_thunderstorm”,
“13n”: “night_snow”,
“50n”: “night_alt_cloudy_windy”
};
this.currentWeatherType = weatherIconTable[data.weather[0].icon];
},// Override notification handler.
notificationReceived: function(notification, payload, sender) {
if (notification == “CURRENTWEATHER_DATA”) {
this.setCurrentWeatherType(payload.data);
}
}, -
});
-
-
NVM .
i checked it agin and the problem was type o /
it should work just fine . -
Glad to hear it. Remember to mark the forum topic as solved!