Files
senior-kiosk/news.html
T

283 lines
7.2 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>News</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: Arial, sans-serif;
background: linear-gradient(135deg, #1a2a6c, #b21f1f, #fdbb2d);
background-attachment: fixed;
color: white;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
padding: 30px 20px;
}
/* Frosted glass container */
.container {
background: rgba(0, 0, 0, 0.4);
backdrop-filter: blur(16px);
-webkit-backdrop-filter: blur(16px);
border: 1px solid rgba(255, 255, 255, 0.1);
border-radius: 36px;
padding: 40px 30px;
width: 100%;
max-width: 1000px;
box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
}
header {
text-align: center;
margin-bottom: 40px;
}
header h1 {
font-size: 48px;
font-weight: bold;
color: #fff;
letter-spacing: 1px;
text-shadow: 0 4px 10px rgba(0,0,0,0.3);
}
header p {
font-size: 20px;
color: #ffd700;
margin-top: 8px;
font-weight: bold;
}
#loading-box {
text-align: center;
font-size: 26px;
padding: 60px 0;
color: #e2e8f0;
}
.category-title {
font-size: 32px;
font-weight: bold;
color: #38bdf8;
margin: 40px 0 20px 0;
border-bottom: 3px solid rgba(56, 189, 248, 0.3);
padding-bottom: 10px;
display: flex;
align-items: center;
gap: 12px;
}
/* Accordion stories list */
.stories-list {
display: flex;
flex-direction: column;
gap: 16px;
}
.story-card {
background: rgba(255, 255, 255, 0.05);
border: 1px solid rgba(255, 255, 255, 0.08);
border-radius: 20px;
overflow: hidden;
transition: background 0.2s, transform 0.15s;
}
.story-card:hover {
background: rgba(255, 255, 255, 0.09);
transform: translateY(-2px);
}
/* Large tap target for header */
.story-header {
padding: 24px 28px;
cursor: pointer;
display: flex;
justify-content: space-between;
align-items: center;
gap: 20px;
user-select: none;
}
.story-headline {
font-size: 24px;
font-weight: bold;
line-height: 1.35;
color: #fff;
}
.story-chevron {
font-size: 28px;
color: #94a3b8;
transition: transform 0.2s;
}
.story-card.open .story-chevron {
transform: rotate(90deg);
color: #38bdf8;
}
/* Smooth accordion drawer */
.story-body {
max-height: 0;
overflow: hidden;
transition: max-height 0.3s cubic-bezier(0, 1, 0, 1);
background: rgba(0, 0, 0, 0.2);
}
.story-card.open .story-body {
max-height: 1000px; /* arbitrary high value to animate cleanly */
transition: max-height 0.3s ease-in;
}
.story-content {
padding: 24px 28px;
border-top: 1px solid rgba(255, 255, 255, 0.05);
}
.story-summary {
font-size: 22px;
line-height: 1.6;
color: #f1f5f9;
margin-bottom: 16px;
}
.story-meta {
font-size: 16px;
color: #94a3b8;
font-weight: bold;
}
/* Giant Home Button */
.footer-nav {
text-align: center;
margin-top: 50px;
}
.home-btn {
display: inline-flex;
align-items: center;
justify-content: center;
background: linear-gradient(135deg, #10b981, #059669);
color: white;
text-decoration: none;
padding: 22px 55px;
font-size: 28px;
font-weight: bold;
border-radius: 22px;
box-shadow: 0 8px 24px rgba(16, 185, 129, 0.35);
cursor: pointer;
border: none;
transition: transform 0.1s, box-shadow 0.1s;
}
.home-btn:hover {
transform: translateY(-3px);
box-shadow: 0 12px 30px rgba(16, 185, 129, 0.5);
}
.home-btn:active {
transform: translateY(0px);
}
</style>
</head>
<body>
<div class="container">
<header>
<h1>📰 Daily Newspaper</h1>
<p id="newspaper-date">Today's Edition</p>
</header>
<div id="loading-box">🗞️ Delivery in progress... Please wait.</div>
<div id="news-content" style="display: none;">
<!-- World News Section -->
<div class="category-title">🌐 World News</div>
<div class="stories-list" id="world-news-list"></div>
<!-- National News Section -->
<div class="category-title">🇺🇸 National News</div>
<div class="stories-list" id="national-news-list"></div>
</div>
<div class="footer-nav">
<a href="index.html" class="home-btn">⌂ Go Home</a>
</div>
</div>
<script>
// Format publication dates cleanly
function formatToday() {
const now = new Date();
return now.toLocaleDateString('en-US', { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' });
}
async function loadNews() {
document.getElementById('newspaper-date').textContent = formatToday();
try {
const resp = await fetch("news-data.json");
const data = await resp.json();
renderCategory("World News", data["World News"], "world-news-list");
renderCategory("National News", data["National News"], "national-news-list");
document.getElementById('loading-box').style.display = 'none';
document.getElementById('news-content').style.display = 'block';
} catch (e) {
document.getElementById('loading-box').textContent = "⚠️ Preparing newspaper... Please wait a moment.";
}
}
function renderCategory(catName, stories, containerId) {
const box = document.getElementById(containerId);
box.innerHTML = ""; // Clear loader
if (!stories || stories.length === 0) {
box.innerHTML = `<div style="padding: 20px; font-size: 20px; color: #94a3b8; text-align: center;">No stories available.</div>`;
return;
}
stories.forEach((story, idx) => {
const card = document.createElement('div');
card.className = 'story-card';
card.innerHTML = `
<div class="story-header" onclick="toggleStory(this)">
<div class="story-headline">${story.title}</div>
<div class="story-chevron">▸</div>
</div>
<div class="story-body">
<div class="story-content">
<div class="story-summary">${story.summary}</div>
<div class="story-meta">⌚ Published: ${story.date || 'Recent'}</div>
</div>
</div>
`;
box.appendChild(card);
});
}
// Interactive in-place accordion expansion
function toggleStory(headerElement) {
const card = headerElement.parentElement;
const isOpen = card.classList.contains('open');
// Close all other story cards in the same list to keep it neat
const allCards = card.parentElement.querySelectorAll('.story-card');
allCards.forEach(c => c.classList.remove('open'));
if (!isOpen) {
card.classList.add('open');
}
}
window.onload = loadNews;
</script>
</body>
</html>