Update chat.js
Browse files
chat.js
CHANGED
@@ -116,8 +116,8 @@ function calculateTiles() {
|
|
116 |
addMessage('bot', `📐 This tile has a very high aspect ratio (${aspectRatio.toFixed(1)}:1). Please double-check if that's correct.`);
|
117 |
}
|
118 |
|
119 |
-
const numTiles = Math.ceil((area / tileArea) * 1.1);
|
120 |
-
const numBoxes = Math.ceil(numTiles / 10);
|
121 |
|
122 |
chatArea.insertAdjacentHTML('beforeend', `
|
123 |
<div class="bot-message bg-gray-100 rounded-lg p-4 mb-3">
|
@@ -159,18 +159,31 @@ function calculateTiles() {
|
|
159 |
function loadProductRecommendations(products) {
|
160 |
recommendations.innerHTML = '';
|
161 |
products.slice(0, 4).forEach(p => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
162 |
recommendations.insertAdjacentHTML('beforeend', `
|
163 |
<div class="bg-white rounded-lg overflow-hidden shadow-sm border border-gray-100">
|
164 |
-
<div class="h-32 bg-gray-
|
165 |
-
${p.image_url ? `<img src="${p.image_url}" class="h-full object-cover" alt="${p.name}">` : `
|
166 |
<svg xmlns="http://www.w3.org/2000/svg" class="h-12 w-12 text-gray-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
167 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1" d="M4 6a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2H6a2 2 0 01-2-2V6zM14 6a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2h-2a2 2 0 01-2-2V6zM4 16a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2H6a2 2 0 01-2-2v-2zM14 16a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2h-2a2 2 0 01-2-2v-2z" />
|
168 |
</svg>`}
|
169 |
</div>
|
170 |
<div class="p-3">
|
171 |
<h4 class="font-medium text-gray-800">${p.name || 'Tile Product'}</h4>
|
172 |
-
<p class="text-sm text-gray-600 mt-1"
|
173 |
-
<
|
|
|
|
|
|
|
174 |
</div>
|
175 |
</div>
|
176 |
`);
|
|
|
116 |
addMessage('bot', `📐 This tile has a very high aspect ratio (${aspectRatio.toFixed(1)}:1). Please double-check if that's correct.`);
|
117 |
}
|
118 |
|
119 |
+
const numTiles = Math.ceil((area / tileArea) * 1.1);
|
120 |
+
const numBoxes = Math.ceil(numTiles / 10);
|
121 |
|
122 |
chatArea.insertAdjacentHTML('beforeend', `
|
123 |
<div class="bot-message bg-gray-100 rounded-lg p-4 mb-3">
|
|
|
159 |
function loadProductRecommendations(products) {
|
160 |
recommendations.innerHTML = '';
|
161 |
products.slice(0, 4).forEach(p => {
|
162 |
+
let ftSize = '';
|
163 |
+
const mmMatch = p.size?.match(/(\d+)\s*[x×X*]\s*(\d+)/);
|
164 |
+
if (mmMatch) {
|
165 |
+
const mmWidth = parseFloat(mmMatch[1]);
|
166 |
+
const mmHeight = parseFloat(mmMatch[2]);
|
167 |
+
const ftWidth = (mmWidth * 0.00328084).toFixed(2);
|
168 |
+
const ftHeight = (mmHeight * 0.00328084).toFixed(2);
|
169 |
+
ftSize = ` (${ftWidth} ft × ${ftHeight} ft)`;
|
170 |
+
}
|
171 |
+
|
172 |
recommendations.insertAdjacentHTML('beforeend', `
|
173 |
<div class="bg-white rounded-lg overflow-hidden shadow-sm border border-gray-100">
|
174 |
+
<div class="h-32 bg-gray-100 flex items-center justify-center">
|
175 |
+
${p.image_url ? `<img src="${p.image_url}" class="h-full object-cover w-full" alt="${p.name}">` : `
|
176 |
<svg xmlns="http://www.w3.org/2000/svg" class="h-12 w-12 text-gray-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
177 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1" d="M4 6a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2H6a2 2 0 01-2-2V6zM14 6a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2h-2a2 2 0 01-2-2V6zM4 16a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2H6a2 2 0 01-2-2v-2zM14 16a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2h-2a2 2 0 01-2-2v-2z" />
|
178 |
</svg>`}
|
179 |
</div>
|
180 |
<div class="p-3">
|
181 |
<h4 class="font-medium text-gray-800">${p.name || 'Tile Product'}</h4>
|
182 |
+
<p class="text-sm text-gray-600 mt-1">₹${p.price || 'N/A'}/box</p>
|
183 |
+
<p class="text-xs text-gray-500 mt-1">Size: ${p.size}${ftSize}</p>
|
184 |
+
<a href="${p.url || '#'}" target="_blank" rel="noopener noreferrer">
|
185 |
+
<button class="mt-2 w-full bg-indigo-600 text-white py-1 rounded text-sm hover:bg-indigo-700 transition">View Product</button>
|
186 |
+
</a>
|
187 |
</div>
|
188 |
</div>
|
189 |
`);
|