Loading...
dynamic-image Scananew Chatbot
ANNA
Welcome to your personal AI Coach! I'm here to assist and guide you. Let's get started on your path to success.
`; setTimeout(() => { $('.mail-write-box').parents('.ac-chat-mn-div').find('.active-chat').append( syCont); playAudio(); setCookie(syCookie, 1, 1); getScrollContainer.scrollTop = getScrollContainer.scrollHeight; }, 100); }, 1000); } } function prodBtnLoad(code, type, mode) { if (mode == 1) { $('#' + type + '_' + code + ' span').show(); $('#' + type + '_' + code).addClass('disabled'); } else { $('#' + type + '_' + code + ' span').hide(); $('#' + type + '_' + code).removeClass('disabled'); } } function paySucc(item, hcode) { let prodThankMsg = `
${botImg}
ANNA
${item.succMsg}
`; setTimeout(() => { $('.mail-write-box').parents('.ac-chat-mn-div').find('.active-chat').append(prodThankMsg); // playAudioMe(); getScrollContainer.scrollTop = getScrollContainer.scrollHeight; }, 300); setCookie('pay' + hcode, 1, 1); } function payErr(msg) { let prodThankMsg = `
${botImg}
ANNA
${msg}
`; setTimeout(() => { $('.mail-write-box').parents('.ac-chat-mn-div').find('.active-chat').append(prodThankMsg); playAudioMe(); getScrollContainer.scrollTop = getScrollContainer.scrollHeight; }, 300); } if (pay == 'success') { var item = { succMsg: "Payment successful!" }; var payhsh = getCookie('pay' + hashcode); if (payhsh == null) { // paySucc(item,hashcode); setCookie('pay' + hashcode, 1, 1); window.parent.postMessage('openPopup', domainURL); } } else if (pay == 'fail') { var item = { succMsg: "Payment Failed!" }; var payhsh = getCookie('pay' + hashcode); if (payhsh == null) { // paySucc(item,hashcode); setCookie('pay' + hashcode, 1, 1); window.parent.postMessage('openPopup', domainURL); } } else if (pay == 'error') { var item = { succMsg: "Payment Error, Check with administrator!" }; var payhsh = getCookie('pay' + hashcode); if (payhsh == null) { // paySucc(item,hashcode); setCookie('pay' + hashcode, 1, 1); window.parent.postMessage('openPopup', domainURL); } } else if (pay == 'cancel') { var payhsh = getCookie('lastpdt' + hashcode); if (payhsh != null) { prodCookie = 'prodB' + payhsh; itemDetails(cId, payhsh); clearCookie(prodCookie); clearCookie('lastpdt' + hashcode); window.parent.postMessage('openPopup', domainURL); } } function targetBlankSet() { var aLink; var gHref; const linkPar = document.querySelectorAll(".ac-chat-res"); linkPar.forEach((el) => { aLink = el.querySelectorAll("a"); aLink.forEach((el) => { gHref = el.getAttribute('href'); if (gHref != '') el.setAttribute('target', '_blank'); }); }); } function answerGen(chatMessageValue) { usrImg = `
`; let messageHtml = `
Visitor
${usrImg}
${chatMessageValue}
`; $('.mail-write-box').parents('.ac-chat-mn-div').find('.active-chat').append(messageHtml); optName(hashcode); playAudioMe(); let dotsHtml = `
${botImg}
ANNA
`; setTimeout(() => { $('.mail-write-box').parents('.ac-chat-mn-div').find('.active-chat').append(dotsHtml); getScrollContainer.scrollTop = getScrollContainer.scrollHeight; }, 500); var clearChatInput = $('.mail-write-box').val(''); var chatCookie = 'chat' + hashcode; if (!getCookie(chatCookie)) { var chatId = 0; } else { var chatId = getCookie(chatCookie); } var viewCookie = 'view' + hashcode; if (!getCookie(viewCookie)) { var viewCnt = 0; setCookie(viewCookie, 1, 60); } else { var viewCnt = 1; } var optinNCookie = 'optinE' + hashcode; if (!getCookie(optinNCookie)) { var optinName = ''; } else { var optinName = getCookie(optinNCookie); } var data = { question: chatMessageValue, hashcode: hashcode, userId: userId, chatId: chatId, wsId: wsId, viewCnt: viewCnt, optinName: optinName, _token: $('meta[name="csrf-token"]').attr("content") }; $.ajax({ url: BASE_URL + "/api/chat", method: "POST", data: data, success: function(response) { if (response.success == true) { chatId = response.chatId; chatCount = response.chatCount; setCookie(chatCookie, chatId, 60); let chatMessageValue = response.result; let responseHtml = `
${botImg}
ANNA
${chatMessageValue}
`; setTimeout(() => { $('.typing-div').remove(); $('.mail-write-box').parents('.ac-chat-mn-div').find('.active-chat').append( responseHtml); playAudio(); getScrollContainer.scrollTop = getScrollContainer.scrollHeight; setTimeout(() => { targetBlankSet(); }, 100); }, 300); if (chatCount >= 1) syntLoad(); } }, }); } function playAudio() { var x = document.getElementById("myAudio"); x.play(); } function playAudioMe() { var x = document.getElementById("myAudioMe"); x.play(); } let quesBtn = document.querySelectorAll(".ques-btn"); quesBtn.forEach((btn) => btn.addEventListener("click", (e) => { let quesVal = e.target.innerHTML; if (quesVal === '') { return; } $("#dqbd-modal").modal("hide"); answerGen(quesVal); var btnFId = e.target.getAttribute("data-id"); console.log(btnFId); document.getElementById(btnFId).remove(); }) ); $('.mail-write-box').on('keydown', function(event) { if (event.key === 'Enter') { var chatInput = $(this); var chatMessageValue = $.trim(chatInput.val()); if (chatMessageValue === '') { return; } answerGen(chatMessageValue); } }); let feaBtn = document.querySelector(".ac-chat-mn-div .ki-send"); feaBtn.addEventListener("click", (e) => { var chatInput = $(".mail-write-box"); var chatMessageValue = $.trim(chatInput.val()); if (chatMessageValue === '') { return; } answerGen(chatMessageValue); }); $("body").on("click", "#dqbd-modal-btn", function() { $("#dqbd-modal").modal("show"); // $('.modal-backdrop').appendTo('.widget-cb'); // $('body').removeClass("modal-open") // $('body').css("padding-right",""); }); function optName(hashcode) { let optNmCke = 'optinE' + hashcode; if (getCookie(optNmCke)) { $(".vn-col").text(getCookie(optNmCke)); } } function itemDetails(cId, payCode) { var data = { coachId: cId, payCode: payCode, _token: $('meta[name="csrf-token"]').attr("content") }; $.ajax({ url: BASE_URL + "/api/get-item-details", method: "POST", data: data, success: function(response) { productLoad(response); } }); } function loadHistories(hashcode) { var chatCookie = 'chat' + hashcode; var chatId = getCookie(chatCookie); var data = { chatId: chatId, _token: $('meta[name="csrf-token"]').attr("content") }; $.ajax({ url: BASE_URL + "/api/load-chathistory", method: "POST", data: data, success: function(response) { if (response) { historyData = JSON.parse(response[0].data); // return; for (i = 0; i < historyData.length; i++) { var history = ''; if (historyData[i].message != '') { history += `
Visitor
${historyData[i].message}
`; } if (historyData[i].response != '') { history += `
ANNA
${historyData[i].response}
`; } $('.mail-write-box').parents('.ac-chat-mn-div').find('.active-chat').append( history); getScrollContainer.scrollTop = getScrollContainer.scrollHeight; } } }, }); }