Spaces:
Paused
Paused
Update index.html
Browse files- index.html +39 -10
index.html
CHANGED
|
@@ -8,18 +8,50 @@
|
|
| 8 |
<style>
|
| 9 |
* { margin: 0; padding: 0; box-sizing: border-box; }
|
| 10 |
body { background: white; height: 100vh; width: 100%; }
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
.chat-icon:hover { transform: scale(1.1); background-color: #128C7E; }
|
| 13 |
.chat-icon i { font-size: 30px; color: white; }
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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,12 +60,7 @@
|
|
| 28 |
</style>
|
| 29 |
</head>
|
| 30 |
<body>
|
| 31 |
-
|
| 32 |
-
white-space: pre-line; /* taake \n new line mein show ho */
|
| 33 |
-
}
|
| 34 |
-
.message ul, .message ol {
|
| 35 |
-
margin-left: 20px;
|
| 36 |
-
}
|
| 37 |
<div class="chat-icon" id="chatIcon">
|
| 38 |
<i class="fas fa-comment-dots"></i>
|
| 39 |
</div>
|
|
@@ -51,6 +78,7 @@
|
|
| 51 |
<button id="sendBtn"><i class="fas fa-paper-plane"></i></button>
|
| 52 |
</div>
|
| 53 |
</div>
|
|
|
|
| 54 |
<script>
|
| 55 |
const API_URL = "/api/chat";
|
| 56 |
const DEFAULT_QUESTIONS = [
|
|
@@ -84,6 +112,7 @@
|
|
| 84 |
function addMessage(text, sender) {
|
| 85 |
const div = document.createElement('div');
|
| 86 |
div.className = `message ${sender === 'user' ? 'user-msg' : 'bot-msg'}`;
|
|
|
|
| 87 |
div.innerText = text;
|
| 88 |
chatMessages.appendChild(div);
|
| 89 |
chatMessages.scrollTop = chatMessages.scrollHeight;
|
|
@@ -120,7 +149,7 @@
|
|
| 120 |
addMessage(data.reply, 'bot');
|
| 121 |
} catch (err) {
|
| 122 |
hideTyping();
|
| 123 |
-
addMessage("Server error: Kuch galat ho gaya.", 'bot');
|
| 124 |
}
|
| 125 |
}
|
| 126 |
|
|
|
|
| 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 |
</style>
|
| 61 |
</head>
|
| 62 |
<body>
|
| 63 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
<div class="chat-icon" id="chatIcon">
|
| 65 |
<i class="fas fa-comment-dots"></i>
|
| 66 |
</div>
|
|
|
|
| 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 = [
|
|
|
|
| 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;
|
|
|
|
| 149 |
addMessage(data.reply, 'bot');
|
| 150 |
} catch (err) {
|
| 151 |
hideTyping();
|
| 152 |
+
addMessage("❌ Server error: Kuch galat ho gaya. Baad mein try karein.", 'bot');
|
| 153 |
}
|
| 154 |
}
|
| 155 |
|