Update index.html
Browse files- index.html +893 -67
index.html
CHANGED
|
@@ -7,77 +7,903 @@
|
|
| 7 |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
|
| 8 |
<link href="https://fonts.googleapis.com/css2?family=Inter:opsz,wght@14..32,300;400;500;600;700&display=swap" rel="stylesheet">
|
| 9 |
<style>
|
| 10 |
-
/* (Keep your existing CSS – the same as in the previous final index.html) */
|
| 11 |
* { margin: 0; padding: 0; box-sizing: border-box; }
|
| 12 |
body { background: linear-gradient(135deg, #f5f7fa 0%, #e9eef5 100%); font-family: 'Inter', sans-serif; height: 100vh; overflow: hidden; }
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
.chat-icon
|
| 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 |
-
.chat-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
.
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
.chat-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
<link href="https://fonts.googleapis.com/css2?family=Inter:opsz,wght@14..32,300;400;500;600;700&display=swap" rel="stylesheet">
|
| 9 |
<style>
|
|
|
|
| 10 |
* { margin: 0; padding: 0; box-sizing: border-box; }
|
| 11 |
body { background: linear-gradient(135deg, #f5f7fa 0%, #e9eef5 100%); font-family: 'Inter', sans-serif; height: 100vh; overflow: hidden; }
|
| 12 |
+
|
| 13 |
+
/* Chat Icon (Floating Button) */
|
| 14 |
+
.chat-icon {
|
| 15 |
+
position: fixed;
|
| 16 |
+
bottom: 28px;
|
| 17 |
+
right: 28px;
|
| 18 |
+
width: 64px;
|
| 19 |
+
height: 64px;
|
| 20 |
+
background: linear-gradient(145deg, #25D366, #128C7E);
|
| 21 |
+
border-radius: 50%;
|
| 22 |
+
display: flex;
|
| 23 |
+
align-items: center;
|
| 24 |
+
justify-content: center;
|
| 25 |
+
cursor: pointer;
|
| 26 |
+
box-shadow: 0 10px 25px rgba(0,0,0,0.2);
|
| 27 |
+
animation: pulse 1.8s infinite;
|
| 28 |
+
z-index: 1000;
|
| 29 |
+
transition: all 0.3s ease;
|
| 30 |
+
}
|
| 31 |
+
@keyframes pulse {
|
| 32 |
+
0% { box-shadow: 0 0 0 0 rgba(37,211,102,0.5); }
|
| 33 |
+
70% { box-shadow: 0 0 0 15px rgba(37,211,102,0); }
|
| 34 |
+
100% { box-shadow: 0 0 0 0 rgba(37,211,102,0); }
|
| 35 |
+
}
|
| 36 |
+
.chat-icon:hover {
|
| 37 |
+
transform: scale(1.08);
|
| 38 |
+
background: #20b859;
|
| 39 |
+
}
|
| 40 |
+
.chat-icon i {
|
| 41 |
+
font-size: 32px;
|
| 42 |
+
color: white;
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
/* Chat Modal */
|
| 46 |
+
.chat-modal {
|
| 47 |
+
position: fixed;
|
| 48 |
+
bottom: 100px;
|
| 49 |
+
right: 28px;
|
| 50 |
+
width: 580px;
|
| 51 |
+
height: 680px;
|
| 52 |
+
background: rgba(255,255,255,0.98);
|
| 53 |
+
border-radius: 28px;
|
| 54 |
+
box-shadow: 0 25px 50px -12px rgba(0,0,0,0.35);
|
| 55 |
+
display: none;
|
| 56 |
+
flex-direction: column;
|
| 57 |
+
overflow: hidden;
|
| 58 |
+
z-index: 1001;
|
| 59 |
+
animation: slideUpFade 0.3s ease-out;
|
| 60 |
+
}
|
| 61 |
+
@keyframes slideUpFade {
|
| 62 |
+
from { opacity: 0; transform: translateY(30px); }
|
| 63 |
+
to { opacity: 1; transform: translateY(0); }
|
| 64 |
+
}
|
| 65 |
+
.chat-header {
|
| 66 |
+
background: linear-gradient(135deg, #075E54, #0b3b32);
|
| 67 |
+
color: white;
|
| 68 |
+
padding: 12px 18px;
|
| 69 |
+
display: flex;
|
| 70 |
+
justify-content: space-between;
|
| 71 |
+
align-items: center;
|
| 72 |
+
}
|
| 73 |
+
.header-buttons {
|
| 74 |
+
display: flex;
|
| 75 |
+
gap: 10px;
|
| 76 |
+
align-items: center;
|
| 77 |
+
}
|
| 78 |
+
.header-btn {
|
| 79 |
+
background: rgba(255,255,255,0.2);
|
| 80 |
+
border: none;
|
| 81 |
+
width: 32px;
|
| 82 |
+
height: 32px;
|
| 83 |
+
border-radius: 50%;
|
| 84 |
+
cursor: pointer;
|
| 85 |
+
color: white;
|
| 86 |
+
transition: 0.2s;
|
| 87 |
+
display: inline-flex;
|
| 88 |
+
align-items: center;
|
| 89 |
+
justify-content: center;
|
| 90 |
+
}
|
| 91 |
+
.header-btn:hover {
|
| 92 |
+
transform: scale(1.05);
|
| 93 |
+
background: rgba(255,255,255,0.4);
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
.chat-invoice-container {
|
| 97 |
+
display: flex;
|
| 98 |
+
flex: 1;
|
| 99 |
+
overflow: hidden;
|
| 100 |
+
transition: all 0.3s ease;
|
| 101 |
+
}
|
| 102 |
+
.chat-column {
|
| 103 |
+
flex: 1.5;
|
| 104 |
+
display: flex;
|
| 105 |
+
flex-direction: column;
|
| 106 |
+
background: #f0f2f5;
|
| 107 |
+
transition: all 0.3s ease;
|
| 108 |
+
}
|
| 109 |
+
.invoice-column {
|
| 110 |
+
width: 40%;
|
| 111 |
+
background: #fff8f0;
|
| 112 |
+
border-left: 1px solid #ddd;
|
| 113 |
+
display: flex;
|
| 114 |
+
flex-direction: column;
|
| 115 |
+
overflow-y: auto;
|
| 116 |
+
padding: 12px;
|
| 117 |
+
gap: 12px;
|
| 118 |
+
transition: all 0.3s ease;
|
| 119 |
+
}
|
| 120 |
+
.invoice-column.hidden {
|
| 121 |
+
display: none;
|
| 122 |
+
width: 0;
|
| 123 |
+
padding: 0;
|
| 124 |
+
}
|
| 125 |
+
.chat-column.expanded {
|
| 126 |
+
flex: 1;
|
| 127 |
+
}
|
| 128 |
+
|
| 129 |
+
.invoice-title {
|
| 130 |
+
font-weight: 700;
|
| 131 |
+
font-size: 1rem;
|
| 132 |
+
color: #075E54;
|
| 133 |
+
border-bottom: 2px solid #25D366;
|
| 134 |
+
padding-bottom: 6px;
|
| 135 |
+
margin-bottom: 8px;
|
| 136 |
+
display: flex;
|
| 137 |
+
justify-content: space-between;
|
| 138 |
+
align-items: center;
|
| 139 |
+
}
|
| 140 |
+
.invoice-items {
|
| 141 |
+
flex: 1;
|
| 142 |
+
overflow-y: auto;
|
| 143 |
+
max-height: 280px;
|
| 144 |
+
}
|
| 145 |
+
.invoice-item {
|
| 146 |
+
background: white;
|
| 147 |
+
border-radius: 12px;
|
| 148 |
+
padding: 8px 12px;
|
| 149 |
+
margin-bottom: 8px;
|
| 150 |
+
display: flex;
|
| 151 |
+
justify-content: space-between;
|
| 152 |
+
align-items: center;
|
| 153 |
+
box-shadow: 0 1px 3px rgba(0,0,0,0.05);
|
| 154 |
+
}
|
| 155 |
+
.invoice-item-name {
|
| 156 |
+
font-weight: 500;
|
| 157 |
+
font-size: 0.8rem;
|
| 158 |
+
}
|
| 159 |
+
.invoice-item-price {
|
| 160 |
+
font-size: 0.8rem;
|
| 161 |
+
color: #2d6a4f;
|
| 162 |
+
font-weight: 600;
|
| 163 |
+
}
|
| 164 |
+
.remove-item {
|
| 165 |
+
color: #e63946;
|
| 166 |
+
cursor: pointer;
|
| 167 |
+
font-size: 14px;
|
| 168 |
+
transition: 0.2s;
|
| 169 |
+
}
|
| 170 |
+
.remove-item:hover {
|
| 171 |
+
transform: scale(1.1);
|
| 172 |
+
}
|
| 173 |
+
.invoice-total {
|
| 174 |
+
border-top: 2px dashed #ccc;
|
| 175 |
+
padding-top: 10px;
|
| 176 |
+
margin-top: 8px;
|
| 177 |
+
font-weight: 700;
|
| 178 |
+
font-size: 0.9rem;
|
| 179 |
+
display: flex;
|
| 180 |
+
justify-content: space-between;
|
| 181 |
+
}
|
| 182 |
+
.empty-invoice {
|
| 183 |
+
color: #888;
|
| 184 |
+
font-size: 0.75rem;
|
| 185 |
+
text-align: center;
|
| 186 |
+
padding: 20px;
|
| 187 |
+
}
|
| 188 |
+
|
| 189 |
+
.final-report-btn, .download-report-btn {
|
| 190 |
+
background: #25D366;
|
| 191 |
+
color: white;
|
| 192 |
+
border: none;
|
| 193 |
+
border-radius: 25px;
|
| 194 |
+
padding: 8px 12px;
|
| 195 |
+
font-size: 0.75rem;
|
| 196 |
+
font-weight: 600;
|
| 197 |
+
cursor: pointer;
|
| 198 |
+
transition: 0.2s;
|
| 199 |
+
width: 100%;
|
| 200 |
+
margin-top: 8px;
|
| 201 |
+
}
|
| 202 |
+
.download-report-btn {
|
| 203 |
+
background: #2a6d4c;
|
| 204 |
+
margin-top: 4px;
|
| 205 |
+
}
|
| 206 |
+
.final-report-btn:hover {
|
| 207 |
+
background: #128C7E;
|
| 208 |
+
transform: scale(1.02);
|
| 209 |
+
}
|
| 210 |
+
.download-report-btn:hover {
|
| 211 |
+
background: #1e5a3e;
|
| 212 |
+
transform: scale(1.02);
|
| 213 |
+
}
|
| 214 |
+
|
| 215 |
+
.chat-messages {
|
| 216 |
+
flex: 1;
|
| 217 |
+
padding: 12px;
|
| 218 |
+
overflow-y: auto;
|
| 219 |
+
display: flex;
|
| 220 |
+
flex-direction: column;
|
| 221 |
+
gap: 12px;
|
| 222 |
+
}
|
| 223 |
+
.message {
|
| 224 |
+
max-width: 85%;
|
| 225 |
+
padding: 8px 12px;
|
| 226 |
+
border-radius: 18px;
|
| 227 |
+
font-size: 0.8rem;
|
| 228 |
+
line-height: 1.4;
|
| 229 |
+
white-space: pre-line;
|
| 230 |
+
animation: fadeIn 0.2s;
|
| 231 |
+
}
|
| 232 |
+
@keyframes fadeIn {
|
| 233 |
+
from { opacity: 0; transform: translateY(5px); }
|
| 234 |
+
to { opacity: 1; transform: translateY(0); }
|
| 235 |
+
}
|
| 236 |
+
.user-msg {
|
| 237 |
+
background: #DCF8C6;
|
| 238 |
+
margin-left: auto;
|
| 239 |
+
border-bottom-right-radius: 4px;
|
| 240 |
+
}
|
| 241 |
+
.bot-msg {
|
| 242 |
+
background: white;
|
| 243 |
+
margin-right: auto;
|
| 244 |
+
border-bottom-left-radius: 4px;
|
| 245 |
+
box-shadow: 0 1px 2px rgba(0,0,0,0.05);
|
| 246 |
+
}
|
| 247 |
+
|
| 248 |
+
.bot-message-wrapper {
|
| 249 |
+
display: flex;
|
| 250 |
+
flex-direction: column;
|
| 251 |
+
align-items: flex-start;
|
| 252 |
+
gap: 6px;
|
| 253 |
+
max-width: 85%;
|
| 254 |
+
margin-right: auto;
|
| 255 |
+
}
|
| 256 |
+
.bot-message-wrapper .message {
|
| 257 |
+
margin: 0;
|
| 258 |
+
max-width: 100%;
|
| 259 |
+
}
|
| 260 |
+
.confirm-btn {
|
| 261 |
+
background: #25D366;
|
| 262 |
+
color: white;
|
| 263 |
+
border: none;
|
| 264 |
+
border-radius: 20px;
|
| 265 |
+
padding: 4px 12px;
|
| 266 |
+
font-size: 0.7rem;
|
| 267 |
+
cursor: pointer;
|
| 268 |
+
transition: 0.2s;
|
| 269 |
+
display: inline-flex;
|
| 270 |
+
align-items: center;
|
| 271 |
+
gap: 4px;
|
| 272 |
+
}
|
| 273 |
+
.confirm-btn:hover {
|
| 274 |
+
background: #128C7E;
|
| 275 |
+
transform: scale(1.02);
|
| 276 |
+
}
|
| 277 |
+
|
| 278 |
+
.live-widget {
|
| 279 |
+
background: white;
|
| 280 |
+
border-radius: 16px;
|
| 281 |
+
margin: 8px 8px 0 8px;
|
| 282 |
+
overflow: hidden;
|
| 283 |
+
box-shadow: 0 2px 6px rgba(0,0,0,0.05);
|
| 284 |
+
}
|
| 285 |
+
.widget-header {
|
| 286 |
+
background: linear-gradient(135deg, #1e2a3a, #0f172a);
|
| 287 |
+
color: white;
|
| 288 |
+
padding: 8px 12px;
|
| 289 |
+
display: flex;
|
| 290 |
+
justify-content: space-between;
|
| 291 |
+
align-items: center;
|
| 292 |
+
font-size: 0.75rem;
|
| 293 |
+
font-weight: 600;
|
| 294 |
+
}
|
| 295 |
+
.widget-controls {
|
| 296 |
+
display: flex;
|
| 297 |
+
gap: 10px;
|
| 298 |
+
}
|
| 299 |
+
.widget-controls button {
|
| 300 |
+
background: rgba(255,255,255,0.2);
|
| 301 |
+
border: none;
|
| 302 |
+
color: white;
|
| 303 |
+
border-radius: 20px;
|
| 304 |
+
padding: 2px 8px;
|
| 305 |
+
font-size: 0.7rem;
|
| 306 |
+
cursor: pointer;
|
| 307 |
+
transition: 0.2s;
|
| 308 |
+
}
|
| 309 |
+
.widget-controls button:hover {
|
| 310 |
+
background: rgba(255,255,255,0.4);
|
| 311 |
+
}
|
| 312 |
+
.toggle-widget {
|
| 313 |
+
cursor: pointer;
|
| 314 |
+
margin-left: 8px;
|
| 315 |
+
}
|
| 316 |
+
.widget-content {
|
| 317 |
+
padding: 10px;
|
| 318 |
+
display: none;
|
| 319 |
+
background: #fef9e6;
|
| 320 |
+
font-size: 0.7rem;
|
| 321 |
+
}
|
| 322 |
+
.widget-content.show {
|
| 323 |
+
display: block;
|
| 324 |
+
}
|
| 325 |
+
.info-row {
|
| 326 |
+
margin: 4px 0;
|
| 327 |
+
}
|
| 328 |
+
.info-label {
|
| 329 |
+
font-weight: 700;
|
| 330 |
+
color: #075E54;
|
| 331 |
+
}
|
| 332 |
+
|
| 333 |
+
.questions-container {
|
| 334 |
+
display: flex;
|
| 335 |
+
flex-wrap: wrap;
|
| 336 |
+
gap: 6px;
|
| 337 |
+
margin: 8px;
|
| 338 |
+
}
|
| 339 |
+
.question-bubble {
|
| 340 |
+
background: #e4e6eb;
|
| 341 |
+
padding: 4px 10px;
|
| 342 |
+
border-radius: 16px;
|
| 343 |
+
font-size: 0.7rem;
|
| 344 |
+
cursor: pointer;
|
| 345 |
+
transition: 0.2s;
|
| 346 |
+
}
|
| 347 |
+
.question-bubble:hover {
|
| 348 |
+
background: #d1d4db;
|
| 349 |
+
transform: translateY(-1px);
|
| 350 |
+
}
|
| 351 |
+
|
| 352 |
+
.typing-indicator {
|
| 353 |
+
background: white;
|
| 354 |
+
padding: 6px 12px;
|
| 355 |
+
border-radius: 20px;
|
| 356 |
+
display: inline-flex;
|
| 357 |
+
gap: 4px;
|
| 358 |
+
width: fit-content;
|
| 359 |
+
}
|
| 360 |
+
.typing-indicator span {
|
| 361 |
+
width: 6px;
|
| 362 |
+
height: 6px;
|
| 363 |
+
background: #888;
|
| 364 |
+
border-radius: 50%;
|
| 365 |
+
animation: wave 1.2s infinite;
|
| 366 |
+
}
|
| 367 |
+
@keyframes wave {
|
| 368 |
+
0%,60%,100% { transform: translateY(0); opacity: 0.4; }
|
| 369 |
+
30% { transform: translateY(-4px); opacity: 1; }
|
| 370 |
+
}
|
| 371 |
+
|
| 372 |
+
.chat-input-area {
|
| 373 |
+
display: flex;
|
| 374 |
+
padding: 10px;
|
| 375 |
+
background: white;
|
| 376 |
+
border-top: 1px solid #ddd;
|
| 377 |
+
gap: 8px;
|
| 378 |
+
}
|
| 379 |
+
.chat-input-area input {
|
| 380 |
+
flex: 1;
|
| 381 |
+
padding: 8px 12px;
|
| 382 |
+
border: 1px solid #ccc;
|
| 383 |
+
border-radius: 30px;
|
| 384 |
+
outline: none;
|
| 385 |
+
font-size: 0.8rem;
|
| 386 |
+
}
|
| 387 |
+
.chat-input-area button {
|
| 388 |
+
background: #25D366;
|
| 389 |
+
border: none;
|
| 390 |
+
width: 36px;
|
| 391 |
+
height: 36px;
|
| 392 |
+
border-radius: 50%;
|
| 393 |
+
color: white;
|
| 394 |
+
cursor: pointer;
|
| 395 |
+
}
|
| 396 |
+
|
| 397 |
+
.media-panel {
|
| 398 |
+
background: #f0f2f5;
|
| 399 |
+
border-radius: 16px;
|
| 400 |
+
padding: 12px;
|
| 401 |
+
margin: 10px 0;
|
| 402 |
+
display: none;
|
| 403 |
+
}
|
| 404 |
+
.media-panel textarea {
|
| 405 |
+
width: 100%;
|
| 406 |
+
padding: 8px;
|
| 407 |
+
border-radius: 12px;
|
| 408 |
+
border: 1px solid #ccc;
|
| 409 |
+
}
|
| 410 |
+
.media-panel input[type="file"] {
|
| 411 |
+
margin: 8px 0;
|
| 412 |
+
}
|
| 413 |
+
.image-preview {
|
| 414 |
+
max-width: 100%;
|
| 415 |
+
max-height: 150px;
|
| 416 |
+
margin-top: 8px;
|
| 417 |
+
}
|
| 418 |
</style>
|
| 419 |
</head>
|
| 420 |
<body>
|
| 421 |
+
<!-- Floating Chat Icon (VISIBLE) -->
|
| 422 |
+
<div class="chat-icon" id="chatIcon">
|
| 423 |
+
<i class="fas fa-comment-dots"></i>
|
| 424 |
+
</div>
|
| 425 |
+
|
| 426 |
+
<!-- Chat Modal -->
|
| 427 |
+
<div class="chat-modal" id="chatModal">
|
| 428 |
+
<div class="chat-header">
|
| 429 |
+
<h3><i class="fas fa-robot"></i> Elite Visuals AI</h3>
|
| 430 |
+
<div class="header-buttons">
|
| 431 |
+
<button class="header-btn" id="toggleInvoiceBtn" title="Toggle Invoice Panel"><i class="fas fa-eye-slash"></i></button>
|
| 432 |
+
<button class="header-btn" id="closeChat"><i class="fas fa-times"></i></button>
|
| 433 |
+
</div>
|
| 434 |
+
</div>
|
| 435 |
+
<div class="chat-invoice-container" id="chatInvoiceContainer">
|
| 436 |
+
<div class="chat-column" id="chatColumn">
|
| 437 |
+
<div class="chat-messages" id="chatMessages">
|
| 438 |
+
<div class="message bot-msg">✨ Assalam-o-Alaikum! I can help you with website packages, extra features, and **step-by-step project building**. To start a new project, simply say: **"I want to build a website"** – I'll ask you all the requirements and then generate a proposal, project ID, and total invoice. You can also ask about packages or use the confirm buttons below.</div>
|
| 439 |
+
<div class="live-widget" id="liveWidget">
|
| 440 |
+
<div class="widget-header">
|
| 441 |
+
<span><i class="fas fa-chart-line"></i> 📊 Live Quote</span>
|
| 442 |
+
<div class="widget-controls">
|
| 443 |
+
<button id="hideWidgetBtn"><i class="fas fa-eye-slash"></i> Hide</button>
|
| 444 |
+
<button id="unhideWidgetBtn" style="display: none;"><i class="fas fa-eye"></i> Show</button>
|
| 445 |
+
<i class="fas fa-chevron-down toggle-widget" id="toggleIcon"></i>
|
| 446 |
+
</div>
|
| 447 |
+
</div>
|
| 448 |
+
<div class="widget-content" id="widgetContent">
|
| 449 |
+
<p id="widgetEmptyMsg">💡 Ask about a package/feature to see details.</p>
|
| 450 |
+
<div id="widgetDetails" style="display: none;"></div>
|
| 451 |
+
</div>
|
| 452 |
+
</div>
|
| 453 |
+
<div id="defaultQuestionsContainer" class="questions-container"></div>
|
| 454 |
+
</div>
|
| 455 |
+
<div class="chat-input-area">
|
| 456 |
+
<input type="text" id="userInput" placeholder="Ask about price, timeline, confirm Basic, add SEO, or say 'I want to build a website'...">
|
| 457 |
+
<button id="sendBtn"><i class="fas fa-paper-plane"></i></button>
|
| 458 |
+
</div>
|
| 459 |
+
</div>
|
| 460 |
+
<div class="invoice-column" id="invoiceColumn">
|
| 461 |
+
<div class="invoice-title">
|
| 462 |
+
<span>🧾 Your Quote</span>
|
| 463 |
+
</div>
|
| 464 |
+
<div class="invoice-items" id="invoiceItems">
|
| 465 |
+
<div class="empty-invoice">✨ No services selected yet.<br>Ask or confirm a package to add.</div>
|
| 466 |
+
</div>
|
| 467 |
+
<div class="invoice-total" id="invoiceTotal">
|
| 468 |
+
<span>Subtotal:</span>
|
| 469 |
+
<span id="totalAmount">PKR 0</span>
|
| 470 |
+
</div>
|
| 471 |
+
<button class="final-report-btn" id="finalReportBtn"><i class="fas fa-file-alt"></i> Generate Final Report</button>
|
| 472 |
+
<button class="download-report-btn" id="downloadReportBtn"><i class="fas fa-download"></i> Download Report</button>
|
| 473 |
+
</div>
|
| 474 |
+
</div>
|
| 475 |
+
</div>
|
| 476 |
+
|
| 477 |
+
<script>
|
| 478 |
+
// ---------- Session ----------
|
| 479 |
+
let sessionId = localStorage.getItem('chat_session_id');
|
| 480 |
+
if (!sessionId) {
|
| 481 |
+
sessionId = 'user_' + Date.now() + '_' + Math.random().toString(36).substr(2, 8);
|
| 482 |
+
localStorage.setItem('chat_session_id', sessionId);
|
| 483 |
+
}
|
| 484 |
+
const API_URL = "/api/chat";
|
| 485 |
+
const DEFAULT_QUESTIONS = [
|
| 486 |
+
"Basic website price and timeline?",
|
| 487 |
+
"Standard package details",
|
| 488 |
+
"Premium package details",
|
| 489 |
+
"Extra: live chat cost increase?",
|
| 490 |
+
"Add e-commerce to my quote",
|
| 491 |
+
"I want to build a website",
|
| 492 |
+
"Contact number"
|
| 493 |
+
];
|
| 494 |
+
|
| 495 |
+
let storedProjectId = localStorage.getItem(`project_id_${sessionId}`) || null;
|
| 496 |
+
let invoiceItems = [];
|
| 497 |
+
let nextId = 1;
|
| 498 |
+
|
| 499 |
+
function parsePrice(priceStr) {
|
| 500 |
+
let match = priceStr.match(/(\d[\d,]+)/);
|
| 501 |
+
if (match) return parseInt(match[0].replace(/,/g, ''));
|
| 502 |
+
return 0;
|
| 503 |
+
}
|
| 504 |
+
|
| 505 |
+
function parseTimelineDays(timelineStr) {
|
| 506 |
+
if (!timelineStr) return 0;
|
| 507 |
+
let match = timelineStr.match(/(\d+)\s*-\s*(\d+)\s*days?/);
|
| 508 |
+
if (match) return parseInt(match[2]);
|
| 509 |
+
match = timelineStr.match(/(\d+)\s*days?/);
|
| 510 |
+
if (match) return parseInt(match[1]);
|
| 511 |
+
return 0;
|
| 512 |
+
}
|
| 513 |
+
|
| 514 |
+
function updateInvoiceDisplay() {
|
| 515 |
+
const container = document.getElementById('invoiceItems');
|
| 516 |
+
const totalSpan = document.getElementById('totalAmount');
|
| 517 |
+
if (invoiceItems.length === 0) {
|
| 518 |
+
container.innerHTML = '<div class="empty-invoice">✨ No services selected yet.<br>Ask or confirm a package to add.</div>';
|
| 519 |
+
totalSpan.innerText = 'PKR 0';
|
| 520 |
+
return;
|
| 521 |
+
}
|
| 522 |
+
let html = '';
|
| 523 |
+
let total = 0;
|
| 524 |
+
invoiceItems.forEach(item => {
|
| 525 |
+
const priceNum = parsePrice(item.price);
|
| 526 |
+
total += priceNum;
|
| 527 |
+
html += `
|
| 528 |
+
<div class="invoice-item" data-id="${item.id}">
|
| 529 |
+
<div class="invoice-item-name">${item.name}</div>
|
| 530 |
+
<div style="display: flex; align-items: center; gap: 12px;">
|
| 531 |
+
<span class="invoice-item-price">${item.price}</span>
|
| 532 |
+
<span class="remove-item" data-id="${item.id}"><i class="fas fa-times-circle"></i></span>
|
| 533 |
+
</div>
|
| 534 |
+
</div>
|
| 535 |
+
`;
|
| 536 |
+
});
|
| 537 |
+
container.innerHTML = html;
|
| 538 |
+
totalSpan.innerText = `PKR ${total.toLocaleString()}`;
|
| 539 |
+
document.querySelectorAll('.remove-item').forEach(el => {
|
| 540 |
+
el.addEventListener('click', (e) => {
|
| 541 |
+
const id = parseInt(el.dataset.id);
|
| 542 |
+
removeInvoiceItem(id);
|
| 543 |
+
});
|
| 544 |
+
});
|
| 545 |
+
}
|
| 546 |
+
|
| 547 |
+
function removeInvoiceItem(id) {
|
| 548 |
+
invoiceItems = invoiceItems.filter(item => item.id !== id);
|
| 549 |
+
updateInvoiceDisplay();
|
| 550 |
+
}
|
| 551 |
+
|
| 552 |
+
function addInvoiceItem(serviceName, priceStr, serviceKey = null, timelineDays = null) {
|
| 553 |
+
if (serviceKey && invoiceItems.some(item => item.serviceKey === serviceKey)) return false;
|
| 554 |
+
const newItem = { id: nextId++, name: serviceName, price: priceStr, serviceKey: serviceKey || serviceName, timelineDays: timelineDays };
|
| 555 |
+
invoiceItems.push(newItem);
|
| 556 |
+
updateInvoiceDisplay();
|
| 557 |
+
return true;
|
| 558 |
+
}
|
| 559 |
+
|
| 560 |
+
// Auto-add from bot messages (NOW DISABLED – only manual confirm buttons)
|
| 561 |
+
function autoAddFromBotMessage(text) {
|
| 562 |
+
// Only extract Project ID – DO NOT automatically add any service
|
| 563 |
+
const match = text.match(/Project ID:\s*`([A-Z0-9\-]+)`/i);
|
| 564 |
+
if (match) {
|
| 565 |
+
storedProjectId = match[1];
|
| 566 |
+
localStorage.setItem(`project_id_${sessionId}`, storedProjectId);
|
| 567 |
+
}
|
| 568 |
+
// No automatic additions anymore!
|
| 569 |
+
}
|
| 570 |
+
|
| 571 |
+
// ---------- Media Upload ----------
|
| 572 |
+
let mediaPanel = null;
|
| 573 |
+
function createMediaPanel() {
|
| 574 |
+
if (mediaPanel) return;
|
| 575 |
+
const chatArea = document.getElementById('chatMessages');
|
| 576 |
+
const panel = document.createElement('div');
|
| 577 |
+
panel.className = 'media-panel';
|
| 578 |
+
panel.innerHTML = `
|
| 579 |
+
<label>Additional Notes (text):</label>
|
| 580 |
+
<textarea id="mediaText" rows="2" placeholder="Type any notes..."></textarea>
|
| 581 |
+
<label>Upload Image (optional):</label>
|
| 582 |
+
<input type="file" id="mediaImage" accept="image/*">
|
| 583 |
+
<img id="mediaPreview" class="image-preview" style="display:none;">
|
| 584 |
+
<button id="mediaSubmitBtn" class="confirm-btn" style="margin-top:8px;">Submit Media</button>
|
| 585 |
+
`;
|
| 586 |
+
chatArea.appendChild(panel);
|
| 587 |
+
mediaPanel = panel;
|
| 588 |
+
const mediaTextarea = document.getElementById('mediaText');
|
| 589 |
+
const mediaFileInput = document.getElementById('mediaImage');
|
| 590 |
+
const mediaImagePreview = document.getElementById('mediaPreview');
|
| 591 |
+
const submitBtn = document.getElementById('mediaSubmitBtn');
|
| 592 |
+
mediaFileInput.onchange = () => {
|
| 593 |
+
const file = mediaFileInput.files[0];
|
| 594 |
+
if (file) {
|
| 595 |
+
const reader = new FileReader();
|
| 596 |
+
reader.onload = (e) => {
|
| 597 |
+
mediaImagePreview.src = e.target.result;
|
| 598 |
+
mediaImagePreview.style.display = 'block';
|
| 599 |
+
};
|
| 600 |
+
reader.readAsDataURL(file);
|
| 601 |
+
} else {
|
| 602 |
+
mediaImagePreview.style.display = 'none';
|
| 603 |
+
}
|
| 604 |
+
};
|
| 605 |
+
submitBtn.onclick = async () => {
|
| 606 |
+
const text = mediaTextarea.value.trim();
|
| 607 |
+
let imageBase64 = '';
|
| 608 |
+
if (mediaFileInput.files[0]) {
|
| 609 |
+
const file = mediaFileInput.files[0];
|
| 610 |
+
imageBase64 = await new Promise((resolve) => {
|
| 611 |
+
const reader = new FileReader();
|
| 612 |
+
reader.onload = (e) => resolve(e.target.result);
|
| 613 |
+
reader.readAsDataURL(file);
|
| 614 |
+
});
|
| 615 |
+
}
|
| 616 |
+
try {
|
| 617 |
+
const res = await fetch('/api/upload_media', {
|
| 618 |
+
method: 'POST',
|
| 619 |
+
headers: { 'Content-Type': 'application/json' },
|
| 620 |
+
body: JSON.stringify({ session_id: sessionId, text: text, image: imageBase64 })
|
| 621 |
+
});
|
| 622 |
+
const data = await res.json();
|
| 623 |
+
if (data.status === 'ok') {
|
| 624 |
+
userInput.value = "DONE";
|
| 625 |
+
sendMessage();
|
| 626 |
+
mediaPanel.style.display = 'none';
|
| 627 |
+
} else {
|
| 628 |
+
alert("Failed to upload media");
|
| 629 |
+
}
|
| 630 |
+
} catch (err) {
|
| 631 |
+
alert("Upload error");
|
| 632 |
+
}
|
| 633 |
+
};
|
| 634 |
+
}
|
| 635 |
+
|
| 636 |
+
function showMediaPanel() {
|
| 637 |
+
if (!mediaPanel) createMediaPanel();
|
| 638 |
+
mediaPanel.style.display = 'block';
|
| 639 |
+
}
|
| 640 |
+
|
| 641 |
+
// ---------- Message Functions ----------
|
| 642 |
+
function addMessageWithConfirm(text, sender, widgetData = null) {
|
| 643 |
+
const chatMessagesDiv = document.getElementById('chatMessages');
|
| 644 |
+
if (sender === 'user') {
|
| 645 |
+
const div = document.createElement('div');
|
| 646 |
+
div.className = 'message user-msg';
|
| 647 |
+
div.innerText = text;
|
| 648 |
+
chatMessagesDiv.appendChild(div);
|
| 649 |
+
chatMessagesDiv.scrollTop = chatMessagesDiv.scrollHeight;
|
| 650 |
+
return;
|
| 651 |
+
}
|
| 652 |
+
const wrapper = document.createElement('div');
|
| 653 |
+
wrapper.className = 'bot-message-wrapper';
|
| 654 |
+
const msgDiv = document.createElement('div');
|
| 655 |
+
msgDiv.className = 'message bot-msg';
|
| 656 |
+
msgDiv.innerText = text;
|
| 657 |
+
wrapper.appendChild(msgDiv);
|
| 658 |
+
|
| 659 |
+
// Check for media request
|
| 660 |
+
if (text.startsWith("MEDIA_REQUEST|")) {
|
| 661 |
+
const cleanMsg = text.replace("MEDIA_REQUEST|", "");
|
| 662 |
+
msgDiv.innerText = cleanMsg;
|
| 663 |
+
showMediaPanel();
|
| 664 |
+
} else {
|
| 665 |
+
// Only extract Project ID, no auto-add
|
| 666 |
+
autoAddFromBotMessage(text);
|
| 667 |
+
}
|
| 668 |
+
|
| 669 |
+
let serviceName = null, servicePrice = null, serviceKey = null, timelineStr = null;
|
| 670 |
+
if (widgetData) {
|
| 671 |
+
if (widgetData.package) {
|
| 672 |
+
serviceName = `${widgetData.package} Website Package`;
|
| 673 |
+
servicePrice = widgetData.price;
|
| 674 |
+
serviceKey = `pkg_${widgetData.package}`;
|
| 675 |
+
timelineStr = widgetData.timeline;
|
| 676 |
+
} else if (widgetData.service) {
|
| 677 |
+
serviceName = widgetData.service;
|
| 678 |
+
servicePrice = widgetData.price;
|
| 679 |
+
serviceKey = `svc_${widgetData.service}`;
|
| 680 |
+
timelineStr = widgetData.timeline;
|
| 681 |
+
} else if (widgetData.extra_feature) {
|
| 682 |
+
serviceName = `Extra: ${widgetData.extra_feature}`;
|
| 683 |
+
servicePrice = widgetData.extra_cost;
|
| 684 |
+
serviceKey = `extra_${widgetData.extra_feature}`;
|
| 685 |
+
timelineStr = widgetData.extra_timeline;
|
| 686 |
+
}
|
| 687 |
+
}
|
| 688 |
+
// Add a confirm button for packages/extra features (manual addition)
|
| 689 |
+
if (serviceName && servicePrice) {
|
| 690 |
+
const confirmBtn = document.createElement('button');
|
| 691 |
+
confirmBtn.className = 'confirm-btn';
|
| 692 |
+
confirmBtn.innerHTML = '<i class="fas fa-check-circle"></i> Confirm & Add to Quote';
|
| 693 |
+
confirmBtn.onclick = () => {
|
| 694 |
+
const timelineDays = timelineStr ? parseTimelineDays(timelineStr) : null;
|
| 695 |
+
addInvoiceItem(serviceName, servicePrice, serviceKey, timelineDays);
|
| 696 |
+
confirmBtn.disabled = true;
|
| 697 |
+
confirmBtn.style.opacity = '0.6';
|
| 698 |
+
confirmBtn.innerText = '✓ Added';
|
| 699 |
+
};
|
| 700 |
+
wrapper.appendChild(confirmBtn);
|
| 701 |
+
}
|
| 702 |
+
chatMessagesDiv.appendChild(wrapper);
|
| 703 |
+
chatMessagesDiv.scrollTop = chatMessagesDiv.scrollHeight;
|
| 704 |
+
}
|
| 705 |
+
|
| 706 |
+
function addMessage(text, sender) {
|
| 707 |
+
const div = document.createElement('div');
|
| 708 |
+
div.className = `message ${sender === 'user' ? 'user-msg' : 'bot-msg'}`;
|
| 709 |
+
div.innerText = text;
|
| 710 |
+
document.getElementById('chatMessages').appendChild(div);
|
| 711 |
+
chatMessagesDiv.scrollTop = chatMessagesDiv.scrollHeight;
|
| 712 |
+
}
|
| 713 |
+
|
| 714 |
+
// ---------- History Loading ----------
|
| 715 |
+
let historyLoaded = false;
|
| 716 |
+
async function loadChatHistory() {
|
| 717 |
+
try {
|
| 718 |
+
const res = await fetch(`/api/history?session_id=${sessionId}`);
|
| 719 |
+
const data = await res.json();
|
| 720 |
+
if (data.messages && data.messages.length) {
|
| 721 |
+
const chatMessagesDiv = document.getElementById('chatMessages');
|
| 722 |
+
const children = Array.from(chatMessagesDiv.children);
|
| 723 |
+
let welcomeIndex = -1;
|
| 724 |
+
for (let i = 0; i < children.length; i++) {
|
| 725 |
+
const child = children[i];
|
| 726 |
+
if (child.classList && child.classList.contains('message') &&
|
| 727 |
+
child.classList.contains('bot-msg') &&
|
| 728 |
+
child.innerText.includes("Assalam-o-Alaikum")) {
|
| 729 |
+
welcomeIndex = i;
|
| 730 |
+
break;
|
| 731 |
+
}
|
| 732 |
+
}
|
| 733 |
+
for (let i = children.length - 1; i >= 0; i--) {
|
| 734 |
+
if (i !== welcomeIndex) {
|
| 735 |
+
children[i].remove();
|
| 736 |
+
}
|
| 737 |
+
}
|
| 738 |
+
for (let msg of data.messages) {
|
| 739 |
+
if (msg.role === 'user') {
|
| 740 |
+
addMessage(msg.content, 'user');
|
| 741 |
+
} else if (msg.role === 'assistant') {
|
| 742 |
+
addMessage(msg.content, 'bot');
|
| 743 |
+
}
|
| 744 |
+
}
|
| 745 |
+
}
|
| 746 |
+
} catch (err) {
|
| 747 |
+
console.error("History load error", err);
|
| 748 |
+
}
|
| 749 |
+
}
|
| 750 |
+
|
| 751 |
+
// ---------- UI Event Listeners ----------
|
| 752 |
+
const chatIcon = document.getElementById('chatIcon');
|
| 753 |
+
const chatModal = document.getElementById('chatModal');
|
| 754 |
+
const closeChat = document.getElementById('closeChat');
|
| 755 |
+
const sendBtn = document.getElementById('sendBtn');
|
| 756 |
+
const userInput = document.getElementById('userInput');
|
| 757 |
+
const chatMessagesDiv = document.getElementById('chatMessages');
|
| 758 |
+
const questionsContainer = document.getElementById('defaultQuestionsContainer');
|
| 759 |
+
const finalReportBtn = document.getElementById('finalReportBtn');
|
| 760 |
+
const downloadReportBtn = document.getElementById('downloadReportBtn');
|
| 761 |
+
|
| 762 |
+
finalReportBtn.onclick = () => {
|
| 763 |
+
if (invoiceItems.length === 0) {
|
| 764 |
+
addMessageWithConfirm("❌ No services added yet.", 'bot');
|
| 765 |
+
return;
|
| 766 |
+
}
|
| 767 |
+
let report = "📋 **Final Project Report**\n\n**Selected Services:**\n";
|
| 768 |
+
let totalPrice = 0, totalDays = 0;
|
| 769 |
+
invoiceItems.forEach(item => {
|
| 770 |
+
totalPrice += parsePrice(item.price);
|
| 771 |
+
report += `- ${item.name}: ${item.price}\n`;
|
| 772 |
+
if (item.timelineDays) totalDays += item.timelineDays;
|
| 773 |
+
});
|
| 774 |
+
report += `\n💰 Total: PKR ${totalPrice.toLocaleString()}`;
|
| 775 |
+
if (totalDays) report += `\n⏱️ Timeline: ${totalDays} days`;
|
| 776 |
+
if (storedProjectId) report += `\n\n📌 Project ID: ${storedProjectId}`;
|
| 777 |
+
addMessageWithConfirm(report, 'bot');
|
| 778 |
+
};
|
| 779 |
+
|
| 780 |
+
downloadReportBtn.onclick = () => {
|
| 781 |
+
if (invoiceItems.length === 0) { alert("No services selected."); return; }
|
| 782 |
+
let content = "ELITE VISUALS – QUOTE REPORT\n\nDate: "+new Date().toLocaleString()+"\n\nServices:\n";
|
| 783 |
+
let total = 0;
|
| 784 |
+
invoiceItems.forEach(item => {
|
| 785 |
+
total += parsePrice(item.price);
|
| 786 |
+
content += `• ${item.name}: ${item.price}\n`;
|
| 787 |
+
});
|
| 788 |
+
content += `\nTOTAL: PKR ${total.toLocaleString()}`;
|
| 789 |
+
if (storedProjectId) content += `\n\nProject ID: ${storedProjectId}`;
|
| 790 |
+
const blob = new Blob([content], {type:"text/plain"});
|
| 791 |
+
const a = document.createElement('a');
|
| 792 |
+
a.href = URL.createObjectURL(blob);
|
| 793 |
+
a.download = `quote_${Date.now()}.txt`;
|
| 794 |
+
a.click();
|
| 795 |
+
URL.revokeObjectURL(a.href);
|
| 796 |
+
};
|
| 797 |
+
|
| 798 |
+
const invoiceColumn = document.getElementById('invoiceColumn');
|
| 799 |
+
const chatColumn = document.getElementById('chatColumn');
|
| 800 |
+
const toggleInvoiceBtn = document.getElementById('toggleInvoiceBtn');
|
| 801 |
+
let invoiceHidden = false;
|
| 802 |
+
toggleInvoiceBtn.onclick = () => {
|
| 803 |
+
if (invoiceHidden) {
|
| 804 |
+
invoiceColumn.classList.remove('hidden');
|
| 805 |
+
chatColumn.classList.remove('expanded');
|
| 806 |
+
toggleInvoiceBtn.innerHTML = '<i class="fas fa-eye-slash"></i>';
|
| 807 |
+
} else {
|
| 808 |
+
invoiceColumn.classList.add('hidden');
|
| 809 |
+
chatColumn.classList.add('expanded');
|
| 810 |
+
toggleInvoiceBtn.innerHTML = '<i class="fas fa-eye"></i>';
|
| 811 |
+
}
|
| 812 |
+
invoiceHidden = !invoiceHidden;
|
| 813 |
+
};
|
| 814 |
+
|
| 815 |
+
function renderQuestionBubbles() {
|
| 816 |
+
questionsContainer.innerHTML = '';
|
| 817 |
+
DEFAULT_QUESTIONS.forEach(q => {
|
| 818 |
+
const bubble = document.createElement('div');
|
| 819 |
+
bubble.className = 'question-bubble';
|
| 820 |
+
bubble.innerText = q;
|
| 821 |
+
bubble.onclick = () => { userInput.value = q; sendMessage(); };
|
| 822 |
+
questionsContainer.appendChild(bubble);
|
| 823 |
+
});
|
| 824 |
+
}
|
| 825 |
+
|
| 826 |
+
let typingDiv = null;
|
| 827 |
+
function showTyping() {
|
| 828 |
+
if (typingDiv) return;
|
| 829 |
+
typingDiv = document.createElement('div');
|
| 830 |
+
typingDiv.className = 'typing-indicator';
|
| 831 |
+
typingDiv.innerHTML = '<span></span><span></span><span></span>';
|
| 832 |
+
chatMessagesDiv.appendChild(typingDiv);
|
| 833 |
+
chatMessagesDiv.scrollTop = chatMessagesDiv.scrollHeight;
|
| 834 |
+
}
|
| 835 |
+
function hideTyping() {
|
| 836 |
+
if (typingDiv) { typingDiv.remove(); typingDiv = null; }
|
| 837 |
+
}
|
| 838 |
+
|
| 839 |
+
async function sendMessage() {
|
| 840 |
+
const msg = userInput.value.trim();
|
| 841 |
+
if (!msg) return;
|
| 842 |
+
if (questionsContainer) questionsContainer.style.display = 'none';
|
| 843 |
+
addMessageWithConfirm(msg, 'user');
|
| 844 |
+
userInput.value = '';
|
| 845 |
+
showTyping();
|
| 846 |
+
try {
|
| 847 |
+
const res = await fetch(API_URL, {
|
| 848 |
+
method: 'POST',
|
| 849 |
+
headers: { 'Content-Type': 'application/json' },
|
| 850 |
+
body: JSON.stringify({ message: msg, session_id: sessionId })
|
| 851 |
+
});
|
| 852 |
+
const data = await res.json();
|
| 853 |
+
hideTyping();
|
| 854 |
+
addMessageWithConfirm(data.reply, 'bot', data.widget);
|
| 855 |
+
} catch (err) {
|
| 856 |
+
hideTyping();
|
| 857 |
+
addMessageWithConfirm("❌ Server error. Try again.", 'bot');
|
| 858 |
+
}
|
| 859 |
+
}
|
| 860 |
+
|
| 861 |
+
chatIcon.onclick = async () => {
|
| 862 |
+
chatModal.style.display = 'flex';
|
| 863 |
+
if (questionsContainer.children.length === 0) renderQuestionBubbles();
|
| 864 |
+
if (!historyLoaded) {
|
| 865 |
+
await loadChatHistory();
|
| 866 |
+
historyLoaded = true;
|
| 867 |
+
}
|
| 868 |
+
};
|
| 869 |
+
closeChat.onclick = () => chatModal.style.display = 'none';
|
| 870 |
+
sendBtn.onclick = sendMessage;
|
| 871 |
+
userInput.addEventListener('keypress', (e) => { if (e.key === 'Enter') sendMessage(); });
|
| 872 |
+
renderQuestionBubbles();
|
| 873 |
+
|
| 874 |
+
const widgetContent = document.getElementById('widgetContent');
|
| 875 |
+
const toggleIcon = document.getElementById('toggleIcon');
|
| 876 |
+
const hideWidgetBtn = document.getElementById('hideWidgetBtn');
|
| 877 |
+
const unhideWidgetBtn = document.getElementById('unhideWidgetBtn');
|
| 878 |
+
const liveWidget = document.getElementById('liveWidget');
|
| 879 |
+
let widgetOpen = false;
|
| 880 |
+
toggleIcon.onclick = (e) => {
|
| 881 |
+
e.stopPropagation();
|
| 882 |
+
if (widgetOpen) {
|
| 883 |
+
widgetContent.classList.remove('show');
|
| 884 |
+
toggleIcon.classList.remove('fa-chevron-up');
|
| 885 |
+
toggleIcon.classList.add('fa-chevron-down');
|
| 886 |
+
} else {
|
| 887 |
+
widgetContent.classList.add('show');
|
| 888 |
+
toggleIcon.classList.remove('fa-chevron-down');
|
| 889 |
+
toggleIcon.classList.add('fa-chevron-up');
|
| 890 |
+
}
|
| 891 |
+
widgetOpen = !widgetOpen;
|
| 892 |
+
};
|
| 893 |
+
hideWidgetBtn.onclick = () => {
|
| 894 |
+
liveWidget.style.display = 'none';
|
| 895 |
+
hideWidgetBtn.style.display = 'none';
|
| 896 |
+
unhideWidgetBtn.style.display = 'inline-flex';
|
| 897 |
+
};
|
| 898 |
+
unhideWidgetBtn.onclick = () => {
|
| 899 |
+
liveWidget.style.display = 'block';
|
| 900 |
+
hideWidgetBtn.style.display = 'inline-flex';
|
| 901 |
+
unhideWidgetBtn.style.display = 'none';
|
| 902 |
+
};
|
| 903 |
+
function updateWidget(data) {
|
| 904 |
+
// Not critical for core functionality
|
| 905 |
+
}
|
| 906 |
+
updateWidget(null);
|
| 907 |
+
</script>
|
| 908 |
</body>
|
| 909 |
</html>
|