Update index.html
Browse files- index.html +347 -467
index.html
CHANGED
|
@@ -3,53 +3,9 @@
|
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
-
<title>
|
| 7 |
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
| 9 |
-
<script>
|
| 10 |
-
tailwind.config = {
|
| 11 |
-
theme: {
|
| 12 |
-
extend: {
|
| 13 |
-
colors: {
|
| 14 |
-
quantumBlue: '#00e1ff',
|
| 15 |
-
neonPink: '#ff36fc',
|
| 16 |
-
matrixGreen: '#00ff9d',
|
| 17 |
-
cyberPurple: '#a600ff',
|
| 18 |
-
hologramTeal: '#00ffcc',
|
| 19 |
-
voidBlack: '#050510',
|
| 20 |
-
spaceGray: '#1a1a2e',
|
| 21 |
-
uiGray: '#2a2a3a',
|
| 22 |
-
uiLight: '#e0e0ff'
|
| 23 |
-
},
|
| 24 |
-
fontFamily: {
|
| 25 |
-
'sans': ['"Rajdhani"', 'sans-serif'],
|
| 26 |
-
'mono': ['"Space Mono"', 'monospace'],
|
| 27 |
-
'display': ['"Orbitron"', 'sans-serif']
|
| 28 |
-
},
|
| 29 |
-
animation: {
|
| 30 |
-
'glow': 'glow 2s ease-in-out infinite alternate',
|
| 31 |
-
'float': 'float 6s ease-in-out infinite',
|
| 32 |
-
'text-shine': 'text-shine 3s ease-in-out infinite alternate',
|
| 33 |
-
'pulse-slow': 'pulse 5s infinite'
|
| 34 |
-
},
|
| 35 |
-
keyframes: {
|
| 36 |
-
glow: {
|
| 37 |
-
'0%': { 'box-shadow': '0 0 5px rgba(0, 225, 255, 0.3)' },
|
| 38 |
-
'100%': { 'box-shadow': '0 0 20px rgba(0, 225, 255, 0.5)' }
|
| 39 |
-
},
|
| 40 |
-
float: {
|
| 41 |
-
'0%, 100%': { transform: 'translateY(0)' },
|
| 42 |
-
'50%': { transform: 'translateY(-10px)' }
|
| 43 |
-
},
|
| 44 |
-
'text-shine': {
|
| 45 |
-
'0%': { 'background-position': '0% 50%' },
|
| 46 |
-
'100%': { 'background-position': '100% 50%' }
|
| 47 |
-
}
|
| 48 |
-
}
|
| 49 |
-
}
|
| 50 |
-
}
|
| 51 |
-
}
|
| 52 |
-
</script>
|
| 53 |
<style>
|
| 54 |
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;500;600;700&family=Space+Mono:ital,wght@0,400;0,700;1,400&family=Rajdhani:wght@300;400;500;600;700&display=swap');
|
| 55 |
|
|
@@ -59,6 +15,7 @@
|
|
| 59 |
min-height: 100vh;
|
| 60 |
position: relative;
|
| 61 |
overflow-x: hidden;
|
|
|
|
| 62 |
}
|
| 63 |
|
| 64 |
body::before {
|
|
@@ -197,247 +154,156 @@
|
|
| 197 |
pointer-events: none;
|
| 198 |
z-index: -1;
|
| 199 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 200 |
</style>
|
| 201 |
</head>
|
| 202 |
-
<body class="
|
| 203 |
-
<!-- Floating elements -->
|
| 204 |
-
<div class="fixed top-1/4 left-10 w-3 h-3 rounded-full bg-quantumBlue opacity-30 animate-float" style="animation-delay: 0s;"></div>
|
| 205 |
-
<div class="fixed top-1/3 right-20 w-4 h-4 rounded-full bg-neonPink opacity-30 animate-float" style="animation-delay: 1s;"></div>
|
| 206 |
-
<div class="fixed bottom-1/4 left-1/4 w-5 h-5 rounded-full bg-cyberPurple opacity-30 animate-float" style="animation-delay: 2s;"></div>
|
| 207 |
-
|
| 208 |
<!-- Header -->
|
| 209 |
-
<header class="
|
| 210 |
-
<div class="container mx-auto px-
|
| 211 |
-
<div class="flex
|
| 212 |
-
<div class="flex items-center
|
| 213 |
-
<div class="
|
| 214 |
-
<
|
| 215 |
</div>
|
| 216 |
-
<
|
| 217 |
-
<span class="gradient-text">NEXUS</span>
|
| 218 |
-
</h1>
|
| 219 |
</div>
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
<a href="#" class="text-uiLight hover:text-quantumBlue transition font-medium">SPACE</a>
|
| 227 |
-
</nav>
|
| 228 |
-
|
| 229 |
-
<div class="flex items-center space-x-4 mt-4 md:mt-0">
|
| 230 |
-
<button class="px-4 py-2 rounded-md bg-uiGray/50 text-uiLight hover:bg-uiGray/70 transition font-mono text-sm cyber-button">
|
| 231 |
-
<i class="fas fa-user-astronaut mr-2"></i> SIGN IN
|
| 232 |
-
</button>
|
| 233 |
</div>
|
| 234 |
</div>
|
| 235 |
</div>
|
| 236 |
</header>
|
| 237 |
|
| 238 |
<!-- Main Content -->
|
| 239 |
-
<main class="container mx-auto px-
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
<div class="
|
| 243 |
-
<div class="
|
| 244 |
-
<
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 259 |
</button>
|
| 260 |
</div>
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
|
| 275 |
-
</div>
|
| 276 |
-
|
| 277 |
-
<!-- News Loading Skeleton -->
|
| 278 |
-
<div id="loading-skeleton" class="space-y-6">
|
| 279 |
-
<div class="ui-panel rounded-lg p-6 animate-pulse">
|
| 280 |
-
<div class="h-6 bg-uiGray/30 rounded w-3/4 mb-4"></div>
|
| 281 |
-
<div class="h-4 bg-uiGray/20 rounded w-full mb-2"></div>
|
| 282 |
-
<div class="h-4 bg-uiGray/20 rounded w-5/6 mb-2"></div>
|
| 283 |
-
<div class="h-4 bg-uiGray/20 rounded w-4/6 mb-4"></div>
|
| 284 |
-
<div class="h-3 bg-uiGray/20 rounded w-1/4"></div>
|
| 285 |
-
</div>
|
| 286 |
-
<div class="ui-panel rounded-lg p-6 animate-pulse">
|
| 287 |
-
<div class="h-6 bg-uiGray/30 rounded w-3/4 mb-4"></div>
|
| 288 |
-
<div class="h-4 bg-uiGray/20 rounded w-full mb-2"></div>
|
| 289 |
-
<div class="h-4 bg-uiGray/20 rounded w-5/6 mb-2"></div>
|
| 290 |
-
<div class="h-4 bg-uiGray/20 rounded w-4/6 mb-4"></div>
|
| 291 |
-
<div class="h-3 bg-uiGray/20 rounded w-1/4"></div>
|
| 292 |
</div>
|
| 293 |
</div>
|
| 294 |
-
|
| 295 |
-
<!-- News Container -->
|
| 296 |
-
<div id="news-container" class="space-y-6 hidden">
|
| 297 |
-
<!-- News cards will be inserted here by JavaScript -->
|
| 298 |
-
</div>
|
| 299 |
-
|
| 300 |
-
<div class="mt-8 flex justify-center">
|
| 301 |
-
<button id="load-more" class="px-8 py-3 bg-gradient-to-r from-cyberPurple to-quantumBlue text-white rounded-md hover:opacity-90 transition-all duration-300 font-mono cyber-button">
|
| 302 |
-
<i class="fas fa-chevron-down mr-2"></i> LOAD MORE
|
| 303 |
-
</button>
|
| 304 |
-
</div>
|
| 305 |
</div>
|
| 306 |
-
|
| 307 |
-
<!--
|
| 308 |
-
<div class="
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
<
|
| 313 |
-
|
| 314 |
-
|
| 315 |
-
|
| 316 |
-
<div class="flex items-center">
|
| 317 |
-
<div class="w-8 h-8 bg-uiGray/30 rounded-full mr-3"></div>
|
| 318 |
-
<div class="h-4 bg-uiGray/20 rounded w-24"></div>
|
| 319 |
-
</div>
|
| 320 |
-
<div class="h-4 bg-uiGray/20 rounded w-12"></div>
|
| 321 |
-
</div>
|
| 322 |
-
<div class="flex justify-between items-center animate-pulse">
|
| 323 |
-
<div class="flex items-center">
|
| 324 |
-
<div class="w-8 h-8 bg-uiGray/30 rounded-full mr-3"></div>
|
| 325 |
-
<div class="h-4 bg-uiGray/20 rounded w-24"></div>
|
| 326 |
-
</div>
|
| 327 |
-
<div class="h-4 bg-uiGray/20 rounded w-12"></div>
|
| 328 |
</div>
|
| 329 |
</div>
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
<i class="fas fa-microchip mr-2"></i> TECH BRIEF
|
| 336 |
-
</h3>
|
| 337 |
-
<div class="space-y-4">
|
| 338 |
-
<div class="p-4 bg-spaceGray/50 rounded-md border-l-4 border-quantumBlue">
|
| 339 |
-
<div class="flex items-start">
|
| 340 |
-
<div class="flex-shrink-0 mt-1">
|
| 341 |
-
<div class="w-3 h-3 rounded-full bg-quantumBlue animate-pulse-slow"></div>
|
| 342 |
-
</div>
|
| 343 |
-
<div class="ml-3">
|
| 344 |
-
<p class="text-sm font-mono text-uiLight">QUANTUM COMPUTING BREAKTHROUGH AT GOOGLE</p>
|
| 345 |
-
<p class="text-xs text-uiLight/50 mt-1">12 MINUTES AGO</p>
|
| 346 |
-
</div>
|
| 347 |
-
</div>
|
| 348 |
-
</div>
|
| 349 |
-
<div class="p-4 bg-spaceGray/50 rounded-md border-l-4 border-neonPink">
|
| 350 |
-
<div class="flex items-start">
|
| 351 |
-
<div class="flex-shrink-0 mt-1">
|
| 352 |
-
<div class="w-3 h-3 rounded-full bg-neonPink animate-pulse-slow"></div>
|
| 353 |
-
</div>
|
| 354 |
-
<div class="ml-3">
|
| 355 |
-
<p class="text-sm font-mono text-uiLight">APPLE ANNOUNCES NEURAL INTERFACE RESEARCH</p>
|
| 356 |
-
<p class="text-xs text-uiLight/50 mt-1">38 MINUTES AGO</p>
|
| 357 |
-
</div>
|
| 358 |
-
</div>
|
| 359 |
-
</div>
|
| 360 |
-
<div class="p-4 bg-spaceGray/50 rounded-md border-l-4 border-matrixGreen">
|
| 361 |
-
<div class="flex items-start">
|
| 362 |
-
<div class="flex-shrink-0 mt-1">
|
| 363 |
-
<div class="w-3 h-3 rounded-full bg-matrixGreen animate-pulse-slow"></div>
|
| 364 |
-
</div>
|
| 365 |
-
<div class="ml-3">
|
| 366 |
-
<p class="text-sm font-mono text-uiLight">SPACEX LAUNCHES NEXT-GEN STARLINK SATELLITES</p>
|
| 367 |
-
<p class="text-xs text-uiLight/50 mt-1">1 HOUR AGO</p>
|
| 368 |
-
</div>
|
| 369 |
-
</div>
|
| 370 |
</div>
|
| 371 |
</div>
|
| 372 |
-
|
| 373 |
-
|
| 374 |
-
|
| 375 |
-
|
| 376 |
-
<h3 class="text-lg font-bold font-mono text-quantumBlue mb-2 tracking-wider">
|
| 377 |
-
<i class="fas fa-envelope mr-2"></i> NEXUS NEWSLETTER
|
| 378 |
-
</h3>
|
| 379 |
-
<p class="mb-4 text-uiLight/70 text-sm">Get the future delivered to your inbox</p>
|
| 380 |
-
<form class="space-y-3">
|
| 381 |
-
<input type="email" placeholder="YOUR@EMAIL.COM"
|
| 382 |
-
class="w-full px-4 py-2 rounded bg-spaceGray/70 text-uiLight placeholder-uiLight/50 border border-uiGray/30 focus:outline-none focus:ring-1 focus:ring-quantumBlue font-mono text-sm tracking-wider">
|
| 383 |
-
<button type="submit" class="w-full px-4 py-2 bg-gradient-to-r from-quantumBlue/90 to-cyberPurple/90 text-white rounded-md font-medium hover:opacity-90 transition font-mono text-sm tracking-wider cyber-button">
|
| 384 |
-
<i class="fas fa-paper-plane mr-2"></i> SUBSCRIBE
|
| 385 |
</button>
|
| 386 |
-
</
|
| 387 |
</div>
|
| 388 |
</div>
|
| 389 |
</div>
|
| 390 |
</main>
|
| 391 |
|
| 392 |
<!-- Footer -->
|
| 393 |
-
<footer class="
|
| 394 |
-
<div class="container mx-auto px-6">
|
| 395 |
-
<div class="
|
| 396 |
-
<div>
|
| 397 |
-
<
|
| 398 |
-
<span class="gradient-text">NEXUS</span>
|
| 399 |
-
</h4>
|
| 400 |
-
<p class="text-uiLight/60 text-sm font-sans">The premier source for tomorrow's technology, today.</p>
|
| 401 |
-
<div class="flex space-x-4 mt-4">
|
| 402 |
-
<a href="#" class="text-uiLight/60 hover:text-quantumBlue transition"><i class="fab fa-twitter"></i></a>
|
| 403 |
-
<a href="#" class="text-uiLight/60 hover:text-quantumBlue transition"><i class="fab fa-linkedin"></i></a>
|
| 404 |
-
<a href="#" class="text-uiLight/60 hover:text-quantumBlue transition"><i class="fab fa-github"></i></a>
|
| 405 |
-
<a href="#" class="text-uiLight/60 hover:text-quantumBlue transition"><i class="fab fa-youtube"></i></a>
|
| 406 |
-
</div>
|
| 407 |
-
</div>
|
| 408 |
-
<div>
|
| 409 |
-
<h4 class="text-sm font-bold font-mono text-quantumBlue mb-4 tracking-wider">EXPLORE</h4>
|
| 410 |
-
<ul class="space-y-2">
|
| 411 |
-
<li><a href="#" class="text-uiLight/60 hover:text-uiLight transition text-sm">Technology</a></li>
|
| 412 |
-
<li><a href="#" class="text-uiLight/60 hover:text-uiLight transition text-sm">Artificial Intelligence</a></li>
|
| 413 |
-
<li><a href="#" class="text-uiLight/60 hover:text-uiLight transition text-sm">Quantum Computing</a></li>
|
| 414 |
-
<li><a href="#" class="text-uiLight/60 hover:text-uiLight transition text-sm">Cybersecurity</a></li>
|
| 415 |
-
</ul>
|
| 416 |
-
</div>
|
| 417 |
-
<div>
|
| 418 |
-
<h4 class="text-sm font-bold font-mono text-quantumBlue mb-4 tracking-wider">COMPANY</h4>
|
| 419 |
-
<ul class="space-y-2">
|
| 420 |
-
<li><a href="#" class="text-uiLight/60 hover:text-uiLight transition text-sm">About</a></li>
|
| 421 |
-
<li><a href="#" class="text-uiLight/60 hover:text-uiLight transition text-sm">Careers</a></li>
|
| 422 |
-
<li><a href="#" class="text-uiLight/60 hover:text-uiLight transition text-sm">Privacy</a></li>
|
| 423 |
-
<li><a href="#" class="text-uiLight/60 hover:text-uiLight transition text-sm">Terms</a></li>
|
| 424 |
-
</ul>
|
| 425 |
-
</div>
|
| 426 |
-
<div>
|
| 427 |
-
<h4 class="text-sm font-bold font-mono text-quantumBlue mb-4 tracking-wider">CONTACT</h4>
|
| 428 |
-
<ul class="space-y-2">
|
| 429 |
-
<li class="text-uiLight/60 text-sm">hello@nexus.tech</li>
|
| 430 |
-
<li class="text-uiLight/60 text-sm">+1 (555) 123-4567</li>
|
| 431 |
-
<li class="text-uiLight/60 text-sm">San Francisco, CA</li>
|
| 432 |
-
</ul>
|
| 433 |
</div>
|
| 434 |
-
</div>
|
| 435 |
-
<div class="border-t border-uiGray/20 mt-8 pt-8 flex flex-col md:flex-row justify-between items-center">
|
| 436 |
-
<p class="text-uiLight/50 text-xs mb-4 md:mb-0">© 2023 NEXUS TECHNOLOGIES. ALL RIGHTS RESERVED.</p>
|
| 437 |
<div class="flex space-x-4">
|
| 438 |
-
<a href="#" class="text-
|
| 439 |
-
|
| 440 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 441 |
</div>
|
| 442 |
</div>
|
| 443 |
</div>
|
|
@@ -448,17 +314,19 @@
|
|
| 448 |
const NEWSAPI_API_KEY = 'f764fe522436442d9bdafbae241d7b63';
|
| 449 |
const MARKETAUX_API_TOKEN = 'x7do5W51vWCggI5OC0qDPYYPRRRBdpsZuydOkfPq';
|
| 450 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 451 |
// API endpoints for each category
|
| 452 |
const API_ENDPOINTS = {
|
| 453 |
all: [
|
| 454 |
'https://api.marketaux.com/v1/news/all?industries=Technology&filter_entities=true&limit=10&api_token=' + MARKETAUX_API_TOKEN,
|
| 455 |
'https://newsapi.org/v2/everything?q=bitcoin&from=2025-04-23&sortBy=publishedAt&apiKey=' + NEWSAPI_API_KEY,
|
| 456 |
'https://newsapi.org/v2/everything?q=apple&from=2025-05-22&to=2025-05-22&sortBy=popularity&apiKey=' + NEWSAPI_API_KEY,
|
| 457 |
-
'https://newsapi.org/v2/top-headlines?sources=techcrunch&apiKey=' + NEWSAPI_API_KEY
|
| 458 |
-
'https://newsapi.org/v2/everything?q=energy&from=2025-05-22&to=2025-05-22&sortBy=popularity&apiKey=' + NEWSAPI_API_KEY,
|
| 459 |
-
'https://newsapi.org/v2/everything?q=solar&from=2025-05-22&to=2025-05-22&sortBy=popularity&apiKey=' + NEWSAPI_API_KEY,
|
| 460 |
-
'https://newsapi.org/v2/everything?q=wind+solar&from=2025-05-22&to=2025-05-22&sortBy=popularity&apiKey=' + NEWSAPI_API_KEY,
|
| 461 |
-
'https://newsapi.org/v2/everything?q=verizonORsprintORt-mobileORmetroOR5gORwireless&from=2025-05-22&to=2025-05-22&sortBy=popularity&apiKey=' + NEWSAPI_API_KEY
|
| 462 |
],
|
| 463 |
technology: [
|
| 464 |
'https://newsapi.org/v2/everything?q=technology&from=2025-04-23&sortBy=publishedAt&apiKey=' + NEWSAPI_API_KEY,
|
|
@@ -494,229 +362,261 @@
|
|
| 494 |
]
|
| 495 |
};
|
| 496 |
|
| 497 |
-
//
|
| 498 |
-
|
| 499 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 500 |
|
|
|
|
| 501 |
document.addEventListener('DOMContentLoaded', function() {
|
| 502 |
-
|
| 503 |
-
loadAllData();
|
| 504 |
|
| 505 |
-
//
|
| 506 |
-
document.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 507 |
});
|
| 508 |
|
| 509 |
-
|
| 510 |
-
|
| 511 |
-
|
| 512 |
-
|
| 513 |
-
|
| 514 |
-
|
| 515 |
-
|
| 516 |
-
|
| 517 |
-
|
| 518 |
-
|
|
|
|
|
|
|
|
|
|
| 519 |
}
|
| 520 |
|
| 521 |
-
|
| 522 |
-
|
| 523 |
-
|
| 524 |
-
|
| 525 |
-
|
| 526 |
|
| 527 |
-
|
|
|
|
|
|
|
|
|
|
| 528 |
|
| 529 |
-
|
| 530 |
-
|
| 531 |
-
|
| 532 |
-
|
| 533 |
-
|
| 534 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 535 |
}
|
| 536 |
|
| 537 |
-
|
| 538 |
-
btn.disabled = false;
|
| 539 |
}
|
| 540 |
|
| 541 |
-
//
|
| 542 |
-
async function
|
| 543 |
-
|
| 544 |
-
const endpoints = API_ENDPOINTS[selectedCategory];
|
| 545 |
-
let allArticles = [];
|
| 546 |
-
|
| 547 |
-
// Fetch from all endpoints for the selected category
|
| 548 |
-
for (const endpoint of endpoints) {
|
| 549 |
-
let url = endpoint;
|
| 550 |
-
|
| 551 |
-
// Add pagination for Marketaux API
|
| 552 |
-
if (url.includes('marketaux.com')) {
|
| 553 |
-
url += `&page=${currentNewsPage}`;
|
| 554 |
-
|
| 555 |
-
// Use current date for published_after
|
| 556 |
-
const now = new Date();
|
| 557 |
-
const oneDayAgo = new Date(now.getTime() - (24 * 60 * 60 * 1000));
|
| 558 |
-
const isoString = oneDayAgo.toISOString().split('.')[0];
|
| 559 |
-
url += `&published_after=${isoString}`;
|
| 560 |
-
}
|
| 561 |
-
|
| 562 |
-
const response = await fetch(url);
|
| 563 |
-
const data = await response.json();
|
| 564 |
-
|
| 565 |
-
if (data) {
|
| 566 |
-
// Handle different API response formats
|
| 567 |
-
if (data.data) {
|
| 568 |
-
// Marketaux format
|
| 569 |
-
allArticles = [...allArticles, ...data.data];
|
| 570 |
-
} else if (data.articles) {
|
| 571 |
-
// NewsAPI format
|
| 572 |
-
allArticles = [...allArticles, ...data.articles.map(article => ({
|
| 573 |
-
title: article.title,
|
| 574 |
-
description: article.description,
|
| 575 |
-
url: article.url,
|
| 576 |
-
image_url: article.urlToImage,
|
| 577 |
-
published_at: article.publishedAt,
|
| 578 |
-
source: article.source?.name
|
| 579 |
-
}))];
|
| 580 |
-
}
|
| 581 |
-
}
|
| 582 |
-
}
|
| 583 |
-
|
| 584 |
-
// Shuffle articles for variety
|
| 585 |
-
allArticles = shuffleArray(allArticles);
|
| 586 |
-
|
| 587 |
-
if (allArticles.length > 0) {
|
| 588 |
-
updateNewsUI(allArticles, refresh, append);
|
| 589 |
-
}
|
| 590 |
-
} catch (error) {
|
| 591 |
-
console.error('Error fetching news:', error);
|
| 592 |
-
throw error;
|
| 593 |
-
}
|
| 594 |
}
|
| 595 |
|
| 596 |
-
//
|
| 597 |
-
function
|
| 598 |
-
|
| 599 |
-
|
| 600 |
-
|
| 601 |
-
|
| 602 |
-
|
| 603 |
-
return newArray;
|
| 604 |
}
|
| 605 |
|
| 606 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 607 |
try {
|
| 608 |
-
|
| 609 |
-
|
| 610 |
-
{ name: "AI ADVANCEMENTS", mentions: 1245 },
|
| 611 |
-
{ name: "QUANTUM COMPUTING", mentions: 876 },
|
| 612 |
-
{ name: "5G ROLLOUT", mentions: 754 },
|
| 613 |
-
{ name: "METAVERSE", mentions: 689 },
|
| 614 |
-
{ name: "CYBERSECURITY", mentions: 632 }
|
| 615 |
-
];
|
| 616 |
-
|
| 617 |
-
updateTrendingTopicsUI(trendingTopics);
|
| 618 |
} catch (error) {
|
| 619 |
-
console.error('Error fetching
|
| 620 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 621 |
}
|
| 622 |
}
|
| 623 |
|
| 624 |
-
//
|
| 625 |
-
function
|
| 626 |
-
const
|
| 627 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 628 |
|
| 629 |
-
|
| 630 |
-
|
| 631 |
-
|
| 632 |
-
|
| 633 |
-
|
| 634 |
-
|
| 635 |
-
|
| 636 |
-
${Math.floor(Math.random() * 9) + 1}
|
| 637 |
-
</div>
|
| 638 |
-
<span class="font-mono text-sm text-uiLight">${topic.name}</span>
|
| 639 |
-
</div>
|
| 640 |
-
<div class="text-right">
|
| 641 |
-
<span class="text-xs font-mono text-uiLight/60">${topic.mentions.toLocaleString()}</span>
|
| 642 |
-
</div>
|
| 643 |
-
`;
|
| 644 |
|
| 645 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 646 |
});
|
| 647 |
}
|
| 648 |
|
| 649 |
-
|
| 650 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 651 |
|
| 652 |
-
// Clear
|
| 653 |
-
if (
|
| 654 |
newsContainer.innerHTML = '';
|
| 655 |
}
|
| 656 |
|
| 657 |
-
//
|
| 658 |
-
|
| 659 |
-
|
| 660 |
-
// Show news container if it's hidden
|
| 661 |
-
if (!append) {
|
| 662 |
-
newsContainer.classList.remove('hidden');
|
| 663 |
-
}
|
| 664 |
|
| 665 |
-
|
| 666 |
-
articles.forEach(article => {
|
| 667 |
const newsCard = document.createElement('div');
|
| 668 |
-
newsCard.className = 'news-card ui-panel rounded-lg
|
| 669 |
-
|
| 670 |
-
// Simple sentiment analysis based on title keywords
|
| 671 |
-
let sentimentColor = 'text-quantumBlue';
|
| 672 |
-
let sentimentIcon = 'fa-newspaper';
|
| 673 |
-
const title = article.title ? article.title.toUpperCase() : '';
|
| 674 |
-
|
| 675 |
-
if (title.includes('BREAKTHROUGH') || title.includes('INNOVATIVE') || title.includes('SUCCESS') ||
|
| 676 |
-
title.includes('GROWTH') || title.includes('LAUNCH') || title.includes('RECORD')) {
|
| 677 |
-
sentimentColor = 'text-matrixGreen';
|
| 678 |
-
sentimentIcon = 'fa-arrow-up';
|
| 679 |
-
} else if (title.includes('HACK') || title.includes('BREACH') || title.includes('LAYOFF') ||
|
| 680 |
-
title.includes('DECLINE') || title.includes('WARNING') || title.includes('ISSUE') ||
|
| 681 |
-
title.includes('PROBLEM') || title.includes('FAILURE')) {
|
| 682 |
-
sentimentColor = 'text-neonPink';
|
| 683 |
-
sentimentIcon = 'fa-arrow-down';
|
| 684 |
-
}
|
| 685 |
|
| 686 |
// Format date
|
| 687 |
-
const date =
|
| 688 |
const formattedDate = date.toLocaleDateString('en-US', {
|
| 689 |
year: 'numeric',
|
| 690 |
month: 'short',
|
| 691 |
-
day: 'numeric'
|
| 692 |
-
|
| 693 |
-
|
| 694 |
-
|
| 695 |
-
const sourceName = article.source ? article.source.toUpperCase() : 'UNKNOWN SOURCE';
|
| 696 |
|
| 697 |
// Create card HTML
|
| 698 |
newsCard.innerHTML = `
|
| 699 |
-
<div class="flex flex-col md:flex-row gap-
|
| 700 |
-
|
| 701 |
-
|
| 702 |
-
|
| 703 |
-
alt="${article.title || 'NEWS IMAGE'}"
|
| 704 |
-
class="w-full h-full object-cover">
|
| 705 |
-
</div>
|
| 706 |
</div>
|
| 707 |
-
|
| 708 |
-
|
| 709 |
-
|
| 710 |
-
|
| 711 |
-
|
| 712 |
-
|
| 713 |
-
|
| 714 |
-
<span>${sourceName} <span class="mx-2">•</span> ${formattedDate}</span>
|
| 715 |
-
<a href="${article.url || '#'}" target="_blank" rel="noopener noreferrer"
|
| 716 |
-
class="text-quantumBlue hover:text-uiLight transition flex items-center">
|
| 717 |
-
READ <i class="fas fa-external-link-alt ml-1 text-xs"></i>
|
| 718 |
-
</a>
|
| 719 |
</div>
|
|
|
|
|
|
|
|
|
|
| 720 |
</div>
|
| 721 |
</div>
|
| 722 |
`;
|
|
@@ -724,33 +624,13 @@
|
|
| 724 |
newsContainer.appendChild(newsCard);
|
| 725 |
});
|
| 726 |
|
| 727 |
-
//
|
| 728 |
-
if (
|
| 729 |
-
|
| 730 |
} else {
|
| 731 |
-
|
| 732 |
}
|
| 733 |
}
|
| 734 |
-
|
| 735 |
-
function showError(message) {
|
| 736 |
-
// Hide loading states
|
| 737 |
-
document.getElementById('loading-skeleton').classList.add('hidden');
|
| 738 |
-
|
| 739 |
-
// Show error message
|
| 740 |
-
const errorElement = document.createElement('div');
|
| 741 |
-
errorElement.className = 'ui-panel rounded-lg p-6';
|
| 742 |
-
errorElement.innerHTML = `
|
| 743 |
-
<div class="flex items-center text-quantumBlue font-mono tracking-wider">
|
| 744 |
-
<i class="fas fa-exclamation-triangle mr-2"></i>
|
| 745 |
-
<span>${message}</span>
|
| 746 |
-
</div>
|
| 747 |
-
`;
|
| 748 |
-
|
| 749 |
-
const newsContainer = document.getElementById('news-container');
|
| 750 |
-
newsContainer.innerHTML = '';
|
| 751 |
-
newsContainer.appendChild(errorElement);
|
| 752 |
-
newsContainer.classList.remove('hidden');
|
| 753 |
-
}
|
| 754 |
</script>
|
| 755 |
-
|
| 756 |
</html>
|
|
|
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>TechPulse - Automated Tech News Aggregator</title>
|
| 7 |
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
<style>
|
| 10 |
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;500;600;700&family=Space+Mono:ital,wght@0,400;0,700;1,400&family=Rajdhani:wght@300;400;500;600;700&display=swap');
|
| 11 |
|
|
|
|
| 15 |
min-height: 100vh;
|
| 16 |
position: relative;
|
| 17 |
overflow-x: hidden;
|
| 18 |
+
font-family: 'Rajdhani', sans-serif;
|
| 19 |
}
|
| 20 |
|
| 21 |
body::before {
|
|
|
|
| 154 |
pointer-events: none;
|
| 155 |
z-index: -1;
|
| 156 |
}
|
| 157 |
+
|
| 158 |
+
.category-btn {
|
| 159 |
+
transition: all 0.3s ease;
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
.category-btn:hover {
|
| 163 |
+
transform: scale(1.05);
|
| 164 |
+
box-shadow: 0 0 15px rgba(0, 225, 255, 0.5);
|
| 165 |
+
}
|
| 166 |
+
|
| 167 |
+
.loading-spinner {
|
| 168 |
+
border: 3px solid rgba(0, 225, 255, 0.3);
|
| 169 |
+
border-radius: 50%;
|
| 170 |
+
border-top: 3px solid #00e1ff;
|
| 171 |
+
width: 30px;
|
| 172 |
+
height: 30px;
|
| 173 |
+
animation: spin 1s linear infinite;
|
| 174 |
+
}
|
| 175 |
+
|
| 176 |
+
@keyframes spin {
|
| 177 |
+
0% { transform: rotate(0deg); }
|
| 178 |
+
100% { transform: rotate(360deg); }
|
| 179 |
+
}
|
| 180 |
+
|
| 181 |
+
.source-tag {
|
| 182 |
+
background: rgba(0, 225, 255, 0.1);
|
| 183 |
+
border-left: 3px solid #00e1ff;
|
| 184 |
+
}
|
| 185 |
+
|
| 186 |
+
.date-badge {
|
| 187 |
+
background: rgba(255, 54, 252, 0.1);
|
| 188 |
+
border-left: 3px solid #ff36fc;
|
| 189 |
+
}
|
| 190 |
</style>
|
| 191 |
</head>
|
| 192 |
+
<body class="min-h-screen flex flex-col">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 193 |
<!-- Header -->
|
| 194 |
+
<header class="holographic-effect">
|
| 195 |
+
<div class="container mx-auto px-4 py-6">
|
| 196 |
+
<div class="flex justify-between items-center">
|
| 197 |
+
<div class="flex items-center space-x-4">
|
| 198 |
+
<div class="ui-panel px-6 py-3 rounded-lg">
|
| 199 |
+
<h1 class="text-3xl font-bold gradient-text font-['Orbitron']">TechPulse</h1>
|
| 200 |
</div>
|
| 201 |
+
<p class="text-sm text-gray-400 hidden md:block">Your automated tech news aggregator</p>
|
|
|
|
|
|
|
| 202 |
</div>
|
| 203 |
+
<div class="ui-panel px-4 py-2 rounded-lg">
|
| 204 |
+
<div class="marquee">
|
| 205 |
+
<span class="text-sm">
|
| 206 |
+
<i class="fas fa-bolt text-yellow-400 mr-2"></i> Latest in Tech: AI advancements • Quantum computing breakthroughs • New smartphone releases • Cybersecurity threats • Cloud computing innovations • Blockchain developments • AR/VR trends • 5G expansion • Semiconductor news • Robotics progress
|
| 207 |
+
</span>
|
| 208 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 209 |
</div>
|
| 210 |
</div>
|
| 211 |
</div>
|
| 212 |
</header>
|
| 213 |
|
| 214 |
<!-- Main Content -->
|
| 215 |
+
<main class="flex-grow container mx-auto px-4 pb-12">
|
| 216 |
+
<div class="grid grid-cols-1 lg:grid-cols-4 gap-6">
|
| 217 |
+
<!-- Sidebar - Categories -->
|
| 218 |
+
<div class="lg:col-span-1">
|
| 219 |
+
<div class="ui-panel p-6 rounded-xl grid-pattern sticky top-6">
|
| 220 |
+
<h2 class="text-xl font-bold mb-4 gradient-text font-['Orbitron']">Categories</h2>
|
| 221 |
+
<div class="space-y-3">
|
| 222 |
+
<button onclick="loadNews('all')" class="category-btn w-full ui-panel px-4 py-3 rounded-lg text-left flex items-center cyber-button active">
|
| 223 |
+
<i class="fas fa-globe mr-3 text-blue-400"></i>
|
| 224 |
+
<span>All Tech News</span>
|
| 225 |
+
</button>
|
| 226 |
+
<button onclick="loadNews('technology')" class="category-btn w-full ui-panel px-4 py-3 rounded-lg text-left flex items-center cyber-button">
|
| 227 |
+
<i class="fas fa-microchip mr-3 text-purple-400"></i>
|
| 228 |
+
<span>Technology</span>
|
| 229 |
+
</button>
|
| 230 |
+
<button onclick="loadNews('energy')" class="category-btn w-full ui-panel px-4 py-3 rounded-lg text-left flex items-center cyber-button">
|
| 231 |
+
<i class="fas fa-bolt mr-3 text-yellow-400"></i>
|
| 232 |
+
<span>Energy Tech</span>
|
| 233 |
+
</button>
|
| 234 |
+
<button onclick="loadNews('communication')" class="category-btn w-full ui-panel px-4 py-3 rounded-lg text-left flex items-center cyber-button">
|
| 235 |
+
<i class="fas fa-satellite-dish mr-3 text-green-400"></i>
|
| 236 |
+
<span>Communication</span>
|
| 237 |
+
</button>
|
| 238 |
+
<button onclick="loadNews('financial')" class="category-btn w-full ui-panel px-4 py-3 rounded-lg text-left flex items-center cyber-button">
|
| 239 |
+
<i class="fas fa-chart-line mr-3 text-teal-400"></i>
|
| 240 |
+
<span>FinTech</span>
|
| 241 |
</button>
|
| 242 |
</div>
|
| 243 |
+
|
| 244 |
+
<div class="mt-8">
|
| 245 |
+
<h3 class="text-lg font-semibold mb-3">Quick Filters</h3>
|
| 246 |
+
<div class="space-y-2">
|
| 247 |
+
<button onclick="loadFilteredNews('ai')" class="quick-filter-btn w-full ui-panel px-3 py-2 rounded-lg text-left text-sm cyber-button">
|
| 248 |
+
<i class="fas fa-robot mr-2"></i> Artificial Intelligence
|
| 249 |
+
</button>
|
| 250 |
+
<button onclick="loadFilteredNews('crypto')" class="quick-filter-btn w-full ui-panel px-3 py-2 rounded-lg text-left text-sm cyber-button">
|
| 251 |
+
<i class="fab fa-bitcoin mr-2"></i> Cryptocurrency
|
| 252 |
+
</button>
|
| 253 |
+
<button onclick="loadFilteredNews('startups')" class="quick-filter-btn w-full ui-panel px-3 py-2 rounded-lg text-left text-sm cyber-button">
|
| 254 |
+
<i class="fas fa-rocket mr-2"></i> Startups
|
| 255 |
+
</button>
|
| 256 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 257 |
</div>
|
| 258 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 259 |
</div>
|
| 260 |
+
|
| 261 |
+
<!-- News Feed -->
|
| 262 |
+
<div class="lg:col-span-3">
|
| 263 |
+
<div class="ui-panel p-6 rounded-xl grid-pattern">
|
| 264 |
+
<div class="flex justify-between items-center mb-6">
|
| 265 |
+
<h2 class="text-2xl font-bold gradient-text font-['Orbitron']" id="current-category">Latest Tech News</h2>
|
| 266 |
+
<div class="flex items-center space-x-3">
|
| 267 |
+
<button onclick="refreshNews()" class="ui-panel px-4 py-2 rounded-lg cyber-button flex items-center">
|
| 268 |
+
<i class="fas fa-sync-alt mr-2"></i> Refresh
|
| 269 |
+
</button>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 270 |
</div>
|
| 271 |
</div>
|
| 272 |
+
|
| 273 |
+
<div id="news-container" class="space-y-6">
|
| 274 |
+
<!-- News cards will be inserted here by JavaScript -->
|
| 275 |
+
<div class="flex justify-center py-12">
|
| 276 |
+
<div class="loading-spinner"></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 277 |
</div>
|
| 278 |
</div>
|
| 279 |
+
|
| 280 |
+
<div class="mt-8 flex justify-center">
|
| 281 |
+
<button onclick="loadMoreNews()" id="load-more-btn" class="ui-panel px-6 py-3 rounded-lg cyber-button hidden">
|
| 282 |
+
<i class="fas fa-plus-circle mr-2"></i> Load More
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 283 |
</button>
|
| 284 |
+
</div>
|
| 285 |
</div>
|
| 286 |
</div>
|
| 287 |
</div>
|
| 288 |
</main>
|
| 289 |
|
| 290 |
<!-- Footer -->
|
| 291 |
+
<footer class="holographic-effect mt-auto">
|
| 292 |
+
<div class="container mx-auto px-4 py-6">
|
| 293 |
+
<div class="flex flex-col md:flex-row justify-between items-center">
|
| 294 |
+
<div class="mb-4 md:mb-0">
|
| 295 |
+
<p class="text-sm text-gray-400">© 2023 TechPulse - Automated Tech News Aggregator</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 296 |
</div>
|
|
|
|
|
|
|
|
|
|
| 297 |
<div class="flex space-x-4">
|
| 298 |
+
<a href="#" class="text-gray-400 hover:text-white transition">
|
| 299 |
+
<i class="fab fa-github"></i>
|
| 300 |
+
</a>
|
| 301 |
+
<a href="#" class="text-gray-400 hover:text-white transition">
|
| 302 |
+
<i class="fab fa-twitter"></i>
|
| 303 |
+
</a>
|
| 304 |
+
<a href="#" class="text-gray-400 hover:text-white transition">
|
| 305 |
+
<i class="fab fa-linkedin"></i>
|
| 306 |
+
</a>
|
| 307 |
</div>
|
| 308 |
</div>
|
| 309 |
</div>
|
|
|
|
| 314 |
const NEWSAPI_API_KEY = 'f764fe522436442d9bdafbae241d7b63';
|
| 315 |
const MARKETAUX_API_TOKEN = 'x7do5W51vWCggI5OC0qDPYYPRRRBdpsZuydOkfPq';
|
| 316 |
|
| 317 |
+
// Current state
|
| 318 |
+
let currentCategory = 'all';
|
| 319 |
+
let currentPage = 1;
|
| 320 |
+
let isLoading = false;
|
| 321 |
+
let allArticles = [];
|
| 322 |
+
|
| 323 |
// API endpoints for each category
|
| 324 |
const API_ENDPOINTS = {
|
| 325 |
all: [
|
| 326 |
'https://api.marketaux.com/v1/news/all?industries=Technology&filter_entities=true&limit=10&api_token=' + MARKETAUX_API_TOKEN,
|
| 327 |
'https://newsapi.org/v2/everything?q=bitcoin&from=2025-04-23&sortBy=publishedAt&apiKey=' + NEWSAPI_API_KEY,
|
| 328 |
'https://newsapi.org/v2/everything?q=apple&from=2025-05-22&to=2025-05-22&sortBy=popularity&apiKey=' + NEWSAPI_API_KEY,
|
| 329 |
+
'https://newsapi.org/v2/top-headlines?sources=techcrunch&apiKey=' + NEWSAPI_API_KEY
|
|
|
|
|
|
|
|
|
|
|
|
|
| 330 |
],
|
| 331 |
technology: [
|
| 332 |
'https://newsapi.org/v2/everything?q=technology&from=2025-04-23&sortBy=publishedAt&apiKey=' + NEWSAPI_API_KEY,
|
|
|
|
| 362 |
]
|
| 363 |
};
|
| 364 |
|
| 365 |
+
// Category display names
|
| 366 |
+
const CATEGORY_NAMES = {
|
| 367 |
+
all: 'Latest Tech News',
|
| 368 |
+
technology: 'Technology',
|
| 369 |
+
energy: 'Energy Tech',
|
| 370 |
+
communication: 'Communication Tech',
|
| 371 |
+
financial: 'FinTech',
|
| 372 |
+
healthcare: 'Health Tech',
|
| 373 |
+
industrial: 'Industrial Tech',
|
| 374 |
+
real_estate: 'Real Estate Tech',
|
| 375 |
+
utilities: 'Utilities Tech',
|
| 376 |
+
ai: 'AI News',
|
| 377 |
+
crypto: 'Cryptocurrency',
|
| 378 |
+
startups: 'Tech Startups'
|
| 379 |
+
};
|
| 380 |
+
|
| 381 |
+
// DOM elements
|
| 382 |
+
const newsContainer = document.getElementById('news-container');
|
| 383 |
+
const currentCategoryElement = document.getElementById('current-category');
|
| 384 |
+
const loadMoreBtn = document.getElementById('load-more-btn');
|
| 385 |
|
| 386 |
+
// Initialize the page
|
| 387 |
document.addEventListener('DOMContentLoaded', function() {
|
| 388 |
+
loadNews('all');
|
|
|
|
| 389 |
|
| 390 |
+
// Set active category button
|
| 391 |
+
document.querySelectorAll('.category-btn').forEach(btn => {
|
| 392 |
+
btn.addEventListener('click', function() {
|
| 393 |
+
document.querySelectorAll('.category-btn').forEach(b => b.classList.remove('active'));
|
| 394 |
+
this.classList.add('active');
|
| 395 |
+
});
|
| 396 |
+
});
|
| 397 |
});
|
| 398 |
|
| 399 |
+
// Load news for a category
|
| 400 |
+
async function loadNews(category) {
|
| 401 |
+
currentCategory = category;
|
| 402 |
+
currentPage = 1;
|
| 403 |
+
allArticles = [];
|
| 404 |
+
|
| 405 |
+
// Update UI
|
| 406 |
+
currentCategoryElement.textContent = CATEGORY_NAMES[category] || 'Tech News';
|
| 407 |
+
newsContainer.innerHTML = '<div class="flex justify-center py-12"><div class="loading-spinner"></div></div>';
|
| 408 |
+
loadMoreBtn.classList.add('hidden');
|
| 409 |
+
|
| 410 |
+
// Fetch news
|
| 411 |
+
await fetchNews(category);
|
| 412 |
}
|
| 413 |
|
| 414 |
+
// Load filtered news
|
| 415 |
+
async function loadFilteredNews(filter) {
|
| 416 |
+
currentCategory = filter;
|
| 417 |
+
currentPage = 1;
|
| 418 |
+
allArticles = [];
|
| 419 |
|
| 420 |
+
// Update UI
|
| 421 |
+
currentCategoryElement.textContent = CATEGORY_NAMES[filter] || 'Tech News';
|
| 422 |
+
newsContainer.innerHTML = '<div class="flex justify-center py-12"><div class="loading-spinner"></div></div>';
|
| 423 |
+
loadMoreBtn.classList.add('hidden');
|
| 424 |
|
| 425 |
+
// Determine which endpoints to use based on filter
|
| 426 |
+
let endpoints = [];
|
| 427 |
+
|
| 428 |
+
switch(filter) {
|
| 429 |
+
case 'ai':
|
| 430 |
+
endpoints = [
|
| 431 |
+
'https://newsapi.org/v2/everything?q=artificial+intelligence+OR+AI&sortBy=publishedAt&apiKey=' + NEWSAPI_API_KEY,
|
| 432 |
+
'https://api.marketaux.com/v1/news/all?industries=Technology&filter_entities=true&limit=10&api_token=' + MARKETAUX_API_TOKEN
|
| 433 |
+
];
|
| 434 |
+
break;
|
| 435 |
+
case 'crypto':
|
| 436 |
+
endpoints = [
|
| 437 |
+
'https://newsapi.org/v2/everything?q=bitcoin+OR+cryptocurrency+OR+blockchain&sortBy=publishedAt&apiKey=' + NEWSAPI_API_KEY,
|
| 438 |
+
'https://api.marketaux.com/v1/news/all?industries=Financial&filter_entities=true&limit=10&api_token=' + MARKETAUX_API_TOKEN
|
| 439 |
+
];
|
| 440 |
+
break;
|
| 441 |
+
case 'startups':
|
| 442 |
+
endpoints = [
|
| 443 |
+
'https://newsapi.org/v2/everything?q=startup+OR+startups+OR+venture+capital&sortBy=publishedAt&apiKey=' + NEWSAPI_API_KEY,
|
| 444 |
+
'https://api.marketaux.com/v1/news/all?industries=Technology&filter_entities=true&limit=10&api_token=' + MARKETAUX_API_TOKEN
|
| 445 |
+
];
|
| 446 |
+
break;
|
| 447 |
+
default:
|
| 448 |
+
endpoints = API_ENDPOINTS.all;
|
| 449 |
}
|
| 450 |
|
| 451 |
+
await fetchFromEndpoints(endpoints);
|
|
|
|
| 452 |
}
|
| 453 |
|
| 454 |
+
// Refresh news
|
| 455 |
+
async function refreshNews() {
|
| 456 |
+
await loadNews(currentCategory);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 457 |
}
|
| 458 |
|
| 459 |
+
// Load more news
|
| 460 |
+
async function loadMoreNews() {
|
| 461 |
+
if (isLoading) return;
|
| 462 |
+
|
| 463 |
+
currentPage++;
|
| 464 |
+
loadMoreBtn.innerHTML = '<div class="loading-spinner"></div>';
|
| 465 |
+
await fetchNews(currentCategory);
|
|
|
|
| 466 |
}
|
| 467 |
|
| 468 |
+
// Fetch news from all endpoints for a category
|
| 469 |
+
async function fetchNews(category) {
|
| 470 |
+
if (isLoading) return;
|
| 471 |
+
|
| 472 |
+
isLoading = true;
|
| 473 |
+
|
| 474 |
try {
|
| 475 |
+
const endpoints = API_ENDPOINTS[category] || API_ENDPOINTS.all;
|
| 476 |
+
await fetchFromEndpoints(endpoints);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 477 |
} catch (error) {
|
| 478 |
+
console.error('Error fetching news:', error);
|
| 479 |
+
newsContainer.innerHTML = `
|
| 480 |
+
<div class="ui-panel p-6 rounded-lg text-center">
|
| 481 |
+
<i class="fas fa-exclamation-triangle text-yellow-400 text-4xl mb-3"></i>
|
| 482 |
+
<p class="text-lg">Failed to load news. Please try again later.</p>
|
| 483 |
+
<button onclick="refreshNews()" class="mt-4 ui-panel px-4 py-2 rounded-lg cyber-button">
|
| 484 |
+
<i class="fas fa-sync-alt mr-2"></i> Retry
|
| 485 |
+
</button>
|
| 486 |
+
</div>
|
| 487 |
+
`;
|
| 488 |
+
} finally {
|
| 489 |
+
isLoading = false;
|
| 490 |
+
loadMoreBtn.innerHTML = '<i class="fas fa-plus-circle mr-2"></i> Load More';
|
| 491 |
}
|
| 492 |
}
|
| 493 |
|
| 494 |
+
// Fetch from multiple endpoints
|
| 495 |
+
async function fetchFromEndpoints(endpoints) {
|
| 496 |
+
const promises = endpoints.map(endpoint => {
|
| 497 |
+
return fetch(endpoint)
|
| 498 |
+
.then(response => {
|
| 499 |
+
if (!response.ok) throw new Error('Network response was not ok');
|
| 500 |
+
return response.json();
|
| 501 |
+
})
|
| 502 |
+
.catch(error => {
|
| 503 |
+
console.error('Error fetching from endpoint:', endpoint, error);
|
| 504 |
+
return null;
|
| 505 |
+
});
|
| 506 |
+
});
|
| 507 |
|
| 508 |
+
const results = await Promise.all(promises);
|
| 509 |
+
|
| 510 |
+
// Process results
|
| 511 |
+
const newArticles = [];
|
| 512 |
+
|
| 513 |
+
results.forEach(result => {
|
| 514 |
+
if (!result) return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 515 |
|
| 516 |
+
// Handle Marketaux API format
|
| 517 |
+
if (result.data) {
|
| 518 |
+
result.data.forEach(article => {
|
| 519 |
+
newArticles.push({
|
| 520 |
+
title: article.title,
|
| 521 |
+
description: article.description,
|
| 522 |
+
url: article.url,
|
| 523 |
+
source: article.source,
|
| 524 |
+
publishedAt: article.published_at,
|
| 525 |
+
imageUrl: article.image_url
|
| 526 |
+
});
|
| 527 |
+
});
|
| 528 |
+
}
|
| 529 |
+
// Handle NewsAPI format
|
| 530 |
+
else if (result.articles) {
|
| 531 |
+
result.articles.forEach(article => {
|
| 532 |
+
newArticles.push({
|
| 533 |
+
title: article.title,
|
| 534 |
+
description: article.description,
|
| 535 |
+
url: article.url,
|
| 536 |
+
source: article.source?.name || 'Unknown',
|
| 537 |
+
publishedAt: article.publishedAt,
|
| 538 |
+
imageUrl: article.urlToImage
|
| 539 |
+
});
|
| 540 |
+
});
|
| 541 |
+
}
|
| 542 |
+
});
|
| 543 |
+
|
| 544 |
+
// Filter out duplicates
|
| 545 |
+
const uniqueArticles = filterDuplicateArticles([...allArticles, ...newArticles]);
|
| 546 |
+
allArticles = uniqueArticles;
|
| 547 |
+
|
| 548 |
+
// Display articles
|
| 549 |
+
displayArticles();
|
| 550 |
+
}
|
| 551 |
+
|
| 552 |
+
// Filter duplicate articles by URL
|
| 553 |
+
function filterDuplicateArticles(articles) {
|
| 554 |
+
const uniqueUrls = new Set();
|
| 555 |
+
return articles.filter(article => {
|
| 556 |
+
if (!article.url || uniqueUrls.has(article.url)) {
|
| 557 |
+
return false;
|
| 558 |
+
}
|
| 559 |
+
uniqueUrls.add(article.url);
|
| 560 |
+
return true;
|
| 561 |
});
|
| 562 |
}
|
| 563 |
|
| 564 |
+
// Display articles in the UI
|
| 565 |
+
function displayArticles() {
|
| 566 |
+
if (allArticles.length === 0) {
|
| 567 |
+
newsContainer.innerHTML = `
|
| 568 |
+
<div class="ui-panel p-6 rounded-lg text-center">
|
| 569 |
+
<i class="fas fa-newspaper text-blue-400 text-4xl mb-3"></i>
|
| 570 |
+
<p class="text-lg">No news articles found for this category.</p>
|
| 571 |
+
<button onclick="refreshNews()" class="mt-4 ui-panel px-4 py-2 rounded-lg cyber-button">
|
| 572 |
+
<i class="fas fa-sync-alt mr-2"></i> Refresh
|
| 573 |
+
</button>
|
| 574 |
+
</div>
|
| 575 |
+
`;
|
| 576 |
+
loadMoreBtn.classList.add('hidden');
|
| 577 |
+
return;
|
| 578 |
+
}
|
| 579 |
|
| 580 |
+
// Clear loading spinner
|
| 581 |
+
if (currentPage === 1) {
|
| 582 |
newsContainer.innerHTML = '';
|
| 583 |
}
|
| 584 |
|
| 585 |
+
// Display articles
|
| 586 |
+
const articlesToShow = allArticles.slice(0, currentPage * 10);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 587 |
|
| 588 |
+
articlesToShow.forEach(article => {
|
|
|
|
| 589 |
const newsCard = document.createElement('div');
|
| 590 |
+
newsCard.className = 'news-card ui-panel p-5 rounded-lg';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 591 |
|
| 592 |
// Format date
|
| 593 |
+
const date = new Date(article.publishedAt);
|
| 594 |
const formattedDate = date.toLocaleDateString('en-US', {
|
| 595 |
year: 'numeric',
|
| 596 |
month: 'short',
|
| 597 |
+
day: 'numeric',
|
| 598 |
+
hour: '2-digit',
|
| 599 |
+
minute: '2-digit'
|
| 600 |
+
});
|
|
|
|
| 601 |
|
| 602 |
// Create card HTML
|
| 603 |
newsCard.innerHTML = `
|
| 604 |
+
<div class="flex flex-col md:flex-row gap-4">
|
| 605 |
+
${article.imageUrl ? `
|
| 606 |
+
<div class="md:w-1/4">
|
| 607 |
+
<img src="${article.imageUrl}" alt="${article.title}" class="w-full h-40 object-cover rounded-lg">
|
|
|
|
|
|
|
|
|
|
| 608 |
</div>
|
| 609 |
+
` : ''}
|
| 610 |
+
<div class="${article.imageUrl ? 'md:w-3/4' : 'w-full'}">
|
| 611 |
+
<h3 class="text-xl font-bold mb-2">${article.title}</h3>
|
| 612 |
+
<p class="text-gray-300 mb-4">${article.description || 'No description available.'}</p>
|
| 613 |
+
<div class="flex flex-wrap gap-2 mb-3">
|
| 614 |
+
<span class="source-tag px-3 py-1 rounded-full text-xs">${article.source || 'Unknown source'}</span>
|
| 615 |
+
<span class="date-badge px-3 py-1 rounded-full text-xs">${formattedDate}</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 616 |
</div>
|
| 617 |
+
<a href="${article.url}" target="_blank" rel="noopener noreferrer" class="inline-block ui-panel px-4 py-2 rounded-lg cyber-button">
|
| 618 |
+
<i class="fas fa-external-link-alt mr-2"></i> Read Full Article
|
| 619 |
+
</a>
|
| 620 |
</div>
|
| 621 |
</div>
|
| 622 |
`;
|
|
|
|
| 624 |
newsContainer.appendChild(newsCard);
|
| 625 |
});
|
| 626 |
|
| 627 |
+
// Show/hide load more button
|
| 628 |
+
if (allArticles.length > articlesToShow.length) {
|
| 629 |
+
loadMoreBtn.classList.remove('hidden');
|
| 630 |
} else {
|
| 631 |
+
loadMoreBtn.classList.add('hidden');
|
| 632 |
}
|
| 633 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 634 |
</script>
|
| 635 |
+
</body>
|
| 636 |
</html>
|