-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnews.html
151 lines (127 loc) · 5.56 KB
/
news.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
Covid tracker
</title>
<link href='./css/styles.css' rel='preload' as="style">
<link rel="shortcut icon" href="./images/favicon.png" type="image/png">
<link rel="preconnect" href="https://fonts.gstatic.com">
<link
href="https://fonts.googleapis.com/css2?family=Montserrat:wght@400;700&family=Red+Hat+Display:wght@400;500&display=swap"
rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.0.1/css/bootstrap.min.css"
integrity="sha512-Ez0cGzNzHR1tYAv56860NLspgUGuQw16GiOOp/I2LuTmpSK9xDXlgJz3XN4cnpXWDmkNBKXR/VDMTCnAaEooxA=="
crossorigin="anonymous" referrerpolicy="no-referrer" />
<link href='https://unpkg.com/boxicons@2.0.7/css/boxicons.min.css' rel='stylesheet'>
<!-- CSS -->
<link rel="stylesheet" href="./css/styles.css">
</head>
<body class="loading" onload="loading()">
<div class="loader">
<i class="bx bxs-virus bx-spin"></i>
</div>
<!-- Header -->
<header class="header">
<div class="container">
<div class="nav-frame">
<figure class="pageLogo">
<img src="images/page-logo.svg" class="pageLogo__image" alt="LOGO">
</figure>
<div class="open-menu" id="open-menu">
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
</div>
<nav class="nav-links" id="nav-links">
<a href="index.html" class="nav-link">Statistics</a>
<a href="overview.html" class="nav-link">Overview</a>
<a href="symptoms.html" class="nav-link">Symptoms</a>
<a href="prevention.html" class="nav-link">Prevention</a>
<a href="news.html" class="nav-link active">News</a>
</nav>
</div>
</div>
</header>
<!-- Main -->
<main>
<!-- Prevention -->
<section id="news-page">
<div class="container">
<div class="row news-page"></div>
</div>
</section>
<!-- footer -->
<footer class="footer mt-5">
<div class="container">
<div class="row align-center">
<div class="col-12 col-md-3 col-lg-3">
<figure class="logo-figure">
<img src="images/page-logo.svg" class="footer__logo" alt="">
</figure>
</div>
<div class="col-12 col-md-6 col-lg-6">
<a href="index.html" class="footer__link">Statistics</a>
<a href="overview.html" class="footer__link">Overview</a>
<a href="symptoms.html" class="footer__link">Symptoms</a>
<a href="prevention.html" class="footer__link">Prevention</a>
<a href="news.html" class="footer__link">News</a>
</div>
</div>
</div>
</footer>
</main>
<script src="./js/functions.js"></script>
<script>
(function (w, d, u) {
var s = d.createElement('script');
s.async = true;
s.src = u + '?' + (Date.now() / 60000 | 0);
var h = d.getElementsByTagName('script')[0];
h.parentNode.insertBefore(s, h);
})(window, document, 'https://cdn.bitrix24.com/b17929189/crm/site_button/loader_2_plnihy.js');
</script>
<script>
fetch(
"https://covid-19-news.p.rapidapi.com/v1/covid?q=covid&lang=en&media=True", {
method: "GET",
headers: {
"x-rapidapi-key": "2d2dea647fmsh577c57bb54abd69p13249djsn06827c6f1fe8",
"x-rapidapi-host": "covid-19-news.p.rapidapi.com",
},
}
)
.then((response) => response.json())
.then((data) => {
var news = document.querySelector(".news-page");
for (let i = 0; i < 32; i++) {
var newsData = `<div class="col-md-3">
<div class="card">
<img src="${data.articles[i].media}" class="card-img-top" alt="news_image">
<div class="card-body">
<h5 class="card-title">${data.articles[i].title}</h5>
<p class="card-text">${data.articles[i].summary}</p>
<a href="${data.articles[i].link}">
<button class="btn btn-primary">Read More</button>
</a>
</div>
</div>
</div>`;
news.innerHTML += newsData;
}
})
.catch((err) => {
let news = document.querySelector(".news-page");
console.error(err);
news.innerHTML += "<h1 class='text-center'>API Request error😪 <br> Please, Try again later!</h1>";
});
function loading() {
let body = document.querySelector("body");
body.classList.remove("loading");
}
</script>
</body>
</html>