- Kiosk mode: fullscreen, wake lock, auto-login, context menu block, PWA/Capacitor detection - AI vision: camera photos analyzed by Gemma 3 27B vision model via OpenRouter - AI part classification: auto-suggest name/brand/category when entering part number - Public catalog chatbot: /api/chat endpoint with rate limiting, chat widget on catalog page Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -121,7 +121,48 @@
|
||||
|
||||
function showCreateModal() {
|
||||
document.getElementById('createModal').classList.add('is-open');
|
||||
// Attach AI classification on part number blur
|
||||
var pnInput = document.getElementById('newPartNumber');
|
||||
if (pnInput && !pnInput._classifyBound) {
|
||||
pnInput._classifyBound = true;
|
||||
pnInput.addEventListener('blur', function () {
|
||||
var pn = this.value.trim();
|
||||
if (pn.length < 3) return;
|
||||
var nameInput = document.getElementById('newName');
|
||||
// Only auto-classify if name is still empty
|
||||
if (nameInput && nameInput.value.trim()) return;
|
||||
classifyPartNumber(pn);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function classifyPartNumber(partNumber) {
|
||||
var resultEl = document.getElementById('createResult');
|
||||
resultEl.innerHTML = '<span style="color:var(--color-text-muted);">Consultando IA...</span>';
|
||||
apiFetch(API + '/classify/' + encodeURIComponent(partNumber)).then(function (data) {
|
||||
if (!data) return;
|
||||
if (data.name) {
|
||||
document.getElementById('newName').value = data.name;
|
||||
}
|
||||
if (data.brand) {
|
||||
document.getElementById('newBrand').value = data.brand;
|
||||
}
|
||||
// Show suggestion label
|
||||
var parts = [];
|
||||
if (data.name) parts.push(data.name);
|
||||
if (data.brand) parts.push(data.brand);
|
||||
if (data.vehicle) parts.push(data.vehicle);
|
||||
if (data.category) parts.push(data.category);
|
||||
if (parts.length > 0) {
|
||||
resultEl.innerHTML = '<span style="color:var(--color-accent);font-size:var(--text-caption);">Sugerido por IA: ' + esc(parts.join(' | ')) + '</span>';
|
||||
} else {
|
||||
resultEl.innerHTML = '<span style="color:var(--color-text-muted);font-size:var(--text-caption);">IA no pudo identificar este numero de parte</span>';
|
||||
}
|
||||
}).catch(function () {
|
||||
resultEl.innerHTML = '';
|
||||
});
|
||||
}
|
||||
|
||||
function closeCreateModal() {
|
||||
document.getElementById('createModal').classList.remove('is-open');
|
||||
document.getElementById('createResult').innerHTML = '';
|
||||
|
||||
Reference in New Issue
Block a user