Modalità di spedizione
Vai al contenuto
NOVITÀ
NEGOZIO
INFO
CHI SIAMO
CONTATTI
SPEDIZIONE
ISTRUZIONI
CATALOGO
IT
DE
EN
FR
ES
IT
NL
SV
DA
JA
ZH
????
Modalità di spedizione
apollon
2019-10-02T00:05:07+02:00
Si prega di selezionare prima il paese di destinazione della spedizione
Germania e Austria
Stati membri dell'Unione Europea
Stati europei al di fuori dell'Unione Europea
Stati al di fuori dell'Europa
Si prega di selezionare prima il paese di spedizione
Germania
e Austria
Stati membri
dell'Unione Europea
Stati europei
al di fuori
dell'Unione Europea
Stati
al di fuori dell'Europa
Collegamento al caricamento della pagina
Invia
'; document.body.appendChild(box); var input = document.getElementById('mz-chat-input'); var sendBtn = document.getElementById('mz-chat-send'); var msgsDiv = document.getElementById('mz-chat-msgs'); var closeBtn = document.getElementById('mz-chat-close'); closeBtn.onclick = function() { box.classList.remove('open'); isOpen = false; }; sendBtn.onclick = sendMessage; input.onkeydown = function(e) { if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); sendMessage(); } }; function toggleChat() { isOpen = !isOpen; if (isOpen) { box.classList.add('open'); if (messages.length === 0) addBotMessage('Benvenuti in MAZANLI. Come posso aiutarvi?'); input.focus(); } else { box.classList.remove('open'); } } function addBotMessage(text) { messages.push({ role: 'bot', text: text }); var div = document.createElement('div'); div.className = 'mz-msg mz-msg-bot'; div.innerHTML = '
' + escapeHtml(text) + '
'; msgsDiv.appendChild(div); msgsDiv.scrollTop = msgsDiv.scrollHeight; } function addUserMessage(text) { messages.push({ role: 'user', text: text }); var div = document.createElement('div'); div.className = 'mz-msg mz-msg-user'; div.innerHTML = '
' + escapeHtml(text) + '
'; msgsDiv.appendChild(div); msgsDiv.scrollTop = msgsDiv.scrollHeight; } function showTyping() { var div = document.createElement('div'); div.className = 'mz-msg mz-msg-bot'; div.id = 'mz-typing'; div.innerHTML = '
'; msgsDiv.appendChild(div); msgsDiv.scrollTop = msgsDiv.scrollHeight; } function hideTyping() { var el = document.getElementById('mz-typing'); if (el) el.remove(); } function showWeiterleitung() { if (document.querySelector('.mz-weiterleitung')) return; var wrap = document.getElementById('mz-chat-input-wrap'); var div = document.createElement('div'); div.className = 'mz-weiterleitung'; div.innerHTML = '
Invia al team
'; wrap.parentNode.insertBefore(div, wrap); } window._mzWeiterleiten = function() { var name = document.getElementById('mz-wl-name').value; var email = document.getElementById('mz-wl-email').value; var msg = document.getElementById('mz-wl-msg').value; if (!email) { alert('Si prega di fornire un indirizzo e-mail'); return; } fetch(API + '/weiterleiten', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ conversation_id: convId, name: name, email: email, nachricht: msg }) }) .then(function(r) { return r.json(); }) .then(function(d) { var el = document.querySelector('.mz-weiterleitung'); if (el) el.remove(); addBotMessage(d.message || 'Il messaggio è stato inoltrato. Vi contatteremo presto.'); }) .catch(function() { addBotMessage('Inoltro non riuscito. Si prega di contattarci direttamente all\'indirizzo info@mazan.li'); }); }; function sendMessage() { var text = input.value.trim(); if (!text) return; input.value = ''; addUserMessage(text); sendBtn.disabled = true; showTyping(); fetch(API + '/message', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ message: text, conversation_id: convId }) }) .then(function(r) { return r.json(); }) .then(function(d) { hideTyping(); sendBtn.disabled = false; if (d.error) { addBotMessage('Scusate, si è verificato un errore.'); return; } convId = d.conversation_id; addBotMessage(d.antwort); if (d.antwort.toLowerCase().indexOf('weiterleiten') > -1 || d.antwort.toLowerCase().indexOf('team') > -1 || d.antwort.toLowerCase().indexOf('info@mazan.li') > -1) { showWeiterleitung(); } input.focus(); }) .catch(function() { hideTyping(); sendBtn.disabled = false; addBotMessage('Connessione non riuscita. Si prega di riprovare.'); }); } function escapeHtml(str) { return str.replace(/&/g,'&').replace(//g,'>').replace(/"/g,'"').replace(/\n/g,'
'); } })();