jblast94 commited on
Commit
ccd5ef3
·
verified ·
1 Parent(s): 9d8ff21

make this site oerational for previewing

Browse files
Files changed (3) hide show
  1. components/navbar.js +10 -4
  2. index.html +14 -7
  3. script.js +55 -59
components/navbar.js CHANGED
@@ -70,7 +70,13 @@ class CustomNavbar extends HTMLElement {
70
  </div>
71
 
72
  <div class="actions">
73
- <button class="action-btn" id="screen-share-btn" title="Share Screen">
74
- <i data-feather="monitor"></i>
75
- </button>
76
- <button
 
 
 
 
 
 
 
70
  </div>
71
 
72
  <div class="actions">
73
+ <button class="action-btn" id="voice-btn" title="Voice Input">
74
+ <i data-feather="mic"></i>
75
+ </button>
76
+ <span id="voice-status" class="text-xs"></span>
77
+ <button class="action-btn" id="screen-share-btn" title="Share Screen">
78
+ <i data-feather="monitor"></i>
79
+ </button>
80
+ <button class="dark-mode-toggle action-btn" id="dark-mode-toggle" title="Toggle Dark Mode">
81
+ <i data-feather="moon"></i>
82
+ </button>
index.html CHANGED
@@ -34,13 +34,20 @@
34
  </div>
35
  </div>
36
  <script src="script.js"></script>
37
- <script>
38
- feather.replace();
39
- // Initialize Supabase
40
- const supabaseUrl = 'https://your-project.supabase.co';
41
- const supabaseKey = 'your-anon-key';
42
- const supabase = window.supabase.createClient(supabaseUrl, supabaseKey);
43
- </script>
 
 
 
 
 
 
 
44
  <script src="https://huggingface.co/deepsite/deepsite-badge.js"></script>
45
  </body>
46
  </html>
 
34
  </div>
35
  </div>
36
  <script src="script.js"></script>
37
+ <script>
38
+ feather.replace();
39
+ // Mock Supabase client for preview
40
+ window.supabase = {
41
+ from: () => ({
42
+ select: () => Promise.resolve({ data: [], error: null }),
43
+ insert: () => Promise.resolve({ error: null }),
44
+ on: () => ({ subscribe: () => {} })
45
+ }),
46
+ channel: () => ({
47
+ on: () => ({ subscribe: () => {} })
48
+ })
49
+ };
50
+ </script>
51
  <script src="https://huggingface.co/deepsite/deepsite-badge.js"></script>
52
  </body>
53
  </html>
script.js CHANGED
@@ -44,25 +44,18 @@ function initVoiceControls() {
44
  }
45
  });
46
  }
47
-
48
  async function processVoiceInput(audioBlob) {
49
- // Send to RunPod TTS endpoint
50
- const formData = new FormData();
51
- formData.append('audio', audioBlob);
52
-
53
- try {
54
- const response = await fetch('YOUR_RUNPOD_ENDPOINT', {
55
- method: 'POST',
56
- body: formData
57
- });
58
-
59
- const { text } = await response.json();
60
- await sendMessage(text);
61
- } catch (err) {
62
- console.error('Error processing voice input:', err);
63
- }
64
  }
65
-
66
  function initScreenShare() {
67
  const screenShareBtn = document.getElementById('screen-share-btn');
68
 
@@ -89,36 +82,26 @@ function initScreenShare() {
89
  }
90
  });
91
  }
92
-
93
  async function initChat() {
94
- // Load chat history from Supabase
95
- const { data: messages, error } = await supabase
96
- .from('messages')
97
- .select('*')
98
- .order('created_at', { ascending: true });
99
-
100
- if (!error && messages) {
101
- const chatContainer = document.getElementById('chat-container');
102
- messages.forEach(msg => {
103
- const messageElement = createMessageElement(msg);
104
- chatContainer.appendChild(messageElement);
105
- });
106
- }
107
 
108
- // Subscribe to new messages
109
- supabase
110
- .channel('messages')
111
- .on('postgres_changes', {
112
- event: 'INSERT',
113
- schema: 'public',
114
- table: 'messages'
115
- }, (payload) => {
116
- const messageElement = createMessageElement(payload.new);
117
- document.getElementById('chat-container').appendChild(messageElement);
118
- })
119
- .subscribe();
120
  }
