consolidation

This commit is contained in:
overcuriousity
2025-07-25 15:48:04 +02:00
parent f21d5b33e3
commit 6e5ea011e0
3 changed files with 122 additions and 29 deletions

View File

@@ -70,14 +70,12 @@ const { title, description = 'CC24-Guide - A comprehensive directory of digital
}
});
// Make theme utils available globally
(window as any).themeUtils = {
initTheme,
toggleTheme,
getStoredTheme
};
// Tool helper functions (consolidated from toolHelpers.ts)
function createToolSlug(toolName) {
if (!toolName || typeof toolName !== 'string') {
console.warn('[toolHelpers] Invalid toolName provided to createToolSlug:', toolName);
@@ -107,6 +105,12 @@ const { title, description = 'CC24-Guide - A comprehensive directory of digital
tool.projectUrl.trim() !== "";
}
// FIXED: Use type assertions to avoid TypeScript errors
// Make functions available globally for existing code compatibility
(window as any).createToolSlug = createToolSlug;
(window as any).findToolByIdentifier = findToolByIdentifier;
(window as any).isToolHosted = isToolHosted;
// Client-side auth functions (consolidated from client-auth.js)
async function checkClientAuth() {
try {
@@ -157,6 +161,7 @@ const { title, description = 'CC24-Guide - A comprehensive directory of digital
document.addEventListener('click', async (e) => {
if (!e.target) return;
// FIXED: Properly cast EventTarget to Element for closest() method
const button = (e.target as Element).closest(selector);
if (!button) return;
@@ -171,10 +176,7 @@ const { title, description = 'CC24-Guide - A comprehensive directory of digital
});
}
// Make functions available globally
(window as any).createToolSlug = createToolSlug;
(window as any).findToolByIdentifier = findToolByIdentifier;
(window as any).isToolHosted = isToolHosted;
// Make auth functions available globally
(window as any).checkClientAuth = checkClientAuth;
(window as any).requireClientAuth = requireClientAuth;
(window as any).showIfAuthenticated = showIfAuthenticated;
@@ -184,7 +186,6 @@ const { title, description = 'CC24-Guide - A comprehensive directory of digital
initTheme();
setupAuthButtons('[data-contribute-button]');
// Initialize AI button visibility (moved from ToolFilters.astro to avoid race condition)
const initAIButton = async () => {
await showIfAuthenticated('#ai-view-toggle');
};