-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnews.html
112 lines (102 loc) · 3.98 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>News - BullsEye</title>
<link rel="stylesheet" href="styles/style.css">
<link rel="stylesheet" href="styles\news.css">
<link rel="apple-touch-icon" sizes="180x180" href="favicon_io/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="favicon_io/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="favicon_io/favicon-16x16.png">
<link rel="manifest" href="favicon_io/site.webmanifest">
</head>
<body>
<!-- Stock Ticker -->
<div class="ticker-wrapper">
<div class="ticker"></div>
</div>
<!-- Navbar -->
<nav class="navbar">
<div class="logo">
<img src="res/img/logo.png" alt="Logo">
<h1>BullsEye</h1>
</div>
<div class="menu">
<a href="index.html">Home</a>
<a href="market.html">Market Dashboard</a>
<a href="crypto.html">Crypto Currency</a>
<a href="discover.html">Discover</a>
<a href="news.html">News</a>
<a href="super.html">Super Investors</a>
</div>
<div class="extras">
<span class="highlight"></span>
<a href="#" class="account">Account</a>
</div>
<!-- Hamburger Icon -->
<div class="hamburger" onclick="toggleMenu()">
<span class="bar"></span>
<span class="bar"></span>
<span class="bar"></span>
</div>
</nav>
<!-- Sidebar (hidden by default) -->
<div id="sidebar" class="sidebar">
<div class="close-btn" onclick="toggleMenu()">X</div>
<div class="sidebar-menu">
<a href="index.html">Home</a>
<a href="market.html">Market Dashboard</a>
<a href="crypto.html">Crypto Currency</a>
<a href="discover.html">Discover</a>
<a href="news.html">News</a>
<a href="super.html">Super Investors</a>
<a href="#">Accounts</a>
</div>
</div>
<!-- News Section -->
<div id="news-section" class="news-container">
<h2>Latest Stock Market News</h2>
<div id="news-articles"></div>
</div>
<!-- Js Of News Articles -->
<script>
document.addEventListener('DOMContentLoaded', () => {
const apiKey = 'bd2807686c2f489596d0eff9f7286f65';
const newsContainer = document.getElementById('news-articles');
async function fetchNews() {
try {
const response = await fetch(`https://newsapi.org/v2/everything?q=stocks&apiKey=${apiKey}`);
const data = await response.json();
data.articles.forEach(article => {
const newsItem = document.createElement('div');
newsItem.className = 'news-item';
newsItem.innerHTML = `
<img src="${article.urlToImage || 'default-image.jpg'}" alt="News Image" class="news-image">
<div class="news-content">
<h3>${article.title}</h3>
<p>${article.description}</p>
<a href="${article.url}" target="_blank">Read more</a>
</div>
<div class="news-footer">
<span>Source: ${article.source.name}</span>
<span>${new Date(article.publishedAt).toLocaleDateString()}</span>
</div>
`;
newsContainer.appendChild(newsItem);
});
} catch (error) {
console.error('Error fetching news:', error);
}
}
fetchNews();
});
// Function to toggle the sidebar on mobile
function toggleMenu() {
var sidebar = document.getElementById("sidebar");
sidebar.classList.toggle("active");
}
</script>
<script src="ticker.js" defer></script>
</body>
</html>