summaryrefslogtreecommitdiff
path: root/posts/2020-12-1-HTML-JS-RSS-Feed/index.html
blob: 3b7c4d66649e3550b5c597c3274717cb24426f97 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"/><meta name="og:site_name" content="Navan Chauhan"/><link rel="canonical" href="https://navanchauhan.github.io/posts/2020-12-1-HTML-JS-RSS-Feed"/><meta name="twitter:url" content="https://navanchauhan.github.io/posts/2020-12-1-HTML-JS-RSS-Feed"/><meta name="og:url" content="https://navanchauhan.github.io/posts/2020-12-1-HTML-JS-RSS-Feed"/><title>RSS Feed written in HTML + JavaScript | Navan Chauhan</title><meta name="twitter:title" content="RSS Feed written in HTML + JavaScript | Navan Chauhan"/><meta name="og:title" content="RSS Feed written in HTML + JavaScript | Navan Chauhan"/><meta name="description" content="Short code-snippet for an RSS feed, written in HTML and JavaScript"/><meta name="twitter:description" content="Short code-snippet for an RSS feed, written in HTML and JavaScript"/><meta name="og:description" content="Short code-snippet for an RSS feed, written in HTML and JavaScript"/><meta name="twitter:card" content="summary"/><link rel="stylesheet" href="/styles.css" type="text/css"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><link rel="shortcut icon" href="/images/favicon.png" type="image/png"/><link rel="alternate" href="/feed.rss" type="application/rss+xml" title="Subscribe to Navan Chauhan"/><meta name="twitter:image" content="https://navanchauhan.github.io/images/logo.png"/><meta name="og:image" content="https://navanchauhan.github.io/images/logo.png"/></head><head><script async src="//gc.zgo.at/count.js" data-goatcounter="https://navanchauhan.goatcounter.com/count"></script></head><body class="item-page"><header><div class="wrapper"><a class="site-name" href="/">Navan Chauhan</a><nav><ul><li><a href="/about">About Me</a></li><li><a class="selected" href="/posts">Posts</a></li><li><a href="/publications">Publications</a></li><li><a href="/assets/résumé.pdf">Résumé</a></li><li><a href="https://navanchauhan.github.io/repo">Repo</a></li><li><a href="/feed.rss">RSS Feed</a></li></ul></nav></div></header><div class="wrapper"><article><div class="content"><span class="reading-time">5 minute read</span><span class="reading-time">Created on December 1, 2020</span><h1>RSS Feed written in HTML + JavaScript</h1><p>If you want to directly open the HTML file in your browser after saving, don't forget to set <code>CORS_PROXY=""</code></p><pre><code><div class="highlight"><span></span><span class="cp">&lt;!doctype html&gt;</span>
<span class="p">&lt;</span><span class="nt">html</span> <span class="na">lang</span><span class="o">=</span><span class="s">&quot;en&quot;</span><span class="p">&gt;</span>
<span class="p">&lt;</span><span class="nt">head</span><span class="p">&gt;</span>
  <span class="p">&lt;</span><span class="nt">meta</span> <span class="na">charset</span><span class="o">=</span><span class="s">&quot;utf-8&quot;</span><span class="p">&gt;</span>
  <span class="p">&lt;</span><span class="nt">meta</span> <span class="na">name</span><span class="o">=</span><span class="s">&quot;viewport&quot;</span> <span class="na">content</span><span class="o">=</span><span class="s">&quot;width=device-width, initial-scale=1&quot;</span><span class="p">&gt;</span>
    <span class="p">&lt;</span><span class="nt">title</span><span class="p">&gt;</span>
        RSS Feed
    <span class="p">&lt;/</span><span class="nt">title</span><span class="p">&gt;</span>
    <span class="p">&lt;</span><span class="nt">link</span> <span class="na">rel</span><span class="o">=</span><span class="s">&quot;stylesheet&quot;</span> <span class="na">href</span><span class="o">=</span><span class="s">&quot;https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css&quot;</span> <span class="na">integrity</span><span class="o">=</span><span class="s">&quot;sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO&quot;</span> <span class="na">crossorigin</span><span class="o">=</span><span class="s">&quot;anonymous&quot;</span><span class="p">&gt;</span>
<span class="p">&lt;/</span><span class="nt">head</span><span class="p">&gt;</span>
<span class="p">&lt;</span><span class="nt">body</span><span class="p">&gt;</span>

