Spaces:
Running
Running
dhruvshettty
commited on
Commit
•
ac68956
1
Parent(s):
1bfaf7d
Update index.html
Browse files- index.html +8 -2
index.html
CHANGED
@@ -19,12 +19,18 @@
|
|
19 |
</nav>
|
20 |
<section id="main-content">
|
21 |
<button id="get-articles" type="button">Get recent articles...</button>
|
|
|
22 |
</section>
|
23 |
|
24 |
<script>
|
25 |
const endpoint = 'https://dhruvshettty--latest-news-webhook-response-articles.modal.run/';
|
26 |
|
27 |
document.getElementById("get-articles").onclick = function() {
|
|
|
|
|
|
|
|
|
|
|
28 |
fetch(endpoint)
|
29 |
.then((response) => response.json())
|
30 |
.then((data) => {
|
@@ -32,9 +38,9 @@
|
|
32 |
data.forEach(post => {
|
33 |
const article = document.createElement('article');
|
34 |
article.innerHTML = `
|
35 |
-
<h2>${post.title}</h2>
|
36 |
<p>Published on ${post.publishedat}</p>
|
37 |
-
<p>Categories: ${post.predicted_topic}</p>
|
38 |
<p>Stance: ${post.predicted_stance}</p>
|
39 |
`;
|
40 |
mainContent.appendChild(article);
|
|
|
19 |
</nav>
|
20 |
<section id="main-content">
|
21 |
<button id="get-articles" type="button">Get recent articles...</button>
|
22 |
+
<div id="message-container">Gettin articles...</div>
|
23 |
</section>
|
24 |
|
25 |
<script>
|
26 |
const endpoint = 'https://dhruvshettty--latest-news-webhook-response-articles.modal.run/';
|
27 |
|
28 |
document.getElementById("get-articles").onclick = function() {
|
29 |
+
var message = document.getElementById("message-container");
|
30 |
+
message.style.display = 'block';
|
31 |
+
setTimeout(function() {
|
32 |
+
message.style.display = 'none';
|
33 |
+
}, 3000);
|
34 |
fetch(endpoint)
|
35 |
.then((response) => response.json())
|
36 |
.then((data) => {
|
|
|
38 |
data.forEach(post => {
|
39 |
const article = document.createElement('article');
|
40 |
article.innerHTML = `
|
41 |
+
<a href="${post.url}"><h2>${post.title}</h2></a>
|
42 |
<p>Published on ${post.publishedat}</p>
|
43 |
+
<p>Categories: [${post.predicted_topic}]</p>
|
44 |
<p>Stance: ${post.predicted_stance}</p>
|
45 |
`;
|
46 |
mainContent.appendChild(article);
|