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