diff --git a/modules/default/compliments/compliments.js b/modules/default/compliments/compliments.js index f05cd9c1..3bfdc8be 100644 --- a/modules/default/compliments/compliments.js +++ b/modules/default/compliments/compliments.js @@ -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. *