mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 11:50:00 +00:00
Added capability to load compliments from the host file system.
This commit is contained in:
parent
5666729fcf
commit
950fa84d1c
@ -29,6 +29,7 @@ Module.register("compliments",{
|
||||
]
|
||||
},
|
||||
updateInterval: 30000,
|
||||
remoteFile: null,
|
||||
fadeSpeed: 4000
|
||||
},
|
||||
|
||||
@ -46,6 +47,12 @@ Module.register("compliments",{
|
||||
|
||||
this.lastComplimentIndex = -1;
|
||||
|
||||
if (this.config.remoteFile != null) {
|
||||
this.complimentFile((response) => {
|
||||
this.config.compliments = JSON.parse(response);
|
||||
});
|
||||
}
|
||||
|
||||
// Schedule update timer.
|
||||
var self = this;
|
||||
setInterval(function() {
|
||||
@ -104,6 +111,21 @@ Module.register("compliments",{
|
||||
|
||||
},
|
||||
|
||||
/* complimentFile(callback)
|
||||
* Retrieve a file from the local filesystem
|
||||
*/
|
||||
complimentFile: function(callback) {
|
||||
var xobj = new XMLHttpRequest();
|
||||
xobj.overrideMimeType("application/json");
|
||||
xobj.open('GET', this.file(this.config.remoteFile), true);
|
||||
xobj.onreadystatechange = function () {
|
||||
if (xobj.readyState == 4 && xobj.status == "200") {
|
||||
callback(xobj.responseText);
|
||||
}
|
||||
};
|
||||
xobj.send(null);
|
||||
},
|
||||
|
||||
/* complimentArray()
|
||||
* Retrieve a random compliment.
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user