<span class="p">&lt;</span><span class="nt">h1</span> <span class="na">align</span><span class="o">=</span><span class="s">&quot;center&quot;</span> <span class="na">class</span><span class="o">=</span><span class="s">&quot;display-1&quot;</span><span class="p">&gt;</span>RSS Feed<span class="p">&lt;/</span><span class="nt">h1</span><span class="p">&gt;</span>
<span class="p">&lt;</span><span class="nt">main</span><span class="p">&gt;</span>
    <span class="p">&lt;</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">&quot;container&quot;</span><span class="p">&gt;</span>
    <span class="p">&lt;</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">&quot;list-group pb-4&quot;</span> <span class="na">id</span><span class="o">=</span><span class="s">&quot;contents&quot;</span><span class="p">&gt;&lt;/</span><span class="nt">div</span><span class="p">&gt;</span>
<span class="p">&lt;</span><span class="nt">div</span> <span class="na">id</span><span class="o">=</span><span class="s">&quot;feed&quot;</span><span class="p">&gt;</span>
<span class="p">&lt;/</span><span class="nt">div</span><span class="p">&gt;&lt;/</span><span class="nt">div</span><span class="p">&gt;</span>
<span class="p">&lt;/</span><span class="nt">main</span><span class="p">&gt;</span>

<span class="p">&lt;</span><span class="nt">script</span> <span class="na">src</span><span class="o">=</span><span class="s">&quot;https://gitcdn.xyz/repo/rbren/rss-parser/master/dist/rss-parser.js&quot;</span><span class="p">&gt;&lt;/</span><span class="nt">script</span><span class="p">&gt;</span>
<span class="p">&lt;</span><span class="nt">script</span><span class="p">&gt;</span>

<span class="kr">const</span> <span class="nx">feeds</span> <span class="o">=</span> <span class="p">{</span>
    <span class="s2">&quot;BuzzFeed - India&quot;</span><span class="o">:</span> <span class="p">{</span>
      <span class="s2">&quot;link&quot;</span><span class="o">:</span><span class="s2">&quot;https://www.buzzfeed.com/in.xml&quot;</span><span class="p">,</span>
      <span class="s2">&quot;summary&quot;</span><span class="o">:</span><span class="kc">true</span>
    <span class="p">},</span>
    <span class="s2">&quot;New Yorker&quot;</span><span class="o">:</span> <span class="p">{</span>
      <span class="s2">&quot;link&quot;</span><span class="o">:</span><span class="s2">&quot;http://www.newyorker.com/feed/news&quot;</span><span class="p">,</span>
    <span class="p">},</span>
    <span class="s2">&quot;Vox&quot;</span><span class="o">:</span><span class="p">{</span>
      <span class="s2">&quot;link&quot;</span><span class="o">:</span><span class="s2">&quot;https://www.vox.com/rss/index.xml&quot;</span><span class="p">,</span>
      <span class="s2">&quot;limit&quot;</span><span class="o">:</span> <span class="mf">3</span>
    <span class="p">},</span>
    <span class="s2">&quot;r/Jokes&quot;</span><span class="o">:</span><span class="p">{</span>
      <span class="s2">&quot;link&quot;</span><span class="o">:</span><span class="s2">&quot;https://reddit.com/r/Jokes/hot/.rss?sort=hot&quot;</span><span class="p">,</span>
      <span class="s2">&quot;ignore&quot;</span><span class="o">:</span> <span class="p">[</span><span class="s2">&quot;repost&quot;</span><span class="p">,</span><span class="s2">&quot;discord&quot;</span><span class="p">]</span>
    <span class="p">}</span>
<span class="p">}</span>

<span class="kr">const</span> <span class="nx">config_extra</span> <span class="o">=</span> <span class="p">{</span>
<span class="s2">&quot;Responsive-Images&quot;</span><span class="o">:</span> <span class="kc">true</span><span class="p">,</span>
<span class="s2">&quot;direct-link&quot;</span><span class="o">:</span> <span class="kc">false</span><span class="p">,</span>
<span class="s2">&quot;show-date&quot;</span><span class="o">:</span><span class="kc">false</span><span class="p">,</span>
<span class="s2">&quot;left-column&quot;</span><span class="o">:</span><span class="kc">false</span><span class="p">,</span>
<span class="s2">&quot;defaults&quot;</span><span class="o">:</span> <span class="p">{</span>
  <span class="s2">&quot;limit&quot;</span><span class="o">:</span> <span class="mf">5</span><span class="p">,</span>
  <span class="s2">&quot;summary&quot;</span><span class="o">:</span> <span class="kc">true</span>
<span class="p">}</span>
<span class="p">}</span>

