279 lines
8.8 KiB
Plaintext
279 lines
8.8 KiB
Plaintext
<!DOCTYPE html>
|
|
<html lang="en">
|
|
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>
|
|
<%= track.title %>
|
|
</title>
|
|
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
|
|
<style>
|
|
body {
|
|
background-color: black;
|
|
color: white;
|
|
font-family: 'Metal Mania', sans-serif;
|
|
}
|
|
|
|
.card {
|
|
background-color: #222;
|
|
border: 1px solid #444;
|
|
border-radius: 8px;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.card-body {
|
|
padding: 1.5rem;
|
|
}
|
|
|
|
.btn-primary {
|
|
background-color: #ff5500;
|
|
border-color: #ff5500;
|
|
transition: background-color 0.3s ease;
|
|
}
|
|
|
|
.btn-primary:hover {
|
|
background-color: #ff3300;
|
|
}
|
|
|
|
::-webkit-scrollbar {
|
|
width: 8px;
|
|
}
|
|
|
|
::-webkit-scrollbar-track {
|
|
background: #1e1e1e;
|
|
}
|
|
|
|
::-webkit-scrollbar-thumb {
|
|
background-color: #4a4a4a;
|
|
border-radius: 10px;
|
|
border: 2px solid #1e1e1e;
|
|
}
|
|
|
|
::-webkit-scrollbar-thumb:hover {
|
|
background-color: #555555;
|
|
}
|
|
|
|
* {
|
|
scrollbar-width: thin;
|
|
scrollbar-color: #4a4a4a #1e1e1e;
|
|
}
|
|
|
|
/* Header styling */
|
|
.site-header {
|
|
color: #ff5500;
|
|
font-size: 2.5rem;
|
|
font-weight: bold;
|
|
text-transform: uppercase;
|
|
letter-spacing: 3px;
|
|
text-align: center;
|
|
margin-bottom: 20px;
|
|
text-shadow: 0 0 10px rgba(255, 85, 0, 0.5);
|
|
transition: color 0.3s ease;
|
|
}
|
|
|
|
.site-header:hover {
|
|
color: #ff3300;
|
|
}
|
|
|
|
/* Search box styling */
|
|
.search-container {
|
|
position: relative;
|
|
width: 100%;
|
|
max-width: 500px;
|
|
margin: 0 auto 20px;
|
|
}
|
|
|
|
.search-input {
|
|
background-color: #222;
|
|
border: 1px solid #444;
|
|
color: white;
|
|
border-radius: 4px;
|
|
padding: 8px 12px;
|
|
width: 100%;
|
|
transition: border-color 0.3s ease;
|
|
}
|
|
|
|
.search-input:focus {
|
|
border-color: #ff5500;
|
|
outline: none;
|
|
box-shadow: 0 0 5px rgba(255, 85, 0, 0.3);
|
|
}
|
|
|
|
.search-results {
|
|
position: absolute;
|
|
top: 100%;
|
|
left: 0;
|
|
right: 0;
|
|
background-color: #222;
|
|
border: 1px solid #444;
|
|
border-radius: 4px;
|
|
max-height: 300px;
|
|
overflow-y: auto;
|
|
z-index: 1000;
|
|
display: none;
|
|
margin-top: 5px;
|
|
}
|
|
|
|
.search-results.show {
|
|
display: block;
|
|
}
|
|
|
|
.search-result-item {
|
|
padding: 10px;
|
|
color: white;
|
|
cursor: pointer;
|
|
transition: background-color 0.2s ease;
|
|
}
|
|
|
|
.search-result-item:hover {
|
|
background-color: #ff5500;
|
|
}
|
|
|
|
.search-result-item small {
|
|
color: #aaa;
|
|
display: block;
|
|
}
|
|
|
|
/* Adjust container padding */
|
|
.container {
|
|
padding-top: 30px;
|
|
padding-bottom: 30px;
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body>
|
|
<div class="container mt-5">
|
|
<h1 class="site-header">Raven Scott Music</h1>
|
|
<div class="search-container">
|
|
<input type="text" class="search-input" placeholder="Search tracks..." aria-label="Search tracks">
|
|
<div class="search-results" id="search-results"></div>
|
|
</div>
|
|
<div class="card text-center">
|
|
<div class="card-body">
|
|
<h1 class="card-title">
|
|
<%= track.title %>
|
|
</h1>
|
|
<iframe width="100%" height="166" scrolling="no" frameborder="no" allow="autoplay"
|
|
src="https://w.soundcloud.com/player/?url=<%= track.url %>&color=%23ff5500&auto_play=false&show_artwork=true">
|
|
</iframe>
|
|
<p class="card-text">
|
|
<%- (track.description && track.description.trim()) ? track.description.replace(/\n/g, '<br>' )
|
|
: 'No description available for this track.' %>
|
|
<br>
|
|
<a id="back-button" class="btn btn-primary mt-3">Back</a>
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
|
|
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.5.4/dist/umd/popper.min.js"></script>
|
|
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
|
|
<script>
|
|
// Set back button href based on URL genre
|
|
const backButton = document.getElementById('back-button');
|
|
const pathSegments = window.location.pathname.split('/').filter(segment => segment);
|
|
const genre = pathSegments[0]; // URL is /:genre/track/:slug, so first segment is genre
|
|
if (genre) {
|
|
backButton.href = `/${genre}`;
|
|
console.log(`Set back button href to /${genre}`);
|
|
} else {
|
|
backButton.href = '/'; // Fallback to home page
|
|
console.warn('Genre not detected in URL, falling back to /');
|
|
}
|
|
|
|
// Search functionality
|
|
const searchInput = document.querySelector('.search-input');
|
|
const searchResults = document.getElementById('search-results');
|
|
const searchContainer = document.querySelector('.search-container');
|
|
let allTracks = [];
|
|
const genres = ['metal', 'altrock', 'rap', 'lofi', 'edm', 'cuts'];
|
|
|
|
// Fetch all tracks from all genres
|
|
async function fetchAllTracks() {
|
|
try {
|
|
const fetchPromises = genres.map(genre =>
|
|
fetch(`/json/${genre}`)
|
|
.then(res => res.json())
|
|
.then(tracks => tracks.map(track => ({ ...track, genre })))
|
|
);
|
|
const tracksArrays = await Promise.all(fetchPromises);
|
|
allTracks = tracksArrays.flat();
|
|
console.log(`Fetched ${allTracks.length} tracks across all genres`);
|
|
} catch (err) {
|
|
console.error('Error fetching tracks:', err);
|
|
}
|
|
}
|
|
|
|
// Initialize tracks on page load
|
|
fetchAllTracks();
|
|
|
|
// Debounce function to limit search frequency
|
|
function debounce(func, wait) {
|
|
let timeout;
|
|
return function executedFunction(...args) {
|
|
const later = () => {
|
|
clearTimeout(timeout);
|
|
func(...args);
|
|
};
|
|
clearTimeout(timeout);
|
|
timeout = setTimeout(later, wait);
|
|
};
|
|
}
|
|
|
|
// Handle search
|
|
const performSearch = debounce(() => {
|
|
const query = searchInput.value.trim().toLowerCase();
|
|
searchResults.innerHTML = '';
|
|
if (query.length < 2) {
|
|
searchResults.classList.remove('show');
|
|
return;
|
|
}
|
|
|
|
const filteredTracks = allTracks.filter(track =>
|
|
track.title.toLowerCase().includes(query) ||
|
|
(track.description && track.description.toLowerCase().includes(query))
|
|
);
|
|
|
|
if (filteredTracks.length === 0) {
|
|
searchResults.innerHTML = '<div class="search-result-item">No results found</div>';
|
|
} else {
|
|
filteredTracks.forEach(track => {
|
|
const resultItem = document.createElement('div');
|
|
resultItem.className = 'search-result-item';
|
|
resultItem.innerHTML = `
|
|
${track.title}
|
|
<small>${track.genre.charAt(0).toUpperCase() + track.genre.slice(1)}</small>
|
|
`;
|
|
resultItem.addEventListener('click', () => {
|
|
window.location.href = `/${track.genre}/track/${track.slug}`;
|
|
});
|
|
searchResults.appendChild(resultItem);
|
|
});
|
|
}
|
|
|
|
searchResults.classList.add('show');
|
|
}, 300);
|
|
|
|
// Search input event listener
|
|
searchInput.addEventListener('input', performSearch);
|
|
|
|
// Hide search results when clicking outside
|
|
document.addEventListener('click', (e) => {
|
|
if (!searchContainer.contains(e.target)) {
|
|
searchResults.classList.remove('show');
|
|
}
|
|
});
|
|
|
|
// Show search results when clicking input
|
|
searchInput.addEventListener('focus', () => {
|
|
if (searchInput.value.trim().length >= 2) {
|
|
performSearch();
|
|
}
|
|
});
|
|
</script>
|
|
</body>
|
|
|
|
</html> |