Ahmad140 commited on
Commit
d352aee
·
verified ·
1 Parent(s): 089aa88

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +14 -41
index.html CHANGED
@@ -8,50 +8,18 @@
8
  <style>
9
  * { margin: 0; padding: 0; box-sizing: border-box; }
10
  body { background: white; height: 100vh; width: 100%; }
11
-
12
- .chat-icon {
13
- position: fixed; bottom: 25px; right: 25px; width: 60px; height: 60px;
14
- background-color: #25D366; border-radius: 50%; display: flex;
15
- align-items: center; justify-content: center; cursor: pointer;
16
- box-shadow: 0 4px 12px rgba(0,0,0,0.2); transition: 0.3s; z-index: 1000;
17
- }
18
  .chat-icon:hover { transform: scale(1.1); background-color: #128C7E; }
19
  .chat-icon i { font-size: 30px; color: white; }
20
-
21
- .chat-modal {
22
- position: fixed; bottom: 100px; right: 25px; width: 350px; height: 500px;
23
- background: white; border-radius: 15px; box-shadow: 0 5px 20px rgba(0,0,0,0.3);
24
- display: none; flex-direction: column; overflow: hidden; z-index: 1001;
25
- border: 1px solid #ddd;
26
- }
27
  .chat-header { background: #075E54; color: white; padding: 12px; font-weight: bold; display: flex; justify-content: space-between; }
28
  .chat-messages { flex: 1; padding: 10px; overflow-y: auto; background: #ECE5DD; display: flex; flex-direction: column; }
29
-
30
- /* Message styling with support for bullet points and line breaks */
31
- .message {
32
- margin: 8px 0;
33
- padding: 8px 12px;
34
- border-radius: 10px;
35
- max-width: 80%;
36
- white-space: pre-line; /* Respects \n new lines from bot responses */
37
- line-height: 1.4;
38
- }
39
  .user-msg { background: #DCF8C6; margin-left: auto; text-align: right; }
40
  .bot-msg { background: white; margin-right: auto; }
41
-
42
- /* Optional: style for lists inside messages (if bot uses HTML) */
43
- .message ul, .message ol {
44
- margin-left: 20px;
45
- padding-left: 10px;
46
- }
47
- .message li {
48
- margin-bottom: 4px;
49
- }
50
-
51
  .questions-container { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; justify-content: flex-start; }
52
  .question-bubble { background: #e4e6eb; color: #050505; padding: 6px 12px; border-radius: 18px; font-size: 12px; cursor: pointer; transition: 0.2s; }
53
  .question-bubble:hover { background: #d1d3d8; transform: scale(1.02); }
54
-
55
  .chat-input-area { display: flex; padding: 10px; background: #f0f0f0; }
56
  .chat-input-area input { flex: 1; padding: 8px; border: 1px solid #ccc; border-radius: 20px; outline: none; }
57
  .chat-input-area button { margin-left: 8px; background: #25D366; border: none; color: white; border-radius: 50%; width: 36px; height: 36px; cursor: pointer; }
@@ -60,7 +28,6 @@
60
  </style>
61
  </head>
62
  <body>
63
-
64
  <div class="chat-icon" id="chatIcon">
65
  <i class="fas fa-comment-dots"></i>
66
  </div>
@@ -78,16 +45,23 @@
78
  <button id="sendBtn"><i class="fas fa-paper-plane"></i></button>
79
  </div>
80
  </div>
81
-
82
  <script>
 
 
 
 
 
 
 
 
83
  const API_URL = "/api/chat";
84
  const DEFAULT_QUESTIONS = [
85
  "Aapke contact number kya hai?",
86
  "Product photography ki price kya hai?",
87
  "Portfolio kahan dekh sakta hoon?",
88
  "Kya aap drone videography karte hain?",
89
- "Architecture rendering ka sample chahiye",
90
- "Corporate headshots ke liye kitna time lagta hai?"
91
  ];
92
 
93
  const chatIcon = document.getElementById('chatIcon');
@@ -112,7 +86,6 @@
112
  function addMessage(text, sender) {
113
  const div = document.createElement('div');
114
  div.className = `message ${sender === 'user' ? 'user-msg' : 'bot-msg'}`;
115
- // text already contains bullet points with \n, white-space: pre-line will display correctly
116
  div.innerText = text;
117
  chatMessages.appendChild(div);
118
  chatMessages.scrollTop = chatMessages.scrollHeight;
@@ -142,7 +115,7 @@
142
  const res = await fetch(API_URL, {
143
  method: 'POST',
144
  headers: { 'Content-Type': 'application/json' },
145
- body: JSON.stringify({ message: msg, session_id: "default_user" })
146
  });
147
  const data = await res.json();
148
  hideTyping();
 
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; }
 
 
 
 
 
 
12
  .chat-icon:hover { transform: scale(1.1); background-color: #128C7E; }
13
  .chat-icon i { font-size: 30px; color: white; }
14
+ .chat-modal { position: fixed; bottom: 100px; right: 25px; width: 350px; height: 500px; background: white; border-radius: 15px; box-shadow: 0 5px 20px rgba(0,0,0,0.3); display: none; flex-direction: column; overflow: hidden; z-index: 1001; border: 1px solid #ddd; }
 
 
 
 
 
 
15
  .chat-header { background: #075E54; color: white; padding: 12px; font-weight: bold; display: flex; justify-content: space-between; }
16
  .chat-messages { flex: 1; padding: 10px; overflow-y: auto; background: #ECE5DD; display: flex; flex-direction: column; }
17
+ .message { margin: 8px 0; padding: 8px 12px; border-radius: 10px; max-width: 80%; white-space: pre-line; line-height: 1.4; }
 
 
 
 
 
 
 
 
 
18
  .user-msg { background: #DCF8C6; margin-left: auto; text-align: right; }
19
  .bot-msg { background: white; margin-right: auto; }
 
 
 
 
 
 
 
 
 
 
20
  .questions-container { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; justify-content: flex-start; }
21
  .question-bubble { background: #e4e6eb; color: #050505; padding: 6px 12px; border-radius: 18px; font-size: 12px; cursor: pointer; transition: 0.2s; }
22
  .question-bubble:hover { background: #d1d3d8; transform: scale(1.02); }
 
23
  .chat-input-area { display: flex; padding: 10px; background: #f0f0f0; }
24
  .chat-input-area input { flex: 1; padding: 8px; border: 1px solid #ccc; border-radius: 20px; outline: none; }
25
  .chat-input-area button { margin-left: 8px; background: #25D366; border: none; color: white; border-radius: 50%; width: 36px; height: 36px; cursor: pointer; }
 
28
  </style>
29
  </head>
30
  <body>
 
31
  <div class="chat-icon" id="chatIcon">
32
  <i class="fas fa-comment-dots"></i>
33
  </div>
 
45
  <button id="sendBtn"><i class="fas fa-paper-plane"></i></button>
46
  </div>
47
  </div>
 
48
  <script>
49
+ // Generate or retrieve session ID from localStorage
50
+ let sessionId = localStorage.getItem('chat_session_id');
51
+ if (!sessionId) {
52
+ sessionId = 'user_' + Date.now() + '_' + Math.random().toString(36).substr(2, 8);
53
+ localStorage.setItem('chat_session_id', sessionId);
54
+ }
55
+ console.log('Session ID:', sessionId);
56
+
57
  const API_URL = "/api/chat";
58
  const DEFAULT_QUESTIONS = [
59
  "Aapke contact number kya hai?",
60
  "Product photography ki price kya hai?",
61
  "Portfolio kahan dekh sakta hoon?",
62
  "Kya aap drone videography karte hain?",
63
+ "Wedding photography karte ho?",
64
+ "Architecture rendering ka sample chahiye"
65
  ];
66
 
67
  const chatIcon = document.getElementById('chatIcon');
 
86
  function addMessage(text, sender) {
87
  const div = document.createElement('div');
88
  div.className = `message ${sender === 'user' ? 'user-msg' : 'bot-msg'}`;
 
89
  div.innerText = text;
90
  chatMessages.appendChild(div);
91
  chatMessages.scrollTop = chatMessages.scrollHeight;
 
115
  const res = await fetch(API_URL, {
116
  method: 'POST',
117
  headers: { 'Content-Type': 'application/json' },
118
+ body: JSON.stringify({ message: msg, session_id: sessionId })
119
  });
120
  const data = await res.json();
121
  hideTyping();