From cbc2eaf908600cdcd237d9d9195ee156937672c6 Mon Sep 17 00:00:00 2001 From: Teddy Payet Date: Mon, 11 Jun 2018 12:54:27 +0200 Subject: [PATCH 1/6] Customize classes for table MagicMirror offers helper classes in the main.css. Therefore, we give the possibility to indicate the class that we want. --- .gitignore | 5 +++++ modules/default/calendar/calendar.js | 5 +++-- modules/default/weatherforecast/weatherforecast.js | 3 ++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 9b851b18..6cd6af96 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,9 @@ jspm_modules # Visual Studio Code ignoramuses. .vscode/ +# IDE Code ignoramuses. +.idea/ + # Various Windows ignoramuses. Thumbs.db ehthumbs.db @@ -78,3 +81,5 @@ Temporary Items *.orig *.rej *.bak + +css/homestyle.css diff --git a/modules/default/calendar/calendar.js b/modules/default/calendar/calendar.js index 3f87b9e2..8dcfa964 100755 --- a/modules/default/calendar/calendar.js +++ b/modules/default/calendar/calendar.js @@ -32,6 +32,7 @@ Module.register("calendar", { hideOngoing: false, colored: false, coloredSymbolOnly: false, + tableClass: "small", calendars: [ { symbol: "calendar", @@ -124,11 +125,11 @@ Module.register("calendar", { var events = this.createEventList(); var wrapper = document.createElement("table"); - wrapper.className = "small"; + wrapper.className = this.config.tableClass; if (events.length === 0) { wrapper.innerHTML = (this.loaded) ? this.translate("EMPTY") : this.translate("LOADING"); - wrapper.className = "small dimmed"; + wrapper.className = this.config.tableClass + " dimmed"; return wrapper; } diff --git a/modules/default/weatherforecast/weatherforecast.js b/modules/default/weatherforecast/weatherforecast.js index ea34afb9..ddb04603 100644 --- a/modules/default/weatherforecast/weatherforecast.js +++ b/modules/default/weatherforecast/weatherforecast.js @@ -36,6 +36,7 @@ Module.register("weatherforecast",{ appendLocationNameToHeader: true, calendarClass: "calendar", + tableClass: "small", roundTemp: false, @@ -117,7 +118,7 @@ Module.register("weatherforecast",{ } var table = document.createElement("table"); - table.className = "small"; + table.className = this.config.tableClass; for (var f in this.forecast) { var forecast = this.forecast[f]; From dcb2e51587afbf8074a3167e557263d2c8fb50c4 Mon Sep 17 00:00:00 2001 From: Teddy Date: Mon, 11 Jun 2018 14:00:16 +0200 Subject: [PATCH 2/6] Update .gitignore --- .gitignore | 2 -- 1 file changed, 2 deletions(-) diff --git a/.gitignore b/.gitignore index 6cd6af96..5733c750 100644 --- a/.gitignore +++ b/.gitignore @@ -81,5 +81,3 @@ Temporary Items *.orig *.rej *.bak - -css/homestyle.css From aeeeb5a37bff31ecc1c696be090a883af996002c Mon Sep 17 00:00:00 2001 From: Teddy Payet Date: Mon, 11 Jun 2018 14:02:34 +0200 Subject: [PATCH 3/6] Add changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b1f6071a..1d91ef9e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). - Added option for new display format in the calendar module with date headers with times/events below. - Ability to fetch compliments from a remote server - Add regex filtering to calendar module +- Customize classes for table ### Changed - Upgrade to Electron 2.0.0. From ed4d17f578e7f32d2d9c7424870ed9c56f8aae81 Mon Sep 17 00:00:00 2001 From: Teddy Payet Date: Mon, 11 Jun 2018 16:41:08 +0200 Subject: [PATCH 4/6] README updated Update of README for the new option. --- modules/default/calendar/README.md | 3 ++- modules/default/weatherforecast/README.md | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/default/calendar/README.md b/modules/default/calendar/README.md index e63f95b2..ae516a63 100755 --- a/modules/default/calendar/README.md +++ b/modules/default/calendar/README.md @@ -34,9 +34,10 @@ The following properties can be configured: | `maxTitleLength` | The maximum title length.

**Possible values:** `10` - `50`
**Default value:** `25` | `wrapEvents` | Wrap event titles to multiple lines. Breaks lines at the length defined by `maxTitleLength`.

**Possible values:** `true` or `false`
**Default value:** `false` | `fetchInterval` | How often does the content needs to be fetched? (Milliseconds)

**Possible values:** `1000` - `86400000`
**Default value:** `300000` (5 minutes) -| `animationSpeed` | Speed of the update animation. (Milliseconds)

**Possible values:**`0` - `5000`
**Default value:** `2000` (2 seconds) +| `animationSpeed` | Speed of the update animation. (Milliseconds)

**Possible values:** `0` - `5000`
**Default value:** `2000` (2 seconds) | `fade` | Fade the future events to black. (Gradient)

**Possible values:** `true` or `false`
**Default value:** `true` | `fadePoint` | Where to start fade?

**Possible values:** `0` (top of the list) - `1` (bottom of list)
**Default value:** `0.25` +| `tableClass` | Name of the classes issued from `main.css`.

**Possible values:** xsmall, small, medium, large, xlarge.
**Default value:** _small._ | `calendars` | The list of calendars.

**Possible values:** An array, see _calendar configuration_ below.
**Default value:** _An example calendar._ | `titleReplace` | An object of textual replacements applied to the tile of the event. This allow to remove or replace certains words in the title.

