From 112f343ecfc2293c3c8febb6f55526de15748f99 Mon Sep 17 00:00:00 2001 From: John Mizerek Date: Thu, 12 Feb 2026 20:31:29 -0800 Subject: [PATCH] Fix wizard: header preview uses cover, add image matching step after HTML import --- portal/index.html | 2 +- portal/setup-wizard.html | 162 +++++++++++++++++++++++++++++++++++---- 2 files changed, 149 insertions(+), 15 deletions(-) diff --git a/portal/index.html b/portal/index.html index 65bde5c..d475d02 100644 --- a/portal/index.html +++ b/portal/index.html @@ -633,7 +633,7 @@

Displayed at the top of your menu. Recommended: 1200x400px

-
+
@@ -1455,6 +1488,107 @@ event.target.value = ''; } + // Show step to upload images from saved webpage subfolder and match to items + function showImageMatchingStep() { + const itemCount = config.extractedData.items ? config.extractedData.items.length : 0; + const mappingCount = config.imageMappings.length; + + addMessage('ai', ` +

I found ${itemCount} menu items and detected ${mappingCount} image references in the HTML.

+

To add images to your menu items, upload the images from the saved webpage folder (usually named something like pagename_files).

+

I'll automatically match images to items based on filenames.

+
+ + + +
+ `); + } + + // Handle image matching from uploaded files + function handleImageMatching(event) { + const files = event.target.files; + if (!files.length) return; + + let matchedCount = 0; + const matchResults = []; + + Array.from(files).forEach(file => { + const filename = file.name.toLowerCase(); + + // Try to find a matching mapping + for (const mapping of config.imageMappings) { + const mappingFilename = mapping.filename.toLowerCase(); + + // Check for exact filename match or close match + if (filename === mappingFilename || + filename.includes(mappingFilename.replace(/\.[^.]+$/, '')) || + mappingFilename.includes(filename.replace(/\.[^.]+$/, ''))) { + + // Find matching item by alt text or name + const altText = (mapping.alt || '').toLowerCase(); + const matchedItem = config.extractedData.items.find(item => { + const itemName = (item.name || '').toLowerCase(); + const itemAlt = (item.imageAlt || '').toLowerCase(); + return itemName === altText || + itemAlt === altText || + itemName.includes(altText) || + altText.includes(itemName) || + (itemAlt && (itemAlt.includes(altText) || altText.includes(itemAlt))); + }); + + if (matchedItem) { + config.itemImages[matchedItem.id] = file; + matchedCount++; + matchResults.push({ item: matchedItem.name, file: file.name }); + break; + } + } + } + }); + + // Show results + const totalFiles = files.length; + const resultHtml = matchResults.length > 0 + ? `` + : ''; + + addMessage('ai', ` +

Matched ${matchedCount} of ${totalFiles} uploaded images to menu items.

+ ${resultHtml} +
+ + +
+ `); + + console.log('Image matching results:', matchResults); + console.log('Item images map:', config.itemImages); + + // Reset input + event.target.value = ''; + } + + function skipImageMatching() { + proceedAfterImageMatching(); + } + + function proceedAfterImageMatching() { + // In add-menu mode, skip business info and header + if (config.businessId && config.menuId) { + showCategoriesStep(); + } else { + showBusinessInfoStep(); + } + } + async function startAnalysis() { if (config.uploadedFiles.length === 0) { showToast('Please upload at least one menu image', 'error');