Cleanup newsfeed jsdoc

This commit is contained in:
rejas 2020-08-03 11:36:29 +02:00
parent 9f3806dabf
commit 3438a5a374
3 changed files with 28 additions and 28 deletions

View File

@ -205,8 +205,8 @@ Module.register("newsfeed", {
return typeof this.newsItems[this.activeItem].url === "string" ? this.newsItems[this.activeItem].url : this.newsItems[this.activeItem].url.href; return typeof this.newsItems[this.activeItem].url === "string" ? this.newsItems[this.activeItem].url : this.newsItems[this.activeItem].url.href;
}, },
/* registerFeeds() /**
* registers the feeds to be used by the backend. * Registers the feeds to be used by the backend.
*/ */
registerFeeds: function () { registerFeeds: function () {
for (var f in this.config.feeds) { for (var f in this.config.feeds) {
@ -218,10 +218,10 @@ Module.register("newsfeed", {
} }
}, },
/* generateFeed() /**
* Generate an ordered list of items for this configured module. * Generate an ordered list of items for this configured module.
* *
* attribute feeds object - An object with feeds returned by the node helper. * @param {object} feeds An object with feeds returned by the node helper.
*/ */
generateFeed: function (feeds) { generateFeed: function (feeds) {
var newsItems = []; var newsItems = [];
@ -274,12 +274,11 @@ Module.register("newsfeed", {
this.newsItems = newsItems; this.newsItems = newsItems;
}, },
/* subscribedToFeed(feedUrl) /**
* Check if this module is configured to show this feed. * Check if this module is configured to show this feed.
* *
* attribute feedUrl string - Url of the feed to check. * @param {string} feedUrl Url of the feed to check.
* * @returns {boolean} True if it is subscribed, false otherwise
* returns bool
*/ */
subscribedToFeed: function (feedUrl) { subscribedToFeed: function (feedUrl) {
for (var f in this.config.feeds) { for (var f in this.config.feeds) {
@ -291,12 +290,11 @@ Module.register("newsfeed", {
return false; return false;
}, },
/* titleForFeed(feedUrl) /**
* Returns title for a specific feed Url. * Returns title for the specific feed url.
* *
* attribute feedUrl string - Url of the feed to check. * @param {string} feedUrl Url of the feed
* * @returns {string} The title of the feed
* returns string
*/ */
titleForFeed: function (feedUrl) { titleForFeed: function (feedUrl) {
for (var f in this.config.feeds) { for (var f in this.config.feeds) {
@ -308,7 +306,7 @@ Module.register("newsfeed", {
return ""; return "";
}, },
/* scheduleUpdateInterval() /**
* Schedule visual update. * Schedule visual update.
*/ */
scheduleUpdateInterval: function () { scheduleUpdateInterval: function () {

View File

@ -9,12 +9,14 @@ const FeedMe = require("feedme");
const request = require("request"); const request = require("request");
const iconv = require("iconv-lite"); const iconv = require("iconv-lite");
/* Fetcher /**
* Responsible for requesting an update on the set interval and broadcasting the data. * Responsible for requesting an update on the set interval and broadcasting the data.
* *
* attribute url string - URL of the news feed. * @param {string} url URL of the news feed.
* attribute reloadInterval number - Reload interval in milliseconds. * @param {number} reloadInterval Reload interval in milliseconds.
* attribute logFeedWarnings boolean - Log warnings when there is an error parsing a news article. * @param {string} encoding Encoding of the feed.
* @param {boolean} logFeedWarnings If true log warnings when there is an error parsing a news article.
* @class
*/ */
const NewsfeedFetcher = function (url, reloadInterval, encoding, logFeedWarnings) { const NewsfeedFetcher = function (url, reloadInterval, encoding, logFeedWarnings) {
const self = this; const self = this;
@ -31,7 +33,7 @@ const NewsfeedFetcher = function (url, reloadInterval, encoding, logFeedWarnings
/* private methods */ /* private methods */
/* fetchNews() /**
* Request the new items. * Request the new items.
*/ */
const fetchNews = function () { const fetchNews = function () {
@ -95,7 +97,7 @@ const NewsfeedFetcher = function (url, reloadInterval, encoding, logFeedWarnings
.pipe(parser); .pipe(parser);
}; };
/* scheduleTimer() /**
* Schedule the timer for the next update. * Schedule the timer for the next update.
*/ */
const scheduleTimer = function () { const scheduleTimer = function () {
@ -107,10 +109,10 @@ const NewsfeedFetcher = function (url, reloadInterval, encoding, logFeedWarnings
/* public methods */ /* public methods */
/* setReloadInterval() /**
* Update the reload interval, but only if we need to increase the speed. * Update the reload interval, but only if we need to increase the speed.
* *
* attribute interval number - Interval for the update in milliseconds. * @param {number} interval Interval for the update in milliseconds.
*/ */
this.setReloadInterval = function (interval) { this.setReloadInterval = function (interval) {
if (interval > 1000 && interval < reloadInterval) { if (interval > 1000 && interval < reloadInterval) {
@ -118,14 +120,14 @@ const NewsfeedFetcher = function (url, reloadInterval, encoding, logFeedWarnings
} }
}; };
/* startFetch() /**
* Initiate fetchNews(); * Initiate fetchNews();
*/ */
this.startFetch = function () { this.startFetch = function () {
fetchNews(); fetchNews();
}; };
/* broadcastItems() /**
* Broadcast the existing items. * Broadcast the existing items.
*/ */
this.broadcastItems = function () { this.broadcastItems = function () {

View File

@ -24,12 +24,12 @@ module.exports = NodeHelper.create({
} }
}, },
/* createFetcher(feed, config) /**
* Creates a fetcher for a new feed if it doesn't exist yet. * Creates a fetcher for a new feed if it doesn't exist yet.
* Otherwise it reuses the existing one. * Otherwise it reuses the existing one.
* *
* attribute feed object - A feed object. * @param {object} feed The feed object.
* attribute config object - A configuration object containing reload interval in milliseconds. * @param {object} config The configuration object.
*/ */
createFetcher: function (feed, config) { createFetcher: function (feed, config) {
const url = feed.url || ""; const url = feed.url || "";
@ -68,7 +68,7 @@ module.exports = NodeHelper.create({
fetcher.startFetch(); fetcher.startFetch();
}, },
/* broadcastFeeds() /**
* Creates an object with all feed items of the different registered feeds, * Creates an object with all feed items of the different registered feeds,
* and broadcasts these using sendSocketNotification. * and broadcasts these using sendSocketNotification.
*/ */