File size: 1,994 Bytes
d225191
6f4b8e1
d225191
 
 
 
 
 
 
 
 
 
 
6f4b8e1
d225191
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6f4b8e1
d225191
 
 
 
6f4b8e1
 
d225191
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60

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);
}