Spaces:
Paused
Paused
Update index.html
Browse files- index.html +98 -76
index.html
CHANGED
|
@@ -138,6 +138,9 @@
|
|
| 138 |
"Contact number"
|
| 139 |
];
|
| 140 |
|
|
|
|
|
|
|
|
|
|
| 141 |
// ---------- Invoice State ----------
|
| 142 |
let invoiceItems = [];
|
| 143 |
let nextId = 1;
|
|
@@ -203,8 +206,97 @@
|
|
| 203 |
return true;
|
| 204 |
}
|
| 205 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 206 |
// ---------- Auto-add services from bot messages ----------
|
| 207 |
-
// Map of keywords to service details (name, price, key)
|
| 208 |
const serviceMap = {
|
| 209 |
"domain": { name: "Domain Registration", price: "PKR 5,000", key: "domain" },
|
| 210 |
"e-commerce": { name: "E‑commerce Functionality", price: "PKR 50,000", key: "ecommerce" },
|
|
@@ -217,11 +309,12 @@
|
|
| 217 |
"multi-language": { name: "Multi-Language", price: "PKR 25,000", key: "multi_language" },
|
| 218 |
"custom backend": { name: "Custom Backend", price: "PKR 100,000", key: "custom_backend" }
|
| 219 |
};
|
| 220 |
-
|
| 221 |
-
// Extra pages price: base 5 pages included, each extra PKR 5,000
|
| 222 |
let currentPages = 5;
|
| 223 |
|
| 224 |
function autoAddFromBotMessage(text) {
|
|
|
|
|
|
|
|
|
|
| 225 |
const lower = text.toLowerCase();
|
| 226 |
// Domain
|
| 227 |
if (lower.includes("domain: yes") || (lower.includes("need a domain") && lower.includes("yes"))) {
|
|
@@ -233,14 +326,11 @@
|
|
| 233 |
const pages = parseInt(pagesMatch[1]);
|
| 234 |
if (pages !== currentPages) {
|
| 235 |
currentPages = pages;
|
| 236 |
-
// Remove existing pages item if any
|
| 237 |
invoiceItems = invoiceItems.filter(item => item.serviceKey !== "pages");
|
| 238 |
const extraPages = Math.max(0, pages - 5);
|
| 239 |
if (extraPages > 0) {
|
| 240 |
const extraCost = extraPages * 5000;
|
| 241 |
addInvoiceItem(`${extraPages} extra page(s)`, `PKR ${extraCost.toLocaleString()}`, "pages");
|
| 242 |
-
} else {
|
| 243 |
-
// base 5 pages included, no extra cost
|
| 244 |
}
|
| 245 |
}
|
| 246 |
}
|
|
@@ -275,7 +365,6 @@
|
|
| 275 |
}
|
| 276 |
}
|
| 277 |
}
|
| 278 |
-
// Also handle "✅ Added **multi-language**" from the bot's response
|
| 279 |
const genericAdded = text.match(/✅ Added (.+?)\./i);
|
| 280 |
if (genericAdded && !addedMatch) {
|
| 281 |
const feature = genericAdded[1].toLowerCase();
|
|
@@ -288,74 +377,7 @@
|
|
| 288 |
}
|
| 289 |
}
|
| 290 |
|
| 291 |
-
// ----------
|
| 292 |
-
function generateFinalReport() {
|
| 293 |
-
if (invoiceItems.length === 0) {
|
| 294 |
-
addMessageWithConfirm("❌ You haven't added any services yet. Please confirm some packages or features first.", 'bot');
|
| 295 |
-
return;
|
| 296 |
-
}
|
| 297 |
-
let report = "📋 **Final Project Report**\n\n**Selected Services:**\n";
|
| 298 |
-
let totalPrice = 0;
|
| 299 |
-
let totalTimelineDays = 0;
|
| 300 |
-
invoiceItems.forEach(item => {
|
| 301 |
-
const priceNum = parsePrice(item.price);
|
| 302 |
-
totalPrice += priceNum;
|
| 303 |
-
report += `- ${item.name}: ${item.price}\n`;
|
| 304 |
-
if (item.timelineDays) {
|
| 305 |
-
totalTimelineDays += item.timelineDays;
|
| 306 |
-
report += ` (timeline: ${item.timelineDays} days)\n`;
|
| 307 |
-
}
|
| 308 |
-
});
|
| 309 |
-
report += `\n**💰 Total Estimated Cost:** PKR ${totalPrice.toLocaleString()}`;
|
| 310 |
-
if (totalTimelineDays > 0) {
|
| 311 |
-
report += `\n**⏱️ Total Estimated Timeline:** ${totalTimelineDays} working days (cumulative)`;
|
| 312 |
-
report += `\n> Note: Some tasks can run in parallel, so actual timeline may be less. We will provide a detailed schedule after confirmation.`;
|
| 313 |
-
} else {
|
| 314 |
-
report += `\n**⏱️ Timeline:** Please contact for detailed timeline based on selected services.`;
|
| 315 |
-
}
|
| 316 |
-
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.`;
|
| 317 |
-
addMessageWithConfirm(report, 'bot');
|
| 318 |
-
}
|
| 319 |
-
|
| 320 |
-
function downloadReport() {
|
| 321 |
-
if (invoiceItems.length === 0) {
|
| 322 |
-
alert("No services selected. Please add items to your quote first.");
|
| 323 |
-
return;
|
| 324 |
-
}
|
| 325 |
-
let content = "ELITE VISUALS – QUOTE REPORT\n";
|
| 326 |
-
content += "==========================\n\n";
|
| 327 |
-
content += `Date: ${new Date().toLocaleString()}\n`;
|
| 328 |
-
content += `Session ID: ${sessionId}\n\n`;
|
| 329 |
-
content += "Selected Services:\n";
|
| 330 |
-
content += "-----------------\n";
|
| 331 |
-
let totalPrice = 0;
|
| 332 |
-
let totalDays = 0;
|
| 333 |
-
invoiceItems.forEach(item => {
|
| 334 |
-
const priceNum = parsePrice(item.price);
|
| 335 |
-
totalPrice += priceNum;
|
| 336 |
-
content += `• ${item.name}: ${item.price}\n`;
|
| 337 |
-
if (item.timelineDays) {
|
| 338 |
-
totalDays += item.timelineDays;
|
| 339 |
-
content += ` (est. timeline: ${item.timelineDays} days)\n`;
|
| 340 |
-
}
|
| 341 |
-
});
|
| 342 |
-
content += "\n-----------------\n";
|
| 343 |
-
content += `TOTAL COST: PKR ${totalPrice.toLocaleString()}\n`;
|
| 344 |
-
if (totalDays > 0) content += `CUMULATIVE TIMELINE: ${totalDays} working days\n`;
|
| 345 |
-
content += "\nThis is an estimate. Final quote may vary.\n";
|
| 346 |
-
content += "Contact: hello@elitevisuals.com | +92 300 1234567\n";
|
| 347 |
-
const blob = new Blob([content], { type: "text/plain" });
|
| 348 |
-
const url = URL.createObjectURL(blob);
|
| 349 |
-
const a = document.createElement("a");
|
| 350 |
-
a.href = url;
|
| 351 |
-
a.download = `quote_${new Date().toISOString().slice(0,19).replace(/:/g, "-")}.txt`;
|
| 352 |
-
document.body.appendChild(a);
|
| 353 |
-
a.click();
|
| 354 |
-
document.body.removeChild(a);
|
| 355 |
-
URL.revokeObjectURL(url);
|
| 356 |
-
}
|
| 357 |
-
|
| 358 |
-
// ---------- Live Widget (same as before) ----------
|
| 359 |
const widgetContent = document.getElementById('widgetContent');
|
| 360 |
const toggleIcon = document.getElementById('toggleIcon');
|
| 361 |
const hideWidgetBtn = document.getElementById('hideWidgetBtn');
|
|
@@ -438,7 +460,7 @@
|
|
| 438 |
msgDiv.innerText = text;
|
| 439 |
wrapper.appendChild(msgDiv);
|
| 440 |
|
| 441 |
-
// Auto-add services from bot message
|
| 442 |
autoAddFromBotMessage(text);
|
| 443 |
|
| 444 |
let serviceName = null, servicePrice = null, serviceKey = null, timelineStr = null;
|
|
|
|
| 138 |
"Contact number"
|
| 139 |
];
|
| 140 |
|
| 141 |
+
// ---------- Store Project ID from bot confirmation ----------
|
| 142 |
+
let storedProjectId = localStorage.getItem(`project_id_${sessionId}`) || null;
|
| 143 |
+
|
| 144 |
// ---------- Invoice State ----------
|
| 145 |
let invoiceItems = [];
|
| 146 |
let nextId = 1;
|
|
|
|
| 206 |
return true;
|
| 207 |
}
|
| 208 |
|
| 209 |
+
// ---------- Extract and store Project ID from bot message ----------
|
| 210 |
+
function extractAndStoreProjectId(text) {
|
| 211 |
+
const match = text.match(/Project ID:\s*`([A-Z0-9\-]+)`/i);
|
| 212 |
+
if (match) {
|
| 213 |
+
const pid = match[1];
|
| 214 |
+
storedProjectId = pid;
|
| 215 |
+
localStorage.setItem(`project_id_${sessionId}`, pid);
|
| 216 |
+
console.log("Project ID stored:", pid);
|
| 217 |
+
}
|
| 218 |
+
}
|
| 219 |
+
|
| 220 |
+
// ---------- Generate Final Report (in chat) ----------
|
| 221 |
+
function generateFinalReport() {
|
| 222 |
+
if (invoiceItems.length === 0) {
|
| 223 |
+
addMessageWithConfirm("❌ You haven't added any services yet. Please confirm some packages or features first.", 'bot');
|
| 224 |
+
return;
|
| 225 |
+
}
|
| 226 |
+
let report = "📋 **Final Project Report**\n\n**Selected Services:**\n";
|
| 227 |
+
let totalPrice = 0;
|
| 228 |
+
let totalTimelineDays = 0;
|
| 229 |
+
invoiceItems.forEach(item => {
|
| 230 |
+
const priceNum = parsePrice(item.price);
|
| 231 |
+
totalPrice += priceNum;
|
| 232 |
+
report += `- ${item.name}: ${item.price}\n`;
|
| 233 |
+
if (item.timelineDays) {
|
| 234 |
+
totalTimelineDays += item.timelineDays;
|
| 235 |
+
report += ` (timeline: ${item.timelineDays} days)\n`;
|
| 236 |
+
}
|
| 237 |
+
});
|
| 238 |
+
report += `\n**💰 Total Estimated Cost:** PKR ${totalPrice.toLocaleString()}`;
|
| 239 |
+
if (totalTimelineDays > 0) {
|
| 240 |
+
report += `\n**⏱️ Total Estimated Timeline:** ${totalTimelineDays} working days (cumulative)`;
|
| 241 |
+
report += `\n> Note: Some tasks can run in parallel, so actual timeline may be less. We will provide a detailed schedule after confirmation.`;
|
| 242 |
+
} else {
|
| 243 |
+
report += `\n**⏱️ Timeline:** Please contact for detailed timeline based on selected services.`;
|
| 244 |
+
}
|
| 245 |
+
if (storedProjectId) {
|
| 246 |
+
report += `\n\n📌 **Project ID:** \`${storedProjectId}\`\n🔍 **Check status:** Type \`status ${storedProjectId}\` anytime.`;
|
| 247 |
+
} else {
|
| 248 |
+
report += `\n\n✅ After final confirmation, you will receive a Project ID to track your request.`;
|
| 249 |
+
}
|
| 250 |
+
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.`;
|
| 251 |
+
addMessageWithConfirm(report, 'bot');
|
| 252 |
+
}
|
| 253 |
+
|
| 254 |
+
// ---------- Download Report (as .txt file) ----------
|
| 255 |
+
function downloadReport() {
|
| 256 |
+
if (invoiceItems.length === 0) {
|
| 257 |
+
alert("No services selected. Please add items to your quote first.");
|
| 258 |
+
return;
|
| 259 |
+
}
|
| 260 |
+
let content = "ELITE VISUALS – QUOTE REPORT\n";
|
| 261 |
+
content += "==========================\n\n";
|
| 262 |
+
content += `Date: ${new Date().toLocaleString()}\n`;
|
| 263 |
+
content += `Session ID: ${sessionId}\n\n`;
|
| 264 |
+
content += "Selected Services:\n";
|
| 265 |
+
content += "-----------------\n";
|
| 266 |
+
let totalPrice = 0;
|
| 267 |
+
let totalDays = 0;
|
| 268 |
+
invoiceItems.forEach(item => {
|
| 269 |
+
const priceNum = parsePrice(item.price);
|
| 270 |
+
totalPrice += priceNum;
|
| 271 |
+
content += `• ${item.name}: ${item.price}\n`;
|
| 272 |
+
if (item.timelineDays) {
|
| 273 |
+
totalDays += item.timelineDays;
|
| 274 |
+
content += ` (est. timeline: ${item.timelineDays} days)\n`;
|
| 275 |
+
}
|
| 276 |
+
});
|
| 277 |
+
content += "\n-----------------\n";
|
| 278 |
+
content += `TOTAL COST: PKR ${totalPrice.toLocaleString()}\n`;
|
| 279 |
+
if (totalDays > 0) content += `CUMULATIVE TIMELINE: ${totalDays} working days\n`;
|
| 280 |
+
if (storedProjectId) {
|
| 281 |
+
content += `\n📌 PROJECT ID: ${storedProjectId}\n`;
|
| 282 |
+
content += `🔍 To check status, type in chat: status ${storedProjectId}\n`;
|
| 283 |
+
} else {
|
| 284 |
+
content += `\n✅ After final confirmation, you will receive a Project ID to track your request.\n`;
|
| 285 |
+
}
|
| 286 |
+
content += "\nThis is an estimate. Final quote may vary.\n";
|
| 287 |
+
content += "Contact: hello@elitevisuals.com | +92 300 1234567\n";
|
| 288 |
+
const blob = new Blob([content], { type: "text/plain" });
|
| 289 |
+
const url = URL.createObjectURL(blob);
|
| 290 |
+
const a = document.createElement("a");
|
| 291 |
+
a.href = url;
|
| 292 |
+
a.download = `quote_${new Date().toISOString().slice(0,19).replace(/:/g, "-")}.txt`;
|
| 293 |
+
document.body.appendChild(a);
|
| 294 |
+
a.click();
|
| 295 |
+
document.body.removeChild(a);
|
| 296 |
+
URL.revokeObjectURL(url);
|
| 297 |
+
}
|
| 298 |
+
|
| 299 |
// ---------- Auto-add services from bot messages ----------
|
|
|
|
| 300 |
const serviceMap = {
|
| 301 |
"domain": { name: "Domain Registration", price: "PKR 5,000", key: "domain" },
|
| 302 |
"e-commerce": { name: "E‑commerce Functionality", price: "PKR 50,000", key: "ecommerce" },
|
|
|
|
| 309 |
"multi-language": { name: "Multi-Language", price: "PKR 25,000", key: "multi_language" },
|
| 310 |
"custom backend": { name: "Custom Backend", price: "PKR 100,000", key: "custom_backend" }
|
| 311 |
};
|
|
|
|
|
|
|
| 312 |
let currentPages = 5;
|
| 313 |
|
| 314 |
function autoAddFromBotMessage(text) {
|
| 315 |
+
// Also check for project ID
|
| 316 |
+
extractAndStoreProjectId(text);
|
| 317 |
+
|
| 318 |
const lower = text.toLowerCase();
|
| 319 |
// Domain
|
| 320 |
if (lower.includes("domain: yes") || (lower.includes("need a domain") && lower.includes("yes"))) {
|
|
|
|
| 326 |
const pages = parseInt(pagesMatch[1]);
|
| 327 |
if (pages !== currentPages) {
|
| 328 |
currentPages = pages;
|
|
|
|
| 329 |
invoiceItems = invoiceItems.filter(item => item.serviceKey !== "pages");
|
| 330 |
const extraPages = Math.max(0, pages - 5);
|
| 331 |
if (extraPages > 0) {
|
| 332 |
const extraCost = extraPages * 5000;
|
| 333 |
addInvoiceItem(`${extraPages} extra page(s)`, `PKR ${extraCost.toLocaleString()}`, "pages");
|
|
|
|
|
|
|
| 334 |
}
|
| 335 |
}
|
| 336 |
}
|
|
|
|
| 365 |
}
|
| 366 |
}
|
| 367 |
}
|
|
|
|
| 368 |
const genericAdded = text.match(/✅ Added (.+?)\./i);
|
| 369 |
if (genericAdded && !addedMatch) {
|
| 370 |
const feature = genericAdded[1].toLowerCase();
|
|
|
|
| 377 |
}
|
| 378 |
}
|
| 379 |
|
| 380 |
+
// ---------- Live Widget (unchanged) ----------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 381 |
const widgetContent = document.getElementById('widgetContent');
|
| 382 |
const toggleIcon = document.getElementById('toggleIcon');
|
| 383 |
const hideWidgetBtn = document.getElementById('hideWidgetBtn');
|
|
|
|
| 460 |
msgDiv.innerText = text;
|
| 461 |
wrapper.appendChild(msgDiv);
|
| 462 |
|
| 463 |
+
// Auto-add services from bot message (and capture project ID)
|
| 464 |
autoAddFromBotMessage(text);
|
| 465 |
|
| 466 |
let serviceName = null, servicePrice = null, serviceKey = null, timelineStr = null;
|