$(document).ready(()=>{ const socket = io(); const baseUrl = "http://coze-training.local"; const serverPath = "http://" + window.location.hostname + ":" + window.location.port + "/";// "http://coze.dev:3000/"; const canVibrate = "vibrate" in navigator || "mozVibrate" in navigator; if (canVibrate && !("vibrate" in navigator)){navigator.vibrate = navigator.mozVibrate;} const content = $('.content') const urlString = window.location.href const url = new URL(urlString); const sid = url.searchParams.get("sid"); $.getJSON( baseUrl + "/apis/getMessages.php", { sid: sid }).done( (data)=> { console.log(data); }); /* socket.on('cloudIndex', showCloud); socket.on('reset', reset); socket.on('message', showMessage); socket.on('response', showResponse); socket.on('actions', showActions); socket.on('display', showHtml); function reset(index){ cloudCount = 0 console.log('RESET:', index) content.empty() parent.postMessage(cloudCount, "*") } function showCloud(index){ console.log('RECEIVE:', index); const thisCloud = $(clouds.get(index)); let offset = 0; if(!thisCloud.hasClass('empty')){ notify(true); } thisCloud.fadeIn(400,()=>{ if(thisCloud.hasClass('scroll')){ offset = thisCloud.offset().top content.animate({ scrollTop: offset }, 400); } }) } function showMessage(message){ let newCloud = $('
' + decodeURIComponent(message) + '
'); content.append(newCloud); newCloud.fadeIn(); content.animate({ scrollTop: newCloud.offset().top }, 400); notify(false); cloudCount++ parent.postMessage(cloudCount, "*") } function showResponse(message){ let newCloud = $('
' + decodeURIComponent(message) + '
'); content.append(newCloud); newCloud.fadeIn(); content.animate({ scrollTop: newCloud.offset().top }, 400); notify(true); } function showActions(actions){ const actionsArray = decodeURIComponent(actions).split("|"); let token = ""; let buttons = ""; let text = ""; let side = ""; $.each(actionsArray, (index, val)=>{ if(index==0){ token = val; }else{ buttons += ""; } }); let newCloud = $('
' + buttons + '
'); content.append(newCloud); newCloud.fadeIn(); content.animate({ scrollTop: newCloud.offset().top }, 400); newCloud.find('button').on('click', ()=>{ $('.iframeGET').attr('src', serverPath + 'control.html?display='+token); }); } function showHtml(token){ switch(token){ case "plans_1": side = "empty"; text = ""; break; case "pull_1": side = "left"; text = "Ricordati di non avvicinarti eccessivamente."; break; case "monit_1": side = "left"; text = "TEMA 3 COMPETENZE DI VENDITA - REGOLA#1

"+ "Non rispondere a domande non fatte


"+ "Il cliente chiede di un prodotto. È meglio limitarsi a domandare cosa il cliente voglia sapere del prodotto.
"+ "Ad esempio, colore, materiale, taglia."+ ""; break; } if(tokenOnce.indexOf(token) < 0){ let newCloud = $('
' + text + '
'); setTimeout( ()=>{ content.append(newCloud); newCloud.fadeIn(); content.animate({ scrollTop: newCloud.offset().top }, 400); content.find('.video-opener').on('click', (e)=>{ const show = $('#video') const video = show.find('video') const close = show.find('.video-close') show.fadeIn() video.get(0).play() close.on('click', (e)=>{ const elem = $(e.currentTarget) const video = elem.siblings('video') video.get(0).pause() elem.parent().fadeOut() }) }); notify(true);; },1000); tokenOnce.push(token); } } function notify(vibrate){ if(vibrate){ navigator.vibrate(500); } $('#notify1')[0].play(); } */ });