You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
193 lines
4.5 KiB
193 lines
4.5 KiB
7 years ago
|
$(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 = $('<div class="cloud right">' + decodeURIComponent(message) + '</div>');
|
||
|
content.append(newCloud);
|
||
|
newCloud.fadeIn();
|
||
|
content.animate({
|
||
|
scrollTop: newCloud.offset().top
|
||
|
}, 400);
|
||
|
notify(false);
|
||
|
|
||
|
cloudCount++
|
||
|
parent.postMessage(cloudCount, "*")
|
||
|
}
|
||
|
|
||
|
function showResponse(message){
|
||
|
let newCloud = $('<div class="cloud left">' + decodeURIComponent(message) + '</div>');
|
||
|
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 += "<button class= \"button dotted\">"+val+"</button>";
|
||
|
}
|
||
|
});
|
||
|
|
||
|
let newCloud = $('<div class="cloud empty">' + buttons + '</div>');
|
||
|
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 = "<img src=\""+serverPath.replace(":3000", "")+"images/video.png\" class=\"video-opener\">";
|
||
|
break;
|
||
|
case "pull_1":
|
||
|
side = "left";
|
||
|
text = "Ricordati di non avvicinarti eccessivamente.";
|
||
|
break;
|
||
|
case "monit_1":
|
||
|
side = "left";
|
||
|
text = "<b>TEMA 3 COMPETENZE DI VENDITA - REGOLA#1<br><br>"+
|
||
|
"Non rispondere a domande non fatte</b><br><br>"+
|
||
|
"Il cliente chiede di un prodotto. È meglio limitarsi a domandare cosa il cliente voglia sapere del prodotto.<br>"+
|
||
|
"<b>Ad esempio, colore, materiale, taglia.</b>"+
|
||
|
"<img src=\""+serverPath.replace(":3000", "")+"images/photo-compare2.jpg\" width=\"100%\">";
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
if(tokenOnce.indexOf(token) < 0){
|
||
|
|
||
|
let newCloud = $('<div class="cloud '+side+'">' + text + '</div>');
|
||
|
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();
|
||
|
}
|
||
|
*/
|
||
|
|
||
|
|
||
|
});
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|