**Example:** `{'Birthday of ' : '', 'foo':'bar'}`
**Default value:** `{ "De verjaardag van ": "", "'s birthday": "" }` | `displayRepeatingCountTitle` | Show count title for yearly repeating events (e.g. "X. Birthday", "X. Anniversary")

**Possible values:** `true` or `false`
**Default value:** `false` diff --git a/modules/default/weatherforecast/README.md b/modules/default/weatherforecast/README.md index ccf81b0f..a487734f 100644 --- a/modules/default/weatherforecast/README.md +++ b/modules/default/weatherforecast/README.md @@ -35,7 +35,7 @@ The following properties can be configured: | `maxNumberOfDays` | How many days of forecast to return. Specified by config.js

**Possible values:** `1` - `16`
**Default value:** `7` (7 days)
This value is optional. By default the weatherforecast module will return 7 days. | `showRainAmount` | Should the predicted rain amount be displayed?

**Possible values:** `true` or `false`
**Default value:** `false`
This value is optional. By default the weatherforecast module will not display the predicted amount of rain. | `updateInterval` | How often does the content needs to be fetched? (Milliseconds)

**Possible values:** `1000` - `86400000`
**Default value:** `600000` (10 minutes) -| `animationSpeed` | Speed of the update animation. (Milliseconds)

**Possible values:**`0` - `5000`
**Default value:** `1000` (1 second) +| `animationSpeed` | Speed of the update animation. (Milliseconds)

**Possible values:** `0` - `5000`
**Default value:** `1000` (1 second) | `lang` | The language of the days.

**Possible values:** `en`, `nl`, `ru`, etc ...
**Default value:** uses value of _config.language_ | `decimalSymbol` | The decimal symbol to use.

**Possible values:** `.`, `,` or any other symbol.
**Default value:** `.` | `fade` | Fade the future events to black. (Gradient)

**Possible values:** `true` or `false`
**Default value:** `true` @@ -47,6 +47,7 @@ The following properties can be configured: | `forecastEndpoint` | The OpenWeatherMap API endPoint.

**Default value:** `'forecast/daily'` | `appendLocationNameToHeader` | If set to `true`, the returned location name will be appended to the header of the module, if the header is enabled. This is mainly intresting when using calender based weather.

**Default value:** `true` | `calendarClass` | The class for the calender module to base the event based weather information on.

**Default value:** `'calendar'` +| `tableClass` | Name of the classes issued from `main.css`.

**Possible values:** xsmall, small, medium, large, xlarge.
**Default value:** _small._ | `iconTable` | The conversion table to convert the weather conditions to weather-icons.

**Default value:** view table below `colored` | If set 'colored' to true the min-temp get a blue tone and the max-temp get a red tone.

