-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnews.html
258 lines (248 loc) · 9.86 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
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Finance Guru - News</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f4f4f9;
color: #333;
}
.container {
width: 80%;
margin: auto;
padding: 20px;
}
.header {
text-align: center;
margin-bottom: 20px;
}
.header h1 {
font-size: 2.5em;
color: #222;
}
.news-bar {
display: flex;
justify-content: center;
margin-bottom: 20px;
}
.news-tab {
padding: 10px 20px;
font-size: 1.2em;
cursor: pointer;
background-color: #e4e4e9;
margin: 0 5px;
border-radius: 5px;
border: 1px solid #ccc;
transition: all 0.3s ease;
}
.news-tab.active {
background-color: #007BFF;
color: white;
border: 1px solid #0056b3;
}
.news-section {
margin-top: 20px;
}
.news-column {
display: flex;
flex-direction: column;
gap: 20px;
}
.news-card {
background: #ffffff;
border-radius: 8px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
padding: 15px;
transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.news-card:hover {
transform: translateY(-5px);
box-shadow: 0 6px 10px rgba(0, 0, 0, 0.15);
}
.news-card h3 {
font-size: 1.5em;
margin-bottom: 10px;
color: #007BFF;
}
.news-card p {
font-size: 1.1em;
color: #555;
}
.hidden {
display: none;
}
.stock-section {
display: flex;
flex-wrap: wrap;
gap: 20px;
margin-top: 20px;
}
.stock-sector {
flex: 1 1 calc(50% - 20px);
background: #ffffff;
border-radius: 8px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
padding: 15px;
}
.stock-sector h3 {
font-size: 1.5em;
color: #007BFF;
margin-bottom: 10px;
}
.stock-table {
width: 100%;
border-collapse: collapse;
}
.stock-table th, .stock-table td {
padding: 10px;
border: 1px solid #ddd;
text-align: left;
}
.stock-table th {
background-color: #007BFF;
color: white;
}
.stock-table tr:nth-child(even) {
background-color: #f9f9f9;
}
</style>
<script>
async function fetchStockDataBySector(sectors) {
const response = await fetch('stock_names.html');
const htmlText = await response.text();
const parser = new DOMParser();
const doc = parser.parseFromString(htmlText, 'text/html');
const stockSection = document.getElementById('stock-section');
stockSection.innerHTML = ''; // Clear previous content
const allHeadings = doc.querySelectorAll('h2');
sectors.forEach(sector => {
allHeadings.forEach(heading => {
if (heading.textContent.includes(`${sector} Sector`)) {
const table = heading.nextElementSibling; // Get the associated table
if (table && table.tagName === 'TABLE') {
const clonedTable = table.cloneNode(true); // Clone the table
clonedTable.classList.add('stock-table');
const sectorDiv = document.createElement('div');
sectorDiv.classList.add('stock-sector');
sectorDiv.innerHTML = `<h3>${sector} Sector</h3>`;
sectorDiv.appendChild(clonedTable);
stockSection.appendChild(sectorDiv);
}
}
});
});
}
function extractSectorsFromHeadlines() {
const headlines = document.querySelectorAll('#positive-news .news-card h3');
const sectors = [];
const sectorKeywords = {
IT: ['IT', 'Cloud', 'Digital'],
EV: ['EV', 'Electric Vehicle', 'Green Vehicles'],
Medical: ['Medical', 'Healthcare', 'Cancer', 'Pharma'],
Steel: ['Steel', 'Metal'],
Solar: ['Solar', 'Clean Energy']
};
headlines.forEach(headline => {
const text = headline.textContent;
for (const [sector, keywords] of Object.entries(sectorKeywords)) {
if (keywords.some(keyword => text.includes(keyword))) {
if (!sectors.includes(sector)) {
sectors.push(sector);
}
}
}
});
return sectors;
}
function showNews(type) {
const positiveNews = document.getElementById('positive-news');
const negativeNews = document.getElementById('negative-news');
const stockSection = document.getElementById('stock-section');
const positiveTab = document.getElementById('positive-tab');
const negativeTab = document.getElementById('negative-tab');
const stockTab = document.getElementById('stock-tab');
if (type === 'positive') {
positiveNews.classList.remove('hidden');
negativeNews.classList.add('hidden');
stockSection.classList.add('hidden');
positiveTab.classList.add('active');
negativeTab.classList.remove('active');
stockTab.classList.remove('active');
} else if (type === 'negative') {
negativeNews.classList.remove('hidden');
positiveNews.classList.add('hidden');
stockSection.classList.add('hidden');
positiveTab.classList.remove('active');
negativeTab.classList.add('active');
stockTab.classList.remove('active');
} else if (type === 'stock') {
positiveNews.classList.add('hidden');
negativeNews.classList.add('hidden');
stockSection.classList.remove('hidden');
positiveTab.classList.remove('active');
negativeTab.classList.remove('active');
stockTab.classList.add('active');
const sectors = extractSectorsFromHeadlines();
fetchStockDataBySector(sectors);
}
}
</script>
</head>
<body>
<div class="container">
<div class="header">
<h1>Market News</h1>
<p>Stay updated with the latest stock market trends and sector news</p>
</div>
<div class="news-bar">
<div id="positive-tab" class="news-tab active" onclick="showNews('positive')">Positive News</div>
<div id="negative-tab" class="news-tab" onclick="showNews('negative')">Negative News</div>
<div id="stock-tab" class="news-tab" onclick="showNews('stock')">Stocks</div>
</div>
<div class="news-section">
<div class="news-column" id="positive-news">
<div class="news-card">
<h3>Breakthrough in cancer research boosts medical sector</h3>
<p>New drug trials have shown promising results in cancer treatment.</p>
</div>
<div class="news-card">
<h3>EV sales surge as demand for green vehicles rises</h3>
<p>Global sales of electric vehicles hit a record high, signaling a positive shift towards sustainable transportation.</p>
</div>
<div class="news-card">
<h3>Solar sector grows as governments push clean energy</h3>
<p>Increased government incentives for solar installations have driven the growth of the solar energy sector.</p>
</div>
<div class="news-card">
<h3>Cloud computing drives IT sector growth</h3>
<p>The IT sector continues to grow with the rapid adoption of cloud technologies and increased demand for digital transformation.</p>
</div>
</div>
<div class="news-column hidden" id="negative-news">
<div class="news-card">
<h3>Oil prices surge due to geopolitical tensions</h3>
<p>Geopolitical conflicts have caused a spike in oil prices.</p>
</div>
<div class="news-card">
<h3>Housing market faces downturn as interest rates rise</h3>
<p>Higher interest rates have dampened the housing market, leading to reduced demand and falling prices.</p>
</div>
<div class="news-card">
<h3>Steel prices fall amid overproduction</h3>
<p>Overproduction in the steel industry has led to falling prices, negatively impacting profits.</p>
</div>
<div class="news-card">
<h3>Tariff disputes hurt solar sector</h3>
<p>Trade tensions and tariffs on solar panels have slowed the growth of the solar energy industry.</p>
</div>
</div>
<div class="stock-section hidden" id="stock-section"></div>
</div>
</div>
</body>
</html>