From 83ee0534f27a5e95e3b2f3d6abb096193059b247 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Ram=C3=ADrez=20Norambuena?= Date: Thu, 1 Dec 2016 19:48:53 -0300 Subject: [PATCH] fixed eslint error into modules for Javascript files --- Gruntfile.js | 5 +- modules/default/calendar/debug.js | 10 +-- modules/default/clock/clock.js | 34 ++++----- modules/default/compliments/compliments.js | 34 ++++----- .../default/currentweather/currentweather.js | 76 +++++++++---------- modules/default/newsfeed/fetcher.js | 6 +- modules/default/newsfeed/newsfeed.js | 36 +++++---- modules/default/newsfeed/node_helper.js | 4 +- .../default/updatenotification/node_helper.js | 2 +- .../updatenotification/updatenotification.js | 2 +- 10 files changed, 110 insertions(+), 99 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index aa8420b3..ec3128ef 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -6,7 +6,10 @@ module.exports = function(grunt) { options: { configFile: ".eslintrc.json" }, - target: ["js/*.js", "modules/default/*.js", "modules/default/*/*.js", "serveronly/*.js", "*.js"] + target: ["js/*.js", "modules/default/*.js", "modules/default/*/*.js", + "serveronly/*.js", "*.js", "!modules/default/alert/notificationFx.js", + "!modules/default/alert/modernizr.custom.js", "!modules/default/alert/classie.js" + ] }, stylelint: { simple: { diff --git a/modules/default/calendar/debug.js b/modules/default/calendar/debug.js index bc0adae6..d52cdc9f 100644 --- a/modules/default/calendar/debug.js +++ b/modules/default/calendar/debug.js @@ -8,18 +8,18 @@ var CalendarFetcher = require("./calendarfetcher.js"); -var url = 'https://calendar.google.com/calendar/ical/pkm1t2uedjbp0uvq1o7oj1jouo%40group.calendar.google.com/private-08ba559f89eec70dd74bbd887d0a3598/basic.ics'; +var url = "https://calendar.google.com/calendar/ical/pkm1t2uedjbp0uvq1o7oj1jouo%40group.calendar.google.com/private-08ba559f89eec70dd74bbd887d0a3598/basic.ics"; var fetchInterval = 60 * 60 * 1000; var maximumEntries = 10; var maximumNumberOfDays = 365; -console.log('Create fetcher ...'); +console.log("Create fetcher ..."); fetcher = new CalendarFetcher(url, fetchInterval, maximumEntries, maximumNumberOfDays); fetcher.onReceive(function(fetcher) { - console.log(fetcher.events()); - console.log('------------------------------------------------------------'); + console.log(fetcher.events()); + console.log("------------------------------------------------------------"); }); fetcher.onError(function(fetcher, error) { @@ -29,5 +29,5 @@ fetcher.onError(function(fetcher, error) { fetcher.startFetch(); -console.log('Create fetcher done! '); +console.log("Create fetcher done! "); diff --git a/modules/default/clock/clock.js b/modules/default/clock/clock.js index cfd8f524..4455b15a 100644 --- a/modules/default/clock/clock.js +++ b/modules/default/clock/clock.js @@ -8,7 +8,7 @@ Module.register("clock",{ // Module config defaults. defaults: { - displayType: 'digital', // options: digital, analog, both + displayType: "digital", // options: digital, analog, both timeFormat: config.timeFormat, displaySeconds: true, @@ -18,11 +18,11 @@ Module.register("clock",{ showDate: true, /* specific to the analog clock */ - analogSize: '200px', - analogFace: 'simple', // options: 'none', 'simple', 'face-###' (where ### is 001 to 012 inclusive) - analogPlacement: 'bottom', // options: 'top', 'bottom', 'left', 'right' - analogShowDate: 'top', // options: false, 'top', or 'bottom' - secondsColor: '#888888', + analogSize: "200px", + analogFace: "simple", // options: 'none', 'simple', 'face-###' (where ### is 001 to 012 inclusive) + analogPlacement: "bottom", // options: 'top', 'bottom', 'left', 'right' + analogShowDate: "top", // options: false, 'top', or 'bottom' + secondsColor: "#888888", timezone: null, }, // Define required scripts. @@ -92,7 +92,7 @@ Module.register("clock",{ } } if(this.config.showDate){ - dateWrapper.innerHTML = now.format("dddd, LL"); + dateWrapper.innerHTML = now.format("dddd, LL"); } timeWrapper.innerHTML = timeString; secondsWrapper.innerHTML = now.format("ss"); @@ -112,7 +112,7 @@ Module.register("clock",{ * Create wrappers for ANALOG clock, only if specified in config */ - if (this.config.displayType !== 'digital') { + if (this.config.displayType !== "digital") { // If it isn't 'digital', then an 'analog' clock was also requested // Calculate the degree offset for each hand of the clock @@ -131,10 +131,10 @@ Module.register("clock",{ clockCircle.style.width = this.config.analogSize; clockCircle.style.height = this.config.analogSize; - if (this.config.analogFace != '' && this.config.analogFace != 'simple' && this.config.analogFace != 'none') { + if (this.config.analogFace != "" && this.config.analogFace != "simple" && this.config.analogFace != "none") { clockCircle.style.background = "url("+ this.data.path + "faces/" + this.config.analogFace + ".svg)"; clockCircle.style.backgroundSize = "100%"; - } else if (this.config.analogFace != 'none') { + } else if (this.config.analogFace != "none") { clockCircle.style.border = "2px solid white"; } var clockFace = document.createElement("div"); @@ -168,18 +168,18 @@ Module.register("clock",{ * Combine wrappers, check for .displayType */ - if (this.config.displayType === 'digital') { + if (this.config.displayType === "digital") { // Display only a digital clock wrapper.appendChild(dateWrapper); wrapper.appendChild(timeWrapper); - } else if (this.config.displayType === 'analog') { + } else if (this.config.displayType === "analog") { // Display only an analog clock dateWrapper.style.textAlign = "center"; dateWrapper.style.paddingBottom = "15px"; - if (this.config.analogShowDate === 'top') { + if (this.config.analogShowDate === "top") { wrapper.appendChild(dateWrapper); wrapper.appendChild(clockCircle); - } else if (this.config.analogShowDate === 'bottom') { + } else if (this.config.analogShowDate === "bottom") { wrapper.appendChild(clockCircle); wrapper.appendChild(dateWrapper); } else { @@ -199,11 +199,11 @@ Module.register("clock",{ digitalWrapper.appendChild(dateWrapper); digitalWrapper.appendChild(timeWrapper); - if (placement === 'left' || placement === 'right') { + if (placement === "left" || placement === "right") { digitalWrapper.style.display = "inline-block"; digitalWrapper.style.verticalAlign = "top"; analogWrapper.style.display = "inline-block"; - if (placement === 'left') { + if (placement === "left") { analogWrapper.style.padding = "0 20px 0 0"; wrapper.appendChild(analogWrapper); wrapper.appendChild(digitalWrapper); @@ -214,7 +214,7 @@ Module.register("clock",{ } } else { digitalWrapper.style.textAlign = "center"; - if (placement === 'top') { + if (placement === "top") { analogWrapper.style.padding = "0 0 20px 0"; wrapper.appendChild(analogWrapper); wrapper.appendChild(digitalWrapper); diff --git a/modules/default/compliments/compliments.js b/modules/default/compliments/compliments.js index 3bfdc8be..cabda03f 100644 --- a/modules/default/compliments/compliments.js +++ b/modules/default/compliments/compliments.js @@ -29,7 +29,7 @@ Module.register("compliments",{ ] }, updateInterval: 30000, - remoteFile: null, + remoteFile: null, fadeSpeed: 4000 }, @@ -47,11 +47,11 @@ Module.register("compliments",{ this.lastComplimentIndex = -1; - if (this.config.remoteFile != null) { - this.complimentFile((response) => { - this.config.compliments = JSON.parse(response); - }); - } + if (this.config.remoteFile != null) { + this.complimentFile((response) => { + this.config.compliments = JSON.parse(response); + }); + } // Schedule update timer. var self = this; @@ -114,17 +114,17 @@ 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); - }, + 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. diff --git a/modules/default/currentweather/currentweather.js b/modules/default/currentweather/currentweather.js index a379332d..35b392ae 100644 --- a/modules/default/currentweather/currentweather.js +++ b/modules/default/currentweather/currentweather.js @@ -165,7 +165,7 @@ Module.register("currentweather",{ } if (!this.loaded) { - wrapper.innerHTML = this.translate('LOADING'); + wrapper.innerHTML = this.translate("LOADING"); wrapper.className = "dimmed light small"; return wrapper; } @@ -322,20 +322,20 @@ Module.register("currentweather",{ // So we need to generate the timestring manually. // See issue: https://github.com/MichMich/MagicMirror/issues/181 var sunriseSunsetDateObject = (sunrise < now && sunset > now) ? sunset : sunrise; - var timeString = moment(sunriseSunsetDateObject).format('HH:mm'); + var timeString = moment(sunriseSunsetDateObject).format("HH:mm"); if (this.config.timeFormat !== 24) { //var hours = sunriseSunsetDateObject.getHours() % 12 || 12; if (this.config.showPeriod) { if (this.config.showPeriodUpper) { //timeString = hours + moment(sunriseSunsetDateObject).format(':mm A'); - timeString = moment(sunriseSunsetDateObject).format('h:mm A'); + timeString = moment(sunriseSunsetDateObject).format("h:mm A"); } else { //timeString = hours + moment(sunriseSunsetDateObject).format(':mm a'); - timeString = moment(sunriseSunsetDateObject).format('h:mm a'); + timeString = moment(sunriseSunsetDateObject).format("h:mm a"); } } else { //timeString = hours + moment(sunriseSunsetDateObject).format(':mm'); - timeString = moment(sunriseSunsetDateObject).format('h:mm'); + timeString = moment(sunriseSunsetDateObject).format("h:mm"); } } @@ -394,39 +394,39 @@ Module.register("currentweather",{ */ deg2Cardinal: function(deg) { - if (deg>11.25 && deg<=33.75){ - return "NNE"; - } else if (deg > 33.75 && deg <= 56.25) { - return "NE"; - } else if (deg > 56.25 && deg <= 78.75) { - return "ENE"; - } else if (deg > 78.75 && deg <= 101.25) { - return "E"; - } else if (deg > 101.25 && deg <= 123.75) { - return "ESE"; - } else if (deg > 123.75 && deg <= 146.25) { - return "SE"; - } else if (deg > 146.25 && deg <= 168.75) { - return "SSE"; - } else if (deg > 168.75 && deg <= 191.25) { - return "S"; - } else if (deg > 191.25 && deg <= 213.75) { - return "SSW"; - } else if (deg > 213.75 && deg <= 236.25) { - return "SW"; - } else if (deg > 236.25 && deg <= 258.75) { - return "WSW"; - } else if (deg > 258.75 && deg <= 281.25) { - return "W"; - } else if (deg > 281.25 && deg <= 303.75) { - return "WNW"; - } else if (deg > 303.75 && deg <= 326.25) { - return "NW"; - } else if (deg > 326.25 && deg <= 348.75) { - return "NNW"; - } else { - return "N"; - } + if (deg>11.25 && deg<=33.75){ + return "NNE"; + } else if (deg > 33.75 && deg <= 56.25) { + return "NE"; + } else if (deg > 56.25 && deg <= 78.75) { + return "ENE"; + } else if (deg > 78.75 && deg <= 101.25) { + return "E"; + } else if (deg > 101.25 && deg <= 123.75) { + return "ESE"; + } else if (deg > 123.75 && deg <= 146.25) { + return "SE"; + } else if (deg > 146.25 && deg <= 168.75) { + return "SSE"; + } else if (deg > 168.75 && deg <= 191.25) { + return "S"; + } else if (deg > 191.25 && deg <= 213.75) { + return "SSW"; + } else if (deg > 213.75 && deg <= 236.25) { + return "SW"; + } else if (deg > 236.25 && deg <= 258.75) { + return "WSW"; + } else if (deg > 258.75 && deg <= 281.25) { + return "W"; + } else if (deg > 281.25 && deg <= 303.75) { + return "WNW"; + } else if (deg > 303.75 && deg <= 326.25) { + return "NW"; + } else if (deg > 326.25 && deg <= 348.75) { + return "NNW"; + } else { + return "N"; + } }, diff --git a/modules/default/newsfeed/fetcher.js b/modules/default/newsfeed/fetcher.js index 8d920eec..3b0d2516 100644 --- a/modules/default/newsfeed/fetcher.js +++ b/modules/default/newsfeed/fetcher.js @@ -44,9 +44,9 @@ var Fetcher = function(url, reloadInterval, encoding) { parser.on("item", function(item) { var title = item.title; - var description = item.description || item.summary || item.content || ''; + var description = item.description || item.summary || item.content || ""; var pubdate = item.pubdate || item.published || item.updated; - var url = item.url || item.link || ''; + var url = item.url || item.link || ""; if (title && pubdate) { @@ -81,7 +81,7 @@ var Fetcher = function(url, reloadInterval, encoding) { scheduleTimer(); }); - var headers = {'User-Agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.75.14 (KHTML, like Gecko) Version/7.0.3 Safari/7046A194A'}; + var headers = {"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.75.14 (KHTML, like Gecko) Version/7.0.3 Safari/7046A194A"}; request({uri: url, encoding: null, headers: headers}).pipe(iconv.decodeStream(encoding)).pipe(parser); }; diff --git a/modules/default/newsfeed/newsfeed.js b/modules/default/newsfeed/newsfeed.js index 7d8d08c7..32fdabdf 100644 --- a/modules/default/newsfeed/newsfeed.js +++ b/modules/default/newsfeed/newsfeed.js @@ -25,8 +25,8 @@ Module.register("newsfeed",{ updateInterval: 10 * 1000, animationSpeed: 2.5 * 1000, maxNewsItems: 0, // 0 for unlimited - removeStartTags: '', - removeEndTags: '', + removeStartTags: "", + removeEndTags: "", startTags: [], endTags: [] @@ -93,33 +93,41 @@ Module.register("newsfeed",{ var sourceAndTimestamp = document.createElement("div"); sourceAndTimestamp.className = "light small dimmed"; - if (this.config.showSourceTitle && this.newsItems[this.activeItem].sourceTitle !== '') sourceAndTimestamp.innerHTML = this.newsItems[this.activeItem].sourceTitle; - if (this.config.showSourceTitle && this.newsItems[this.activeItem].sourceTitle !== '' && this.config.showPublishDate) sourceAndTimestamp.innerHTML += ', '; - if (this.config.showPublishDate) sourceAndTimestamp.innerHTML += moment(new Date(this.newsItems[this.activeItem].pubdate)).fromNow(); - if (this.config.showSourceTitle && this.newsItems[this.activeItem].sourceTitle !== '' || this.config.showPublishDate) sourceAndTimestamp.innerHTML += ':'; + if (this.config.showSourceTitle && this.newsItems[this.activeItem].sourceTitle !== "") { + sourceAndTimestamp.innerHTML = this.newsItems[this.activeItem].sourceTitle; + } + if (this.config.showSourceTitle && this.newsItems[this.activeItem].sourceTitle !== "" && this.config.showPublishDate) { + sourceAndTimestamp.innerHTML += ", "; + } + if (this.config.showPublishDate) { + sourceAndTimestamp.innerHTML += moment(new Date(this.newsItems[this.activeItem].pubdate)).fromNow(); + } + if (this.config.showSourceTitle && this.newsItems[this.activeItem].sourceTitle !== "" || this.config.showPublishDate) { + sourceAndTimestamp.innerHTML += ":"; + } wrapper.appendChild(sourceAndTimestamp); } //Remove selected tags from the beginning of rss feed items (title or description) - if (this.config.removeStartTags == 'title' || 'both') { + if (this.config.removeStartTags == "title" || "both") { for (f=0; f