var nbchat; var oldchat; var toutvar; var linktmp = ''; var iconfont = '0'; var offre = 'xChat++'; var chat_id = 'bexter_170643714665171779'; function getNewChat(){ let chatlink = 'https://xchat.bexter.fr/webchat.php?webchat_id=bexter&chat_id='+chat_id; if (chatlink != linktmp) { jQuery.ajax('https://xchat.bexter.fr/webview/getNewChat.php?webchat_id=bexter&id=bexter_170643714665171779&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=bexter&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 = 7 + ''; if(tmout != '0'){ jQuery.ajax('https://xchat.bexter.fr/admin/nochat.php', { type: 'POST', data: {'id': 'bexter_170643714665171779'}, success: function(result) { //console.log('log', result); } }); } } jQuery(window).load(function(){ var htmlicon = `
xChat Bexter : Chat pour poser vos questions
`; if(iconfont == '1' || offre === 'xChat'){ htmlicon = `
xChat Bexter : Chat pour poser vos questions
`; } jQuery('#webchat').html(`
`+ htmlicon +`
`); var tmout = 7 + '000'; console.log(tmout); if(tmout=='-1000') { openWebchat(); // sans attendre } else if(tmout != '0000'){ toutvar = setTimeout(openWebchat, tmout); } })