Spaces:
Running
Running
| document.addEventListener('DOMContentLoaded', () => { | |
| // Initialize tooltips for icons | |
| const initTooltips = () => { | |
| const buttons = document.querySelectorAll('button'); | |
| buttons.forEach(button => { | |
| const icon = button.querySelector('[data-feather]'); | |
| if (icon) { | |
| const iconName = icon.getAttribute('data-feather'); | |
| button.setAttribute('title', iconName.charAt(0).toUpperCase() + iconName.slice(1)); | |
| } | |
| }); | |
| }; | |
| // Handle microphone functionality | |
| const setupMicrophone = () => { | |
| const micButton = document.querySelector('#btnMic'); | |
| if (!micButton) return; | |
| micButton.addEventListener('click', async () => { | |
| try { | |
| const stream = await navigator.mediaDevices.getUserMedia({ audio: true }); | |
| // Here you would typically connect to a speech recognition API | |
| alert('Microphone access granted. Speech recognition would be implemented here.'); | |
| stream.getTracks().forEach(track => track.stop()); | |
| } catch (error) { | |
| console.error('Error accessing microphone:', error); | |
| alert('Could not access microphone. Please check permissions.'); | |
| } | |
| }); | |
| }; | |
| // Initialize everything | |
| feather.replace(); | |
| initTooltips(); | |
| setupMicrophone(); | |
| }); | |
| // Toast notification utility | |
| export function toast(msg) { | |
| const t = document.createElement("div"); | |
| t.textContent = msg; | |
| t.style.position="fixed"; | |
| t.style.left="50%"; | |
| t.style.bottom="18px"; | |
| t.style.transform="translateX(-50%)"; | |
| t.style.padding="10px 12px"; | |
| t.style.borderRadius="14px"; | |
| t.style.border="1px solid rgba(255,255,255,.12)"; | |
| t.style.background="rgba(0,0,0,.55)"; | |
| t.style.backdropFilter="blur(8px)"; | |
| t.style.color="rgba(232,238,252,.95)"; | |
| t.style.fontSize="13px"; | |
| t.style.boxShadow="0 10px 24px rgba(0,0,0,.35)"; | |
| t.style.zIndex=9999; | |
| document.body.appendChild(t); | |
| setTimeout(()=>{ t.style.opacity="0"; t.style.transition="opacity .2s"; }, 1100); | |
| setTimeout(()=> t.remove(), 1400); | |
| } | |