/** * GoingsOn - Unified Namespace * Central namespace for the entire application, reducing window pollution */ // ============ Main Namespace ============ window.GoingsOn = { // Namespace version for debugging version: '1.0.0', // ============ State Module (populated by state.js) ============ state: null, // ============ API Module (populated by api.js) ============ api: null, // ============ Utilities (populated by utils.js) ============ utils: {}, // ============ UI Components (populated by components.js) ============ ui: {}, // ============ Domain Modules ============ projects: {}, tasks: {}, events: {}, emails: {}, // ============ Feature Modules ============ dayPlan: {}, snooze: {}, search: {}, navigation: {}, // ============ Facades for Cross-Module Access ============ /** * Get projects cache from centralized state * @returns {Array} Projects array */ getProjectsCache: function() { return this.state?.projects || []; }, /** * Get current project ID * @returns {string|null} */ getCurrentProjectId: function() { return this.state?.currentProjectId ?? null; }, /** * Get tasks cache from centralized state * @returns {Array} Tasks array */ getTasksCache: function() { return this.state?.tasks || []; }, /** * Get emails cache from centralized state * @returns {Array} Emails array */ getEmailsCache: function() { return this.state?.emails || []; }, /** * Get email accounts cache from centralized state * @returns {Array} Email accounts array */ getEmailAccountsCache: function() { return this.state?.emailAccounts || []; }, /** * Get current view name * @returns {string} */ getCurrentView: function() { if (this.navigation?.getCurrentView) return this.navigation.getCurrentView(); return this.state?.currentView || 'projects'; }, // ============ Handle Helper for onclick ============ /** * Universal handler for onclick attributes * Usage: onclick="GoingsOn.handle('tasks.openNew')" * @param {string} path - Dot-separated path to function (e.g., 'tasks.openNew') * @param {...*} args - Arguments to pass to the function */ handle: function(path, ...args) { const parts = path.split('.'); let target = this; for (const part of parts) { if (target && typeof target === 'object' && part in target) { target = target[part]; } else { console.error(`GoingsOn.handle: Path "${path}" not found at "${part}"`); return; } } if (typeof target === 'function') { return target.apply(this, args); } else { console.error(`GoingsOn.handle: "${path}" is not a function`); } } };