Spaces:
Running
Running
| // Theme management functionality | |
| document.addEventListener('DOMContentLoaded', function() { | |
| console.log('NetMind Nexus Hub initialized'); | |
| // Available themes from Vector35 community | |
| const themes = [ | |
| { name: 'Default Light', id: 'default-light', type: 'light' }, | |
| { name: 'Default Dark', id: 'default-dark', type: 'dark' }, | |
| { name: 'Solarized Light', id: 'solarized-light', type: 'light' }, | |
| { name: 'Solarized Dark', id: 'solarized-dark', type: 'dark' }, | |
| { name: 'Dracula', id: 'dracula', type: 'dark' }, | |
| { name: 'Nord', id: 'nord', type: 'dark' }, | |
| { name: 'GitHub', id: 'github', type: 'light' }, | |
| { name: 'Monokai', id: 'monokai', type: 'dark' } | |
| ]; | |
| // Initialize theme | |
| function initTheme() { | |
| const savedTheme = localStorage.getItem('theme'); | |
| const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches; | |
| if (savedTheme) { | |
| applyTheme(savedTheme); | |
| } else { | |
| // Auto-detect system preference | |
| const defaultTheme = prefersDark ? 'default-dark' : 'default-light'; | |
| applyTheme(defaultTheme); | |
| } | |
| } | |
| // Apply theme to the page | |
| function applyTheme(themeId) { | |
| const theme = themes.find(t => t.id === themeId) || themes[0]; | |
| // Remove all theme classes | |
| document.body.classList.remove('light-theme', 'dark-theme'); | |
| themes.forEach(t => document.body.classList.remove(t.id)); | |
| // Add selected theme class | |
| document.body.classList.add(theme.id); | |
| document.body.classList.add(`${theme.type}-theme`); | |
| // Update theme selector | |
| const themeSelect = document.getElementById('themeSelect'); | |
| if (themeSelect) { | |
| themeSelect.value = themeId; | |
| } | |
| // Save to localStorage | |
| localStorage.setItem('theme', themeId); | |
| localStorage.setItem('themeType', theme.type); | |
| } | |
| // Initialize theme selector dropdown | |
| function initThemeSelector() { | |
| const themeSelect = document.getElementById('themeSelect'); | |
| if (!themeSelect) return; | |
| // Populate dropdown | |
| themes.forEach(theme => { | |
| const option = document.createElement('option'); | |
| option.value = theme.id; | |
| option.textContent = theme.name; | |
| themeSelect.appendChild(option); | |
| }); | |
| // Set current theme | |
| const currentTheme = localStorage.getItem('theme') || | |
| (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'default-dark' : 'default-light'); | |
| themeSelect.value = currentTheme; | |
| // Listen for changes | |
| themeSelect.addEventListener('change', (e) => { | |
| applyTheme(e.target.value); | |
| }); | |
| } | |
| // Listen for system theme changes | |
| window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', e => { | |
| if (!localStorage.getItem('theme')) { | |
| applyTheme(e.matches ? 'default-dark' : 'default-light'); | |
| } | |
| }); | |
| // Initialize everything | |
| initTheme(); | |
| initThemeSelector(); | |
| }); | |
| // Function to load Tiddlers (content items) | |
| function loadTiddlers(category) { | |
| // This would be replaced with actual TiddlyWiki integration | |
| console.log(`Loading tiddlers for category: ${category}`); | |
| } | |
| // Function to create a new note/project | |
| function createNewItem(type) { | |
| console.log(`Creating new ${type}`); | |
| // Implementation would open a modal or new page for content creation | |
| } |