// Mobile Menu Toggle
function toggleMobileMenu() {
const menu = document.getElementById('mobile-menu');
menu.classList.toggle('hidden');
}
// Non-Blocking Toast Notification
let toastTimeout = null;
function showToast(title, message) {
const toast = document.getElementById('toast');
const titleEl = document.getElementById('toast-title');
const msgEl = document.getElementById('toast-msg');
if (!toast || !titleEl || !msgEl) return;
titleEl.textContent = title;
msgEl.textContent = message;
toast.classList.remove('hidden');
clearTimeout(toastTimeout);
toastTimeout = setTimeout(() => {
toast.classList.add('hidden');
}, 4200);
}
// =========================================================================
// STUDIO ASSET & IMAGE MANAGER (Upload Local Files, Paste URLs & Export)
// =========================================================================
function openAssetManager() {
renderAssetManagerList();
const modal = document.getElementById('asset-manager-modal');
modal.classList.remove('hidden');
modal.classList.add('flex');
document.body.style.overflow = 'hidden';
}
function closeAssetManager(event) {
if (event && event.target !== event.currentTarget) return;
const modal = document.getElementById('asset-manager-modal');
modal.classList.add('hidden');
modal.classList.remove('flex');
document.body.style.overflow = '';
}
function renderAssetManagerList() {
const container = document.getElementById('asset-manager-list');
if (!container) return;
const heroCard = `
00 • Opening Hero Frame
Main Architectural Hero
1920 × 1080 px
`;
const brandCards = BRANDS.map((brand, idx) => {
const entry = SITE_ASSETS.brands[brand.id] || { primary: '', gallery: [] };
const galleryThumbs = (entry.gallery || []).map((gUrl, gIdx) => `
`).join('');
return `
${String(idx + 1).padStart(2, '0')} • ${brand.origin}
${brand.name}
${entry.gallery && entry.gallery.length > 0 ? `
Extra Gallery & Walkthrough Slides (${entry.gallery.length})
${galleryThumbs}
` : ''}
`;
}).join('');
container.innerHTML = heroCard + brandCards;
}
function updateHeroAsset(field, value) {
if (!value.trim() && field === 'image') return;
SITE_ASSETS.hero[field] = value.trim();
saveSiteAssets();
renderAssetManagerList();
showToast('Hero Updated', 'Opening architectural frame updated.');
}
function updateBrandPrimaryImage(brandId, url) {
if (!url.trim() || !SITE_ASSETS.brands[brandId]) return;
SITE_ASSETS.brands[brandId].primary = url.trim();
saveSiteAssets();
renderAssetManagerList();
showToast('Brand Image Updated', 'Primary card & walkthrough image updated.');
}
function removeBrandGalleryImage(brandId, index) {
if (!SITE_ASSETS.brands[brandId]) return;
SITE_ASSETS.brands[brandId].gallery.splice(index, 1);
saveSiteAssets();
renderAssetManagerList();
showToast('Slide Removed', 'Extra gallery slide removed.');
}
function handleLocalImageUpload(event, targetType, targetId) {
const files = Array.from(event.target.files || []);
if (!files.length) return;
files.forEach((file) => {
const reader = new FileReader();
reader.onload = (e) => {
const dataUrl = e.target.result;
if (targetType === 'hero') {
SITE_ASSETS.hero.image = dataUrl;
} else if (targetType === 'brand-primary' && SITE_ASSETS.brands[targetId]) {
SITE_ASSETS.brands[targetId].primary = dataUrl;
} else if (targetType === 'brand-gallery' && SITE_ASSETS.brands[targetId]) {
SITE_ASSETS.brands[targetId].gallery.push(dataUrl);
}
saveSiteAssets();
renderAssetManagerList();
showToast('Photo Uploaded', `${file.name} added to Bombay Luxe studio assets.`);
};
reader.readAsDataURL(file);
});
event.target.value = '';
}
function exportSiteAssetsConfig() {
const panel = document.getElementById('export-config-panel');
const textarea = document.getElementById('export-config-textarea');
const formatted = `const DEFAULT_SITE_ASSETS = ${JSON.stringify(SITE_ASSETS, null, 2)};`;
textarea.value = formatted;
panel.classList.remove('hidden');
showToast('Config Generated', 'Copy the DEFAULT_SITE_ASSETS block or use Copy Full HTML.');
}
function copyToClipboardFallback(text, successTitle, successMsg) {
const temp = document.createElement('textarea');
temp.value = text;
temp.style.position = 'fixed';
temp.style.opacity = '0';
document.body.appendChild(temp);
temp.select();
try {
document.execCommand('copy');
showToast(successTitle, successMsg);
} catch (err) {
showToast('Copy Notice', 'Select the text in the box and press Ctrl+C / Cmd+C.');
}
document.body.removeChild(temp);
}
function copyExportedConfig() {
const textarea = document.getElementById('export-config-textarea');
if (!textarea || !textarea.value) return;
copyToClipboardFallback(textarea.value, 'Config Copied', 'DEFAULT_SITE_ASSETS copied to your clipboard.');
}
function copyFullPageSource() {
let fullHtml = '\n' + document.documentElement.outerHTML;
const serializedAssets = `const DEFAULT_SITE_ASSETS = ${JSON.stringify(SITE_ASSETS, null, 2)};`;
fullHtml = fullHtml.replace(/const DEFAULT_SITE_ASSETS = \{[\s\S]*?\n \};/, serializedAssets);
copyToClipboardFallback(fullHtml, 'Full HTML Copied', 'Complete index.html code with your current images copied to clipboard.');
}
function resetAllAssets() {
SITE_ASSETS = JSON.parse(JSON.stringify(DEFAULT_SITE_ASSETS));
localStorage.removeItem(STORAGE_KEY);
applySiteAssetsToDOM();
renderAssetManagerList();
showToast('Assets Reset', 'Restored original curated portfolio photography.');
}
// Helper for inline form status banners
function renderFormStatus(elementId, type, htmlContent) {
} finally {
submitBtn.disabled = false;
submitBtn.textContent = originalBtnText;
submitBtn.classList.remove('opacity-75', 'cursor-not-allowed');
}
}
// =========================================================================
// CINEMATIC VIRTUAL SHOWROOM WALKTHROUGH ENGINE
// =========================================================================
let wtSlides = [];
let wtCurrentIndex = 0;
let wtIsPlaying = true;
let wtActiveStage = 'a';
let wtTimer = null;
let wtProgressRaf = null;
let wtSlideStartTime = 0;
const WT_SPEEDS = [
{ label: '1.0x Pace', duration: 6500 },
{ label: '1.4x Pace', duration: 4500 },
{ label: '0.75x Pace', duration: 9000 }
];
let wtSpeedIndex = 0;
function buildWalkthroughPlaylist(scope = 'all') {
const playlist = [];
if (scope === 'all') {
playlist.push({
image: SITE_ASSETS.hero.image,
title: 'BOMBAY LUXE',
origin: 'Mumbai • Milan • Florence',
category: 'Architectural Curation',
caption: SITE_ASSETS.hero.caption || 'Curating European Architectural Luxury for India’s Finest Spaces.',
inquireSubject: 'Full Portfolio Curation'
});
BRANDS.forEach((brand) => {
const images = getBrandAllImages(brand.id);
images.forEach((imgUrl, idx) => {
playlist.push({
image: imgUrl,
title: brand.name,
origin: brand.origin,
category: idx === 0 ? brand.categoryLabel : `${brand.categoryLabel} • View ${idx + 1}`,
caption: brand.tagline,
inquireSubject: brand.name
});
});
});
} else {
const brand = BRANDS.find(b => b.id === scope);
if (brand) {
const images = getBrandAllImages(brand.id);
images.forEach((imgUrl, idx) => {
playlist.push({
image: imgUrl,
title: brand.name,
origin: brand.origin,
category: `${brand.categoryLabel} • Frame ${idx + 1}`,
caption: idx === 0 ? brand.tagline : brand.description,
inquireSubject: brand.name
});
});
}
}
return playlist;
}
function openWalkthrough(scope = 'all') {
wtSlides = buildWalkthroughPlaylist(scope);
if (!wtSlides.length) return;
const scopeLabel = document.getElementById('wt-scope-label');
if (scopeLabel) {
scopeLabel.textContent = scope === 'all'
? `Architectural Showroom Walkthrough • ${wtSlides.length} Scenes`
: `${wtSlides[0].title} • Brand Monograph Reel`;
}
// Build segmented progress bars
const segContainer = document.getElementById('wt-progress-segments');
segContainer.style.gridTemplateColumns = `repeat(${wtSlides.length}, minmax(0, 1fr))`;
segContainer.innerHTML = wtSlides.map((_, idx) => `
`).join('');
// Build quick chapter pills
const pillsContainer = document.getElementById('wt-chapter-pills');
pillsContainer.innerHTML = wtSlides.map((slide, idx) => `
`).join('');
const modal = document.getElementById('walkthrough-modal');
modal.classList.remove('hidden');
modal.classList.add('flex');
document.body.style.overflow = 'hidden';
wtIsPlaying = true;
updatePlayPauseUI();
showWalkthroughSlide(0);
}
function closeWalkthrough() {
clearTimeout(wtTimer);
cancelAnimationFrame(wtProgressRaf);
const modal = document.getElementById('walkthrough-modal');
modal.classList.add('hidden');
modal.classList.remove('flex');
document.body.style.overflow = '';
}
function showWalkthroughSlide(rawIndex) {
if (!wtSlides.length) return;
clearTimeout(wtTimer);
cancelAnimationFrame(wtProgressRaf);
wtCurrentIndex = (rawIndex + wtSlides.length) % wtSlides.length;
const slide = wtSlides[wtCurrentIndex];
const duration = WT_SPEEDS[wtSpeedIndex].duration;
// Update segment bars & chapter pills
wtSlides.forEach((_, idx) => {
const fill = document.getElementById(`wt-seg-fill-${idx}`);
const pill = document.getElementById(`wt-pill-${idx}`);
if (fill) {
fill.style.width = idx < wtCurrentIndex ? '100%' : '0%';
}
if (pill) {
if (idx === wtCurrentIndex) {
pill.classList.add('bg-white', 'text-black', 'border-white');
pill.classList.remove('text-white/70');
} else {
pill.classList.remove('bg-white', 'text-black', 'border-white');
pill.classList.add('text-white/70');
}
}
});
// Cross-dissolve between stage A and stage B
const incomingStage = wtActiveStage === 'a' ? document.getElementById('wt-stage-b') : document.getElementById('wt-stage-a');
const outgoingStage = wtActiveStage === 'a' ? document.getElementById('wt-stage-a') : document.getElementById('wt-stage-b');
const incomingImg = wtActiveStage === 'a' ? document.getElementById('wt-img-b') : document.getElementById('wt-img-a');
incomingImg.src = slide.image;
incomingImg.alt = slide.title;
incomingImg.style.setProperty('--slide-duration', `${duration + 1200}ms`);
incomingImg.className = `w-full h-full object-cover will-change-transform kb-motion-${wtCurrentIndex % 4}`;
if (!wtIsPlaying) incomingImg.classList.add('kb-paused');
incomingStage.classList.remove('opacity-0');
incomingStage.classList.add('opacity-100');
outgoingStage.classList.remove('opacity-100');
outgoingStage.classList.add('opacity-0');
wtActiveStage = wtActiveStage === 'a' ? 'b' : 'a';
// Update editorial lower-third metadata
document.getElementById('wt-slide-counter').textContent = `${String(wtCurrentIndex + 1).padStart(2, '0')} / ${String(wtSlides.length).padStart(2, '0')}`;
document.getElementById('wt-slide-origin').textContent = slide.origin;
document.getElementById('wt-slide-category').textContent = slide.category;
document.getElementById('wt-slide-title').textContent = slide.title;
document.getElementById('wt-slide-caption').textContent = slide.caption;
const inquireBtn = document.getElementById('wt-inquire-slide-btn');
if (inquireBtn) {
inquireBtn.onclick = () => {
closeWalkthrough();
openInquiryModal(slide.inquireSubject);
};
}
if (wtIsPlaying) {
wtSlideStartTime = performance.now();
animateSegmentProgress(duration);
wtTimer = setTimeout(() => {
nextWalkthroughSlide();
}, duration);
}
}
function animateSegmentProgress(duration) {