Organized all the code

Updated the update notification to check periodically every 5 minutes
Added in headless browser support for extensions (check the extensions repo to see an example)
Added in DiscordRPC support
This commit is contained in:
2025-11-19 16:28:33 -05:00
parent 2f556c2ddc
commit 5f3020ca6e
24 changed files with 1077 additions and 815 deletions

View File

@@ -0,0 +1,52 @@
import { loadFavorites } from '../favorites/favorites-loader.js';
export function showPage(pageId, domRefs, callbacks, state) {
const {
browseButton,
favoritesButton,
settingsButton,
pageTitle,
headerContext,
favoritesGallery
} = domRefs;
const { updateHeader, applyLayoutToGallery, createImageCard } = callbacks;
const { currentLayout } = state;
document.querySelectorAll('.page').forEach((page) => {
page.classList.add('hidden');
});
document.querySelectorAll('.nav-button').forEach((tab) => {
tab.classList.remove('bg-indigo-600', 'text-white');
tab.classList.add('text-gray-400', 'hover:bg-gray-700');
});
const activePage = document.getElementById(pageId);
if (activePage) {
activePage.classList.remove('hidden');
}
let activeTab;
if (pageId === 'browse-page') {
activeTab = browseButton;
pageTitle.textContent = 'Browse';
updateHeader();
} else if (pageId === 'favorites-page') {
activeTab = favoritesButton;
pageTitle.textContent = 'Favorites';
headerContext.textContent = '';
loadFavorites(favoritesGallery, currentLayout, applyLayoutToGallery, createImageCard);
} else if (pageId === 'settings-page') {
activeTab = settingsButton;
pageTitle.textContent = 'Settings';
headerContext.textContent = '';
}
if (activeTab) {
activeTab.classList.add('bg-indigo-600', 'text-white');
activeTab.classList.remove('text-gray-400', 'hover:bg-gray-700');
}
}