mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 19:53:36 +00:00
Tabs and spaces from the original files
With a diff, here the orginal tabulations.
This commit is contained in:
parent
09abdc0f12
commit
afd829307d
@ -1,15 +1,15 @@
|
|||||||
/* global Module */
|
/* global Module */
|
||||||
|
|
||||||
/* Magic Mirror
|
/* Magic Mirror
|
||||||
* Module: Calendar
|
* Module: Calendar
|
||||||
*
|
*
|
||||||
* By Michael Teeuw http://michaelteeuw.nl
|
* By Michael Teeuw http://michaelteeuw.nl
|
||||||
* MIT Licensed.
|
* MIT Licensed.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Module.register("calendar", {
|
Module.register("calendar", {
|
||||||
|
|
||||||
// Define module defaults
|
// Define module defaults
|
||||||
defaults: {
|
defaults: {
|
||||||
maximumEntries: 10, // Total Maximum Entries
|
maximumEntries: 10, // Total Maximum Entries
|
||||||
maximumNumberOfDays: 365,
|
maximumNumberOfDays: 365,
|
||||||
@ -82,7 +82,7 @@ Module.register("calendar", {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// we check user and password here for backwards compatibility with old configs
|
// 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("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");
|
Log.warn("https://github.com/MichMich/MagicMirror/tree/v2.1.2/modules/default/calendar#calendar-authentication-options");
|
||||||
calendar.auth = {
|
calendar.auth = {
|
||||||
@ -138,8 +138,8 @@ Module.register("calendar", {
|
|||||||
for (var e in events) {
|
for (var e in events) {
|
||||||
var event = events[e];
|
var event = events[e];
|
||||||
var dateAsString = moment(event.startDate, "x").format(this.config.dateFormat);
|
var dateAsString = moment(event.startDate, "x").format(this.config.dateFormat);
|
||||||
if (this.config.timeFormat === "dateheaders") {
|
if(this.config.timeFormat === "dateheaders"){
|
||||||
if (lastSeenDate !== dateAsString) {
|
if(lastSeenDate !== dateAsString){
|
||||||
var dateRow = document.createElement("tr");
|
var dateRow = document.createElement("tr");
|
||||||
dateRow.className = "normal"
|
dateRow.className = "normal"
|
||||||
var dateCell = document.createElement("td");
|
var dateCell = document.createElement("td");
|
||||||
@ -172,20 +172,20 @@ Module.register("calendar", {
|
|||||||
|
|
||||||
symbolWrapper.className = "symbol align-right";
|
symbolWrapper.className = "symbol align-right";
|
||||||
var symbols = this.symbolsForUrl(event.url);
|
var symbols = this.symbolsForUrl(event.url);
|
||||||
if (typeof symbols === "string") {
|
if(typeof symbols === "string") {
|
||||||
symbols = [symbols];
|
symbols = [symbols];
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var i = 0; i < symbols.length; i++) {
|
for(var i = 0; i < symbols.length; i++) {
|
||||||
var symbol = document.createElement("span");
|
var symbol = document.createElement("span");
|
||||||
symbol.className = "fa fa-fw fa-" + symbols[i];
|
symbol.className = "fa fa-fw fa-" + symbols[i];
|
||||||
if (i > 0) {
|
if(i > 0){
|
||||||
symbol.style.paddingLeft = "5px";
|
symbol.style.paddingLeft = "5px";
|
||||||
}
|
}
|
||||||
symbolWrapper.appendChild(symbol);
|
symbolWrapper.appendChild(symbol);
|
||||||
}
|
}
|
||||||
eventWrapper.appendChild(symbolWrapper);
|
eventWrapper.appendChild(symbolWrapper);
|
||||||
} else if (this.config.timeFormat === "dateheaders") {
|
}else if(this.config.timeFormat === "dateheaders"){
|
||||||
var blankCell = document.createElement("td");
|
var blankCell = document.createElement("td");
|
||||||
blankCell.innerHTML = " "
|
blankCell.innerHTML = " "
|
||||||
eventWrapper.appendChild(blankCell);
|
eventWrapper.appendChild(blankCell);
|
||||||
@ -214,13 +214,13 @@ Module.register("calendar", {
|
|||||||
titleWrapper.className = "title";
|
titleWrapper.className = "title";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.config.timeFormat === "dateheaders") {
|
if(this.config.timeFormat === "dateheaders"){
|
||||||
|
|
||||||
if (event.fullDayEvent) {
|
if (event.fullDayEvent) {
|
||||||
titleWrapper.colSpan = "2";
|
titleWrapper.colSpan = "2";
|
||||||
titleWrapper.align = "left";
|
titleWrapper.align = "left";
|
||||||
|
|
||||||
} else {
|
}else{
|
||||||
var timeWrapper = document.createElement("td");
|
var timeWrapper = document.createElement("td");
|
||||||
timeWrapper.className = "time light";
|
timeWrapper.className = "time light";
|
||||||
timeWrapper.align = "left";
|
timeWrapper.align = "left";
|
||||||
@ -246,7 +246,7 @@ Module.register("calendar", {
|
|||||||
}
|
}
|
||||||
|
|
||||||
eventWrapper.appendChild(titleWrapper);
|
eventWrapper.appendChild(titleWrapper);
|
||||||
} else {
|
}else{
|
||||||
var timeWrapper = document.createElement("td");
|
var timeWrapper = document.createElement("td");
|
||||||
|
|
||||||
eventWrapper.appendChild(titleWrapper);
|
eventWrapper.appendChild(titleWrapper);
|
||||||
@ -270,12 +270,12 @@ Module.register("calendar", {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Check to see if the user displays absolute or relative dates with their events
|
/* 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
|
* 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
|
* 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()
|
* 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
|
* 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.timeFormat === "absolute") {
|
||||||
if ((this.config.urgency > 1) && (event.startDate - now < (this.config.urgency * oneDay))) {
|
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
|
// This event falls within the config.urgency period that the user has set
|
||||||
@ -300,12 +300,12 @@ Module.register("calendar", {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Check to see if the user displays absolute or relative dates with their events
|
/* 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
|
* 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
|
* 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()
|
* 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
|
* 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.timeFormat === "absolute") {
|
||||||
if ((this.config.urgency > 1) && (event.startDate - now < (this.config.urgency * oneDay))) {
|
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
|
// 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
|
* 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)
|
* 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.
|
* it will a localeSpecification object with the system locale time format.
|
||||||
*
|
*
|
||||||
* @param {number} timeFormat Specifies either 12 or 24 hour time format
|
* @param {number} timeFormat Specifies either 12 or 24 hour time format
|
||||||
* @returns {moment.LocaleSpecification}
|
* @returns {moment.LocaleSpecification}
|
||||||
*/
|
*/
|
||||||
getLocaleSpecification: function (timeFormat) {
|
getLocaleSpecification: function(timeFormat) {
|
||||||
switch (timeFormat) {
|
switch (timeFormat) {
|
||||||
case 12: {
|
case 12: {
|
||||||
return {longDateFormat: {LT: "h:mm A"}};
|
return { longDateFormat: {LT: "h:mm A"} };
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 24: {
|
case 24: {
|
||||||
return {longDateFormat: {LT: "HH:mm"}};
|
return { longDateFormat: {LT: "HH:mm"} };
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
return {longDateFormat: {LT: moment.localeData().longDateFormat("LT")}};
|
return { longDateFormat: {LT: moment.localeData().longDateFormat("LT")} };
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/* hasCalendarURL(url)
|
/* hasCalendarURL(url)
|
||||||
* Check if this config contains the calendar url.
|
* Check if this config contains the calendar url.
|
||||||
*
|
*
|
||||||
* argument url string - Url to look for.
|
* argument url string - Url to look for.
|
||||||
*
|
*
|
||||||
* return bool - Has calendar url
|
* return bool - Has calendar url
|
||||||
*/
|
*/
|
||||||
hasCalendarURL: function (url) {
|
hasCalendarURL: function (url) {
|
||||||
for (var c in this.config.calendars) {
|
for (var c in this.config.calendars) {
|
||||||
var calendar = this.config.calendars[c];
|
var calendar = this.config.calendars[c];
|
||||||
@ -395,10 +395,10 @@ Module.register("calendar", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
/* createEventList()
|
/* createEventList()
|
||||||
* Creates the sorted list of all events.
|
* Creates the sorted list of all events.
|
||||||
*
|
*
|
||||||
* return array - Array with events.
|
* return array - Array with events.
|
||||||
*/
|
*/
|
||||||
createEventList: function () {
|
createEventList: function () {
|
||||||
var events = [];
|
var events = [];
|
||||||
var today = moment().startOf("day");
|
var today = moment().startOf("day");
|
||||||
@ -407,18 +407,18 @@ Module.register("calendar", {
|
|||||||
var calendar = this.calendarData[c];
|
var calendar = this.calendarData[c];
|
||||||
for (var e in calendar) {
|
for (var e in calendar) {
|
||||||
var event = calendar[e];
|
var event = calendar[e];
|
||||||
if (this.config.hidePrivate) {
|
if(this.config.hidePrivate) {
|
||||||
if (event.class === "PRIVATE") {
|
if(event.class === "PRIVATE") {
|
||||||
// do not add the current event, skip it
|
// do not add the current event, skip it
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(this.config.hideOngoing) {
|
||||||
|
if(event.startDate < now) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.config.hideOngoing) {
|
if(this.listContainsEvent(events,event)){
|
||||||
if (event.startDate < now) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (this.listContainsEvent(events, event)) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
event.url = c;
|
event.url = c;
|
||||||
@ -435,9 +435,9 @@ Module.register("calendar", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
listContainsEvent: function (eventList, event) {
|
listContainsEvent: function(eventList, event){
|
||||||
for (let evt of eventList) {
|
for(let evt of eventList){
|
||||||
if (evt.title === event.title && parseInt(evt.startDate) === parseInt(event.startDate)) {
|
if(evt.title === event.title && parseInt(evt.startDate) === parseInt(event.startDate)){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -446,10 +446,10 @@ Module.register("calendar", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
/* createEventList(url)
|
/* createEventList(url)
|
||||||
* Requests node helper to add calendar url.
|
* Requests node helper to add calendar url.
|
||||||
*
|
*
|
||||||
* argument url string - Url to add.
|
* argument url string - Url to add.
|
||||||
*/
|
*/
|
||||||
addCalendar: function (url, auth, calendarConfig) {
|
addCalendar: function (url, auth, calendarConfig) {
|
||||||
this.sendSocketNotification("ADD_CALENDAR", {
|
this.sendSocketNotification("ADD_CALENDAR", {
|
||||||
url: url,
|
url: url,
|
||||||
@ -462,47 +462,47 @@ Module.register("calendar", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
/* symbolsForUrl(url)
|
/* symbolsForUrl(url)
|
||||||
* Retrieves the symbols for a specific url.
|
* Retrieves the symbols for a specific url.
|
||||||
*
|
*
|
||||||
* argument url string - Url to look for.
|
* argument url string - Url to look for.
|
||||||
*
|
*
|
||||||
* return string/array - The Symbols
|
* return string/array - The Symbols
|
||||||
*/
|
*/
|
||||||
symbolsForUrl: function (url) {
|
symbolsForUrl: function (url) {
|
||||||
return this.getCalendarProperty(url, "symbol", this.config.defaultSymbol);
|
return this.getCalendarProperty(url, "symbol", this.config.defaultSymbol);
|
||||||
},
|
},
|
||||||
|
|
||||||
/* colorForUrl(url)
|
/* colorForUrl(url)
|
||||||
* Retrieves the color for a specific url.
|
* Retrieves the color for a specific url.
|
||||||
*
|
*
|
||||||
* argument url string - Url to look for.
|
* argument url string - Url to look for.
|
||||||
*
|
*
|
||||||
* return string - The Color
|
* return string - The Color
|
||||||
*/
|
*/
|
||||||
colorForUrl: function (url) {
|
colorForUrl: function (url) {
|
||||||
return this.getCalendarProperty(url, "color", "#fff");
|
return this.getCalendarProperty(url, "color", "#fff");
|
||||||
},
|
},
|
||||||
|
|
||||||
/* countTitleForUrl(url)
|
/* countTitleForUrl(url)
|
||||||
* Retrieves the name for a specific url.
|
* Retrieves the name for a specific url.
|
||||||
*
|
*
|
||||||
* argument url string - Url to look for.
|
* argument url string - Url to look for.
|
||||||
*
|
*
|
||||||
* return string - The Symbol
|
* return string - The Symbol
|
||||||
*/
|
*/
|
||||||
countTitleForUrl: function (url) {
|
countTitleForUrl: function (url) {
|
||||||
return this.getCalendarProperty(url, "repeatingCountTitle", this.config.defaultRepeatingCountTitle);
|
return this.getCalendarProperty(url, "repeatingCountTitle", this.config.defaultRepeatingCountTitle);
|
||||||
},
|
},
|
||||||
|
|
||||||
/* getCalendarProperty(url, property, defaultValue)
|
/* getCalendarProperty(url, property, defaultValue)
|
||||||
* Helper method to retrieve the property for a specific url.
|
* Helper method to retrieve the property for a specific url.
|
||||||
*
|
*
|
||||||
* argument url string - Url to look for.
|
* argument url string - Url to look for.
|
||||||
* argument property string - Property to look for.
|
* argument property string - Property to look for.
|
||||||
* argument defaultValue string - Value if property is not found.
|
* argument defaultValue string - Value if property is not found.
|
||||||
*
|
*
|
||||||
* return string - The Property
|
* return string - The Property
|
||||||
*/
|
*/
|
||||||
getCalendarProperty: function (url, property, defaultValue) {
|
getCalendarProperty: function (url, property, defaultValue) {
|
||||||
for (var c in this.config.calendars) {
|
for (var c in this.config.calendars) {
|
||||||
var calendar = this.config.calendars[c];
|
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
|
* Shortens a string if it's longer than maxLength and add a ellipsis to the end
|
||||||
*
|
*
|
||||||
* @param {string} string Text string to shorten
|
* @param {string} string Text string to shorten
|
||||||
* @param {number} maxLength The max length of the string
|
* @param {number} maxLength The max length of the string
|
||||||
* @param {boolean} wrapEvents Wrap the text after the line has reached maxLength
|
* @param {boolean} wrapEvents Wrap the text after the line has reached maxLength
|
||||||
* @returns {string} The shortened string
|
* @returns {string} The shortened string
|
||||||
*/
|
*/
|
||||||
shorten: function (string, maxLength, wrapEvents) {
|
shorten: function (string, maxLength, wrapEvents) {
|
||||||
if (typeof string !== "string") {
|
if (typeof string !== "string") {
|
||||||
return "";
|
return "";
|
||||||
@ -557,31 +557,31 @@ Module.register("calendar", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
/* capFirst(string)
|
/* capFirst(string)
|
||||||
* Capitalize the first letter of a string
|
* Capitalize the first letter of a string
|
||||||
* Return capitalized string
|
* Return capitalized string
|
||||||
*/
|
*/
|
||||||
|
|
||||||
capFirst: function (string) {
|
capFirst: function (string) {
|
||||||
return string.charAt(0).toUpperCase() + string.slice(1);
|
return string.charAt(0).toUpperCase() + string.slice(1);
|
||||||
},
|
},
|
||||||
|
|
||||||
/* titleTransform(title)
|
/* titleTransform(title)
|
||||||
* Transforms the title of an event for usage.
|
* Transforms the title of an event for usage.
|
||||||
* Replaces parts of the text as defined in config.titleReplace.
|
* Replaces parts of the text as defined in config.titleReplace.
|
||||||
* Shortens title based on config.maxTitleLength and config.wrapEvents
|
* Shortens title based on config.maxTitleLength and config.wrapEvents
|
||||||
*
|
*
|
||||||
* argument title string - The title to transform.
|
* argument title string - The title to transform.
|
||||||
*
|
*
|
||||||
* return string - The transformed title.
|
* return string - The transformed title.
|
||||||
*/
|
*/
|
||||||
titleTransform: function (title) {
|
titleTransform: function (title) {
|
||||||
for (var needle in this.config.titleReplace) {
|
for (var needle in this.config.titleReplace) {
|
||||||
var replacement = this.config.titleReplace[needle];
|
var replacement = this.config.titleReplace[needle];
|
||||||
|
|
||||||
var regParts = needle.match(/^\/(.+)\/([gim]*)$/);
|
var regParts = needle.match(/^\/(.+)\/([gim]*)$/);
|
||||||
if (regParts) {
|
if (regParts) {
|
||||||
// the parsed pattern is a regexp.
|
// the parsed pattern is a regexp.
|
||||||
needle = new RegExp(regParts[1], regParts[2]);
|
needle = new RegExp(regParts[1], regParts[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
title = title.replace(needle, replacement);
|
title = title.replace(needle, replacement);
|
||||||
@ -592,9 +592,9 @@ Module.register("calendar", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
/* broadcastEvents()
|
/* broadcastEvents()
|
||||||
* Broadcasts the events to all other modules for reuse.
|
* Broadcasts the events to all other modules for reuse.
|
||||||
* The all events available in one array, sorted on startdate.
|
* The all events available in one array, sorted on startdate.
|
||||||
*/
|
*/
|
||||||
broadcastEvents: function () {
|
broadcastEvents: function () {
|
||||||
var eventList = [];
|
var eventList = [];
|
||||||
for (var url in this.calendarData) {
|
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;
|
return a.startDate - b.startDate;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
/* global Module */
|
/* global Module */
|
||||||
|
|
||||||
/* Magic Mirror
|
/* Magic Mirror
|
||||||
* Module: WeatherForecast
|
* Module: WeatherForecast
|
||||||
*
|
*
|
||||||
* By Michael Teeuw http://michaelteeuw.nl
|
* By Michael Teeuw http://michaelteeuw.nl
|
||||||
* MIT Licensed.
|
* MIT Licensed.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Module.register("weatherforecast",{
|
Module.register("weatherforecast",{
|
||||||
|
|
||||||
// Default module config.
|
// Default module config.
|
||||||
defaults: {
|
defaults: {
|
||||||
location: false,
|
location: false,
|
||||||
locationID: false,
|
locationID: false,
|
||||||
@ -236,9 +236,9 @@ Module.register("weatherforecast",{
|
|||||||
},
|
},
|
||||||
|
|
||||||
/* updateWeather(compliments)
|
/* updateWeather(compliments)
|
||||||
* Requests new data from openweather.org.
|
* Requests new data from openweather.org.
|
||||||
* Calls processWeather on succesfull response.
|
* Calls processWeather on succesfull response.
|
||||||
*/
|
*/
|
||||||
updateWeather: function() {
|
updateWeather: function() {
|
||||||
if (this.config.appid === "") {
|
if (this.config.appid === "") {
|
||||||
Log.error("WeatherForecast: APPID not set!");
|
Log.error("WeatherForecast: APPID not set!");
|
||||||
@ -277,10 +277,10 @@ Module.register("weatherforecast",{
|
|||||||
},
|
},
|
||||||
|
|
||||||
/* getParams(compliments)
|
/* getParams(compliments)
|
||||||
* Generates an url with api parameters based on the config.
|
* Generates an url with api parameters based on the config.
|
||||||
*
|
*
|
||||||
* return String - URL params.
|
* return String - URL params.
|
||||||
*/
|
*/
|
||||||
getParams: function() {
|
getParams: function() {
|
||||||
var params = "?";
|
var params = "?";
|
||||||
if(this.config.locationID) {
|
if(this.config.locationID) {
|
||||||
@ -304,12 +304,12 @@ Module.register("weatherforecast",{
|
|||||||
},
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* parserDataWeather(data)
|
* parserDataWeather(data)
|
||||||
*
|
*
|
||||||
* Use the parse to keep the same struct between daily and forecast Endpoint
|
* Use the parse to keep the same struct between daily and forecast Endpoint
|
||||||
* from Openweather
|
* from Openweather
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
parserDataWeather: function(data) {
|
parserDataWeather: function(data) {
|
||||||
if (data.hasOwnProperty("main")) {
|
if (data.hasOwnProperty("main")) {
|
||||||
data["temp"] = {"min": data.main.temp_min, "max": data.main.temp_max}
|
data["temp"] = {"min": data.main.temp_min, "max": data.main.temp_max}
|
||||||
@ -318,10 +318,10 @@ Module.register("weatherforecast",{
|
|||||||
},
|
},
|
||||||
|
|
||||||
/* processWeather(data)
|
/* processWeather(data)
|
||||||
* Uses the received data to set the various values.
|
* Uses the received data to set the various values.
|
||||||
*
|
*
|
||||||
* argument data object - Weather information received form openweather.org.
|
* argument data object - Weather information received form openweather.org.
|
||||||
*/
|
*/
|
||||||
processWeather: function(data) {
|
processWeather: function(data) {
|
||||||
this.fetchedLocationName = data.city.name + ", " + data.city.country;
|
this.fetchedLocationName = data.city.name + ", " + data.city.country;
|
||||||
|
|
||||||
@ -374,10 +374,10 @@ Module.register("weatherforecast",{
|
|||||||
},
|
},
|
||||||
|
|
||||||
/* scheduleUpdate()
|
/* scheduleUpdate()
|
||||||
* Schedule next update.
|
* Schedule next update.
|
||||||
*
|
*
|
||||||
* argument delay number - Milliseconds before next update. If empty, this.config.updateInterval is used.
|
* argument delay number - Milliseconds before next update. If empty, this.config.updateInterval is used.
|
||||||
*/
|
*/
|
||||||
scheduleUpdate: function(delay) {
|
scheduleUpdate: function(delay) {
|
||||||
var nextLoad = this.config.updateInterval;
|
var nextLoad = this.config.updateInterval;
|
||||||
if (typeof delay !== "undefined" && delay >= 0) {
|
if (typeof delay !== "undefined" && delay >= 0) {
|
||||||
@ -392,16 +392,16 @@ Module.register("weatherforecast",{
|
|||||||
},
|
},
|
||||||
|
|
||||||
/* ms2Beaufort(ms)
|
/* ms2Beaufort(ms)
|
||||||
* Converts m2 to beaufort (windspeed).
|
* Converts m2 to beaufort (windspeed).
|
||||||
*
|
*
|
||||||
* see:
|
* see:
|
||||||
* http://www.spc.noaa.gov/faq/tornado/beaufort.html
|
* http://www.spc.noaa.gov/faq/tornado/beaufort.html
|
||||||
* https://en.wikipedia.org/wiki/Beaufort_scale#Modern_scale
|
* https://en.wikipedia.org/wiki/Beaufort_scale#Modern_scale
|
||||||
*
|
*
|
||||||
* argument ms number - Windspeed in m/s.
|
* argument ms number - Windspeed in m/s.
|
||||||
*
|
*
|
||||||
* return number - Windspeed in beaufort.
|
* return number - Windspeed in beaufort.
|
||||||
*/
|
*/
|
||||||
ms2Beaufort: function(ms) {
|
ms2Beaufort: function(ms) {
|
||||||
var kmh = ms * 60 * 60 / 1000;
|
var kmh = ms * 60 * 60 / 1000;
|
||||||
var speeds = [1, 5, 11, 19, 28, 38, 49, 61, 74, 88, 102, 117, 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)
|
/* function(temperature)
|
||||||
* Rounds a temperature to 1 decimal or integer (depending on config.roundTemp).
|
* Rounds a temperature to 1 decimal or integer (depending on config.roundTemp).
|
||||||
*
|
*
|
||||||
* argument temperature number - Temperature.
|
* argument temperature number - Temperature.
|
||||||
*
|
*
|
||||||
* return string - Rounded Temperature.
|
* return string - Rounded Temperature.
|
||||||
*/
|
*/
|
||||||
roundValue: function(temperature) {
|
roundValue: function(temperature) {
|
||||||
var decimals = this.config.roundTemp ? 0 : 1;
|
var decimals = this.config.roundTemp ? 0 : 1;
|
||||||
return parseFloat(temperature).toFixed(decimals);
|
return parseFloat(temperature).toFixed(decimals);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user