mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-30 13:09:34 +00:00
Merge pull request #2021 from ndom91/update-compliments-module-advice-api
Update Compliments Module - Add Advice API
This commit is contained in:
commit
bbf48a0dd0
@ -10,6 +10,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).
|
||||
*This release is scheduled to be released on 2020-07-01.*
|
||||
|
||||
### Added
|
||||
- Compliments Module - Add Advice API (https://api.adviceslip.com/) Option
|
||||
|
||||
### Updated
|
||||
- Cleaned up alert module code
|
||||
|
@ -39,7 +39,8 @@ Module.register("compliments", {
|
||||
afternoonStartTime: 12,
|
||||
afternoonEndTime: 17,
|
||||
random: true,
|
||||
mockDate: null
|
||||
mockDate: null,
|
||||
advice: false
|
||||
},
|
||||
lastIndexUsed:-1,
|
||||
// Set currentweather from module
|
||||
@ -62,6 +63,18 @@ Module.register("compliments", {
|
||||
self.config.compliments = JSON.parse(response);
|
||||
self.updateDom();
|
||||
});
|
||||
} else if (this.config.advice) {
|
||||
var xobj = new XMLHttpRequest();
|
||||
xobj.overrideMimeType("application/json");
|
||||
xobj.open("GET", "https://api.adviceslip.com/advice", true);
|
||||
xobj.onreadystatechange = function() {
|
||||
if (xobj.readyState === 4 && xobj.status === 200) {
|
||||
const adviceResp = JSON.parse(xobj.responseText);
|
||||
self.config.compliments = adviceResp.slip.advice
|
||||
self.updateDom();
|
||||
}
|
||||
};
|
||||
xobj.send(null);
|
||||
}
|
||||
|
||||
// Schedule update timer.
|
||||
|
Loading…
x
Reference in New Issue
Block a user