diff --git a/api/setup/analyzeMenuUrl.cfm b/api/setup/analyzeMenuUrl.cfm new file mode 100644 index 0000000..29ea73e --- /dev/null +++ b/api/setup/analyzeMenuUrl.cfm @@ -0,0 +1,368 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ]+src=["'']([^"'']+)["''][^>]*>', menuPage.html)> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ]*>.*?", "", "all")> + ]*>.*?", "", "all")> + ", "", "all")> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +#serializeJSON(response)# diff --git a/portal/setup-wizard.html b/portal/setup-wizard.html index 81a6beb..2e75242 100644 --- a/portal/setup-wizard.html +++ b/portal/setup-wizard.html @@ -769,31 +769,71 @@

Let's Setup Your Menu

-

Upload your menu images or PDFs and I'll extract then input all the information for you to preview!

+

Import your menu from a website URL or upload images/PDFs

-
- - - - - -

Drop your menu images here

-

or click to browse (JPG, PNG, PDF supported)

- + +
+ +
-
- - +
+ + +
@@ -1209,6 +1249,115 @@ } } + // Switch between URL and file upload tabs + function switchImportTab(tab) { + const tabUrl = document.getElementById('tabUrl'); + const tabUpload = document.getElementById('tabUpload'); + const urlPanel = document.getElementById('urlImportPanel'); + const filePanel = document.getElementById('fileUploadPanel'); + + if (tab === 'url') { + tabUrl.style.background = 'var(--primary)'; + tabUrl.style.color = 'white'; + tabUpload.style.background = 'var(--gray-100)'; + tabUpload.style.color = 'var(--gray-700)'; + urlPanel.style.display = 'block'; + filePanel.style.display = 'none'; + } else { + tabUpload.style.background = 'var(--primary)'; + tabUpload.style.color = 'white'; + tabUrl.style.background = 'var(--gray-100)'; + tabUrl.style.color = 'var(--gray-700)'; + urlPanel.style.display = 'none'; + filePanel.style.display = 'block'; + } + } + + // URL-based menu import + async function startUrlAnalysis() { + const urlInput = document.getElementById('menuUrlInput'); + const url = urlInput.value.trim(); + + if (!url) { + showToast('Please enter a website URL', 'error'); + return; + } + + // Hide upload section, show conversation + document.getElementById('uploadSection').style.display = 'none'; + + addMessage('ai', ` +
+
+ Crawling website and extracting menu data... +
+

This may take 30-60 seconds while I fetch pages, download images, and analyze everything.

+ `); + + try { + const response = await fetch(`${config.apiBaseUrl}/setup/analyzeMenuUrl.cfm`, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ url }) + }); + + const result = await response.json(); + + if (!result.OK) { + throw new Error(result.MESSAGE || 'Failed to analyze URL'); + } + + // Store extracted data + config.extractedData = result.DATA; + config.sourceUrl = result.sourceUrl; + + // Log debug info + console.log('=== URL IMPORT RESPONSE ==='); + console.log('Source URL:', result.sourceUrl); + console.log('Pages processed:', result.pagesProcessed); + console.log('Images found:', result.imagesFound); + console.log('Extracted data:', result.DATA); + if (result.steps) { + console.log('Steps:', result.steps); + } + console.log('==========================='); + + // Remove loading message and start conversation flow + document.getElementById('conversation').innerHTML = ''; + + // In add-menu mode, skip business info and header + if (config.businessId && config.menuId) { + showCategoriesStep(); + } else { + showBusinessInfoStep(); + } + + } catch (error) { + console.error('URL analysis error:', error); + document.getElementById('conversation').innerHTML = ''; + addMessage('ai', ` +

Sorry, I encountered an error importing from that URL:

+

${error.message}

+
+ + +
+ `); + } + } + + function retryUrlAnalysis() { + document.getElementById('conversation').innerHTML = ''; + document.getElementById('uploadSection').style.display = 'block'; + switchImportTab('url'); + } + + function switchToFileUpload() { + document.getElementById('conversation').innerHTML = ''; + document.getElementById('uploadSection').style.display = 'block'; + switchImportTab('upload'); + } + async function startAnalysis() { if (config.uploadedFiles.length === 0) { showToast('Please upload at least one menu image', 'error');