From f3bdddfaa928c2392bd022fea4cfd75aa2bd15e9 Mon Sep 17 00:00:00 2001 From: rejas Date: Tue, 16 Mar 2021 22:46:19 +0100 Subject: [PATCH] Final es6 notation stuff --- modules/default/newsfeed/newsfeed.js | 42 +++++++++++++--------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/modules/default/newsfeed/newsfeed.js b/modules/default/newsfeed/newsfeed.js index 5c97f47e..441984f4 100644 --- a/modules/default/newsfeed/newsfeed.js +++ b/modules/default/newsfeed/newsfeed.js @@ -196,18 +196,18 @@ Module.register("newsfeed", { newsItems.forEach((item) => { //Remove selected tags from the beginning of rss feed items (title or description) if (this.config.removeStartTags === "title" || this.config.removeStartTags === "both") { - for (let f = 0; f < this.config.startTags.length; f++) { - if (item.title.slice(0, this.config.startTags[f].length) === this.config.startTags[f]) { - item.title = item.title.slice(this.config.startTags[f].length, item.title.length); + for (let startTag of this.config.startTags) { + if (item.title.slice(0, startTag.length) === startTag) { + item.title = item.title.slice(startTag.length, item.title.length); } } } if (this.config.removeStartTags === "description" || this.config.removeStartTags === "both") { if (this.isShowingDescription) { - for (let f = 0; f < this.config.startTags.length; f++) { - if (item.description.slice(0, this.config.startTags[f].length) === this.config.startTags[f]) { - item.description = item.description.slice(this.config.startTags[f].length, item.description.length); + for (let startTag of this.config.startTags) { + if (item.description.slice(0, startTag.length) === startTag) { + item.description = item.description.slice(startTag.length, item.description.length); } } } @@ -216,16 +216,16 @@ Module.register("newsfeed", { //Remove selected tags from the end of rss feed items (title or description) if (this.config.removeEndTags) { - for (let f = 0; f < this.config.endTags.length; f++) { - if (item.title.slice(-this.config.endTags[f].length) === this.config.endTags[f]) { - item.title = item.title.slice(0, -this.config.endTags[f].length); + for (let endTag of this.config.endTags) { + if (item.title.slice(-endTag.length) === endTag) { + item.title = item.title.slice(0, -endTag.length); } } if (this.isShowingDescription) { - for (let f = 0; f < this.config.endTags.length; f++) { - if (item.description.slice(-this.config.endTags[f].length) === this.config.endTags[f]) { - item.description = item.description.slice(0, -this.config.endTags[f].length); + for (let endTag of this.config.endTags) { + if (item.description.slice(-endTag.length) === endTag) { + item.description = item.description.slice(0, -endTag.length); } } } @@ -283,22 +283,20 @@ Module.register("newsfeed", { * Schedule visual update. */ scheduleUpdateInterval: function () { - var self = this; - - self.updateDom(self.config.animationSpeed); + this.updateDom(this.config.animationSpeed); // Broadcast NewsFeed if needed - if (self.config.broadcastNewsFeeds) { - self.sendNotification("NEWS_FEED", { items: self.newsItems }); + if (this.config.broadcastNewsFeeds) { + this.sendNotification("NEWS_FEED", { items: this.newsItems }); } - this.timer = setInterval(function () { - self.activeItem++; - self.updateDom(self.config.animationSpeed); + this.timer = setInterval(() => { + this.activeItem++; + this.updateDom(this.config.animationSpeed); // Broadcast NewsFeed if needed - if (self.config.broadcastNewsFeeds) { - self.sendNotification("NEWS_FEED", { items: self.newsItems }); + if (this.config.broadcastNewsFeeds) { + this.sendNotification("NEWS_FEED", { items: this.newsItems }); } }, this.config.updateInterval); },