Ahmad140 commited on
Commit
fce760b
·
verified ·
1 Parent(s): 0ddb3c8

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +21 -34
index.html CHANGED
@@ -3,10 +3,9 @@
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>AI Chatbot</title>
7
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
8
  <style>
9
- /* same CSS as before, copy from your previous code */
10
  * { margin: 0; padding: 0; box-sizing: border-box; }
11
  body { background: white; height: 100vh; width: 100%; }
12
  .chat-icon { position: fixed; bottom: 25px; right: 25px; width: 60px; height: 60px; background-color: #25D366; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; box-shadow: 0 4px 12px rgba(0,0,0,0.2); transition: 0.3s; z-index: 1000; }
@@ -34,11 +33,11 @@
34
  </div>
35
  <div class="chat-modal" id="chatModal">
36
  <div class="chat-header">
37
- <span>AI Assistant 🤖</span>
38
  <button class="close-btn" id="closeChat"><i class="fas fa-times"></i></button>
39
  </div>
40
  <div class="chat-messages" id="chatMessages">
41
- <div class="message bot-msg">Assalam-o-Alaikum! Main aapki madad kaise kar sakta hoon?</div>
42
  <div id="defaultQuestionsContainer" class="questions-container"></div>
43
  </div>
44
  <div class="chat-input-area">
@@ -47,15 +46,14 @@
47
  </div>
48
  </div>
49
  <script>
50
- // Flask API endpoint (same origin)
51
  const API_URL = "/api/chat";
52
  const DEFAULT_QUESTIONS = [
53
- "Mera order status kya hai?",
54
- "Main refund kaise le sakta hoon?",
55
  "Aapke contact number kya hai?",
56
- "Product ka warranty kitne saal ki hai?",
57
- "Shipping charges kitne hain?",
58
- "Kya aap COD provide karte hain?"
 
 
59
  ];
60
 
61
  const chatIcon = document.getElementById('chatIcon');
@@ -68,23 +66,20 @@
68
 
69
  function renderQuestionBubbles() {
70
  questionsContainer.innerHTML = '';
71
- DEFAULT_QUESTIONS.forEach(question => {
72
  const bubble = document.createElement('div');
73
  bubble.className = 'question-bubble';
74
- bubble.innerText = question;
75
- bubble.onclick = () => {
76
- userInput.value = question;
77
- sendMessage();
78
- };
79
  questionsContainer.appendChild(bubble);
80
  });
81
  }
82
 
83
  function addMessage(text, sender) {
84
- const msgDiv = document.createElement('div');
85
- msgDiv.className = `message ${sender === 'user' ? 'user-msg' : 'bot-msg'}`;
86
- msgDiv.innerText = text;
87
- chatMessages.appendChild(msgDiv);
88
  chatMessages.scrollTop = chatMessages.scrollHeight;
89
  }
90
 
@@ -98,10 +93,7 @@
98
  chatMessages.scrollTop = chatMessages.scrollHeight;
99
  }
100
  function hideTyping() {
101
- if (typingDiv) {
102
- typingDiv.remove();
103
- typingDiv = null;
104
- }
105
  }
106
 
107
  async function sendMessage() {
@@ -112,26 +104,21 @@
112
  userInput.value = '';
113
  showTyping();
114
  try {
115
- const response = await fetch(API_URL, {
116
  method: 'POST',
117
  headers: { 'Content-Type': 'application/json' },
118
  body: JSON.stringify({ message: msg, session_id: "default_user" })
119
  });
120
- const result = await response.json();
121
- const botReply = result.reply;
122
  hideTyping();
123
- addMessage(botReply, 'bot');
124
  } catch (err) {
125
  hideTyping();
126
- addMessage("Error: Server se baat nahi ho pa rahi.", 'bot');
127
- console.error(err);
128
  }
129
  }
130
 
131
- chatIcon.onclick = () => {
132
- chatModal.style.display = 'flex';
133
- if (questionsContainer.children.length === 0) renderQuestionBubbles();
134
- };
135
  closeChat.onclick = () => chatModal.style.display = 'none';
