mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 11:50:00 +00:00
Allow for the removal of feed tags
User-specified feed tags in description and title can be removed
This commit is contained in:
parent
e720efabdc
commit
6f104f5056
@ -108,18 +108,35 @@ The following properties can be configured:
|
||||
<br><b>Default value:</b> <code>0</code>
|
||||
</td>
|
||||
</tr>
|
||||
removeStartTags: false,
|
||||
removeEndTags: false,
|
||||
startTags: [],
|
||||
endTags: []
|
||||
|
||||
|
||||
<tr>
|
||||
<td><code>showMore</code></td>
|
||||
<td>Remove "more..." tags from the end of the item description.<br>
|
||||
<br><b>Possible values:</b><code>true</code> or <code>false</code>
|
||||
<br><b>Default value:</b> <code>false</code>
|
||||
<td><code>removeStartTags</code></td>
|
||||
<td>Some newsfeeds feature tags at the <B>beginning</B> of their titles or descriptions, such as "[VIDEO]".
|
||||
This setting allows for the removal of specified tags from the beginning of an item's description and / or title.<br>
|
||||
<br><b>Possible values:</b><code>'none'</code>,<code>description</code>, <code>title</code>, <code>both</code>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>moreTag</code></td>
|
||||
<td>Specify the exact wording of the "more..." tag.<br>
|
||||
<br><b>Possible values:</b> 'YOUR_MORE_TAG_HERE'
|
||||
<br><b>Default value:</b> <code>'more'</code>
|
||||
<td><code>startTags</code></td>
|
||||
<td>List the tags you would like to have removed at the beginning of the feed item<br>
|
||||
<br><b>Possible values:</b> ['TAG'] or ['TAG1','TAG2',...]
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>removeEndTags</code></td>
|
||||
<td>Remove specified tags from the <B>end</B> of an item's description and / or title.<br>
|
||||
<br><b>Possible values:</b><code>description</code>, <code>title</code>, <code>both</code>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>endTags</code></td>
|
||||
<td>List the tags you would like to have removed at the end of the feed item<br>
|
||||
<br><b>Possible values:</b> ['TAG'] or ['TAG1','TAG2',...]
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
@ -25,8 +25,11 @@ Module.register("newsfeed",{
|
||||
updateInterval: 10 * 1000,
|
||||
animationSpeed: 2.5 * 1000,
|
||||
maxNewsItems: 0, // 0 for unlimited
|
||||
more: false,
|
||||
moreTag: 'more'
|
||||
removeStartTags: false,
|
||||
removeEndTags: false,
|
||||
startTags: [],
|
||||
endTags: []
|
||||
|
||||
},
|
||||
|
||||
// Define required scripts.
|
||||
@ -98,20 +101,50 @@ Module.register("newsfeed",{
|
||||
wrapper.appendChild(sourceAndTimestamp);
|
||||
}
|
||||
|
||||
//Remove selected tags from the beginning of rss feed items (title or description)
|
||||
|
||||
if (this.config.removeStartTags) {
|
||||
|
||||
for (f=0; f<this.config.startTags.length;f++) {
|
||||
if (this.newsItems[this.activeItem].title.slice(0,this.config.startTags[f].length) == this.config.startTags[f]) {
|
||||
this.newsItems[this.activeItem].title = this.newsItems[this.activeItem].title.slice(this.config.startTags[f].length,this.newsItems[this.activeItem].title.length);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.config.showDescription) {
|
||||
for (f=0; f<this.config.startTags.length;f++) {
|
||||
if (this.newsItems[this.activeItem].description.slice(0,this.config.startTags[f].length) == this.config.startTags[f]) {
|
||||
this.newsItems[this.activeItem].title = this.newsItems[this.activeItem].description.slice(this.config.startTags[f].length,this.newsItems[this.activeItem].description.length);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Remove selected tags from the end of rss feed items (title or description)
|
||||
|
||||
if (this.config.removeEndTags) {
|
||||
for (f=0; f<this.config.endTags.length;f++) {
|
||||
if (this.newsItems[this.activeItem].title.slice(-this.config.endTags[f].length)==this.config.endTags[f]) {
|
||||
this.newsItems[this.activeItem].title = this.newsItems[this.activeItem].title.slice(0,-this.config.endTags[f].length);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.config.showDescription) {
|
||||
for (f=0; f<this.config.endTags.length;f++) {
|
||||
if (this.newsItems[this.activeItem].description.slice(-this.config.endTags[f].length)==this.config.endTags[f]) {
|
||||
this.newsItems[this.activeItem].description = this.newsItems[this.activeItem].description.slice(0,-this.config.endTags[f].length);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var title = document.createElement("div");
|
||||
title.className = "bright medium light";
|
||||
title.innerHTML = this.newsItems[this.activeItem].title;
|
||||
wrapper.appendChild(title);
|
||||
|
||||
//Remove "more" tag from description of rss feeds
|
||||
|
||||
if (this.config.showMore) {
|
||||
if (this.newsItems[this.activeItem].description.slice(-this.config.moreTag.length)==this.config.moreTag) {
|
||||
this.newsItems[this.activeItem].description = this.newsItems[this.activeItem].description.slice(0,-this.config.moreTag.length);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (this.config.showDescription) {
|
||||
var description = document.createElement("div");
|
||||
description.className = "small light";
|
||||
@ -226,5 +259,7 @@ Module.register("newsfeed",{
|
||||
*/
|
||||
capitalizeFirstLetter: function(string) {
|
||||
return string.charAt(0).toUpperCase() + string.slice(1);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user