var nbchat;
var oldchat;
var toutvar;
var linktmp = '';
var iconfont = '0';
var offre = 'xChat+';
var chat_id = 'bellesvac_174199680967137461';
function getNewChat(){
let chatlink = 'https://xchat.bexter.fr/webchat.php?webchat_id=bellesvac&chat_id='+chat_id;
if (chatlink != linktmp) {
jQuery.ajax('https://xchat.bexter.fr/webview/getNewChat.php?webchat_id=bellesvac&id=bellesvac_174199680967137461&chat_id='+chat_id, {
type: 'POST',
success: function(result) {
//console.log(result);
if(result == 'NEW'){
openWebchat();
}
}
});
}
}
getNewChat();
setInterval(getNewChat, 5000);
function openWebchat() {
clearTimeout(toutvar);
let chatlink = 'https://xchat.bexter.fr/webchat.php?webchat_id=bellesvac&chat_id='+chat_id;
//let currentLink = framechatsrc.location.href
//console.log(chatlink, 'chatlink', linktmp, 'linktmp');
if (chatlink == linktmp) {
// console.log('ok');
return;
}
framechatsrc.location= chatlink;
linktmp = chatlink;
jQuery('#webchat_notif').hide();
jQuery('#webchat_iframe').show();
}
function closeWebChat() {
clearTimeout(toutvar);
jQuery('#webchat_iframe').hide();
linktmp = 'https://xchat.bexter.fr/webview/wait.php';
framechatsrc.location= 'https://xchat.bexter.fr/webview/wait.php'; // Pour arreter les maj
jQuery('#webchat_notif').show();
var tmout = 0 + '';
if(tmout != '0'){
jQuery.ajax('https://xchat.bexter.fr/admin/nochat.php', {
type: 'POST',
data: {'id': 'bellesvac_174199680967137461'},
success: function(result) {
//console.log('log', result);
}
});
}
}
jQuery(window).load(function(){
var htmlicon = `
`;
if(iconfont == '1' || offre === 'xChat'){
htmlicon = `
`;
}
jQuery('#webchat').html(`
`);
var tmout = 0 + '000';
console.log(tmout);
if(tmout=='-1000') {
openWebchat(); // sans attendre
} else if(tmout != '0000'){
toutvar = setTimeout(openWebchat, tmout);
}
})