121
-
122
  function createMessageElement(message) {
123
  const messageDiv = document.createElement('div');
124
  messageDiv.className = `message mb-4 p-3 rounded-lg max-w-3/4 ${
@@ -143,20 +126,33 @@ function createMessageElement(message) {
143
  feather.replace({ scope: messageDiv });
144
  return messageDiv;
145
  }
146
-
147
  async function sendMessage(content) {
148
- const { error } = await supabase
149
- .from('messages')
150
- .insert([{ content, is_user: true }]);
151
 
152
- if (!error) {
153
- // Trigger n8n workflow for AI response
154
- await fetch('YOUR_N8N_WORKFLOW_URL', {
155
- method: 'POST',
156
- headers: {
157
- 'Content-Type': 'application/json'
158
- },
159
- body: JSON.stringify({ message: content })
160
- });
161
- }
162
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  }
45
  });
46
  }
 
47
  async function processVoiceInput(audioBlob) {
48
+ // Mock voice processing for preview
49
+ const mockResponses = [
50
+ "Hello! How can I help you today?",
51
+ "I'm an AI assistant here to answer your questions.",
52
+ "The weather looks nice today, isn't it?",
53
+ "Would you like me to search for something?",
54
+ "I can help with various topics including technology, science, and more."
55
+ ];
56
+ const randomResponse = mockResponses[Math.floor(Math.random() * mockResponses.length)];
57
+ await sendMessage(randomResponse);
 
 
 
 
 
58
  }
 
59
  function initScreenShare() {
60
  const screenShareBtn = document.getElementById('screen-share-btn');
61
 
 
82
  }
83
  });
84
  }
 
85
  async function initChat() {
86
+ // Load mock chat history for preview
87
+ const mockMessages = [
88
+ {
89
+ content: "Welcome to ChatVerse!",
90
+ is_user: false,
91
+ created_at: new Date().toISOString()
92
+ },
93
+ {
94
+ content: "Try sending a message or using voice input",
95
+ is_user: false,
96
+ created_at: new Date().toISOString()
97
+ }
98
+ ];
99
 
100
+ const chatContainer = document.getElementById('chat-container');
101
+ mockMessages.forEach(msg => {
102
+ chatContainer.appendChild(createMessageElement(msg));
103
+ });
 
 
 
 
 
 
 
 
104
  }
 
105
  function createMessageElement(message) {
106
  const messageDiv = document.createElement('div');
107
  messageDiv.className = `message mb-4 p-3 rounded-lg max-w-3/4 ${
 
126
  feather.replace({ scope: messageDiv });
127
  return messageDiv;
128
  }
 
129
  async function sendMessage(content) {
130
+ // Mock message sending for preview
131
+ const chatContainer = document.getElementById('chat-container');
 
132
 
133
+ // Add user message
134
+ const userMsg = {
135
+ content,
136
+ is_user: true,
137
+ created_at: new Date().toISOString()
138
+ };
139
+ chatContainer.appendChild(createMessageElement(userMsg));
140
+
141
+ // Add mock AI response after delay
142
+ setTimeout(async () => {
143
+ const mockResponses = [
144
+ "I understand you're asking about " + content,
145
+ "That's an interesting question about " + content,
146
+ "Let me think about " + content,
147
+ "I can help with " + content,
148
+ content + " is something I know about."
149
+ ];
150
+ const aiMsg = {
151
+ content: mockResponses[Math.floor(Math.random() * mockResponses.length)],
152
+ is_user: false,
153
+ created_at: new Date().toISOString()
154
+ };
155
+ chatContainer.appendChild(createMessageElement(aiMsg));
156
+ chatContainer.scrollTop = chatContainer.scrollHeight;
157
+ }, 1000);
158
+ }