**Default value:** `'false'` From 09abdc0f120ed91cce444fa781e1a4f1644573e4 Mon Sep 17 00:00:00 2001 From: Teddy Payet Date: Mon, 11 Jun 2018 19:59:21 +0200 Subject: [PATCH 5/6] ESLint format Resolve format ith eslint --- modules/default/calendar/calendar.js | 231 +++++++++--------- .../weatherforecast/weatherforecast.js | 88 +++---- 2 files changed, 159 insertions(+), 160 deletions(-) diff --git a/modules/default/calendar/calendar.js b/modules/default/calendar/calendar.js index 8dcfa964..d0ab4b82 100755 --- a/modules/default/calendar/calendar.js +++ b/modules/default/calendar/calendar.js @@ -1,15 +1,15 @@ /* global Module */ /* Magic Mirror - * Module: Calendar - * - * By Michael Teeuw http://michaelteeuw.nl - * MIT Licensed. - */ +* Module: Calendar +* +* By Michael Teeuw http://michaelteeuw.nl +* MIT Licensed. +*/ Module.register("calendar", { - // Define module defaults +// Define module defaults defaults: { maximumEntries: 10, // Total Maximum Entries maximumNumberOfDays: 365, @@ -82,7 +82,7 @@ Module.register("calendar", { }; // we check user and password here for backwards compatibility with old configs - if(calendar.user && calendar.pass) { + if (calendar.user && calendar.pass) { Log.warn("Deprecation warning: Please update your calendar authentication configuration."); Log.warn("https://github.com/MichMich/MagicMirror/tree/v2.1.2/modules/default/calendar#calendar-authentication-options"); calendar.auth = { @@ -138,8 +138,8 @@ Module.register("calendar", { for (var e in events) { var event = events[e]; var dateAsString = moment(event.startDate, "x").format(this.config.dateFormat); - if(this.config.timeFormat === "dateheaders"){ - if(lastSeenDate !== dateAsString){ + if (this.config.timeFormat === "dateheaders") { + if (lastSeenDate !== dateAsString) { var dateRow = document.createElement("tr"); dateRow.className = "normal" var dateCell = document.createElement("td"); @@ -155,7 +155,6 @@ Module.register("calendar", { } - var eventWrapper = document.createElement("tr"); if (this.config.colored && !this.config.coloredSymbolOnly) { @@ -173,20 +172,20 @@ Module.register("calendar", { symbolWrapper.className = "symbol align-right"; var symbols = this.symbolsForUrl(event.url); - if(typeof symbols === "string") { + if (typeof symbols === "string") { symbols = [symbols]; } - for(var i = 0; i < symbols.length; i++) { + for (var i = 0; i < symbols.length; i++) { var symbol = document.createElement("span"); symbol.className = "fa fa-fw fa-" + symbols[i]; - if(i > 0){ + if (i > 0) { symbol.style.paddingLeft = "5px"; } symbolWrapper.appendChild(symbol); } eventWrapper.appendChild(symbolWrapper); - }else if(this.config.timeFormat === "dateheaders"){ + } else if (this.config.timeFormat === "dateheaders") { var blankCell = document.createElement("td"); blankCell.innerHTML = "   " eventWrapper.appendChild(blankCell); @@ -215,13 +214,13 @@ Module.register("calendar", { titleWrapper.className = "title"; } - if(this.config.timeFormat === "dateheaders"){ + if (this.config.timeFormat === "dateheaders") { if (event.fullDayEvent) { titleWrapper.colSpan = "2"; titleWrapper.align = "left"; - }else{ + } else { var timeWrapper = document.createElement("td"); timeWrapper.className = "time light"; timeWrapper.align = "left"; @@ -247,7 +246,7 @@ Module.register("calendar", { } eventWrapper.appendChild(titleWrapper); - }else{ + } else { var timeWrapper = document.createElement("td"); eventWrapper.appendChild(titleWrapper); @@ -271,12 +270,12 @@ Module.register("calendar", { } } else { /* Check to see if the user displays absolute or relative dates with their events - * Also check to see if an event is happening within an 'urgency' time frameElement - * For example, if the user set an .urgency of 7 days, those events that fall within that - * time frame will be displayed with 'in xxx' time format or moment.fromNow() - * - * Note: this needs to be put in its own function, as the whole thing repeats again verbatim - */ +* Also check to see if an event is happening within an 'urgency' time frameElement +* For example, if the user set an .urgency of 7 days, those events that fall within that +* time frame will be displayed with 'in xxx' time format or moment.fromNow() +* +* Note: this needs to be put in its own function, as the whole thing repeats again verbatim +*/ if (this.config.timeFormat === "absolute") { if ((this.config.urgency > 1) && (event.startDate - now < (this.config.urgency * oneDay))) { // This event falls within the config.urgency period that the user has set @@ -301,12 +300,12 @@ Module.register("calendar", { } } else { /* Check to see if the user displays absolute or relative dates with their events - * Also check to see if an event is happening within an 'urgency' time frameElement - * For example, if the user set an .urgency of 7 days, those events that fall within that - * time frame will be displayed with 'in xxx' time format or moment.fromNow() - * - * Note: this needs to be put in its own function, as the whole thing repeats again verbatim - */ +* Also check to see if an event is happening within an 'urgency' time frameElement +* For example, if the user set an .urgency of 7 days, those events that fall within that +* time frame will be displayed with 'in xxx' time format or moment.fromNow() +* +* Note: this needs to be put in its own function, as the whole thing repeats again verbatim +*/ if (this.config.timeFormat === "absolute") { if ((this.config.urgency > 1) && (event.startDate - now < (this.config.urgency * oneDay))) { // This event falls within the config.urgency period that the user has set @@ -353,37 +352,37 @@ Module.register("calendar", { }, /** - * This function accepts a number (either 12 or 24) and returns a moment.js LocaleSpecification with the - * corresponding timeformat to be used in the calendar display. If no number is given (or otherwise invalid input) - * it will a localeSpecification object with the system locale time format. - * - * @param {number} timeFormat Specifies either 12 or 24 hour time format - * @returns {moment.LocaleSpecification} - */ - getLocaleSpecification: function(timeFormat) { +* This function accepts a number (either 12 or 24) and returns a moment.js LocaleSpecification with the +* corresponding timeformat to be used in the calendar display. If no number is given (or otherwise invalid input) +* it will a localeSpecification object with the system locale time format. +* +* @param {number} timeFormat Specifies either 12 or 24 hour time format +* @returns {moment.LocaleSpecification} +*/ + getLocaleSpecification: function (timeFormat) { switch (timeFormat) { case 12: { - return { longDateFormat: {LT: "h:mm A"} }; + return {longDateFormat: {LT: "h:mm A"}}; break; } case 24: { - return { longDateFormat: {LT: "HH:mm"} }; + return {longDateFormat: {LT: "HH:mm"}}; break; } default: { - return { longDateFormat: {LT: moment.localeData().longDateFormat("LT")} }; + return {longDateFormat: {LT: moment.localeData().longDateFormat("LT")}}; break; } } }, /* hasCalendarURL(url) - * Check if this config contains the calendar url. - * - * argument url string - Url to look for. - * - * return bool - Has calendar url - */ +* Check if this config contains the calendar url. +* +* argument url string - Url to look for. +* +* return bool - Has calendar url +*/ hasCalendarURL: function (url) { for (var c in this.config.calendars) { var calendar = this.config.calendars[c]; @@ -396,10 +395,10 @@ Module.register("calendar", { }, /* createEventList() - * Creates the sorted list of all events. - * - * return array - Array with events. - */ +* Creates the sorted list of all events. +* +* return array - Array with events. +*/ createEventList: function () { var events = []; var today = moment().startOf("day"); @@ -408,18 +407,18 @@ Module.register("calendar", { var calendar = this.calendarData[c]; for (var e in calendar) { var event = calendar[e]; - if(this.config.hidePrivate) { - if(event.class === "PRIVATE") { - // do not add the current event, skip it - continue; - } - } - if(this.config.hideOngoing) { - if(event.startDate < now) { + if (this.config.hidePrivate) { + if (event.class === "PRIVATE") { + // do not add the current event, skip it continue; } } - if(this.listContainsEvent(events,event)){ + if (this.config.hideOngoing) { + if (event.startDate < now) { + continue; + } + } + if (this.listContainsEvent(events, event)) { continue; } event.url = c; @@ -436,9 +435,9 @@ Module.register("calendar", { }, - listContainsEvent: function(eventList, event){ - for(let evt of eventList){ - if(evt.title === event.title && parseInt(evt.startDate) === parseInt(event.startDate)){ + listContainsEvent: function (eventList, event) { + for (let evt of eventList) { + if (evt.title === event.title && parseInt(evt.startDate) === parseInt(event.startDate)) { return true; } } @@ -447,10 +446,10 @@ Module.register("calendar", { }, /* createEventList(url) - * Requests node helper to add calendar url. - * - * argument url string - Url to add. - */ +* Requests node helper to add calendar url. +* +* argument url string - Url to add. +*/ addCalendar: function (url, auth, calendarConfig) { this.sendSocketNotification("ADD_CALENDAR", { url: url, @@ -463,47 +462,47 @@ Module.register("calendar", { }, /* symbolsForUrl(url) - * Retrieves the symbols for a specific url. - * - * argument url string - Url to look for. - * - * return string/array - The Symbols - */ +* Retrieves the symbols for a specific url. +* +* argument url string - Url to look for. +* +* return string/array - The Symbols +*/ symbolsForUrl: function (url) { return this.getCalendarProperty(url, "symbol", this.config.defaultSymbol); }, /* colorForUrl(url) - * Retrieves the color for a specific url. - * - * argument url string - Url to look for. - * - * return string - The Color - */ +* Retrieves the color for a specific url. +* +* argument url string - Url to look for. +* +* return string - The Color +*/ colorForUrl: function (url) { return this.getCalendarProperty(url, "color", "#fff"); }, /* countTitleForUrl(url) - * Retrieves the name for a specific url. - * - * argument url string - Url to look for. - * - * return string - The Symbol - */ +* Retrieves the name for a specific url. +* +* argument url string - Url to look for. +* +* return string - The Symbol +*/ countTitleForUrl: function (url) { return this.getCalendarProperty(url, "repeatingCountTitle", this.config.defaultRepeatingCountTitle); }, /* getCalendarProperty(url, property, defaultValue) - * Helper method to retrieve the property for a specific url. - * - * argument url string - Url to look for. - * argument property string - Property to look for. - * argument defaultValue string - Value if property is not found. - * - * return string - The Property - */ +* Helper method to retrieve the property for a specific url. +* +* argument url string - Url to look for. +* argument property string - Property to look for. +* argument defaultValue string - Value if property is not found. +* +* return string - The Property +*/ getCalendarProperty: function (url, property, defaultValue) { for (var c in this.config.calendars) { var calendar = this.config.calendars[c]; @@ -516,13 +515,13 @@ Module.register("calendar", { }, /** - * Shortens a string if it's longer than maxLength and add a ellipsis to the end - * - * @param {string} string Text string to shorten - * @param {number} maxLength The max length of the string - * @param {boolean} wrapEvents Wrap the text after the line has reached maxLength - * @returns {string} The shortened string - */ +* Shortens a string if it's longer than maxLength and add a ellipsis to the end +* +* @param {string} string Text string to shorten +* @param {number} maxLength The max length of the string +* @param {boolean} wrapEvents Wrap the text after the line has reached maxLength +* @returns {string} The shortened string +*/ shorten: function (string, maxLength, wrapEvents) { if (typeof string !== "string") { return ""; @@ -558,31 +557,31 @@ Module.register("calendar", { }, /* capFirst(string) - * Capitalize the first letter of a string - * Return capitalized string - */ +* Capitalize the first letter of a string +* Return capitalized string +*/ capFirst: function (string) { return string.charAt(0).toUpperCase() + string.slice(1); }, /* titleTransform(title) - * Transforms the title of an event for usage. - * Replaces parts of the text as defined in config.titleReplace. - * Shortens title based on config.maxTitleLength and config.wrapEvents - * - * argument title string - The title to transform. - * - * return string - The transformed title. - */ +* Transforms the title of an event for usage. +* Replaces parts of the text as defined in config.titleReplace. +* Shortens title based on config.maxTitleLength and config.wrapEvents +* +* argument title string - The title to transform. +* +* return string - The transformed title. +*/ titleTransform: function (title) { for (var needle in this.config.titleReplace) { var replacement = this.config.titleReplace[needle]; var regParts = needle.match(/^\/(.+)\/([gim]*)$/); if (regParts) { - // the parsed pattern is a regexp. - needle = new RegExp(regParts[1], regParts[2]); + // the parsed pattern is a regexp. + needle = new RegExp(regParts[1], regParts[2]); } title = title.replace(needle, replacement); @@ -593,9 +592,9 @@ Module.register("calendar", { }, /* broadcastEvents() - * Broadcasts the events to all other modules for reuse. - * The all events available in one array, sorted on startdate. - */ +* Broadcasts the events to all other modules for reuse. +* The all events available in one array, sorted on startdate. +*/ broadcastEvents: function () { var eventList = []; for (var url in this.calendarData) { @@ -609,7 +608,7 @@ Module.register("calendar", { } } - eventList.sort(function(a,b) { + eventList.sort(function (a, b) { return a.startDate - b.startDate; }); diff --git a/modules/default/weatherforecast/weatherforecast.js b/modules/default/weatherforecast/weatherforecast.js index ddb04603..957b2e40 100644 --- a/modules/default/weatherforecast/weatherforecast.js +++ b/modules/default/weatherforecast/weatherforecast.js @@ -1,15 +1,15 @@ /* global Module */ /* Magic Mirror - * Module: WeatherForecast - * - * By Michael Teeuw http://michaelteeuw.nl - * MIT Licensed. - */ +* Module: WeatherForecast +* +* By Michael Teeuw http://michaelteeuw.nl +* MIT Licensed. +*/ Module.register("weatherforecast",{ - // Default module config. +// Default module config. defaults: { location: false, locationID: false, @@ -36,7 +36,7 @@ Module.register("weatherforecast",{ appendLocationNameToHeader: true, calendarClass: "calendar", - tableClass: "small", + tableClass: "small", roundTemp: false, @@ -236,9 +236,9 @@ Module.register("weatherforecast",{ }, /* updateWeather(compliments) - * Requests new data from openweather.org. - * Calls processWeather on succesfull response. - */ +* Requests new data from openweather.org. +* Calls processWeather on succesfull response. +*/ updateWeather: function() { if (this.config.appid === "") { Log.error("WeatherForecast: APPID not set!"); @@ -277,10 +277,10 @@ Module.register("weatherforecast",{ }, /* getParams(compliments) - * Generates an url with api parameters based on the config. - * - * return String - URL params. - */ +* Generates an url with api parameters based on the config. +* +* return String - URL params. +*/ getParams: function() { var params = "?"; if(this.config.locationID) { @@ -304,12 +304,12 @@ Module.register("weatherforecast",{ }, /* - * parserDataWeather(data) - * - * Use the parse to keep the same struct between daily and forecast Endpoint - * from Openweather - * - */ +* parserDataWeather(data) +* +* Use the parse to keep the same struct between daily and forecast Endpoint +* from Openweather +* +*/ parserDataWeather: function(data) { if (data.hasOwnProperty("main")) { data["temp"] = {"min": data.main.temp_min, "max": data.main.temp_max} @@ -318,10 +318,10 @@ Module.register("weatherforecast",{ }, /* processWeather(data) - * Uses the received data to set the various values. - * - * argument data object - Weather information received form openweather.org. - */ +* Uses the received data to set the various values. +* +* argument data object - Weather information received form openweather.org. +*/ processWeather: function(data) { this.fetchedLocationName = data.city.name + ", " + data.city.country; @@ -374,10 +374,10 @@ Module.register("weatherforecast",{ }, /* scheduleUpdate() - * Schedule next update. - * - * argument delay number - Milliseconds before next update. If empty, this.config.updateInterval is used. - */ +* Schedule next update. +* +* argument delay number - Milliseconds before next update. If empty, this.config.updateInterval is used. +*/ scheduleUpdate: function(delay) { var nextLoad = this.config.updateInterval; if (typeof delay !== "undefined" && delay >= 0) { @@ -392,16 +392,16 @@ Module.register("weatherforecast",{ }, /* ms2Beaufort(ms) - * Converts m2 to beaufort (windspeed). - * - * see: - * http://www.spc.noaa.gov/faq/tornado/beaufort.html - * https://en.wikipedia.org/wiki/Beaufort_scale#Modern_scale - * - * argument ms number - Windspeed in m/s. - * - * return number - Windspeed in beaufort. - */ +* Converts m2 to beaufort (windspeed). +* +* see: +* http://www.spc.noaa.gov/faq/tornado/beaufort.html +* https://en.wikipedia.org/wiki/Beaufort_scale#Modern_scale +* +* argument ms number - Windspeed in m/s. +* +* return number - Windspeed in beaufort. +*/ ms2Beaufort: function(ms) { var kmh = ms * 60 * 60 / 1000; var speeds = [1, 5, 11, 19, 28, 38, 49, 61, 74, 88, 102, 117, 1000]; @@ -415,12 +415,12 @@ Module.register("weatherforecast",{ }, /* function(temperature) - * Rounds a temperature to 1 decimal or integer (depending on config.roundTemp). - * - * argument temperature number - Temperature. - * - * return string - Rounded Temperature. - */ +* Rounds a temperature to 1 decimal or integer (depending on config.roundTemp). +* +* argument temperature number - Temperature. +* +* return string - Rounded Temperature. +*/ roundValue: function(temperature) { var decimals = this.config.roundTemp ? 0 : 1; return parseFloat(temperature).toFixed(decimals); From afd829307dc489ee6e5fc8df8103134c8fe04ee3 Mon Sep 17 00:00:00 2001 From: Teddy Payet Date: Mon, 11 Jun 2018 23:09:00 +0200 Subject: [PATCH 6/6] Tabs and spaces from the original files With a diff, here the orginal tabulations. --- modules/default/calendar/calendar.js | 230 +++++++++--------- .../weatherforecast/weatherforecast.js | 86 +++---- 2 files changed, 158 insertions(+), 158 deletions(-) diff --git a/modules/default/calendar/calendar.js b/modules/default/calendar/calendar.js index d0ab4b82..0780fb5c 100755 --- a/modules/default/calendar/calendar.js +++ b/modules/default/calendar/calendar.js @@ -1,15 +1,15 @@ /* global Module */ /* Magic Mirror -* Module: Calendar -* -* By Michael Teeuw http://michaelteeuw.nl -* MIT Licensed. -*/ + * Module: Calendar + * + * By Michael Teeuw http://michaelteeuw.nl + * MIT Licensed. + */ Module.register("calendar", { -// Define module defaults + // Define module defaults defaults: { maximumEntries: 10, // Total Maximum Entries maximumNumberOfDays: 365, @@ -82,7 +82,7 @@ Module.register("calendar", { }; // we check user and password here for backwards compatibility with old configs - if (calendar.user && calendar.pass) { + if(calendar.user && calendar.pass) { Log.warn("Deprecation warning: Please update your calendar authentication configuration."); Log.warn("https://github.com/MichMich/MagicMirror/tree/v2.1.2/modules/default/calendar#calendar-authentication-options"); calendar.auth = { @@ -138,8 +138,8 @@ Module.register("calendar", { for (var e in events) { var event = events[e]; var dateAsString = moment(event.startDate, "x").format(this.config.dateFormat); - if (this.config.timeFormat === "dateheaders") { - if (lastSeenDate !== dateAsString) { + if(this.config.timeFormat === "dateheaders"){ + if(lastSeenDate !== dateAsString){ var dateRow = document.createElement("tr"); dateRow.className = "normal" var dateCell = document.createElement("td"); @@ -172,20 +172,20 @@ Module.register("calendar", { symbolWrapper.className = "symbol align-right"; var symbols = this.symbolsForUrl(event.url); - if (typeof symbols === "string") { + if(typeof symbols === "string") { symbols = [symbols]; } - for (var i = 0; i < symbols.length; i++) { + for(var i = 0; i < symbols.length; i++) { var symbol = document.createElement("span"); symbol.className = "fa fa-fw fa-" + symbols[i]; - if (i > 0) { + if(i > 0){ symbol.style.paddingLeft = "5px"; } symbolWrapper.appendChild(symbol); } eventWrapper.appendChild(symbolWrapper); - } else if (this.config.timeFormat === "dateheaders") { + }else if(this.config.timeFormat === "dateheaders"){ var blankCell = document.createElement("td"); blankCell.innerHTML = "   " eventWrapper.appendChild(blankCell); @@ -214,13 +214,13 @@ Module.register("calendar", { titleWrapper.className = "title"; } - if (this.config.timeFormat === "dateheaders") { + if(this.config.timeFormat === "dateheaders"){ if (event.fullDayEvent) { titleWrapper.colSpan = "2"; titleWrapper.align = "left"; - } else { + }else{ var timeWrapper = document.createElement("td"); timeWrapper.className = "time light"; timeWrapper.align = "left"; @@ -246,7 +246,7 @@ Module.register("calendar", { } eventWrapper.appendChild(titleWrapper); - } else { + }else{ var timeWrapper = document.createElement("td"); eventWrapper.appendChild(titleWrapper); @@ -270,12 +270,12 @@ Module.register("calendar", { } } else { /* Check to see if the user displays absolute or relative dates with their events -* Also check to see if an event is happening within an 'urgency' time frameElement -* For example, if the user set an .urgency of 7 days, those events that fall within that -* time frame will be displayed with 'in xxx' time format or moment.fromNow() -* -* Note: this needs to be put in its own function, as the whole thing repeats again verbatim -*/ + * Also check to see if an event is happening within an 'urgency' time frameElement + * For example, if the user set an .urgency of 7 days, those events that fall within that + * time frame will be displayed with 'in xxx' time format or moment.fromNow() + * + * Note: this needs to be put in its own function, as the whole thing repeats again verbatim + */ if (this.config.timeFormat === "absolute") { if ((this.config.urgency > 1) && (event.startDate - now < (this.config.urgency * oneDay))) { // This event falls within the config.urgency period that the user has set @@ -300,12 +300,12 @@ Module.register("calendar", { } } else { /* Check to see if the user displays absolute or relative dates with their events -* Also check to see if an event is happening within an 'urgency' time frameElement -* For example, if the user set an .urgency of 7 days, those events that fall within that -* time frame will be displayed with 'in xxx' time format or moment.fromNow() -* -* Note: this needs to be put in its own function, as the whole thing repeats again verbatim -*/ + * Also check to see if an event is happening within an 'urgency' time frameElement + * For example, if the user set an .urgency of 7 days, those events that fall within that + * time frame will be displayed with 'in xxx' time format or moment.fromNow() + * + * Note: this needs to be put in its own function, as the whole thing repeats again verbatim + */ if (this.config.timeFormat === "absolute") { if ((this.config.urgency > 1) && (event.startDate - now < (this.config.urgency * oneDay))) { // This event falls within the config.urgency period that the user has set @@ -352,37 +352,37 @@ Module.register("calendar", { }, /** -* This function accepts a number (either 12 or 24) and returns a moment.js LocaleSpecification with the -* corresponding timeformat to be used in the calendar display. If no number is given (or otherwise invalid input) -* it will a localeSpecification object with the system locale time format. -* -* @param {number} timeFormat Specifies either 12 or 24 hour time format -* @returns {moment.LocaleSpecification} -*/ - getLocaleSpecification: function (timeFormat) { + * This function accepts a number (either 12 or 24) and returns a moment.js LocaleSpecification with the + * corresponding timeformat to be used in the calendar display. If no number is given (or otherwise invalid input) + * it will a localeSpecification object with the system locale time format. + * + * @param {number} timeFormat Specifies either 12 or 24 hour time format + * @returns {moment.LocaleSpecification} + */ + getLocaleSpecification: function(timeFormat) { switch (timeFormat) { case 12: { - return {longDateFormat: {LT: "h:mm A"}}; + return { longDateFormat: {LT: "h:mm A"} }; break; } case 24: { - return {longDateFormat: {LT: "HH:mm"}}; + return { longDateFormat: {LT: "HH:mm"} }; break; } default: { - return {longDateFormat: {LT: moment.localeData().longDateFormat("LT")}}; + return { longDateFormat: {LT: moment.localeData().longDateFormat("LT")} }; break; } } }, /* hasCalendarURL(url) -* Check if this config contains the calendar url. -* -* argument url string - Url to look for. -* -* return bool - Has calendar url -*/ + * Check if this config contains the calendar url. + * + * argument url string - Url to look for. + * + * return bool - Has calendar url + */ hasCalendarURL: function (url) { for (var c in this.config.calendars) { var calendar = this.config.calendars[c]; @@ -395,10 +395,10 @@ Module.register("calendar", { }, /* createEventList() -* Creates the sorted list of all events. -* -* return array - Array with events. -*/ + * Creates the sorted list of all events. + * + * return array - Array with events. + */ createEventList: function () { var events = []; var today = moment().startOf("day"); @@ -407,18 +407,18 @@ Module.register("calendar", { var calendar = this.calendarData[c]; for (var e in calendar) { var event = calendar[e]; - if (this.config.hidePrivate) { - if (event.class === "PRIVATE") { - // do not add the current event, skip it + if(this.config.hidePrivate) { + if(event.class === "PRIVATE") { + // do not add the current event, skip it + continue; + } + } + if(this.config.hideOngoing) { + if(event.startDate < now) { continue; } } - if (this.config.hideOngoing) { - if (event.startDate < now) { - continue; - } - } - if (this.listContainsEvent(events, event)) { + if(this.listContainsEvent(events,event)){ continue; } event.url = c; @@ -435,9 +435,9 @@ Module.register("calendar", { }, - listContainsEvent: function (eventList, event) { - for (let evt of eventList) { - if (evt.title === event.title && parseInt(evt.startDate) === parseInt(event.startDate)) { + listContainsEvent: function(eventList, event){ + for(let evt of eventList){ + if(evt.title === event.title && parseInt(evt.startDate) === parseInt(event.startDate)){ return true; } } @@ -446,10 +446,10 @@ Module.register("calendar", { }, /* createEventList(url) -* Requests node helper to add calendar url. -* -* argument url string - Url to add. -*/ + * Requests node helper to add calendar url. + * + * argument url string - Url to add. + */ addCalendar: function (url, auth, calendarConfig) { this.sendSocketNotification("ADD_CALENDAR", { url: url, @@ -462,47 +462,47 @@ Module.register("calendar", { }, /* symbolsForUrl(url) -* Retrieves the symbols for a specific url. -* -* argument url string - Url to look for. -* -* return string/array - The Symbols -*/ + * Retrieves the symbols for a specific url. + * + * argument url string - Url to look for. + * + * return string/array - The Symbols + */ symbolsForUrl: function (url) { return this.getCalendarProperty(url, "symbol", this.config.defaultSymbol); }, /* colorForUrl(url) -* Retrieves the color for a specific url. -* -* argument url string - Url to look for. -* -* return string - The Color -*/ + * Retrieves the color for a specific url. + * + * argument url string - Url to look for. + * + * return string - The Color + */ colorForUrl: function (url) { return this.getCalendarProperty(url, "color", "#fff"); }, /* countTitleForUrl(url) -* Retrieves the name for a specific url. -* -* argument url string - Url to look for. -* -* return string - The Symbol -*/ + * Retrieves the name for a specific url. + * + * argument url string - Url to look for. + * + * return string - The Symbol + */ countTitleForUrl: function (url) { return this.getCalendarProperty(url, "repeatingCountTitle", this.config.defaultRepeatingCountTitle); }, /* getCalendarProperty(url, property, defaultValue) -* Helper method to retrieve the property for a specific url. -* -* argument url string - Url to look for. -* argument property string - Property to look for. -* argument defaultValue string - Value if property is not found. -* -* return string - The Property -*/ + * Helper method to retrieve the property for a specific url. + * + * argument url string - Url to look for. + * argument property string - Property to look for. + * argument defaultValue string - Value if property is not found. + * + * return string - The Property + */ getCalendarProperty: function (url, property, defaultValue) { for (var c in this.config.calendars) { var calendar = this.config.calendars[c]; @@ -515,13 +515,13 @@ Module.register("calendar", { }, /** -* Shortens a string if it's longer than maxLength and add a ellipsis to the end -* -* @param {string} string Text string to shorten -* @param {number} maxLength The max length of the string -* @param {boolean} wrapEvents Wrap the text after the line has reached maxLength -* @returns {string} The shortened string -*/ + * Shortens a string if it's longer than maxLength and add a ellipsis to the end + * + * @param {string} string Text string to shorten + * @param {number} maxLength The max length of the string + * @param {boolean} wrapEvents Wrap the text after the line has reached maxLength + * @returns {string} The shortened string + */ shorten: function (string, maxLength, wrapEvents) { if (typeof string !== "string") { return ""; @@ -557,31 +557,31 @@ Module.register("calendar", { }, /* capFirst(string) -* Capitalize the first letter of a string -* Return capitalized string -*/ + * Capitalize the first letter of a string + * Return capitalized string + */ capFirst: function (string) { return string.charAt(0).toUpperCase() + string.slice(1); }, /* titleTransform(title) -* Transforms the title of an event for usage. -* Replaces parts of the text as defined in config.titleReplace. -* Shortens title based on config.maxTitleLength and config.wrapEvents -* -* argument title string - The title to transform. -* -* return string - The transformed title. -*/ + * Transforms the title of an event for usage. + * Replaces parts of the text as defined in config.titleReplace. + * Shortens title based on config.maxTitleLength and config.wrapEvents + * + * argument title string - The title to transform. + * + * return string - The transformed title. + */ titleTransform: function (title) { for (var needle in this.config.titleReplace) { var replacement = this.config.titleReplace[needle]; var regParts = needle.match(/^\/(.+)\/([gim]*)$/); if (regParts) { - // the parsed pattern is a regexp. - needle = new RegExp(regParts[1], regParts[2]); + // the parsed pattern is a regexp. + needle = new RegExp(regParts[1], regParts[2]); } title = title.replace(needle, replacement); @@ -592,9 +592,9 @@ Module.register("calendar", { }, /* broadcastEvents() -* Broadcasts the events to all other modules for reuse. -* The all events available in one array, sorted on startdate. -*/ + * Broadcasts the events to all other modules for reuse. + * The all events available in one array, sorted on startdate. + */ broadcastEvents: function () { var eventList = []; for (var url in this.calendarData) { @@ -608,7 +608,7 @@ Module.register("calendar", { } } - eventList.sort(function (a, b) { + eventList.sort(function(a,b) { return a.startDate - b.startDate; }); diff --git a/modules/default/weatherforecast/weatherforecast.js b/modules/default/weatherforecast/weatherforecast.js index 957b2e40..c16759ef 100644 --- a/modules/default/weatherforecast/weatherforecast.js +++ b/modules/default/weatherforecast/weatherforecast.js @@ -1,15 +1,15 @@ /* global Module */ /* Magic Mirror -* Module: WeatherForecast -* -* By Michael Teeuw http://michaelteeuw.nl -* MIT Licensed. -*/ + * Module: WeatherForecast + * + * By Michael Teeuw http://michaelteeuw.nl + * MIT Licensed. + */ Module.register("weatherforecast",{ -// Default module config. + // Default module config. defaults: { location: false, locationID: false, @@ -236,9 +236,9 @@ Module.register("weatherforecast",{ }, /* updateWeather(compliments) -* Requests new data from openweather.org. -* Calls processWeather on succesfull response. -*/ + * Requests new data from openweather.org. + * Calls processWeather on succesfull response. + */ updateWeather: function() { if (this.config.appid === "") { Log.error("WeatherForecast: APPID not set!"); @@ -277,10 +277,10 @@ Module.register("weatherforecast",{ }, /* getParams(compliments) -* Generates an url with api parameters based on the config. -* -* return String - URL params. -*/ + * Generates an url with api parameters based on the config. + * + * return String - URL params. + */ getParams: function() { var params = "?"; if(this.config.locationID) { @@ -304,12 +304,12 @@ Module.register("weatherforecast",{ }, /* -* parserDataWeather(data) -* -* Use the parse to keep the same struct between daily and forecast Endpoint -* from Openweather -* -*/ + * parserDataWeather(data) + * + * Use the parse to keep the same struct between daily and forecast Endpoint + * from Openweather + * + */ parserDataWeather: function(data) { if (data.hasOwnProperty("main")) { data["temp"] = {"min": data.main.temp_min, "max": data.main.temp_max} @@ -318,10 +318,10 @@ Module.register("weatherforecast",{ }, /* processWeather(data) -* Uses the received data to set the various values. -* -* argument data object - Weather information received form openweather.org. -*/ + * Uses the received data to set the various values. + * + * argument data object - Weather information received form openweather.org. + */ processWeather: function(data) { this.fetchedLocationName = data.city.name + ", " + data.city.country; @@ -374,10 +374,10 @@ Module.register("weatherforecast",{ }, /* scheduleUpdate() -* Schedule next update. -* -* argument delay number - Milliseconds before next update. If empty, this.config.updateInterval is used. -*/ + * Schedule next update. + * + * argument delay number - Milliseconds before next update. If empty, this.config.updateInterval is used. + */ scheduleUpdate: function(delay) { var nextLoad = this.config.updateInterval; if (typeof delay !== "undefined" && delay >= 0) { @@ -392,16 +392,16 @@ Module.register("weatherforecast",{ }, /* ms2Beaufort(ms) -* Converts m2 to beaufort (windspeed). -* -* see: -* http://www.spc.noaa.gov/faq/tornado/beaufort.html -* https://en.wikipedia.org/wiki/Beaufort_scale#Modern_scale -* -* argument ms number - Windspeed in m/s. -* -* return number - Windspeed in beaufort. -*/ + * Converts m2 to beaufort (windspeed). + * + * see: + * http://www.spc.noaa.gov/faq/tornado/beaufort.html + * https://en.wikipedia.org/wiki/Beaufort_scale#Modern_scale + * + * argument ms number - Windspeed in m/s. + * + * return number - Windspeed in beaufort. + */ ms2Beaufort: function(ms) { var kmh = ms * 60 * 60 / 1000; var speeds = [1, 5, 11, 19, 28, 38, 49, 61, 74, 88, 102, 117, 1000]; @@ -415,12 +415,12 @@ Module.register("weatherforecast",{ }, /* function(temperature) -* Rounds a temperature to 1 decimal or integer (depending on config.roundTemp). -* -* argument temperature number - Temperature. -* -* return string - Rounded Temperature. -*/ + * Rounds a temperature to 1 decimal or integer (depending on config.roundTemp). + * + * argument temperature number - Temperature. + * + * return string - Rounded Temperature. + */ roundValue: function(temperature) { var decimals = this.config.roundTemp ? 0 : 1; return parseFloat(temperature).toFixed(decimals);