added channel/profile view

This commit is contained in:
2025-02-09 14:51:20 -05:00
parent 8939f52f20
commit f9d81ecb24
7 changed files with 573 additions and 95 deletions

View File

@@ -1,7 +1,9 @@
// js/viewManager.js
import { initChannelProfileView } from "./channelProfile.js";
// Load a partial view by URL into the #viewContainer
// js/viewManager.js
/**
* Load a partial view by URL into the #viewContainer.
*/
export async function loadView(viewUrl) {
try {
const res = await fetch(viewUrl);
@@ -10,14 +12,14 @@ export async function loadView(viewUrl) {
}
const text = await res.text();
// DOMParser, parse out the body, inject
// Use a DOMParser to extract the body contents
const parser = new DOMParser();
const doc = parser.parseFromString(text, "text/html");
const container = document.getElementById("viewContainer");
container.innerHTML = doc.body.innerHTML;
// Now copy and execute each script
// Copy and execute any inline scripts
const scriptTags = doc.querySelectorAll("script");
scriptTags.forEach((oldScript) => {
const newScript = document.createElement("script");
@@ -34,13 +36,16 @@ export async function loadView(viewUrl) {
}
}
/**
* Registry of view-specific initialization functions.
*/
export const viewInitRegistry = {
"most-recent-videos": () => {
if (window.app && window.app.loadVideos) {
window.app.videoList = document.getElementById("videoList");
window.app.loadVideos();
}
// Force the profiles to update after the new view is in place.
// Force profile updates after the new view is in place.
if (window.app && window.app.forceRefreshAllProfiles) {
window.app.forceRefreshAllProfiles();
}
@@ -51,5 +56,8 @@ export const viewInitRegistry = {
subscriptions: () => {
console.log("Subscriptions view loaded.");
},
// Add additional view-specific functions here as needed.
"channel-profile": () => {
// Call the initialization function from channelProfile.js
initChannelProfileView();
}
};