mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 11:50:00 +00:00
Cleanup newsfeed jsdoc
This commit is contained in:
parent
9f3806dabf
commit
3438a5a374
@ -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;
|
||||
},
|
||||
|
||||
/* registerFeeds()
|
||||
* registers the feeds to be used by the backend.
|
||||
/**
|
||||
* Registers the feeds to be used by the backend.
|
||||
*/
|
||||
registerFeeds: function () {
|
||||
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.
|
||||
*
|
||||
* 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) {
|
||||
var newsItems = [];
|
||||
@ -274,12 +274,11 @@ Module.register("newsfeed", {
|
||||
this.newsItems = newsItems;
|
||||
},
|
||||
|
||||
/* subscribedToFeed(feedUrl)
|
||||
/**
|
||||
* Check if this module is configured to show this feed.
|
||||
*
|
||||
* attribute feedUrl string - Url of the feed to check.
|
||||
*
|
||||
* returns bool
|
||||
* @param {string} feedUrl Url of the feed to check.
|
||||
* @returns {boolean} True if it is subscribed, false otherwise
|
||||
*/
|
||||
subscribedToFeed: function (feedUrl) {
|
||||
for (var f in this.config.feeds) {
|
||||
@ -291,12 +290,11 @@ Module.register("newsfeed", {
|
||||
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.
|
||||
*
|
||||
* returns string
|
||||
* @param {string} feedUrl Url of the feed
|
||||
* @returns {string} The title of the feed
|
||||
*/
|
||||
titleForFeed: function (feedUrl) {
|
||||
for (var f in this.config.feeds) {
|
||||
@ -308,7 +306,7 @@ Module.register("newsfeed", {
|
||||
return "";
|
||||
},
|
||||
|
||||
/* scheduleUpdateInterval()
|
||||
/**
|
||||
* Schedule visual update.
|
||||
*/
|
||||
scheduleUpdateInterval: function () {
|
||||
|
@ -9,12 +9,14 @@ const FeedMe = require("feedme");
|
||||
const request = require("request");
|
||||
const iconv = require("iconv-lite");
|
||||
|
||||
/* Fetcher
|
||||
/**
|
||||
* Responsible for requesting an update on the set interval and broadcasting the data.
|
||||
*
|
||||
* attribute url string - URL of the news feed.
|
||||
* attribute reloadInterval number - Reload interval in milliseconds.
|
||||
* attribute logFeedWarnings boolean - Log warnings when there is an error parsing a news article.
|
||||
* @param {string} url URL of the news feed.
|
||||
* @param {number} reloadInterval Reload interval in milliseconds.
|
||||
* @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 self = this;
|
||||
@ -31,7 +33,7 @@ const NewsfeedFetcher = function (url, reloadInterval, encoding, logFeedWarnings
|
||||
|
||||
/* private methods */
|
||||
|
||||
/* fetchNews()
|
||||
/**
|
||||
* Request the new items.
|
||||
*/
|
||||
const fetchNews = function () {
|
||||
@ -95,7 +97,7 @@ const NewsfeedFetcher = function (url, reloadInterval, encoding, logFeedWarnings
|
||||
.pipe(parser);
|
||||
};
|
||||
|
||||
/* scheduleTimer()
|
||||
/**
|
||||
* Schedule the timer for the next update.
|
||||
*/
|
||||
const scheduleTimer = function () {
|
||||
@ -107,10 +109,10 @@ const NewsfeedFetcher = function (url, reloadInterval, encoding, logFeedWarnings
|
||||
|
||||
/* public methods */
|
||||
|
||||
/* setReloadInterval()
|
||||
/**
|
||||
* 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) {
|
||||
if (interval > 1000 && interval < reloadInterval) {
|
||||
@ -118,14 +120,14 @@ const NewsfeedFetcher = function (url, reloadInterval, encoding, logFeedWarnings
|
||||
}
|
||||
};
|
||||
|
||||
/* startFetch()
|
||||
/**
|
||||
* Initiate fetchNews();
|
||||
*/
|
||||
this.startFetch = function () {
|
||||
fetchNews();
|
||||
};
|
||||
|
||||
/* broadcastItems()
|
||||
/**
|
||||
* Broadcast the existing items.
|
||||
*/
|
||||
this.broadcastItems = function () {
|
||||
|
@ -24,12 +24,12 @@ module.exports = NodeHelper.create({
|
||||
}
|
||||
},
|
||||
|
||||
/* createFetcher(feed, config)
|
||||
/**
|
||||
* Creates a fetcher for a new feed if it doesn't exist yet.
|
||||
* Otherwise it reuses the existing one.
|
||||
*
|
||||
* attribute feed object - A feed object.
|
||||
* attribute config object - A configuration object containing reload interval in milliseconds.
|
||||
* @param {object} feed The feed object.
|
||||
* @param {object} config The configuration object.
|
||||
*/
|
||||
createFetcher: function (feed, config) {
|
||||
const url = feed.url || "";
|
||||
@ -68,7 +68,7 @@ module.exports = NodeHelper.create({
|
||||
fetcher.startFetch();
|
||||
},
|
||||
|
||||
/* broadcastFeeds()
|
||||
/**
|
||||
* Creates an object with all feed items of the different registered feeds,
|
||||
* and broadcasts these using sendSocketNotification.
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user