<span class="kr">const</span> <span class="nx">CORS_PROXY</span> <span class="o">=</span> <span class="s2">&quot;https://cors-anywhere.herokuapp.com/&quot;</span>

<span class="kd">var</span> <span class="nx">contents_title</span> <span class="o">=</span> <span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">&quot;h2&quot;</span><span class="p">)</span>
<span class="nx">contents_title</span><span class="p">.</span><span class="nx">textContent</span> <span class="o">=</span> <span class="s2">&quot;Contents&quot;</span>
<span class="nx">contents_title</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">&quot;pb-1&quot;</span><span class="p">)</span>
<span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s2">&quot;contents&quot;</span><span class="p">).</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">contents_title</span><span class="p">)</span>

<span class="nx">async</span> <span class="kd">function</span> <span class="nx">myfunc</span><span class="p">(</span><span class="nx">key</span><span class="p">){</span>

  <span class="kd">var</span> <span class="nx">count_lim</span> <span class="o">=</span> <span class="nx">feeds</span><span class="p">[</span><span class="nx">key</span><span class="p">][</span><span class="s2">&quot;limit&quot;</span><span class="p">]</span>
  <span class="kd">var</span> <span class="nx">count_lim</span> <span class="o">=</span> <span class="p">(</span><span class="nx">count_lim</span> <span class="o">===</span> <span class="kc">undefined</span><span class="p">)</span> <span class="o">?</span> <span class="nx">config_extra</span><span class="p">[</span><span class="s2">&quot;defaults&quot;</span><span class="p">][</span><span class="s2">&quot;limit&quot;</span><span class="p">]</span> <span class="o">:</span> <span class="nx">count_lim</span>
  
  <span class="kd">var</span> <span class="nx">show_summary</span> <span class="o">=</span> <span class="nx">feeds</span><span class="p">[</span><span class="nx">key</span><span class="p">][</span><span class="s2">&quot;summary&quot;</span><span class="p">]</span>
  <span class="kd">var</span> <span class="nx">show_summary</span> <span class="o">=</span> <span class="p">(</span><span class="nx">show_summary</span> <span class="o">===</span> <span class="kc">undefined</span><span class="p">)</span> <span class="o">?</span> <span class="nx">config_extra</span><span class="p">[</span><span class="s2">&quot;defaults&quot;</span><span class="p">][</span><span class="s2">&quot;summary&quot;</span><span class="p">]</span> <span class="o">:</span> <span class="nx">show_summary</span>

  <span class="kd">var</span> <span class="nx">ignore_tags</span> <span class="o">=</span> <span class="nx">feeds</span><span class="p">[</span><span class="nx">key</span><span class="p">][</span><span class="s2">&quot;ignore&quot;</span><span class="p">]</span>
  <span class="kd">var</span> <span class="nx">ignore_tags</span> <span class="o">=</span> <span class="p">(</span><span class="nx">ignore_tags</span> <span class="o">===</span> <span class="kc">undefined</span><span class="p">)</span> <span class="o">?</span> <span class="p">[]</span> <span class="o">:</span> <span class="nx">ignore_tags</span>

  <span class="kd">var</span> <span class="nx">contents</span> <span class="o">=</span> <span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">&quot;a&quot;</span><span class="p">)</span>
  <span class="nx">contents</span><span class="p">.</span><span class="nx">href</span> <span class="o">=</span> <span class="s2">&quot;#&quot;</span> <span class="o">+</span> <span class="nx">key</span>
  <span class="nx">contents</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">&quot;list-group-item&quot;</span><span class="p">,</span><span class="s2">&quot;list-group-item-action&quot;</span><span class="p">)</span>
  <span class="nx">contents</span><span class="p">.</span><span class="nx">textContent</span> <span class="o">=</span> <span class="nx">key</span>
  <span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s2">&quot;contents&quot;</span><span class="p">).</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">contents</span><span class="p">)</span>
  <span class="kd">var</span> <span class="nx">feed_div</span> <span class="o">=</span> <span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">&quot;div&quot;</span><span class="p">)</span>
  <span class="nx">feed_div</span><span class="p">.</span><span class="nx">id</span> <span class="o">=</span> <span class="nx">key</span>
  <span class="nx">feed_div</span><span class="p">.</span><span class="nx">setAttribute</span><span class="p">(</span><span class="s2">&quot;id&quot;</span><span class="p">,</span> <span class="nx">key</span><span class="p">);</span>
  <span class="kd">var</span> <span class="nx">title</span> <span class="o">=</span> <span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">&quot;h2&quot;</span><span class="p">);</span>
  <span class="nx">title</span><span class="p">.</span><span class="nx">textContent</span> <span class="o">=</span> <span class="s2">&quot;From &quot;</span> <span class="o">+</span> <span class="nx">key</span><span class="p">;</span>
  <span class="nx">title</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">&quot;pb-1&quot;</span><span class="p">)</span>
  <span class="nx">feed_div</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">title</span><span class="p">)</span>
  <span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s2">&quot;feed&quot;</span><span class="p">).</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">feed_div</span><span class="p">)</span>
  <span class="kd">var</span> <span class="nx">parser</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">RSSParser</span><span class="p">();</span>
  <span class="kd">var</span> <span class="nx">countPosts</span> <span class="o">=</span> <span class="mf">0</span>
  <span class="nx">parser</span><span class="p">.</span><span class="nx">parseURL</span><span class="p">(</span><span class="nx">CORS_PROXY</span> <span class="o">+</span> <span class="nx">feeds</span><span class="p">[</span><span class="nx">key</span><span class="p">][</span><span class="s2">&quot;link&quot;</span><span class="p">],</span> <span class="kd">function</span><span class="p">(</span><span class="nx">err</span><span class="p">,</span> <span class="nx">feed</span><span class="p">)</span> <span class="p">{</span>
    <span class="k">if</span> <span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="k">throw</span> <span class="nx">err</span><span class="p">;</span>
    <span class="nx">feed</span><span class="p">.</span><span class="nx">items</span><span class="p">.</span><span class="nx">forEach</span><span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="nx">entry</span><span class="p">)</span> <span class="p">{</span>
      <span class="k">if</span> <span class="p">(</span><span class="nx">countPosts</span> <span class="o">&lt;</span> <span class="nx">count_lim</span><span class="p">)</span> <span class="p">{</span>

      <span class="kd">var</span> <span class="nx">skip</span> <span class="o">=</span> <span class="kc">false</span>
      <span class="k">for</span><span class="p">(</span><span class="kd">var</span> <span class="nx">i</span> <span class="o">=</span> <span class="mf">0</span><span class="p">;</span> <span class="nx">i</span> <span class="o">&lt;</span> <span class="nx">ignore_tags</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span> <span class="nx">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
        <span class="k">if</span> <span class="p">(</span><span class="nx">entry</span><span class="p">.</span><span class="nx">title</span><span class="p">.</span><span class="nx">includes</span><span class="p">(</span><span class="nx">ignore_tags</span><span class="p">[</span><span class="nx">i</span><span class="p">])){</span>
          <span class="kd">var</span> <span class="nx">skip</span> <span class="o">=</span> <span class="kc">true</span>
        <span class="p">}</span> <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nx">entry</span><span class="p">.</span><span class="nx">content</span><span class="p">.</span><span class="nx">includes</span><span class="p">(</span><span class="nx">ignore_tags</span><span class="p">[</span><span class="nx">i</span><span class="p">])){</span>
          <span class="kd">var</span> <span class="nx">skip</span> <span class="o">=</span> <span class="kc">true</span>
        <span class="p">}</span>
      <span class="p">}</span>

      <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">skip</span><span class="p">)</span> <span class="p">{</span>

      <span class="kd">var</span> <span class="nx">node</span> <span class="o">=</span> <span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">&quot;div&quot;</span><span class="p">);</span>
      <span class="nx">node</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">&quot;card&quot;</span><span class="p">,</span><span class="s2">&quot;mb-3&quot;</span><span class="p">);</span>
      <span class="kd">var</span> <span class="nx">row</span> <span class="o">=</span> <span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">&quot;div&quot;</span><span class="p">)</span>
      <span class="nx">row</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">&quot;row&quot;</span><span class="p">,</span><span class="s2">&quot;no-gutters&quot;</span><span class="p">)</span>
      
      <span class="k">if</span> <span class="p">(</span><span class="nx">config_extra</span><span class="p">[</span><span class="s2">&quot;left-column&quot;</span><span class="p">]){</span>
      <span class="kd">var</span> <span class="nx">left_col</span> <span class="o">=</span> <span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">&quot;div&quot;</span><span class="p">)</span>
      <span class="nx">left_col</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">&quot;col-md-2&quot;</span><span class="p">)</span>
      <span class="kd">var</span> <span class="nx">left_col_body</span> <span class="o">=</span> <span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">&quot;div&quot;</span><span class="p">)</span>
      <span class="nx">left_col_body</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">&quot;card-body&quot;</span><span class="p">)</span>
      <span class="p">}</span>
      
      <span class="kd">var</span> <span class="nx">right_col</span> <span class="o">=</span> <span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">&quot;div&quot;</span><span class="p">)</span>
      <span class="k">if</span> <span class="p">(</span><span class="nx">config_extra</span><span class="p">[</span><span class="s2">&quot;left-column&quot;</span><span class="p">]){</span>
        <span class="nx">right_col</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">&quot;col-md-10&quot;</span><span class="p">)</span>
      <span class="p">}</span>
      <span class="kd">var</span> <span class="nx">node_title</span> <span class="o">=</span> <span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">&quot;h5&quot;</span><span class="p">)</span>
      
      <span class="nx">node_title</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">&quot;card-header&quot;</span><span class="p">)</span>
      <span class="nx">node_title</span><span class="p">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="nx">entry</span><span class="p">.</span><span class="nx">title</span>
      
      <span class="nx">node_body</span> <span class="o">=</span> <span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">&quot;div&quot;</span><span class="p">)</span>
      <span class="nx">node_body</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">&quot;card-body&quot;</span><span class="p">)</span>
      
      <span class="nx">node_content</span> <span class="o">=</span> <span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">&quot;p&quot;</span><span class="p">)</span>
      
      <span class="k">if</span> <span class="p">(</span><span class="nx">show_summary</span><span class="p">){</span>
        <span class="nx">node_content</span><span class="p">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="nx">entry</span><span class="p">.</span><span class="nx">content</span>
      <span class="p">}</span>
      <span class="nx">node_content</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">&quot;card-text&quot;</span><span class="p">)</span>
      
      <span class="k">if</span> <span class="p">(</span><span class="nx">config_extra</span><span class="p">[</span><span class="s2">&quot;direct-link&quot;</span><span class="p">]){</span>
      <span class="nx">node_link</span> <span class="o">=</span> <span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">&quot;p&quot;</span><span class="p">)</span>
      <span class="nx">node_link</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">&quot;card-text&quot;</span><span class="p">)</span>
      <span class="nx">node_link</span><span class="p">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="s2">&quot;&lt;b&gt;Link:&lt;/b&gt; &lt;a href=&#39;&quot;</span> <span class="o">+</span> <span class="nx">entry</span><span class="p">.</span><span class="nx">link</span> <span class="o">+</span><span class="s2">&quot;&#39;&gt;Direct Link&lt;/a&gt;&quot;</span>
      <span class="k">if</span> <span class="p">(</span><span class="nx">config_extra</span><span class="p">[</span><span class="s2">&quot;left-column&quot;</span><span class="p">]){</span>
      <span class="nx">left_col_body</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">node_link</span><span class="p">)</span>
        <span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
          <span class="nx">node_content</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">node_link</span><span class="p">)</span>
        <span class="p">}</span>
      <span class="p">}</span>

      <span class="k">if</span> <span class="p">(</span><span class="nx">config_extra</span><span class="p">[</span><span class="s2">&quot;show-date&quot;</span><span class="p">]){</span>
        <span class="nx">node_date</span> <span class="o">=</span> <span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">&quot;p&quot;</span><span class="p">)</span>
        <span class="nx">node_date</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">&quot;card-text&quot;</span><span class="p">)</span>
        <span class="nx">node_date</span><span class="p">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="s2">&quot;&lt;p&gt;&lt;b&gt;Date: &lt;/b&gt;&quot;</span> <span class="o">+</span> <span class="nx">entry</span><span class="p">.</span><span class="nx">pubDate</span> <span class="o">+</span> <span class="s2">&quot;&lt;/p&gt;&quot;</span>
        <span class="k">if</span> <span class="p">(</span><span class="nx">config_extra</span><span class="p">[</span><span class="s2">&quot;left-column&quot;</span><span class="p">]){</span>
        <span class="nx">left_col_body</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">node_date</span><span class="p">)</span>
          <span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
            <span class="nx">node_content</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">node_date</span><span class="p">)</span>
          
        <span class="p">}</span>
      <span class="p">}</span>

      <span class="nx">node</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">node_title</span><span class="p">)</span>
      
      <span class="nx">node_body</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">node_content</span><span class="p">)</span>
      
      <span class="nx">right_col</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">node_body</span><span class="p">)</span>

      <span class="k">if</span> <span class="p">(</span><span class="nx">config_extra</span><span class="p">[</span><span class="s2">&quot;left-column&quot;</span><span class="p">]){</span>
        <span class="nx">left_col</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">left_col_body</span><span class="p">)</span>
        <span class="nx">row</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">left_col</span><span class="p">)</span>
      <span class="p">}</span>
      
      <span class="nx">row</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">right_col</span><span class="p">)</span>

      <span class="nx">node</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">row</span><span class="p">)</span>

      <span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="nx">key</span><span class="p">).</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">node</span><span class="p">)</span>
      <span class="nx">countPosts</span><span class="o">+=</span><span class="mf">1</span>
    <span class="p">}</span>
    <span class="p">}</span>
  <span class="p">})</span>

  <span class="k">if</span> <span class="p">(</span><span class="nx">config_extra</span><span class="p">[</span><span class="s2">&quot;Responsive-Images&quot;</span><span class="p">]){</span>
  <span class="kd">var</span> <span class="nx">inputs</span> <span class="o">=</span> <span class="nb">document</span><span class="p">.</span><span class="nx">getElementsByTagName</span><span class="p">(</span><span class="s1">&#39;img&#39;</span><span class="p">)</span>
      <span class="k">for</span><span class="p">(</span><span class="kd">var</span> <span class="nx">i</span> <span class="o">=</span> <span class="mf">0</span><span class="p">;</span> <span class="nx">i</span> <span class="o">&lt;</span> <span class="nx">inputs</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span> <span class="nx">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
        <span class="nx">inputs</span><span class="p">[</span><span class="nx">i</span><span class="p">].</span><span class="nx">classList</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">&quot;img-fluid&quot;</span><span class="p">)</span>
      <span class="p">}</span>
  <span class="p">}</span>

  <span class="p">})</span>

  <span class="k">return</span> <span class="kc">true</span>
