@sdetweil Thank you! That one is edited for the forum actually, but anyway, you solved my problem
A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.
Read the statement by Michael Teeuw here.
B
Latest posts made by Bobae
-
RE: Error on loading script (new module not working)
-
Error on loading script (new module not working)
Hi,
I developed a new module. It seems okay,
but if i try to load it, its aborted and not able to load[GET http://localhost:8080/modules/{mymodule} net::ERR_ABORTED 404 (Not Found)]
[loader.js:187 Error on loading script: modules/{mymodule}]what could be the reason for this? Well probably my module has problems, so i attached it also.
Thank you
Module.register("mymodule",{ defaults: { location: false, locationID: false, apiKey: "", apiBase: "https://api.openweathermap.org/data/2.5/weather", animationSpeed: 1000, updateInterval: 10 * 60 * 1000, // every 10 minutes }, // Define required scripts. getScripts: function() { return ["moment.js"]; }, // Define required scripts. getStyles: function() { return ["mymodule.css"]; }, // No translations getTranslations: function() { return false; }, // Define start sequence. start: function() { Log.info("Starting module: " + this.name); // Set locale. moment.locale(config.language); this.type = null; this.temperature = null; this.loaded = false; this.initialDelay = 0; this.retryDelay = 2500; this.scheduleUpdate(this.initialDelay); }, getDom: function(){ var wrapper = document.createElement("div"); if (this.config.apikey === "") { wrapper.innerHTML = "Please set the valid APIKEY: " + this.name + "."; wrapper.className = "dimmed light small"; return wrapper; } if (!this.loaded) { wrapper.innerHTML = "LOADING"; wrapper.className = "dimmed light small"; return wrapper; } switch(this.type){ case "Rain": wrapper.classList.add("rain"); break; case "Drizzle": //이슬비 wrapper.classList.add("drizzle"); break; case "Snow": wrapper.classList.add("snow") break; case "Thunderstorm": wrapper.classList.add("thunderstorm") break; case "default": break; } if(this.temperature > 27){ var hot = document.createElement("span"); hot.classList.add("hot"); wrapper.appendChild(hot); } return wrapper; }, updateWeather: function(){ if (this.config.apiKey === "") { Log.error("RainAndSnow: Please set APIKEY"); return; } var url = this.config.apiBase + this.getParams(); var self = this; var retry = true; var request = new XMLHttpRequest(); request.open("GET", url, true); request.onreadystatechange = function() { if (this.readyState === 4) { if (this.status === 200) { self.processWeather(JSON.parse(this.response)); } else if (this.status === 401) { self.updateDom(self.config.animationSpeed); Log.error(self.name + ": Incorrect APIKEY."); retry = true; } else { Log.error(self.name + ": Could not load weather."); } if (retry) { self.scheduleUpdate((self.loaded) ? -1 : self.retryDelay); } } }; request.send(); }, scheduleUpdate: function(delay){ var nextLoad = this.config.updateInterval; if (typeof delay !== "undefined" && delay >= 0) { nextLoad = delay; } var self = this; setTimeout(function() { self.updateWeather(); }, nextLoad); }, processWeather: function(data){ if(!data) return; this.type = data.weather[0].main; this.temperature = data.main.temp - 273.15; this.loaded = true; this.updateDom(this.config.animationSpeed); }, getParams: function(){ var params = "?"; if(this.config.locationID){ params += "id="+this.config.locationID; } else if(this.config.location){ params += "q="+this.config.location; } params += "&appid="+this.config.apiKey; return params; }, });