Spaces:
Paused
Paused
Update index.html
Browse files- index.html +58 -400
index.html
CHANGED
|
@@ -2,76 +2,51 @@
|
|
| 2 |
<html lang="en">
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0
|
| 6 |
-
<title>Elite Visuals AI –
|
| 7 |
-
<link
|
| 8 |
-
<link href="https://
|
| 9 |
<style>
|
| 10 |
* { margin: 0; padding: 0; box-sizing: border-box; }
|
| 11 |
-
body { background: linear-gradient(135deg, #
|
| 12 |
|
| 13 |
.chat-icon { position: fixed; bottom: 28px; right: 28px; width: 64px; height: 64px; background: linear-gradient(145deg, #25D366, #128C7E); border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; box-shadow: 0 10px 25px rgba(0,0,0,0.2); animation: pulse 1.8s infinite; z-index: 1000; }
|
| 14 |
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(37,211,102,0.5); } 70% { box-shadow: 0 0 0 15px rgba(37,211,102,0); } 100% { box-shadow: 0 0 0 0 rgba(37,211,102,0); } }
|
| 15 |
.chat-icon:hover { transform: scale(1.08); background: #20b859; }
|
| 16 |
.chat-icon i { font-size: 32px; color: white; }
|
| 17 |
|
| 18 |
-
.chat-modal { position: fixed; bottom: 100px; right: 28px; width:
|
| 19 |
@keyframes slideUpFade { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } }
|
| 20 |
-
.chat-header { background: linear-gradient(135deg, #075E54, #0b3b32); color: white; padding: 12px 18px; display: flex; justify-content: space-between; align-items: center; }
|
| 21 |
-
.header-buttons { display: flex; gap: 10px; align-items: center; }
|
| 22 |
-
.header-btn { background: rgba(255,255,255,0.2); border: none; width: 32px; height: 32px; border-radius: 50%; cursor: pointer; color: white; transition: 0.2s; display: inline-flex; align-items: center; justify-content: center; }
|
| 23 |
-
.header-btn:hover { transform: scale(1.05); background: rgba(255,255,255,0.4); }
|
| 24 |
|
| 25 |
-
.chat-
|
| 26 |
-
.
|
| 27 |
-
.
|
| 28 |
-
.invoice-column.hidden { display: none; width: 0; padding: 0; }
|
| 29 |
-
.chat-column.expanded { flex: 1; }
|
| 30 |
|
| 31 |
-
.
|
| 32 |
-
.
|
| 33 |
-
.invoice-item { background: white; border-radius: 12px; padding: 8px 12px; margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
|
| 34 |
-
.invoice-item-name { font-weight: 500; font-size: 0.8rem; }
|
| 35 |
-
.invoice-item-price { font-size: 0.8rem; color: #2d6a4f; font-weight: 600; }
|
| 36 |
-
.remove-item { color: #e63946; cursor: pointer; font-size: 14px; transition: 0.2s; }
|
| 37 |
-
.remove-item:hover { transform: scale(1.1); }
|
| 38 |
-
.invoice-total { border-top: 2px dashed #ccc; padding-top: 10px; margin-top: 8px; font-weight: 700; font-size: 0.9rem; display: flex; justify-content: space-between; }
|
| 39 |
-
.empty-invoice { color: #888; font-size: 0.75rem; text-align: center; padding: 20px; }
|
| 40 |
-
.final-report-btn { background: #25D366; color: white; border: none; border-radius: 25px; padding: 8px 12px; font-size: 0.75rem; font-weight: 600; cursor: pointer; transition: 0.2s; width: 100%; margin-top: 8px; }
|
| 41 |
-
.final-report-btn:hover { background: #128C7E; transform: scale(1.02); }
|
| 42 |
-
|
| 43 |
-
.chat-messages { flex: 1; padding: 12px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
|
| 44 |
-
.message { max-width: 85%; padding: 8px 12px; border-radius: 18px; font-size: 0.8rem; line-height: 1.4; white-space: pre-line; animation: fadeIn 0.2s; }
|
| 45 |
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
|
| 46 |
-
.user-msg { background: #DCF8C6; margin-left: auto; border-bottom-right-radius:
|
| 47 |
-
.bot-msg { background: white; margin-right: auto; border-bottom-left-radius:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
-
.
|
| 50 |
-
.
|
| 51 |
-
.
|
| 52 |
-
.
|
|
|
|
| 53 |
|
| 54 |
-
.
|
| 55 |
-
.
|
| 56 |
-
.
|
| 57 |
-
.widget-controls button { background: rgba(255,255,255,0.2); border: none; color: white; border-radius: 20px; padding: 2px 8px; font-size: 0.7rem; cursor: pointer; transition: 0.2s; }
|
| 58 |
-
.widget-controls button:hover { background: rgba(255,255,255,0.4); }
|
| 59 |
-
.toggle-widget { cursor: pointer; margin-left: 8px; }
|
| 60 |
-
.widget-content { padding: 10px; display: none; background: #fef9e6; font-size: 0.7rem; }
|
| 61 |
-
.widget-content.show { display: block; }
|
| 62 |
-
.info-row { margin: 4px 0; }
|
| 63 |
-
.info-label { font-weight: 700; color: #075E54; }
|
| 64 |
|
| 65 |
-
.
|
| 66 |
-
.question-bubble { background: #e4e6eb; padding: 4px 10px; border-radius: 16px; font-size: 0.7rem; cursor: pointer; transition: 0.2s; }
|
| 67 |
-
.question-bubble:hover { background: #d1d4db; transform: translateY(-1px); }
|
| 68 |
|
| 69 |
-
|
| 70 |
-
.
|
| 71 |
-
@keyframes wave { 0%,60%,100% { transform: translateY(0); } 30% { transform: translateY(-4px); } }
|
| 72 |
-
.chat-input-area { display: flex; padding: 10px; background: white; border-top: 1px solid #ddd; gap: 8px; }
|
| 73 |
-
.chat-input-area input { flex: 1; padding: 8px 12px; border: 1px solid #ccc; border-radius: 30px; outline: none; font-size: 0.8rem; }
|
| 74 |
-
.chat-input-area button { background: #25D366; border: none; width: 36px; height: 36px; border-radius: 50%; color: white; cursor: pointer; }
|
| 75 |
</style>
|
| 76 |
</head>
|
| 77 |
<body>
|
|
@@ -79,344 +54,52 @@
|
|
| 79 |
<div class="chat-modal" id="chatModal">
|
| 80 |
<div class="chat-header">
|
| 81 |
<h3><i class="fas fa-robot"></i> Elite Visuals AI</h3>
|
| 82 |
-
<
|
| 83 |
-
<button class="header-btn" id="toggleInvoiceBtn" title="Toggle Invoice Panel"><i class="fas fa-eye-slash"></i></button>
|
| 84 |
-
<button class="header-btn" id="closeChat"><i class="fas fa-times"></i></button>
|
| 85 |
-
</div>
|
| 86 |
</div>
|
| 87 |
-
<div class="chat-
|
| 88 |
-
<
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
<span><i class="fas fa-chart-line"></i> 📊 Live Quote</span>
|
| 95 |
-
<div class="widget-controls">
|
| 96 |
-
<button id="hideWidgetBtn"><i class="fas fa-eye-slash"></i> Hide</button>
|
| 97 |
-
<button id="unhideWidgetBtn" style="display: none;"><i class="fas fa-eye"></i> Show</button>
|
| 98 |
-
<i class="fas fa-chevron-down toggle-widget" id="toggleIcon"></i>
|
| 99 |
-
</div>
|
| 100 |
-
</div>
|
| 101 |
-
<div class="widget-content" id="widgetContent">
|
| 102 |
-
<p id="widgetEmptyMsg">💡 Ask about a package/feature to see details.</p>
|
| 103 |
-
<div id="widgetDetails" style="display: none;"></div>
|
| 104 |
-
</div>
|
| 105 |
-
</div>
|
| 106 |
-
<div id="defaultQuestionsContainer" class="questions-container"></div>
|
| 107 |
-
</div>
|
| 108 |
-
<div class="chat-input-area">
|
| 109 |
-
<input type="text" id="userInput" placeholder="Ask about price, timeline, confirm Basic, add SEO...">
|
| 110 |
-
<button id="sendBtn"><i class="fas fa-paper-plane"></i></button>
|
| 111 |
-
</div>
|
| 112 |
-
</div>
|
| 113 |
-
<!-- Invoice Column -->
|
| 114 |
-
<div class="invoice-column" id="invoiceColumn">
|
| 115 |
-
<div class="invoice-title">
|
| 116 |
-
<span>🧾 Your Quote</span>
|
| 117 |
-
</div>
|
| 118 |
-
<div class="invoice-items" id="invoiceItems">
|
| 119 |
-
<div class="empty-invoice">✨ No services selected yet.<br>Ask or confirm a package to add.</div>
|
| 120 |
-
</div>
|
| 121 |
-
<div class="invoice-total" id="invoiceTotal">
|
| 122 |
-
<span>Subtotal:</span>
|
| 123 |
-
<span id="totalAmount">PKR 0</span>
|
| 124 |
-
</div>
|
| 125 |
-
<button class="final-report-btn" id="finalReportBtn"><i class="fas fa-file-alt"></i> Generate Final Report</button>
|
| 126 |
</div>
|
| 127 |
</div>
|
| 128 |
</div>
|
| 129 |
|
| 130 |
<script>
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
localStorage.setItem('chat_session_id', sessionId);
|
| 136 |
-
}
|
| 137 |
-
const API_URL = "/api/chat";
|
| 138 |
-
const DEFAULT_QUESTIONS = [
|
| 139 |
-
"Basic website price and timeline?",
|
| 140 |
-
"Standard package details",
|
| 141 |
-
"Premium package details",
|
| 142 |
-
"Extra: live chat cost increase?",
|
| 143 |
-
"Add e-commerce to my quote",
|
| 144 |
-
"Contact number"
|
| 145 |
-
];
|
| 146 |
-
|
| 147 |
-
// ---------- Invoice State ----------
|
| 148 |
-
let invoiceItems = []; // each item: { id, name, price, serviceKey, timelineDays (optional) }
|
| 149 |
-
let nextId = 1;
|
| 150 |
-
|
| 151 |
-
// Helper to parse price number
|
| 152 |
-
function parsePrice(priceStr) {
|
| 153 |
-
let match = priceStr.match(/(\d[\d,]+)/);
|
| 154 |
-
if (match) return parseInt(match[0].replace(/,/g, ''));
|
| 155 |
-
return 0;
|
| 156 |
-
}
|
| 157 |
-
|
| 158 |
-
// Helper to extract timeline days from string (e.g., "7-10 days" -> max 10)
|
| 159 |
-
function parseTimelineDays(timelineStr) {
|
| 160 |
-
if (!timelineStr) return 0;
|
| 161 |
-
let match = timelineStr.match(/(\d+)\s*-\s*(\d+)\s*days?/);
|
| 162 |
-
if (match) return parseInt(match[2]); // take max days
|
| 163 |
-
match = timelineStr.match(/(\d+)\s*days?/);
|
| 164 |
-
if (match) return parseInt(match[1]);
|
| 165 |
-
return 0;
|
| 166 |
-
}
|
| 167 |
-
|
| 168 |
-
function updateInvoiceDisplay() {
|
| 169 |
-
const container = document.getElementById('invoiceItems');
|
| 170 |
-
const totalSpan = document.getElementById('totalAmount');
|
| 171 |
-
if (invoiceItems.length === 0) {
|
| 172 |
-
container.innerHTML = '<div class="empty-invoice">✨ No services selected yet.<br>Ask or confirm a package to add.</div>';
|
| 173 |
-
totalSpan.innerText = 'PKR 0';
|
| 174 |
-
return;
|
| 175 |
-
}
|
| 176 |
-
let html = '';
|
| 177 |
-
let total = 0;
|
| 178 |
-
invoiceItems.forEach(item => {
|
| 179 |
-
const priceNum = parsePrice(item.price);
|
| 180 |
-
total += priceNum;
|
| 181 |
-
html += `
|
| 182 |
-
<div class="invoice-item" data-id="${item.id}">
|
| 183 |
-
<div class="invoice-item-name">${item.name}</div>
|
| 184 |
-
<div style="display: flex; align-items: center; gap: 12px;">
|
| 185 |
-
<span class="invoice-item-price">${item.price}</span>
|
| 186 |
-
<span class="remove-item" data-id="${item.id}"><i class="fas fa-times-circle"></i></span>
|
| 187 |
-
</div>
|
| 188 |
-
</div>
|
| 189 |
-
`;
|
| 190 |
-
});
|
| 191 |
-
container.innerHTML = html;
|
| 192 |
-
totalSpan.innerText = `PKR ${total.toLocaleString()}`;
|
| 193 |
-
document.querySelectorAll('.remove-item').forEach(el => {
|
| 194 |
-
el.addEventListener('click', (e) => {
|
| 195 |
-
const id = parseInt(el.dataset.id);
|
| 196 |
-
removeInvoiceItem(id);
|
| 197 |
-
});
|
| 198 |
-
});
|
| 199 |
-
}
|
| 200 |
-
|
| 201 |
-
function removeInvoiceItem(id) {
|
| 202 |
-
invoiceItems = invoiceItems.filter(item => item.id !== id);
|
| 203 |
-
updateInvoiceDisplay();
|
| 204 |
-
}
|
| 205 |
-
|
| 206 |
-
// Add item with optional timeline
|
| 207 |
-
function addInvoiceItem(serviceName, priceStr, serviceKey = null, timelineDays = null) {
|
| 208 |
-
if (serviceKey && invoiceItems.some(item => item.serviceKey === serviceKey)) return false;
|
| 209 |
-
const newItem = {
|
| 210 |
-
id: nextId++,
|
| 211 |
-
name: serviceName,
|
| 212 |
-
price: priceStr,
|
| 213 |
-
serviceKey: serviceKey || serviceName,
|
| 214 |
-
timelineDays: timelineDays
|
| 215 |
-
};
|
| 216 |
-
invoiceItems.push(newItem);
|
| 217 |
-
updateInvoiceDisplay();
|
| 218 |
-
return true;
|
| 219 |
-
}
|
| 220 |
-
|
| 221 |
-
// ---------- Generate Final Report ----------
|
| 222 |
-
function generateFinalReport() {
|
| 223 |
-
if (invoiceItems.length === 0) {
|
| 224 |
-
addMessageWithConfirm("❌ You haven't added any services yet. Please confirm some packages or features first.", 'bot');
|
| 225 |
-
return;
|
| 226 |
-
}
|
| 227 |
-
let report = "📋 **Final Project Report**\n\n**Selected Services:**\n";
|
| 228 |
-
let totalPrice = 0;
|
| 229 |
-
let totalTimelineDays = 0;
|
| 230 |
-
invoiceItems.forEach(item => {
|
| 231 |
-
const priceNum = parsePrice(item.price);
|
| 232 |
-
totalPrice += priceNum;
|
| 233 |
-
report += `- ${item.name}: ${item.price}\n`;
|
| 234 |
-
if (item.timelineDays) {
|
| 235 |
-
totalTimelineDays += item.timelineDays;
|
| 236 |
-
report += ` (timeline: ${item.timelineDays} days)\n`;
|
| 237 |
-
}
|
| 238 |
-
});
|
| 239 |
-
report += `\n**💰 Total Estimated Cost:** PKR ${totalPrice.toLocaleString()}`;
|
| 240 |
-
if (totalTimelineDays > 0) {
|
| 241 |
-
report += `\n**⏱️ Total Estimated Timeline:** ${totalTimelineDays} working days (cumulative)`;
|
| 242 |
-
report += `\n> Note: Some tasks can run in parallel, so actual timeline may be less. We will provide a detailed schedule after confirmation.`;
|
| 243 |
-
} else {
|
| 244 |
-
report += `\n**⏱️ Timeline:** Please contact for detailed timeline based on selected services.`;
|
| 245 |
-
}
|
| 246 |
-
report += `\n\n✅ This is a preliminary quote. For final confirmation and payment, please share your contact details or email us at hello@elitevisuals.com.`;
|
| 247 |
-
addMessageWithConfirm(report, 'bot');
|
| 248 |
}
|
| 249 |
|
| 250 |
-
// ---------- Live Widget ----------
|
| 251 |
-
const widgetContent = document.getElementById('widgetContent');
|
| 252 |
-
const toggleIcon = document.getElementById('toggleIcon');
|
| 253 |
-
const hideWidgetBtn = document.getElementById('hideWidgetBtn');
|
| 254 |
-
const unhideWidgetBtn = document.getElementById('unhideWidgetBtn');
|
| 255 |
-
const liveWidget = document.getElementById('liveWidget');
|
| 256 |
-
let widgetOpen = false;
|
| 257 |
-
|
| 258 |
-
toggleIcon.addEventListener('click', (e) => {
|
| 259 |
-
e.stopPropagation();
|
| 260 |
-
if (widgetOpen) {
|
| 261 |
-
widgetContent.classList.remove('show');
|
| 262 |
-
toggleIcon.classList.remove('fa-chevron-up');
|
| 263 |
-
toggleIcon.classList.add('fa-chevron-down');
|
| 264 |
-
} else {
|
| 265 |
-
widgetContent.classList.add('show');
|
| 266 |
-
toggleIcon.classList.remove('fa-chevron-down');
|
| 267 |
-
toggleIcon.classList.add('fa-chevron-up');
|
| 268 |
-
}
|
| 269 |
-
widgetOpen = !widgetOpen;
|
| 270 |
-
});
|
| 271 |
-
|
| 272 |
-
hideWidgetBtn.addEventListener('click', () => {
|
| 273 |
-
liveWidget.style.display = 'none';
|
| 274 |
-
hideWidgetBtn.style.display = 'none';
|
| 275 |
-
unhideWidgetBtn.style.display = 'inline-flex';
|
| 276 |
-
});
|
| 277 |
-
unhideWidgetBtn.addEventListener('click', () => {
|
| 278 |
-
liveWidget.style.display = 'block';
|
| 279 |
-
hideWidgetBtn.style.display = 'inline-flex';
|
| 280 |
-
unhideWidgetBtn.style.display = 'none';
|
| 281 |
-
});
|
| 282 |
-
|
| 283 |
-
function updateWidget(data) {
|
| 284 |
-
const widgetEmptyMsg = document.getElementById('widgetEmptyMsg');
|
| 285 |
-
const widgetDetailsDiv = document.getElementById('widgetDetails');
|
| 286 |
-
if (!data || Object.keys(data).length === 0) {
|
| 287 |
-
widgetEmptyMsg.style.display = 'block';
|
| 288 |
-
widgetDetailsDiv.style.display = 'none';
|
| 289 |
-
return;
|
| 290 |
-
}
|
| 291 |
-
let html = '';
|
| 292 |
-
if (data.package) {
|
| 293 |
-
html += `<div class="info-row"><span class="info-label">📦 Package:</span> ${data.package}</div>`;
|
| 294 |
-
if (data.price) html += `<div class="info-row"><span class="info-label">💰 Price:</span> ${data.price}</div>`;
|
| 295 |
-
if (data.timeline) html += `<div class="info-row"><span class="info-label">⏱️ Timeline:</span> ${data.timeline}</div>`;
|
| 296 |
-
if (data.features && data.features.length) {
|
| 297 |
-
html += `<div class="info-row"><span class="info-label">✅ Includes:</span><ul>${data.features.map(f => `<li>${f}</li>`).join('')}</ul></div>`;
|
| 298 |
-
}
|
| 299 |
-
// Save timeline days for later when adding to invoice
|
| 300 |
-
window._lastWidgetTimeline = data.timeline;
|
| 301 |
-
} else if (data.extra_feature) {
|
| 302 |
-
html += `<div class="info-row"><span class="info-label">✨ Extra:</span> ${data.extra_feature}</div>`;
|
| 303 |
-
if (data.extra_cost) html += `<div class="info-row"><span class="info-label">💰 Additional Cost:</span> ${data.extra_cost}</div>`;
|
| 304 |
-
if (data.extra_timeline) html += `<div class="info-row"><span class="info-label">⏱️ Timeline Increase:</span> ${data.extra_timeline}</div>`;
|
| 305 |
-
window._lastWidgetTimeline = data.extra_timeline;
|
| 306 |
-
} else if (data.service) {
|
| 307 |
-
html += `<div class="info-row"><span class="info-label">🛠️ Service:</span> ${data.service}</div>`;
|
| 308 |
-
if (data.price) html += `<div class="info-row"><span class="info-label">💰 Price:</span> ${data.price}</div>`;
|
| 309 |
-
if (data.timeline) html += `<div class="info-row"><span class="info-label">⏱️ Timeline:</span> ${data.timeline}</div>`;
|
| 310 |
-
window._lastWidgetTimeline = data.timeline;
|
| 311 |
-
} else {
|
| 312 |
-
html = `<div class="info-row">ℹ️ Ask about a package or feature.</div>`;
|
| 313 |
-
}
|
| 314 |
-
widgetDetailsDiv.innerHTML = html;
|
| 315 |
-
widgetEmptyMsg.style.display = 'none';
|
| 316 |
-
widgetDetailsDiv.style.display = 'block';
|
| 317 |
-
}
|
| 318 |
-
|
| 319 |
-
// ---------- Message with Confirm Button ----------
|
| 320 |
-
function addMessageWithConfirm(text, sender, widgetData = null) {
|
| 321 |
-
const chatMessagesDiv = document.getElementById('chatMessages');
|
| 322 |
-
if (sender === 'user') {
|
| 323 |
-
const div = document.createElement('div');
|
| 324 |
-
div.className = 'message user-msg';
|
| 325 |
-
div.innerText = text;
|
| 326 |
-
chatMessagesDiv.appendChild(div);
|
| 327 |
-
chatMessagesDiv.scrollTop = chatMessagesDiv.scrollHeight;
|
| 328 |
-
return;
|
| 329 |
-
}
|
| 330 |
-
const wrapper = document.createElement('div');
|
| 331 |
-
wrapper.className = 'bot-message-wrapper';
|
| 332 |
-
const msgDiv = document.createElement('div');
|
| 333 |
-
msgDiv.className = 'message bot-msg';
|
| 334 |
-
msgDiv.innerText = text;
|
| 335 |
-
wrapper.appendChild(msgDiv);
|
| 336 |
-
|
| 337 |
-
let serviceName = null, servicePrice = null, serviceKey = null, timelineStr = null;
|
| 338 |
-
if (widgetData) {
|
| 339 |
-
if (widgetData.package) {
|
| 340 |
-
serviceName = `${widgetData.package} Website Package`;
|
| 341 |
-
servicePrice = widgetData.price;
|
| 342 |
-
serviceKey = `pkg_${widgetData.package}`;
|
| 343 |
-
timelineStr = widgetData.timeline;
|
| 344 |
-
} else if (widgetData.service) {
|
| 345 |
-
serviceName = widgetData.service;
|
| 346 |
-
servicePrice = widgetData.price;
|
| 347 |
-
serviceKey = `svc_${widgetData.service}`;
|
| 348 |
-
timelineStr = widgetData.timeline;
|
| 349 |
-
} else if (widgetData.extra_feature) {
|
| 350 |
-
serviceName = `Extra: ${widgetData.extra_feature}`;
|
| 351 |
-
servicePrice = widgetData.extra_cost;
|
| 352 |
-
serviceKey = `extra_${widgetData.extra_feature}`;
|
| 353 |
-
timelineStr = widgetData.extra_timeline;
|
| 354 |
-
}
|
| 355 |
-
}
|
| 356 |
-
if (serviceName && servicePrice) {
|
| 357 |
-
const confirmBtn = document.createElement('button');
|
| 358 |
-
confirmBtn.className = 'confirm-btn';
|
| 359 |
-
confirmBtn.innerHTML = '<i class="fas fa-check-circle"></i> Confirm & Add to Quote';
|
| 360 |
-
confirmBtn.onclick = () => {
|
| 361 |
-
const timelineDays = timelineStr ? parseTimelineDays(timelineStr) : null;
|
| 362 |
-
addInvoiceItem(serviceName, servicePrice, serviceKey, timelineDays);
|
| 363 |
-
confirmBtn.disabled = true;
|
| 364 |
-
confirmBtn.style.opacity = '0.6';
|
| 365 |
-
confirmBtn.innerText = '✓ Added';
|
| 366 |
-
};
|
| 367 |
-
wrapper.appendChild(confirmBtn);
|
| 368 |
-
}
|
| 369 |
-
chatMessagesDiv.appendChild(wrapper);
|
| 370 |
-
chatMessagesDiv.scrollTop = chatMessagesDiv.scrollHeight;
|
| 371 |
-
}
|
| 372 |
-
|
| 373 |
-
// ---------- Chat UI ----------
|
| 374 |
const chatIcon = document.getElementById('chatIcon');
|
| 375 |
const chatModal = document.getElementById('chatModal');
|
| 376 |
const closeChat = document.getElementById('closeChat');
|
| 377 |
const sendBtn = document.getElementById('sendBtn');
|
| 378 |
const userInput = document.getElementById('userInput');
|
| 379 |
-
const
|
| 380 |
-
const questionsContainer = document.getElementById('defaultQuestionsContainer');
|
| 381 |
-
const finalReportBtn = document.getElementById('finalReportBtn');
|
| 382 |
-
finalReportBtn.addEventListener('click', () => generateFinalReport());
|
| 383 |
|
| 384 |
-
|
| 385 |
-
|
| 386 |
-
const toggleInvoiceBtn = document.getElementById('toggleInvoiceBtn');
|
| 387 |
-
let invoiceHidden = false;
|
| 388 |
-
toggleInvoiceBtn.addEventListener('click', () => {
|
| 389 |
-
if (invoiceHidden) {
|
| 390 |
-
invoiceColumn.classList.remove('hidden');
|
| 391 |
-
chatColumn.classList.remove('expanded');
|
| 392 |
-
toggleInvoiceBtn.innerHTML = '<i class="fas fa-eye-slash"></i>';
|
| 393 |
-
} else {
|
| 394 |
-
invoiceColumn.classList.add('hidden');
|
| 395 |
-
chatColumn.classList.add('expanded');
|
| 396 |
-
toggleInvoiceBtn.innerHTML = '<i class="fas fa-eye"></i>';
|
| 397 |
-
}
|
| 398 |
-
invoiceHidden = !invoiceHidden;
|
| 399 |
-
});
|
| 400 |
|
| 401 |
-
function
|
| 402 |
-
|
| 403 |
-
|
| 404 |
-
|
| 405 |
-
|
| 406 |
-
|
| 407 |
-
bubble.onclick = () => { userInput.value = q; sendMessage(); };
|
| 408 |
-
questionsContainer.appendChild(bubble);
|
| 409 |
-
});
|
| 410 |
}
|
| 411 |
|
| 412 |
let typingDiv = null;
|
| 413 |
function showTyping() {
|
| 414 |
if (typingDiv) return;
|
| 415 |
typingDiv = document.createElement('div');
|
| 416 |
-
typingDiv.className = '
|
| 417 |
typingDiv.innerHTML = '<span></span><span></span><span></span>';
|
| 418 |
-
|
| 419 |
-
|
| 420 |
}
|
| 421 |
function hideTyping() {
|
| 422 |
if (typingDiv) { typingDiv.remove(); typingDiv = null; }
|
|
@@ -425,51 +108,26 @@
|
|
| 425 |
async function sendMessage() {
|
| 426 |
const msg = userInput.value.trim();
|
| 427 |
if (!msg) return;
|
| 428 |
-
|
| 429 |
-
addMessageWithConfirm(msg, 'user');
|
| 430 |
userInput.value = '';
|
| 431 |
-
|
| 432 |
-
// Check for final report trigger
|
| 433 |
-
if (msg.toLowerCase().includes('final report') || msg.toLowerCase().includes('summary') || msg.toLowerCase().includes('total quote')) {
|
| 434 |
-
generateFinalReport();
|
| 435 |
-
return;
|
| 436 |
-
}
|
| 437 |
-
|
| 438 |
showTyping();
|
| 439 |
try {
|
| 440 |
-
const res = await fetch(
|
| 441 |
method: 'POST',
|
| 442 |
headers: { 'Content-Type': 'application/json' },
|
| 443 |
-
body: JSON.stringify({
|
| 444 |
});
|
| 445 |
const data = await res.json();
|
| 446 |
hideTyping();
|
| 447 |
-
|
| 448 |
-
addMessageWithConfirm(data.reply, 'bot', widgetData);
|
| 449 |
-
if (widgetData) {
|
| 450 |
-
updateWidget(widgetData);
|
| 451 |
-
if (!widgetOpen) {
|
| 452 |
-
widgetContent.classList.add('show');
|
| 453 |
-
toggleIcon.classList.remove('fa-chevron-down');
|
| 454 |
-
toggleIcon.classList.add('fa-chevron-up');
|
| 455 |
-
widgetOpen = true;
|
| 456 |
-
}
|
| 457 |
-
}
|
| 458 |
} catch (err) {
|
| 459 |
hideTyping();
|
| 460 |
-
|
| 461 |
}
|
| 462 |
}
|
| 463 |
|
| 464 |
-
chatIcon.onclick = () => {
|
| 465 |
-
chatModal.style.display = 'flex';
|
| 466 |
-
if (questionsContainer.children.length === 0) renderQuestionBubbles();
|
| 467 |
-
};
|
| 468 |
-
closeChat.onclick = () => chatModal.style.display = 'none';
|
| 469 |
sendBtn.onclick = sendMessage;
|
| 470 |
userInput.addEventListener('keypress', (e) => { if (e.key === 'Enter') sendMessage(); });
|
| 471 |
-
renderQuestionBubbles();
|
| 472 |
-
updateWidget(null);
|
| 473 |
</script>
|
| 474 |
</body>
|
| 475 |
</html>
|
|
|
|
| 2 |
<html lang="en">
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Elite Visuals AI – Website Builder</title>
|
| 7 |
+
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
|
| 8 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
| 9 |
<style>
|
| 10 |
* { margin: 0; padding: 0; box-sizing: border-box; }
|
| 11 |
+
body { background: linear-gradient(135deg, #0a0a0f 0%, #12121a 100%); font-family: 'Inter', sans-serif; height: 100vh; overflow: hidden; }
|
| 12 |
|
| 13 |
.chat-icon { position: fixed; bottom: 28px; right: 28px; width: 64px; height: 64px; background: linear-gradient(145deg, #25D366, #128C7E); border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; box-shadow: 0 10px 25px rgba(0,0,0,0.2); animation: pulse 1.8s infinite; z-index: 1000; }
|
| 14 |
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(37,211,102,0.5); } 70% { box-shadow: 0 0 0 15px rgba(37,211,102,0); } 100% { box-shadow: 0 0 0 0 rgba(37,211,102,0); } }
|
| 15 |
.chat-icon:hover { transform: scale(1.08); background: #20b859; }
|
| 16 |
.chat-icon i { font-size: 32px; color: white; }
|
| 17 |
|
| 18 |
+
.chat-modal { position: fixed; bottom: 100px; right: 28px; width: 420px; height: 620px; background: rgba(255,255,255,0.98); border-radius: 28px; box-shadow: 0 25px 50px -12px rgba(0,0,0,0.35); display: none; flex-direction: column; overflow: hidden; z-index: 1001; animation: slideUpFade 0.3s ease-out; }
|
| 19 |
@keyframes slideUpFade { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } }
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
+
.chat-header { background: linear-gradient(135deg, #075E54, #0b3b32); color: white; padding: 14px 20px; display: flex; justify-content: space-between; align-items: center; }
|
| 22 |
+
.close-btn { background: rgba(255,255,255,0.2); border: none; width: 32px; height: 32px; border-radius: 50%; cursor: pointer; color: white; transition: 0.2s; }
|
| 23 |
+
.close-btn:hover { transform: rotate(90deg); background: rgba(255,255,255,0.4); }
|
|
|
|
|
|
|
| 24 |
|
| 25 |
+
.chat-messages { flex: 1; padding: 16px; overflow-y: auto; background: #f0f2f5; display: flex; flex-direction: column; gap: 12px; }
|
| 26 |
+
.message { max-width: 85%; padding: 10px 14px; border-radius: 22px; font-size: 0.85rem; line-height: 1.45; white-space: pre-line; animation: fadeIn 0.25s; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
|
| 28 |
+
.user-msg { background: #DCF8C6; margin-left: auto; border-bottom-right-radius: 6px; }
|
| 29 |
+
.bot-msg { background: white; margin-right: auto; border-bottom-left-radius: 6px; box-shadow: 0 1px 2px rgba(0,0,0,0.05); }
|
| 30 |
+
|
| 31 |
+
.status-badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 0.7rem; margin-left: 8px; }
|
| 32 |
+
.status-pending { background: #ffc107; color: #333; }
|
| 33 |
+
.status-progress { background: #17a2b8; color: white; }
|
| 34 |
+
.status-completed { background: #28a745; color: white; }
|
| 35 |
|
| 36 |
+
.input-container { padding: 12px; background: white; border-top: 1px solid #ddd; }
|
| 37 |
+
.input-box { display: flex; gap: 8px; align-items: center; background: #f0f2f5; border-radius: 40px; padding: 5px 15px; }
|
| 38 |
+
.input-box input { flex: 1; background: transparent; border: none; padding: 12px 8px; font-size: 0.9rem; outline: none; }
|
| 39 |
+
.input-box button { background: #25D366; border: none; width: 42px; height: 42px; border-radius: 50%; color: white; cursor: pointer; transition: 0.2s; }
|
| 40 |
+
.input-box button:hover { background: #128C7E; transform: scale(1.02); }
|
| 41 |
|
| 42 |
+
.typing { display: flex; gap: 6px; padding: 5px 0; }
|
| 43 |
+
.typing span { width: 8px; height: 8px; background: #aaa; border-radius: 50%; animation: wave 1.2s infinite; }
|
| 44 |
+
@keyframes wave { 0%,60%,100% { opacity: 0.3; } 30% { opacity: 1; transform: translateY(-3px); } }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
+
.project-id { background: #1e2a3a; color: #ffd700; padding: 2px 6px; border-radius: 6px; font-family: monospace; }
|
|
|
|
|
|
|
| 47 |
|
| 48 |
+
/* Project status panel */
|
| 49 |
+
.status-panel { background: white; border-radius: 16px; padding: 12px; margin: 8px 0; border-left: 4px solid #25D366; }
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
</style>
|
| 51 |
</head>
|
| 52 |
<body>
|
|
|
|
| 54 |
<div class="chat-modal" id="chatModal">
|
| 55 |
<div class="chat-header">
|
| 56 |
<h3><i class="fas fa-robot"></i> Elite Visuals AI</h3>
|
| 57 |
+
<button class="close-btn" id="closeChat"><i class="fas fa-times"></i></button>
|
|
|
|
|
|
|
|
|
|
| 58 |
</div>
|
| 59 |
+
<div class="chat-messages" id="chatMessages">
|
| 60 |
+
<div class="message bot-msg">👋 Assalam-o-Alaikum! I'm Elite Visuals AI. I can help you plan your website project step by step. Type <strong>"I want to build a website"</strong> to start.</div>
|
| 61 |
+
</div>
|
| 62 |
+
<div class="input-container">
|
| 63 |
+
<div class="input-box">
|
| 64 |
+
<input type="text" id="userInput" placeholder="Type your message...">
|
| 65 |
+
<button id="sendBtn"><i class="fas fa-arrow-right"></i></button>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
</div>
|
| 67 |
</div>
|
| 68 |
</div>
|
| 69 |
|
| 70 |
<script>
|
| 71 |
+
let userId = localStorage.getItem('chat_user_id');
|
| 72 |
+
if (!userId) {
|
| 73 |
+
userId = 'user_' + Date.now() + '_' + Math.random().toString(36).substr(2, 8);
|
| 74 |
+
localStorage.setItem('chat_user_id', userId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
}
|
| 76 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
const chatIcon = document.getElementById('chatIcon');
|
| 78 |
const chatModal = document.getElementById('chatModal');
|
| 79 |
const closeChat = document.getElementById('closeChat');
|
| 80 |
const sendBtn = document.getElementById('sendBtn');
|
| 81 |
const userInput = document.getElementById('userInput');
|
| 82 |
+
const chatMessages = document.getElementById('chatMessages');
|
|
|
|
|
|
|
|
|
|
| 83 |
|
| 84 |
+
chatIcon.onclick = () => chatModal.style.display = 'flex';
|
| 85 |
+
closeChat.onclick = () => chatModal.style.display = 'none';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
|
| 87 |
+
function addMessage(text, sender) {
|
| 88 |
+
const div = document.createElement('div');
|
| 89 |
+
div.className = `message ${sender === 'user' ? 'user-msg' : 'bot-msg'}`;
|
| 90 |
+
div.innerHTML = text.replace(/\n/g, '<br>');
|
| 91 |
+
chatMessages.appendChild(div);
|
| 92 |
+
chatMessages.scrollTop = chatMessages.scrollHeight;
|
|
|
|
|
|
|
|
|
|
| 93 |
}
|
| 94 |
|
| 95 |
let typingDiv = null;
|
| 96 |
function showTyping() {
|
| 97 |
if (typingDiv) return;
|
| 98 |
typingDiv = document.createElement('div');
|
| 99 |
+
typingDiv.className = 'message bot-msg typing';
|
| 100 |
typingDiv.innerHTML = '<span></span><span></span><span></span>';
|
| 101 |
+
chatMessages.appendChild(typingDiv);
|
| 102 |
+
chatMessages.scrollTop = chatMessages.scrollHeight;
|
| 103 |
}
|
| 104 |
function hideTyping() {
|
| 105 |
if (typingDiv) { typingDiv.remove(); typingDiv = null; }
|
|
|
|
| 108 |
async function sendMessage() {
|
| 109 |
const msg = userInput.value.trim();
|
| 110 |
if (!msg) return;
|
| 111 |
+
addMessage(msg, 'user');
|
|
|
|
| 112 |
userInput.value = '';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 113 |
showTyping();
|
| 114 |
try {
|
| 115 |
+
const res = await fetch('/api/chat', {
|
| 116 |
method: 'POST',
|
| 117 |
headers: { 'Content-Type': 'application/json' },
|
| 118 |
+
body: JSON.stringify({ user_id: userId, message: msg })
|
| 119 |
});
|
| 120 |
const data = await res.json();
|
| 121 |
hideTyping();
|
| 122 |
+
addMessage(data.reply, 'bot');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
} catch (err) {
|
| 124 |
hideTyping();
|
| 125 |
+
addMessage("❌ Server error. Please try again.", 'bot');
|
| 126 |
}
|
| 127 |
}
|
| 128 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 129 |
sendBtn.onclick = sendMessage;
|
| 130 |
userInput.addEventListener('keypress', (e) => { if (e.key === 'Enter') sendMessage(); });
|
|
|
|
|
|
|
| 131 |
</script>
|
| 132 |
</body>
|
| 133 |
</html>
|