<span class="p">}</span>
<span class="p">(</span><span class="nx">async</span> <span class="p">()</span> <span class="p">=&gt;</span> <span class="p">{</span>
<span class="k">for</span><span class="p">(</span><span class="kd">var</span> <span class="nx">key</span> <span class="k">in</span> <span class="nx">feeds</span><span class="p">)</span> <span class="p">{</span>
  <span class="kd">let</span> <span class="nx">result</span> <span class="o">=</span> <span class="nx">await</span> <span class="nx">myfunc</span><span class="p">(</span><span class="nx">key</span><span class="p">);</span>
<span class="p">}})();</span>

<span class="p">&lt;/</span><span class="nt">script</span><span class="p">&gt;</span>
<span class="p">&lt;</span><span class="nt">noscript</span><span class="p">&gt;</span>Uh Oh! Your browser does not support JavaScript or JavaScript is currently disabled. Please enable JavaScript or switch to a different browser.<span class="p">&lt;/</span><span class="nt">noscript</span><span class="p">&gt;</span>
<span class="p">&lt;/</span><span class="nt">body</span><span class="p">&gt;&lt;/</span><span class="nt">html</span><span class="p">&gt;</span>
</div></code></pre></div><span>Tagged with: </span><ul class="tag-list"><li><a href="/tags/tutorial">Tutorial</a></li><li><a href="/tags/codesnippet">Code-Snippet</a></li><li><a href="/tags/html">HTML</a></li><li><a href="/tags/javascript">JavaScript</a></li></ul></article></div><footer><p>Made with ❤️ using <a href="https://github.com/johnsundell/publish">Publish</a></p><p><a href="/feed.rss">RSS feed</a></p></footer></body></html>