136
  sendBtn.onclick = sendMessage;
137
  userInput.addEventListener('keypress', (e) => { if (e.key === 'Enter') sendMessage(); });
 
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Elite Visuals AI Assistant</title>
7
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
8
  <style>
 
9
  * { margin: 0; padding: 0; box-sizing: border-box; }
10
  body { background: white; height: 100vh; width: 100%; }
11
  .chat-icon { position: fixed; bottom: 25px; right: 25px; width: 60px; height: 60px; background-color: #25D366; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; box-shadow: 0 4px 12px rgba(0,0,0,0.2); transition: 0.3s; z-index: 1000; }
 
33
  </div>
34
  <div class="chat-modal" id="chatModal">
35
  <div class="chat-header">
36
+ <span>Elite Visuals AI 🤖</span>
37
  <button class="close-btn" id="closeChat"><i class="fas fa-times"></i></button>
38
  </div>
39
  <div class="chat-messages" id="chatMessages">
40
+ <div class="message bot-msg">Assalam-o-Alaikum! Main Elite Visuals ka assistant hoon. Main aapki premium imagery services mein madad kar sakta hoon.</div>
41
  <div id="defaultQuestionsContainer" class="questions-container"></div>
42
  </div>
43
  <div class="chat-input-area">
 
46
  </div>
47
  </div>
48
  <script>
 
49
  const API_URL = "/api/chat";
50
  const DEFAULT_QUESTIONS = [
 
 
51
  "Aapke contact number kya hai?",
52
+ "Product photography ki price kya hai?",
53
+ "Portfolio kahan dekh sakta hoon?",
54
+ "Kya aap drone videography karte hain?",
55
+ "Architecture rendering ka sample chahiye",
56
+ "Corporate headshots ke liye kitna time lagta hai?"
57
  ];
58
 
59
  const chatIcon = document.getElementById('chatIcon');
 
66
 
67
  function renderQuestionBubbles() {
68
  questionsContainer.innerHTML = '';
69
+ DEFAULT_QUESTIONS.forEach(q => {
70
  const bubble = document.createElement('div');
71
  bubble.className = 'question-bubble';
72
+ bubble.innerText = q;
73
+ bubble.onclick = () => { userInput.value = q; sendMessage(); };
 
 
 
74
  questionsContainer.appendChild(bubble);
75
  });
76
  }
77
 
78
  function addMessage(text, sender) {
79
+ const div = document.createElement('div');
80
+ div.className = `message ${sender === 'user' ? 'user-msg' : 'bot-msg'}`;
81
+ div.innerText = text;
82
+ chatMessages.appendChild(div);
83
  chatMessages.scrollTop = chatMessages.scrollHeight;
84
  }
85
 
 
93
  chatMessages.scrollTop = chatMessages.scrollHeight;
94
  }
95
  function hideTyping() {
96
+ if (typingDiv) { typingDiv.remove(); typingDiv = null; }
 
 
 
97
  }
98
 
99
  async function sendMessage() {
 
104
  userInput.value = '';
105
  showTyping();
106
  try {
107
+ const res = await fetch(API_URL, {
108
  method: 'POST',
109
  headers: { 'Content-Type': 'application/json' },
110
  body: JSON.stringify({ message: msg, session_id: "default_user" })
111
  });
112
+ const data = await res.json();
 
113
  hideTyping();
114
+ addMessage(data.reply, 'bot');
115
  } catch (err) {
116
  hideTyping();
117
+ addMessage("Server error: Kuch galat ho gaya.", 'bot');
 
118
  }
119
  }
120
 
121
+ chatIcon.onclick = () => { chatModal.style.display = 'flex'; if (questionsContainer.children.length === 0) renderQuestionBubbles(); };
 
 
 
122
  closeChat.onclick = () => chatModal.style.display = 'none';
123
  sendBtn.onclick = sendMessage;
124
  userInput.addEventListener('keypress', (e) => { if (e.key === 'Enter') sendMessage(); });