Cleanup calendar jsdoc

This commit is contained in:
rejas 2020-07-30 12:54:39 +02:00
parent 90cca28e01
commit 8ce1e2c956

View File

@ -416,7 +416,7 @@ Module.register("calendar", {
* 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} formatted time
*/ */
getLocaleSpecification: function (timeFormat) { getLocaleSpecification: function (timeFormat) {
switch (timeFormat) { switch (timeFormat) {
@ -432,12 +432,11 @@ Module.register("calendar", {
} }
}, },
/* hasCalendarURL(url) /**
* Check if this config contains the calendar url. * Checks if this config contains the calendar url.
* *
* argument url string - Url to look for. * @param {string} url The calendar url
* * @returns {boolean} True if the calendar config contains the url, False otherwise
* 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) {
@ -450,10 +449,10 @@ Module.register("calendar", {
return false; return false;
}, },
/* createEventList() /**
* Creates the sorted list of all events. * Creates the sorted list of all events.
* *
* return array - Array with events. * @returns {*[]} Array with events.
*/ */
createEventList: function () { createEventList: function () {
var events = []; var events = [];
@ -535,10 +534,17 @@ Module.register("calendar", {
}, },
/* createEventList(url) /* createEventList(url)
* Requests node helper to add calendar url.
* *
* argument url string - Url to add. * argument url string - Url to add.
*/ */
/**
* Requests node helper to add calendar url.
*
* @param {string} url The calendar url to add
* @param {object} auth The authentication method and credentials
* @param {object} calendarConfig The config of the specific calendar
*/
addCalendar: function (url, auth, calendarConfig) { addCalendar: function (url, auth, calendarConfig) {
this.sendSocketNotification("ADD_CALENDAR", { this.sendSocketNotification("ADD_CALENDAR", {
id: this.identifier, id: this.identifier,
@ -559,8 +565,7 @@ Module.register("calendar", {
* Retrieves the symbols for a specific event. * Retrieves the symbols for a specific event.
* *
* @param {object} event Event to look for. * @param {object} event Event to look for.
* * @returns {string[]} The symbols
* @returns {*} array The Symbols
*/ */
symbolsForEvent: function (event) { symbolsForEvent: function (event) {
let symbols = this.getCalendarPropertyAsArray(event.url, "symbol", this.config.defaultSymbol); let symbols = this.getCalendarPropertyAsArray(event.url, "symbol", this.config.defaultSymbol);
@ -585,82 +590,72 @@ Module.register("calendar", {
}, },
/** /**
* symbolClassForUrl(url) * Retrieves the symbolClass for a specific calendar url.
* Retrieves the symbolClass for a specific url.
* *
* @param url string - Url to look for. * @param {string} url The calendar url
* * @returns {string} The class to be used for the symbols of the calendar
* @returns string
*/ */
symbolClassForUrl: function (url) { symbolClassForUrl: function (url) {
return this.getCalendarProperty(url, "symbolClass", ""); return this.getCalendarProperty(url, "symbolClass", "");
}, },
/** /**
* titleClassForUrl(url) * Retrieves the titleClass for a specific calendar url.
* Retrieves the titleClass for a specific url.
* *
* @param url string - Url to look for. * @param {string} url The calendar url
* * @returns {string} The class to be used for the title of the calendar
* @returns string
*/ */
titleClassForUrl: function (url) { titleClassForUrl: function (url) {
return this.getCalendarProperty(url, "titleClass", ""); return this.getCalendarProperty(url, "titleClass", "");
}, },
/** /**
* timeClassForUrl(url) * Retrieves the timeClass for a specific calendar url.
* Retrieves the timeClass for a specific url.
* *
* @param url string - Url to look for. * @param {string} url The calendar url
* * @returns {string} The class to be used for the time of the calendar
* @returns string
*/ */
timeClassForUrl: function (url) { timeClassForUrl: function (url) {
return this.getCalendarProperty(url, "timeClass", ""); return this.getCalendarProperty(url, "timeClass", "");
}, },
/* calendarNameForUrl(url) /**
* Retrieves the calendar name for a specific url. * Retrieves the calendar name for a specific calendar url.
* *
* argument url string - Url to look for. * @param {string} url The calendar url
* * @returns {string} The name of the calendar
* return string - The name of the calendar
*/ */
calendarNameForUrl: function (url) { calendarNameForUrl: function (url) {
return this.getCalendarProperty(url, "name", ""); return this.getCalendarProperty(url, "name", "");
}, },
/* colorForUrl(url) /**
* Retrieves the color for a specific url. * Retrieves the color for a specific calendar url.
* *
* argument url string - Url to look for. * @param {string} url The calendar url
* * @returns {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) /**
* Retrieves the name for a specific url. * Retrieves the count title for a specific calendar url.
* *
* argument url string - Url to look for. * @param {string} url The calendar url
* * @returns {string} The title
* 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) /**
* Helper method to retrieve the property for a specific url. * Helper method to retrieve the property for a specific calendar url.
* *
* argument url string - Url to look for. * @param {string} url The calendar url
* argument property string - Property to look for. * @param {string} property The property to look for
* argument defaultValue string - Value if property is not found. * @param {string} defaultValue The value if the property is not found
* * @returns {*} 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) {
@ -736,22 +731,27 @@ Module.register("calendar", {
} }
}, },
/* capFirst(string) /**
* Capitalize the first letter of a string * Capitalize the first letter of a string
* Return capitalized string *
* @param {string} string The string to capitalize
* @returns {string} The 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) /**
* 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. * @param {string} title The title to transform.
* * @param {object} titleReplace Pairs of strings to be replaced in the title
* return string - The transformed title. * @param {boolean} wrapEvents Wrap the text after the line has reached maxLength
* @param {number} maxTitleLength The max length of the string
* @param {number} maxTitleLines The max number of vertical lines before cutting event title
* @returns {string} The transformed title.
*/ */
titleTransform: function (title, titleReplace, wrapEvents, maxTitleLength, maxTitleLines) { titleTransform: function (title, titleReplace, wrapEvents, maxTitleLength, maxTitleLines) {
for (var needle in titleReplace) { for (var needle in titleReplace) {
@ -770,7 +770,7 @@ Module.register("calendar", {
return title; return title;
}, },
/* 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.
*/ */