Update to improve RSS

This commit is contained in:
William Moore 2023-06-14 04:26:11 -05:00
parent 73415a4a0d
commit dfd0f12a15
2 changed files with 12 additions and 7 deletions

View File

@ -1,6 +1,7 @@
<html> <html>
<head> <head>
<meta http-equiv="refresh" content="3600"> <meta http-equiv="refresh" content="3600">
<script src="FONTAWESOME_SCRIPT_URL" crossorigin="anonymous"></script>
<script type="module" src="./js/RSS.js"></script> <script type="module" src="./js/RSS.js"></script>
</head> </head>
<body> <body>

View File

@ -41,7 +41,6 @@ export class RSS extends LitElement {
const result = await response.text(); const result = await response.text();
const rss = (new DOMParser()).parseFromString(result.trim(), 'text/xml'); const rss = (new DOMParser()).parseFromString(result.trim(), 'text/xml');
const channel = rss.getElementsByTagName('channel')[0] ?? null; const channel = rss.getElementsByTagName('channel')[0] ?? null;
console.log(rss);
for (let channelI = 0; channelI < channel?.children?.length; channelI++) { for (let channelI = 0; channelI < channel?.children?.length; channelI++) {
const channelChild = channel?.children?.item(channelI); const channelChild = channel?.children?.item(channelI);
@ -98,12 +97,17 @@ export class RSS extends LitElement {
override render() { override render() {
return html` return html`
<div class="gauge-body"> <div class="gauge-body">
<div class="gauge-label">RSS Feed for ${this.rssTitle}${this.rssLink ? html`<a href="${this.rssLink}">link</a>` : ''}</div> ${this.rssItems?.length > 0
? html`
<div class="gauge-label">RSS Feed for ${this.rssTitle}${this.rssLink ? html` <a href="${this.rssLink}"><i class="fa-solid fa-link"></i></a>` : ''}</div>
${this.rssItems.map(rssItem => html` ${this.rssItems.map(rssItem => html`
<div> <div>
<div>${rssItem.link ? html`<a href="${rssItem.link}">${rssItem.title}</a>` : rssItem.title}</div> <div>${rssItem.link ? html`<a href="${rssItem.link}">${rssItem.title}</a>` : rssItem.title}</div>
</div> </div>
`)} `)}
`
: html`<div class="gauge-label">There was no valid RSS feed found.</div>`
}
</div> </div>
`; `;