// This code provides a foundation for a website that allows anyone to generate a personalized "TV" page by supplying: // - A YouTube Playlist ID // - A name (used to generate {name}TV) // - A description // // ✅ Users receive a **shareable link** to their generated page in the format: https://agedaily.com/{username}TV // ✅ No user registration or login is required. // ------------------------- // Frontend Code // ------------------------- // Handle form submission to generate the custom TV page document.addEventListener('DOMContentLoaded', () => { const form = document.getElementById('channel-form'); form.addEventListener('submit', (e) => { e.preventDefault(); const username = document.getElementById('username').value.trim(); const playlistId = document.getElementById('playlistId').value.trim(); const description = document.getElementById('description').value.trim(); if (!username || !playlistId || !description) { alert('Please fill in all fields.'); return; } const channelSlug = `${username}TV`.replace(/\s+/g, ''); const generatedURL = `${window.location.origin}/${channelSlug}?playlistId=${encodeURIComponent(playlistId)}&description=${encodeURIComponent(description)}`; // Display the shareable link document.getElementById('shareable-link').innerHTML = `
Your TV page is ready!
${generatedURL} `; }); }); // ------------------------- // Channel Page Code (channel.html) // ------------------------- // This code should be placed on the channel page template (e.g., channel.html) to render the user's TV page. // Function to get URL parameters function getURLParameter(name) { return new URLSearchParams(window.location.search).get(name); } // Generate the custom channel page based on URL parameters function generateChannelPageFromURL() { const urlParts = window.location.pathname.split('/'); const usernameSlug = urlParts[urlParts.length - 1].replace('TV', ''); const playlistId = getURLParameter('playlistId'); const description = getURLParameter('description'); if (!usernameSlug || !playlistId || !description) { document.body.innerHTML = 'Invalid or missing data. Please go back and create your TV page.
'; return; } document.body.innerHTML = `${decodeURIComponent(description)}