/* global Module */ /* Magic Mirror * Module: MMM-Horoscope * * By FILL_YOUR_NAME_HERE * MIT Licensed. */ Module.register("MMM-Horoscope", { // var request = require('request'); // Default module config. defaults: { starSign: "Aries", initialLoadDelay: 2500, // 0 seconds delay retryDelay: 2500 signs: { "Aries" }, }, // Override start method. start: function() { Log.log("Starting module: " + this.name); }, getDom: function() { var wrapper = document.createElement("div"); if (this.config.starSign === "") //if the sign is empty notify the user { wrapper.innerHTML = " Please set the solar horoscope sign in the config for module: " + this.name + "."; wrapper.className = "dimmed light small"; return wrapper; } else if (signs.indexOf(this.config.starSign) != -1) // Valid sign { var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (xhttp.readyState == 4 && this.status == 200) { parseRequest(this); } } } xhttp.open("GET", "http://feeds.feedburner.com/AstroSage"+ this.config.starSign +"?format=xml", true); xhttp.send(); // This function is declared inside the loop to make it private // It is also where the "magic" happens... function parseRequest(request){ wrapper.innerHTML = xhttp.getElementsByTagName("channel").childNodes[0].nodeValue; return wrapper; }}});