"use strict"; function isArray(o) { return Object.prototype.toString.call(o) === '[object Array]'; } var newWidthString = 'calc(100% - 301px)'; var overHeadVisPing = -1 ; var current_FocusId = ""; var listOpenedVis = new Array(); var listWaitingVis = new Array(); var listIncomingVis = new Array(); var histo = ""; var excel = ""; var agents= ""; var transferAuthor = 0; ////////////////////////// // DETAILS DE NAVIGATION function detailComBox( vw_session_id, vw_key, tab_i) { creatLoading("visitor_ongoing", "watcheezyCanvasLoaderChat", vw_session_id+"A", "80"); var xdrd = getXDomainRequest(); //progression du chargement xdrd.onprogress = function(e) { var percentComplete; if (e.lengthComputable) { percentComplete = Math.round((e.loaded / e.total) * 100);//contenu de la div enfant //si la div existe if(document.getElementById('WatchBox_pourcent')) { document.getElementById('WatchBox_pourcent').innerHTML = "Loading "+percentComplete +" %";//ajoute le contenu } } }; xdrd.onload = function() { if(document.getElementById("visitor_content_"+tab_i)) document.getElementById("visitor_content_"+tab_i).innerHTML= xdrd.responseText; if(document.getElementById("superDragContent-"+tab_i)) $('#superDragContent-'+tab_i).antiscroll(); //desactive tous les boutons desactivBT(tab_i); //active le bouton changeClasses("dtl"+tab_i, "inactif", "actif"); //change la class //efface le loading //effaceLoading(vw_session_id+"A"); effaceLoadingVisitor(vw_session_id+"A", function(message) { }); } xdrd.open("GET", urlSrvRoot+"/appli"+version+"/ajax/visitor_info_mobile.php?session="+vw_session_id+"&key="+vw_key+"&tab="+tab_i+"&allLic="+allLic+"&specialtable="+specialtable+"&lang="+bo_lang); xdrd.send(); if(document.querySelector('.icone_export')) document.querySelector('.icone_export').style.display = ''; if(document.querySelector('.icone_sendlead')) document.querySelector('.icone_sendlead').style.display = ''; } /////////////// // DETAILS API function detailComBoxApi(jsonDetail, tab_i) { var details_vis = jsonDetail.replace(/@@/g,"\"");details_vis = details_vis.replace(/%%/g,"'");details_vis = details_vis.replace(/#@/g,'+'); var customInfo = JSON.parse(details_vis); var apiDetail = ""; apiDetail += "
";
histoDetail += ""+dateMessage+"";
histoDetail += ""+contenuMessage+"";
var msg = contenuMessage.replace("
","");
msg = msg.replace(/
/g,"");
msg = msg.replace("","");
msg = msg.replace(/;/g,",");
excel+=';'+dateMessage+';'+msg+"\n";
histoDetail += "
";
histoDetail += "
";
histoDetail += ""+dateMessage+"";
histoDetail += ""+contenuMessage+"";
var msg = contenuMessage.replace("
","");
msg = msg.replace("
","");
msg = msg.replace(''+txtMessageAuto,"");
msg = msg.replace("","");
excel+=';'+dateMessage+';'+msg+"\n";
histoDetail += "
";
histoDetail += "
/g,"");
}
return conversExport;
}
//////////////////////////////////////////
// EXPORT DES INFO DU VISITEUR ET LE CHAT
function exportVis(vw_session_id, vw_key, tab_i, apiDetails)
{
var apiDetail = "";
if(apiDetails != "")
{
var details_vis = apiDetails.replace(/@@/g,"\"");
details_vis = details_vis.replace(/%%/g,"'");
details_vis = details_vis.replace(/#@/g,'+');
var customInfo = JSON.parse(details_vis);
for(var l_key in customInfo)
{
apiDetail += customInfo[l_key][0]+": ";
if(isArray(customInfo[l_key][1]))
{
for(var subkey in customInfo[l_key][1])
{
apiDetail += customInfo[l_key][1][subkey][0];
apiDetail += ": ";
apiDetail += customInfo[l_key][1][subkey][1];
apiDetail += "\n";
}
}
else
{
apiDetail += customInfo[l_key][1];
}
apiDetail += "\n";
}
}
var convers = '';
convers = chatToString(vw_session_id);
var infoParam = apiDetail;
if(document.getElementById("vis_fname_"+tab_i))
infoParam += "Prénom : "+document.getElementById("vis_fname_"+tab_i).innerHTML+"\n";
if(document.getElementById("vis_lname_"+tab_i))
infoParam += "Nom : "+document.getElementById("vis_lname_"+tab_i).innerHTML+"\n";
if(document.getElementById("vis_name_"+tab_i))
infoParam += "Identité : "+document.getElementById("vis_name_"+tab_i).innerHTML+"\n";
if(document.getElementById("vis_email_"+tab_i))
infoParam += "Email : "+document.getElementById("vis_email_"+tab_i).innerHTML+"\n";
if(document.getElementById("vis_tel_"+tab_i))
infoParam += "Tel : "+document.getElementById("vis_tel_"+tab_i).innerHTML+"\n";
if(document.getElementById("vis_coord_"+tab_i))
infoParam += "Coordonnées : "+document.getElementById("vis_coord_"+tab_i).innerHTML+"\n";
if(document.getElementById("vis_comment_"+tab_i))
infoParam += "Commentaires : "+document.getElementById("vis_comment_"+tab_i).innerHTML+"\n";
if(document.getElementById("vis_transformed_"+tab_i))
infoParam += "Type lead : "+document.getElementById("vis_transformed_"+tab_i).innerHTML+"\n";
if(document.getElementById("vis_focus_"+tab_i))
infoParam += "Dernière page : "+document.getElementById("vis_focus_"+tab_i).innerHTML+"\n";
if(document.getElementById("vis_wzid_"+tab_i))
infoParam += "ID watcheezy : "+document.getElementById("vis_wzid_"+tab_i).innerHTML+"\n";
if(document.getElementById("vis_lang_"+tab_i))
infoParam += "Langue : "+document.getElementById("vis_lang_"+tab_i).innerHTML+"\n";
if(document.getElementById("vis_ip_"+tab_i))
infoParam += "IP : "+document.getElementById("vis_ip_"+tab_i).innerHTML+"\n";
if(document.getElementById("vis_purchase_"+tab_i))
infoParam += "Achats : "+document.getElementById("vis_purchase_"+tab_i).innerHTML+"\n";
if(document.getElementById("vis_funnel_"+tab_i))
infoParam += "Tunnel achat : "+document.getElementById("vis_funnel_"+tab_i).innerHTML+"\n";
if(document.getElementById("vis_contacted_"+tab_i))
infoParam += "Contacté : "+document.getElementById("vis_contacted_"+tab_i).innerHTML+"\n";
if(document.getElementById("vis_nav_"+tab_i))
infoParam += "Navigateur : "+document.getElementById("vis_nav_"+tab_i).innerHTML+"\n";
if(document.getElementById("vis_tps_focus_"+tab_i))
infoParam += "Durée Navigation : "+document.getElementById("vis_tps_focus_"+tab_i).innerHTML+"\n";
if(document.getElementById("vis_last_focus_"+tab_i))
infoParam += "Dernière visite : "+document.getElementById("vis_last_focus_"+tab_i).innerHTML+"\n";
if(document.getElementById("vis_list_page_"+tab_i))
infoParam += "Liste pages vues : \n"+document.getElementById("vis_list_page_"+tab_i).innerHTML+"\n";
infoParam += "Conversation : \n"+convers;
var vwParams = "info_div="+infoParam;
var xdr = getXDomainRequest();
xdr.onload = function()
{
window.open('../../ajx/visitor_export.php','',''); // on retourne sur la page pour l'export (données ont été sauvées dans SESSION)
}
xdr.open("POST", urlSrvRoot+"/bo/ajx/visitor_export.php"); // on envoi les info en POST
xdr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xdr.send(vwParams);
}
function sendLeadFromDB(vw_key, viz_id, viz_sess_id, leadGender, leadFName, leadLName, leadName, leadEmail, leadTel, leadCoord, leadComment,
LeadZip, LeadVille, LeadTelf, LeadTelm, LeadCompany, Leadimpos, LeadProprio,LeadRevenu,LeadRevenuf,LeadAge,
LeadJob,LeadSituation,LeadEnfant,LeadcResi,LeadcVehic,LeadcConso,LeadcAutres,LeadcTotal,LeadEpargne,LeadDateRappel,
LeadHorraireRappel, LeadApport, LeadSurface, LeadTypeBien, LeadProgramme, LeadBudget, LeadDestination, LeadNbPieces, LeadSuite, LeadHisto, LeadIp)
{
var dest = "";
if(vw_key == 'efe59c556a4504811f4170e760bf17af')
dest = "K&B";
else if(vw_key =='255060f06325f027c1ec93ea8a154824')
dest = "GdA";
else if(vw_key =='ccce7652b939d6f85b4f1ffcac476d6c')
dest = "Akerys";
else if(vw_key =='149555db90cc2f1d32de849a3f0d79d8')
dest = "Marie (pour Parapharmacie-A)";
else if(vw_key =='af8af9b7589e2e88caa912c0b9ae376c')
dest = "Ikinoa"
else if(vw_key =='8926c7d949ad81061a7842d37acee54a')
dest = "Bodemer"
else if(vw_key =='e28d337bdc3e661c54fb31d17cdb3f59')
dest = "Loi-Pinel";
else if(vw_key == '228413cdfaac739b0bae1f11fff5fcef')
dest = "Nacarat";
else if(vw_key == '14301691e0421a8d43f67d50c57ab942' || vw_key == "adad9e37fb749c6884c852e38f1bf17c")
dest = "BNP";
else if(vw_key == '62343cdaeed801935008b68f92f93c1c' || vw_key == "612502dcd54eaf3125eab789aeb26820" || vw_key == "1eza21dz79r84tbnsgfb")
dest = "Watcheezy";
else if(vw_key == '3b1da41bcd93f3fda87ff6044cb70e98')
dest = "Waterair";
else if(vw_key == '673884106768f60e5af531abf9145f39')
dest = "Aiguillon";
else if(vw_key == '75df02197ff09ffec6186dd2906bee88')
dest = "Fitnext";
else if(vw_key == '5eb25bcfd75671b42f7b9df5cabb5fb7')
dest = "FRG immobilier";
else if(vw_key == "unknownsupervisitor")
dest = "Transférer";
var apiinfo = "";
var apiDetail = "";
if(document.getElementById('watchee_apiinfo_'+viz_sess_id))
{
apiinfo = document.getElementById('watchee_apiinfo_'+viz_sess_id).value;
if(apiinfo != "")
{
var details_vis = apiinfo.replace(/@@/g,"\"");
details_vis = details_vis.replace(/%%/g,"'");
details_vis = details_vis.replace(/#@/g,'+');
var customInfo = JSON.parse(details_vis);
for(var l_key in customInfo)
{
apiDetail += customInfo[l_key][0]+" : ";
if(isArray(customInfo[l_key][1]))
{
for(var subkey in customInfo[l_key][1])
{
apiDetail += customInfo[l_key][1][subkey][0];
apiDetail += " : ";
apiDetail += customInfo[l_key][1][subkey][1];
apiDetail += "
";
}
apiDetail += "
";
}
else
{
apiDetail += customInfo[l_key][1];
}
apiDetail += "
";
}
apiDetail += "
";
}
}
var leadCommentString = leadComment.replace(/%%/g,"'"); leadCommentString = leadComment.replace(/
/g,'\n');
var leadFNameString = leadFName.replace(/%%/g,"'");
var leadLNameString = leadLName.replace(/%%/g,"'");
var leadNameString = leadName.replace(/%%/g,"'");
var LeadHistoString = "";
if(typeof LeadHisto !== 'undefined')
LeadHistoString = LeadHisto.replace(/
/g,"\n");
var apiDetailString = apiDetail.replace(/
/g,"\n");
var confirmMsg = "Envoyer à "+dest+"?\n";
if(leadGender != "") confirmMsg += "Genre : "+leadGender+" \n";
if(leadFName != "") confirmMsg += "Prénom : "+leadFNameString+" \n";
if(leadLName != "") confirmMsg += "Nom : "+leadLNameString+" \n";
if(leadName != "") confirmMsg += "Identité : "+leadNameString+" \n";
if(leadEmail != "") confirmMsg += "Email : "+leadEmail+" \n";
if(leadTel != "") confirmMsg += "Tel : "+leadTel+" \n";
if(leadCoord != "") confirmMsg += "Coordonnées : "+leadCoord+" \n";
if(leadComment != "") confirmMsg += "Commentaire : "+leadCommentString+" \n";
if(LeadSurface != "") confirmMsg += "Surface Recherchée : "+LeadSurface+" \n";
if(LeadTypeBien != "") confirmMsg += "Type de bien : "+LeadTypeBien+" \n";
if(LeadProgramme != "") confirmMsg += "Programme : "+LeadProgramme+" \n";
if(LeadNbPieces!= "") confirmMsg += "Nb de pièces : "+LeadNbPieces+" \n";
if(LeadDestination != "") confirmMsg += "Destination : "+LeadDestination+" \n";
if(LeadSuite != "") confirmMsg += "Suites attendues : "+LeadSuite+" \n";
if(LeadBudget != "") confirmMsg += "Budget : "+LeadBudget+" \n";
if(LeadZip != "") confirmMsg += "Code postal : "+LeadZip+" \n";
if(LeadVille != "") confirmMsg += "Ville : "+LeadVille+" \n";
if(LeadTelf != "") confirmMsg += "Téléphone Fixe : "+LeadTelf+" \n";
if(LeadTelm != "") confirmMsg += "Téléphone Mobile : "+LeadTelm+" \n";
if(LeadCompany != "") confirmMsg += "Entreprise : "+LeadCompany+" \n";
if(Leadimpos != "") confirmMsg += "Imposition : "+Leadimpos+" \n";
if(LeadProprio != "") confirmMsg += "Propriétaire : "+LeadProprio+" \n";
if(LeadRevenu != "") confirmMsg += "Revenus : "+LeadRevenu+" \n";
if(LeadRevenuf != "") confirmMsg += "Revenus foncier : "+LeadRevenuf+" \n";
if(LeadAge != "") confirmMsg += "Age : "+LeadAge+" \n";
if(LeadJob != "") confirmMsg += "Profession : "+LeadJob+" \n";
if(LeadApport != "") confirmMsg += "Apport : "+LeadApport+" \n";
if(LeadSituation != "") confirmMsg += "Situation : "+LeadSituation+" \n";
if(LeadEnfant != "") confirmMsg += "Nb enfants : "+LeadEnfant+" \n";
if(LeadcResi != "") confirmMsg += "Credit Immo : "+LeadcResi+" \n";
if(LeadcVehic != "") confirmMsg += "Credit Auto : "+LeadcVehic+" \n";
if(LeadcConso != "") confirmMsg += "Credit Conso : "+LeadcConso+" \n";
if(LeadcAutres != "") confirmMsg += "Credit Autre : "+LeadcAutres+" \n";
if(LeadcTotal != "") confirmMsg += "Cretit Total : "+LeadcTotal+" \n";
if(LeadEpargne != "") confirmMsg += "Epargne : "+LeadEpargne+" \n";
if(LeadDateRappel != "") confirmMsg += "Date Rappel : "+LeadDateRappel+" \n";
if(LeadHorraireRappel != "") confirmMsg += "Horaires rappel : "+LeadHorraireRappel+" \n";
if(LeadHisto != "") confirmMsg += "Historique : "+LeadHistoString+" \n";
if(LeadIp != "" && vw_key =='149555db90cc2f1d32de849a3f0d79d8') confirmMsg += "Ip : "+LeadIp+" \n";
if(apiDetail != "") confirmMsg += "Informations G.Analytics : \n"+apiDetailString+" \n";
if(confirm(confirmMsg))
{
var vwParams = 'vizid='+viz_id+'&licKey='+vw_key+"&gender="+leadGender+"&fname="+leadFName+"&lname="+leadLName+"&name="+leadName+"&email="+leadEmail+"&tel="+leadTel+"&coord="+leadCoord+"&comment="+
leadComment+'&zip='+LeadZip+'&ville='+LeadVille+'&telf='+LeadTelf+'&telm='+LeadTelm+'&company='+LeadCompany+'&impos='+Leadimpos+'&proprio='+LeadProprio+'&revenu='+LeadRevenu+'&revenuf='+
LeadRevenuf+'&age='+LeadAge+'&job='+LeadJob+'&situation='+LeadSituation+'&enfant='+LeadEnfant+'&cResi='+LeadcResi+'&cVehic='+LeadcVehic+'&cConso='+LeadcConso+'&cAutres='+LeadcAutres+'&cTotal='+
LeadcTotal+'&epargne='+LeadEpargne+'&dateRappel='+LeadDateRappel+'&horraireRappel='+LeadHorraireRappel+'&apport='+LeadApport+'&surface='+LeadSurface+'&typebien='+LeadTypeBien+'&programme='+LeadProgramme+
'&budget='+LeadBudget+'&nbpieces='+LeadNbPieces+'&destination='+LeadDestination+'&suite='+LeadSuite+'&histo='+LeadHisto+'&ip='+LeadIp+'&apiDetail='+apiDetail;
var xdr = getXDomainRequest();
xdr.onload = function()
{
if(xdr.responseText != '0')
alert("Envoyé à "+xdr.responseText);
}
xdr.open("POST", urlSrvRoot+"/bo/ajx/send_lead.php"); // on envoi les info en POST
xdr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xdr.send(vwParams);
}
}
var phrases = new Array();
$.ajax({
url: urlSrvRoot+"/bo/ajx/get_agent_sentences.php", // Le nom du fichier indiqué dans le formulaire
type: 'GET', // La méthode indiquée dans le formulaire (get ou post)
data: "uid="+uid,
dataType: 'json',
encode: true,
success: function(json) { //Je récupère la réponse du fichier PHP
phrases = json;
}
});
//////////////////////////////////////////////////
//FONCTION COMPLETION
//////////////////////////////////////////////////
function completion()
{
$('.newMessage').textcomplete([
{
match: /\b(\w{2,})$/,
search: function (term, callback)
{
callback($.map(phrases, function (phrases)
{
return phrases.indexOf(term) === 0 ? phrases : null;
}));
},
index: 1,
replace: function (phrases)
{
return phrases;
}
}
]);
}
//////////////////////////////////////////////////
// AJAX POUR LES PHRASES
//////////////////////////////////////////////////
function ajaxSentence (action, msg, lang, userId, sentenceId, sessionId, oldMsg )
{
creatLoading("visitor_ongoing", "watcheezyCanvasLoaderChat", sessionId, "80");
var xdrd = getXDomainRequest();
//progression du chargement
xdrd.onprogress = function(e)
{
var percentComplete;
if (e.lengthComputable)
{
percentComplete = Math.round((e.loaded / e.total) * 100);//contenu de la div enfant
//si la div existe
if(document.getElementById('WatchBox_pourcent'))
{
document.getElementById('WatchBox_pourcent').innerHTML = "Loading "+percentComplete +" %";//ajoute le contenu
}
}
};
xdrd.onload = function()
{
if(action == 'newMsg')
addPhraseList(msg,xdrd.responseText,sessionId);
document.getElementById("newPhrase").value = "";
if(action == 'deleteMsg')
removePhraseList(xdrd.responseText);
if(action == 'modifyMsg')
btEditPhrase(xdrd.responseText);//ferme le teaxtarea
changeMsg(msg,xdrd.responseText);//remplace le text modifié
changeArrayPhrases(action,oldMsg,msg);//modif array phrases
//efface le loading
effaceLoadingVisitor(sessionId, function(message) { });
//effaceLoading(sessionId);
}
xdrd.open("GET", urlSrvRoot+"/bo/ajx/update_sentence.php?action="+action+"&msg="+msg+"&lang="+lang+"&userId="+userId+"&sentenceId="+sentenceId);
xdrd.send();
}
//////////////////////////////////////////////////
//clique pour ajouter une nouvelle phrase
//////////////////////////////////////////////////
function sendNewMsg (action, msg, lang, userId, sentenceId, sessionId )
{
if (!document.getElementById("newPhrase").value)
{
//il faut saisir quelques chose
}
else
{
msg = document.getElementById("newPhrase").value;
msg = msg.replace(/"/g,"'");
ajaxSentence (action, msg, lang, userId, sentenceId, sessionId, msg )
}
};
//////////////////////////////////////////////////
//clique pour modifier une phrase
//////////////////////////////////////////////////
function modifMsg (action, msg, lang, userId, sentenceId, sessionId )
{
if (!document.getElementById("modifPhrase_"+sentenceId).value)
{
//il faut saisir quelques chose
}
else
{
var oldMsg = msg;//l'ancien message
msg = document.getElementById("modifPhrase_"+sentenceId).value;
msg = msg.replace(/"/g,"'");
ajaxSentence (action, msg, lang, userId, sentenceId, sessionId, oldMsg )
}
};
//////////////////////////////////////////////////
//change la phrase modifiée dans la liste
//////////////////////////////////////////////////
function changeMsg (msg,id)
{
$("#phr_"+id).text(msg);
};
//////////////////////////////////////////////////
//rajoute la phrase dans la liste
//////////////////////////////////////////////////
function addPhraseList (msg,id,sessId)
{
var msg2 = msg.replace(/'/g,"%%"); msg2 = msg2.replace(/\"/g,"%%");
var newline ='';
newline += '