Sindbad~EG File Manager
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>JAM ON | Your Home For Urban Music</title>
<meta name="description" content="Jam-On FM brings you the best in nonstop music, fresh hits, and smooth vibes. Tune in anytime, anywhere.">
<?php include 'head.php'?>
</head>
<body>
<?php include 'header.php'?>
<?php include 'conn.php'; ?>
<section class="news-section py-5 text-white">
<div class="container ">
<div class=" motion-features">
<div class="row align-items-center mb-4">
<div class="col-lg-8" data-aos="fade-right">
<h2 class="display-5 fw-bold mb-4">News</h2>
</div>
<div class="col-lg-4 text-lg-end text-start" data-aos="fade-left">
<select id="sortSelect" class="form-select w-auto border-light ms-auto mb-4" aria-label="Sort news">
<option value="latest" selected>Sort by Latest</option>
<option value="popular">Sort by Popular</option>
</select>
</div>
</div>
<!-- News Container -->
<div class="row g-4" id="news-container"></div>
<!-- Load More Button -->
<div class="text-center mt-4">
<button id="loadMoreNews" class="btn btn-outline-light btn-sm rounded-pill px-4 mt-3 browse-btn">Load More</button>
</div>
</div>
</div>
</section>
<!-- JS for Dynamic News Loading -->
<script>
const newsContainer = document.getElementById('news-container');
const loadMoreBtn = document.getElementById('loadMoreNews');
const sortSelect = document.getElementById('sortSelect');
let offset = 0;
const limit = 3;
let sort = 'latest';
let endOfNews = false;
async function fetchNews() {
if (endOfNews) return;
try {
const res = await fetch(`fetch-news.php?offset=${offset}&limit=${limit}&sort=${sort}`);
const data = await res.json();
if (data.length === 0) {
endOfNews = true;
loadMoreBtn.style.display = 'none';
return;
}
data.forEach(news => {
const col = document.createElement('div');
col.className = 'col-md-4';
const formattedDate = new Date(news.news_date).toLocaleDateString('de-CH', {
day: '2-digit', month: 'long', year: 'numeric'
});
col.innerHTML = `
<a href="news-detail-page.php?id=${news.id}" class="text-decoration-none text-white h-100 w-100 d-block">
<div class="card text-white h-100 border-0">
<div class="motion-img mx-auto mt-auto">
<img src="images/news/${news.image}" class="img-fluid" alt="${news.heading_normal}">
</div>
<div class="text-center motion-text-container flex-grow-1 d-flex flex-column align-items-center p-3">
<h4 class="motion-title a1">${news.heading_normal}</h4>
<p class="motion-text a1">${news.intro}</p>
</div>
<div class="d-flex justify-content-between text-muted small mb-2 p-2">
<span class="text-white">📅 ${formattedDate}</span>
</div>
</div>
</a>
`;
newsContainer.appendChild(col);
});
offset += data.length;
} catch (err) {
console.error('Error loading news:', err);
}
}
loadMoreBtn.addEventListener('click', fetchNews);
sortSelect.addEventListener('change', () => {
sort = sortSelect.value;
offset = 0;
endOfNews = false;
newsContainer.innerHTML = '';
loadMoreBtn.style.display = 'block';
fetchNews();
});
// Initial load
fetchNews();
</script>
<?php include 'footer.php'?>
</body>
</html>
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists