First round of undef fixes

This commit is contained in:
rejas
2020-05-02 10:39:09 +02:00
parent d8f093b226
commit b9d19cfcb4
22 changed files with 56 additions and 50 deletions

View File

@@ -5,8 +5,8 @@
* MIT Licensed.
*/
var ical = require("./vendor/ical.js");
var moment = require("moment");
const ical = require("./vendor/ical.js");
const moment = require("moment");
var CalendarFetcher = function(url, reloadInterval, excludedEvents, maximumEntries, maximumNumberOfDays, auth, includePastEvents) {
var self = this;
@@ -25,7 +25,7 @@ var CalendarFetcher = function(url, reloadInterval, excludedEvents, maximumEntri
clearTimeout(reloadTimer);
reloadTimer = null;
nodeVersion = Number(process.version.match(/^v(\d+\.\d+)/)[1]);
var nodeVersion = Number(process.version.match(/^v(\d+\.\d+)/)[1]);
var opts = {
headers: {
"User-Agent": "Mozilla/5.0 (Node.js "+ nodeVersion + ") MagicMirror/" + global.version + " (https://github.com/MichMich/MagicMirror/)"
@@ -61,7 +61,7 @@ var CalendarFetcher = function(url, reloadInterval, excludedEvents, maximumEntri
}
// console.log(data);
newEvents = [];
var newEvents = [];
// limitFunction doesn't do much limiting, see comment re: the dates array in rrule section below as to why we need to do the filtering ourselves
var limitFunction = function(date, i) {return true;};
@@ -97,7 +97,7 @@ var CalendarFetcher = function(url, reloadInterval, excludedEvents, maximumEntri
if (typeof event.end !== "undefined") {
endDate = eventDate(event, "end");
} else if(typeof event.duration !== "undefined") {
dur=moment.duration(event.duration);
var dur=moment.duration(event.duration);
endDate = startDate.clone().add(dur);
} else {
if (!isFacebookBirthday) {

View File

@@ -15,8 +15,6 @@ var maximumEntries = 10;
var maximumNumberOfDays = 365;
var user = "magicmirror";
var pass = "MyStrongPass";
var broadcastPastEvents = false;
var auth = {
user: user,
pass: pass
@@ -24,7 +22,7 @@ var auth = {
console.log("Create fetcher ...");
fetcher = new CalendarFetcher(url, fetchInterval, [], maximumEntries, maximumNumberOfDays, auth);
var fetcher = new CalendarFetcher(url, fetchInterval, [], maximumEntries, maximumNumberOfDays, auth);
fetcher.onReceive(function(fetcher) {
console.log(fetcher.events());

View File

@@ -1,4 +1,4 @@
/* global Module */
/* global Module, SunCalc */
/* Magic Mirror
* Module: Clock
@@ -289,11 +289,12 @@ Module.register("clock",{
// Both clocks have been configured, check position
var placement = this.config.analogPlacement;
analogWrapper = document.createElement("div");
var analogWrapper = document.createElement("div");
analogWrapper.id = "analog";
analogWrapper.style.cssFloat = "none";
analogWrapper.appendChild(clockCircle);
digitalWrapper = document.createElement("div");
var digitalWrapper = document.createElement("div");
digitalWrapper.id = "digital";
digitalWrapper.style.cssFloat = "none";
digitalWrapper.appendChild(dateWrapper);

View File

@@ -127,7 +127,7 @@ Module.register("compliments", {
compliments.push.apply(compliments, this.config.compliments.anytime);
for (entry in this.config.compliments) {
for (var entry in this.config.compliments) {
if (new RegExp(entry).test(date)) {
compliments.push.apply(compliments, this.config.compliments[entry]);
}
@@ -188,7 +188,7 @@ Module.register("compliments", {
// create a span to hold it all
var compliment = document.createElement("span");
// process all the parts of the compliment text
for (part of parts){
for (var part of parts){
// create a text element for each part
compliment.appendChild(document.createTextNode(part));
// add a break `

View File

@@ -81,8 +81,8 @@ var Fetcher = function(url, reloadInterval, encoding, logFeedWarnings) {
scheduleTimer();
});
nodeVersion = Number(process.version.match(/^v(\d+\.\d+)/)[1]);
headers = {"User-Agent": "Mozilla/5.0 (Node.js "+ nodeVersion + ") MagicMirror/" + global.version + " (https://github.com/MichMich/MagicMirror/)",
var nodeVersion = Number(process.version.match(/^v(\d+\.\d+)/)[1]);
var headers = {"User-Agent": "Mozilla/5.0 (Node.js "+ nodeVersion + ") MagicMirror/" + global.version + " (https://github.com/MichMich/MagicMirror/)",
"Cache-Control": "max-age=0, no-cache, no-store, must-revalidate",
"Pragma": "no-cache"};

View File

@@ -126,7 +126,7 @@ Module.register("newsfeed",{
if (this.config.removeStartTags === "title" || this.config.removeStartTags === "both") {
for (f=0; f<this.config.startTags.length;f++) {
for (let f=0; f<this.config.startTags.length;f++) {
if (this.newsItems[this.activeItem].title.slice(0,this.config.startTags[f].length) === this.config.startTags[f]) {
this.newsItems[this.activeItem].title = this.newsItems[this.activeItem].title.slice(this.config.startTags[f].length,this.newsItems[this.activeItem].title.length);
}
@@ -137,7 +137,7 @@ Module.register("newsfeed",{
if (this.config.removeStartTags === "description" || this.config.removeStartTags === "both") {
if (this.isShowingDescription) {
for (f=0; f<this.config.startTags.length;f++) {
for (let f=0; f<this.config.startTags.length;f++) {
if (this.newsItems[this.activeItem].description.slice(0,this.config.startTags[f].length) === this.config.startTags[f]) {
this.newsItems[this.activeItem].description = this.newsItems[this.activeItem].description.slice(this.config.startTags[f].length,this.newsItems[this.activeItem].description.length);
}
@@ -149,14 +149,14 @@ Module.register("newsfeed",{
//Remove selected tags from the end of rss feed items (title or description)
if (this.config.removeEndTags) {
for (f=0; f<this.config.endTags.length;f++) {
for (let f=0; f<this.config.endTags.length;f++) {
if (this.newsItems[this.activeItem].title.slice(-this.config.endTags[f].length)===this.config.endTags[f]) {
this.newsItems[this.activeItem].title = this.newsItems[this.activeItem].title.slice(0,-this.config.endTags[f].length);
}
}
if (this.isShowingDescription) {
for (f=0; f<this.config.endTags.length;f++) {
for (let f=0; f<this.config.endTags.length;f++) {
if (this.newsItems[this.activeItem].description.slice(-this.config.endTags[f].length)===this.config.endTags[f]) {
this.newsItems[this.activeItem].description = this.newsItems[this.activeItem].description.slice(0,-this.config.endTags[f].length);
}
@@ -331,7 +331,7 @@ Module.register("newsfeed",{
self.sendNotification("NEWS_FEED", {items: self.newsItems});
}
timer = setInterval(function() {
this.timer = setInterval(function() {
self.activeItem++;
self.updateDom(self.config.animationSpeed);
@@ -360,7 +360,7 @@ Module.register("newsfeed",{
// reset bottom bar alignment
document.getElementsByClassName("region bottom bar")[0].style.bottom = "0";
document.getElementsByClassName("region bottom bar")[0].style.top = "inherit";
if(!timer){
if(!this.timer){
this.scheduleUpdateInterval();
}
},
@@ -433,10 +433,9 @@ Module.register("newsfeed",{
document.getElementsByClassName("region bottom bar")[0].style.bottom = "inherit";
document.getElementsByClassName("region bottom bar")[0].style.top = "-90px";
}
clearInterval(timer);
timer = null;
clearInterval(this.timer);
this.timer = null;
Log.info(this.name + " - showing " + this.isShowingDescription ? "article description" : "full article");
this.updateDom(100);
}
});

View File

@@ -24,7 +24,7 @@ module.exports = NodeHelper.create({
var promises = [];
for (moduleName in modules) {
for (var moduleName in modules) {
if (!this.ignoreUpdateChecking(moduleName)) {
// Default modules are included in the main MagicMirror repo
var moduleFolder = path.normalize(__dirname + "/../../" + moduleName);

View File

@@ -74,8 +74,8 @@ Module.register("updatenotification", {
var wrapper = document.createElement("div");
if(this.suspended === false){
// process the hash of module info found
for(key of Object.keys(this.moduleList)){
let m= this.moduleList[key];
for(var key of Object.keys(this.moduleList)){
let m = this.moduleList[key];
var message = document.createElement("div");
message.className = "small bright";