Spaces:
Running
Running
Update scripts/ui.js
Browse files- scripts/ui.js +13 -96
scripts/ui.js
CHANGED
|
@@ -1,108 +1,25 @@
|
|
| 1 |
// scripts/ui.js
|
| 2 |
|
| 3 |
-
// --- DOM Element Getters ---
|
| 4 |
const getElement = (id) => document.getElementById(id);
|
| 5 |
|
| 6 |
-
|
| 7 |
-
const streamingData = [
|
| 8 |
-
// ... (keep the full streamingData array here)
|
| 9 |
-
];
|
| 10 |
-
const rssFeedData = {
|
| 11 |
-
// ... (keep the full rssFeedData object here)
|
| 12 |
-
};
|
| 13 |
-
|
| 14 |
-
// --- Functions ---
|
| 15 |
-
|
| 16 |
-
function showNotification(title, message) {
|
| 17 |
-
const notification = getElement('notification');
|
| 18 |
-
getElement('notification-title').textContent = title;
|
| 19 |
-
getElement('notification-message').textContent = message;
|
| 20 |
-
|
| 21 |
-
notification.classList.remove('hidden');
|
| 22 |
-
notification.classList.add('show');
|
| 23 |
-
|
| 24 |
-
setTimeout(() => {
|
| 25 |
-
notification.classList.remove('show');
|
| 26 |
-
setTimeout(() => notification.classList.add('hidden'), 300);
|
| 27 |
-
}, 3000);
|
| 28 |
-
}
|
| 29 |
-
|
| 30 |
-
function saveShow(title, broadcastTime) {
|
| 31 |
-
console.log(`Saved show: ${title}`);
|
| 32 |
-
showNotification("Reminder Set!", `We'll notify you when "${title}" is about to broadcast.`);
|
| 33 |
-
|
| 34 |
-
if (broadcastTime) {
|
| 35 |
-
const broadcastDate = new Date(broadcastTime);
|
| 36 |
-
const now = new Date();
|
| 37 |
-
if (broadcastDate > now) {
|
| 38 |
-
const timeUntilBroadcast = broadcastDate - now;
|
| 39 |
-
setTimeout(() => {
|
| 40 |
-
showNotification("Starting Soon!", `"${title}" will begin broadcasting in 30 minutes!`);
|
| 41 |
-
}, timeUntilBroadcast - (30 * 60 * 1000));
|
| 42 |
-
}
|
| 43 |
-
}
|
| 44 |
-
}
|
| 45 |
-
|
| 46 |
-
function loadRecommendations(filter = 'all') {
|
| 47 |
const container = getElement('recommendations-container');
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
filteredData.forEach(item => {
|
| 53 |
-
const card = document.createElement('div');
|
| 54 |
-
card.className = 'stream-card bg-white rounded-lg overflow-hidden shadow-md hover:shadow-xl transition duration-300 fade-in p-4';
|
| 55 |
-
// ... (keep the card.innerHTML logic here)
|
| 56 |
-
container.appendChild(card);
|
| 57 |
-
});
|
| 58 |
-
}
|
| 59 |
-
|
| 60 |
-
function loadRSSFeed(filter) {
|
| 61 |
-
const container = getElement('rss-feed');
|
| 62 |
-
container.innerHTML = '';
|
| 63 |
-
const feedItems = rssFeedData[filter] || rssFeedData.all;
|
| 64 |
-
feedItems.forEach(item => {
|
| 65 |
-
const feedItem = document.createElement('div');
|
| 66 |
-
// ... (keep the rss item creation logic here)
|
| 67 |
-
container.appendChild(feedItem);
|
| 68 |
-
});
|
| 69 |
-
}
|
| 70 |
-
|
| 71 |
-
function setupTab(tabId, sectionId) {
|
| 72 |
-
getElement(tabId).addEventListener('click', () => {
|
| 73 |
-
// Deactivate all tabs and hide all sections
|
| 74 |
-
document.querySelectorAll('.tab').forEach(t => t.classList.replace('active', 'inactive'));
|
| 75 |
-
document.querySelectorAll('.production-panel > div[id$="-section"]').forEach(s => s.classList.add('hidden'));
|
| 76 |
-
|
| 77 |
-
// Activate the selected tab and show the corresponding section
|
| 78 |
-
getElement(tabId).classList.replace('inactive', 'active');
|
| 79 |
-
getElement(sectionId).classList.remove('hidden');
|
| 80 |
-
});
|
| 81 |
}
|
| 82 |
|
| 83 |
-
// --- Initialization ---
|
| 84 |
-
|
| 85 |
export function initUI() {
|
| 86 |
-
|
| 87 |
-
|
| 88 |
|
| 89 |
-
//
|
| 90 |
-
|
| 91 |
-
getElement('production-panel').classList.toggle('open');
|
| 92 |
-
});
|
| 93 |
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
document.querySelectorAll('.rss-filter-btn').forEach(b => b.classList.replace('bg-indigo-100', 'bg-gray-100'));
|
| 98 |
-
this.classList.replace('bg-gray-100', 'bg-indigo-100');
|
| 99 |
-
loadRSSFeed(this.dataset.filter);
|
| 100 |
});
|
| 101 |
-
}
|
| 102 |
-
|
| 103 |
-
// Setup production panel tabs
|
| 104 |
-
setupTab('record-tab', 'record-section');
|
| 105 |
-
setupTab('edit-tab', 'edit-section');
|
| 106 |
-
setupTab('share-tab', 'share-section');
|
| 107 |
-
setupTab('rank-tab', 'rank-section');
|
| 108 |
}
|
|
|
|
| 1 |
// scripts/ui.js
|
| 2 |
|
|
|
|
| 3 |
const getElement = (id) => document.getElementById(id);
|
| 4 |
|
| 5 |
+
function loadRecommendations() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
const container = getElement('recommendations-container');
|
| 7 |
+
// The error happened here. Now the container should be found.
|
| 8 |
+
if (container) {
|
| 9 |
+
container.innerHTML = '<p>Recommendations will appear here soon...</p>';
|
| 10 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
}
|
| 12 |
|
|
|
|
|
|
|
| 13 |
export function initUI() {
|
| 14 |
+
const productionButton = getElement('production-button');
|
| 15 |
+
const productionPanel = getElement('production-panel');
|
| 16 |
|
| 17 |
+
// This will run our function on page load
|
| 18 |
+
loadRecommendations();
|
|
|
|
|
|
|
| 19 |
|
| 20 |
+
if (productionButton && productionPanel) {
|
| 21 |
+
productionButton.addEventListener('click', () => {
|
| 22 |
+
productionPanel.classList.toggle('open');
|
|
|
|
|
|
|
|
|
|
| 23 |
});
|
| 24 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
}
|