PageSourceSearch

https://bikingman.com/contenu/plugins/wpbot-pro-master/js/qcld-wp-chatbot-front.js?ver=15.6.7

js bikingman.com collected 2026-09-24 22:40:52 UTC 166,169 bytes, 3,325 lines download raw bytes

1var LoadwpwBotPlugin = 0;
2jQuery(function ($) {
3    "use strict";
4    //Global object passed by admin
5    var wpChatBotVar = wp_chatbot_obj;
6    var textEditorHandler = 0;
7    var exitintentcount = 0;
8    if (typeof (openingHourIsFn) != 'undefined') {
9        var openingHourIs = openingHourIsFn;
10    } else {
11        var openingHourIs = 0;
12    }
13
14    var OnchatWindow = false;
15    var justOpen = true;
16    // if(wpChatBotVar.disable_livechat_operator_offline == '1'){
17    //     var menu = jQuery('.qcld-chatbot-custom-intent');
18    //     setTimeout(function(){jQuery('.qcld-chatbot-custom-intent').hide()}, 5000);
19
20    //     if(menu.text() == 'Live Chat'){
21    //         menu.hide();
22    //     }
23    // }
24    function wpbotGetStartMenuScrollEl(box) {
25        var nodes = box.querySelectorAll('.wp-chatbot-start-content, .wp-chatbot-start-screen');
26        var i, el, style, overflowY, canScroll;
27        for (i = 0; i < nodes.length; i++) {
28            el = nodes[i];
29            style = window.getComputedStyle(el);
30            overflowY = style.overflowY;
31            canScroll = (overflowY === 'auto' || overflowY === 'scroll') &&
32                (el.scrollHeight - el.clientHeight > 1);
33            if (canScroll) {
34                return el;
35            }
36        }
37        if (box.scrollHeight - box.clientHeight > 1) {
38            return box;
39        }
40        return box.querySelector('.wp-chatbot-start-content') || box;
41    }
42
43    function wpbotEnableStartMenuNativeScroll() {
44        var $box = $('.wp-chatbot-start-container');
45        var $screen = $('.wp-chatbot-start-screen');
46        if (!$box.length) {
47            return;
48        }
49        if ($screen.length && $screen.parent().hasClass('slimScrollDiv')) {
50            $screen.slimScroll({ destroy: true });
51        }
52        $screen.css({ height: 'auto', overflow: 'visible' });
53        if ($box.data('wpbotWheelBound')) {
54            return;
55        }
56        $box.data('wpbotWheelBound', 1);
57        $box.get(0).addEventListener('wheel', function (e) {
58            var el = wpbotGetStartMenuScrollEl($box.get(0));
59            var max = el.scrollHeight - el.clientHeight;
60            if (max <= 1) {
61                e.preventDefault();
62                e.stopPropagation();
63                return;
64            }
65            var next = el.scrollTop + e.deltaY;
66            if (next < 0) {
67                next = 0;
68            } else if (next > max) {
69                next = max;
70            }
71            if (el.scrollTop !== next) {
72                el.scrollTop = next;
73            }
74            e.preventDefault();
75            e.stopPropagation();
76        }, { passive: false, capture: true });
77    }
78
79    $(document).on({
80        mouseenter: function () {
81            OnchatWindow = true;
82
83            if (wpChatBotVar.auto_hide_floating_button == 1 && !justOpen) {
84                $('#wp-chatbot-integration-container').fadeIn(500);
85                $('#wp-chatbot-desktop-close').fadeIn(500);
86                $('#wp-chatbot-desktop-reload').fadeIn(500);
87            }
88        },
89        mouseleave: function () {
90            OnchatWindow = false;
91
92            if (wpChatBotVar.auto_hide_floating_button == 1 && !justOpen) {
93                setTimeout(function () {
94                    if (!OnchatWindow) {
95                        $('#wp-chatbot-integration-container').fadeOut(500);
96                        $('#wp-chatbot-desktop-close').fadeOut(500);
97                        $('#wp-chatbot-desktop-reload').fadeOut(500);
98                    }
99
100                }, 3000)
101            }
102        },
103    },
104        '.slimScrollDiv'
105    );
106
107    wpChatBotVar.exit_intent_handler = 0;
108    wpChatBotVar.scroll_open_handler = 0;
109    wpChatBotVar.auto_open_handler = 0;
110    wpChatBotVar.re_target_handler = 0;
111
112    $(document).on('click', '.qcwpbot_close_ret', function (e) {
113        $(this).parent().parent().remove();
114    })
115    $(document).on('click', '.qc_wpbot_floating_main', function (e) {
116        e.preventDefault();
117        if (e.target.className == 'qcwp_notification_nav') {
118            return;
119        }
120        if (e.target.className == 'wp-chatbot-notification-close') {
121            $('.wp-chatbot-notification-container').addClass('wp-chatbot-notification-container-disable');
122            //clearInterval(notificationInterval);
123            sessionStorage.setItem('wpChatbotNotification', 'removed');
124            return;
125        }
126        $('.wp-chatbot-ball').trigger("click");
127    })
128    $(document).on('click', '.wp-chatbot-notification-close', function () {
129        if (typeof iframe_exists !== 'undefined' || typeof insideIframe !== 'undefined') {
130            setTimeout(function () {
131                sendMessageIframe({
132                    msg: 'chatbot_close'
133                });
134            }, 20);
135        }
136    });
137    $(document).on('click', '.wp-chatbot-notification-widget-avatar', function (e) {
138         $('.wp-chatbot-ball').trigger("click");
139    })
140    $(document).on('click', '.wp-chatbot-notification-message', function (e) {
141         $('.wp-chatbot-ball').trigger("click");
142    })
143    $(window).on('load', function () {
144
145
146
147        if (wpChatBotVar.template == 'template-06' || wpChatBotVar.template == 'template-07') {
148            if (jQuery('#menuItems').find('.wp-chatbot-integration-button-container').children().length == 0) {
149                jQuery('#menuItems').hide();
150                jQuery('#menuTrigger').hide();
151            }
152        }
153
154
155        if (wpChatBotVar.wp_keep_chat_window_open == 1) {
156
157            // if( $('.active-chat-board').length<1){
158            //setTimeout(function(){
159            if ($('.active-chat-board').length == 0) {
160                var delay_chat_window_open = parseInt(wpChatBotVar.delay_chat_window_open) + parseInt(wpChatBotVar.delay_wp_chatbot_floating_icon);
161
162                jQuery('#wp-chatbot-chat-container').removeClass('wpbot_hide_floating_icon');
163                setTimeout(function () {
164                    $('.wp-chatbot-ball').trigger("click");
165                }, delay_chat_window_open)
166                var date = new Date();
167                date.setTime(date.getTime() + 12 * 60 * 60 * 1000);
168                $.cookie('auto_open_cookie', 'yes', {
169                    expires: date
170                });
171            }
172            //	$('.wp-chatbot-ball').trigger( "click" );
173            //}, 3000)
174
175            // }
176        }
177
178        if (typeof iframe_exists !== 'undefined' || typeof insideIframe !== 'undefined') {
179            setTimeout(function () {
180                sendMessageIframe({
181                    msg: $('.active-chat-board').length > 0 ? 'chatbot_open' : 'chatbot_close'
182                });
183            }, 300);
184        }
185
186    });
187
188    function wpbot_destroy_chat_slimscroll() {
189        var $inner = $('.wp-chatbot-ball-inner');
190        if ($inner.length && $inner.parent().hasClass('slimScrollDiv')) {
191            $inner.slimScroll({ destroy: true });
192        }
193    }
194
195    function wpbot_set_mobile_body_scroll_lock(lock) {
196        if (!window.matchMedia('(max-width: 768px)').matches) {
197            return;
198        }
199
200        var $body = $('body');
201
202        if (lock) {
203            if ($body.hasClass('wpbot-chat-scroll-locked')) {
204                return;
205            }
206
207            var scrollY = window.pageYOffset || document.documentElement.scrollTop || 0;
208            $body.data('wpbot-scroll-y', scrollY);
209            $body.addClass('wpbot-chat-scroll-locked');
210            $body.css({
211                position: 'fixed',
212                top: '-' + scrollY + 'px',
213                left: '0',
214                right: '0',
215                width: '100%',
216                overflow: 'hidden'
217            });
218        } else if ($body.hasClass('wpbot-chat-scroll-locked')) {
219            var savedScrollY = parseInt($body.data('wpbot-scroll-y'), 10) || 0;
220            $body.removeClass('wpbot-chat-scroll-locked');
221            $body.css({
222                position: '',
223                top: '',
224                left: '',
225                right: '',
226                width: '',
227                overflow: ''
228            });
229            window.scrollTo(0, savedScrollY);
230        }
231    }
232
233    function wpbot_apply_native_chat_scroll() {
234        var $inner = $('.wp-chatbot-ball-inner');
235        if (!$inner.length || !$('.active-chat-board').length) {
236            return;
237        }
238
239        wpbot_destroy_chat_slimscroll();
240
241        var widowH = $(window).height();
242        var headerH = $('.wp-chatbot-header').outerHeight() || 0;
243        var footerH = $('.wp-chatbot-footer').outerHeight() || 0;
244        var contentH = widowH - footerH - headerH;
245
246        if (wpChatBotVar.template == 'template-07') {
247            contentH = (parseFloat(contentH) + 2) - (parseFloat($('.wp-bot-header').height() * 2));
248        }
249
250        if (wpChatBotVar.template == 'template-06') {
251            contentH = (parseFloat(contentH) + 2) - (parseFloat($('.wp-bot-header').height()));
252        }
253
254        $inner.css({
255            height: contentH + 'px',
256            maxHeight: contentH + 'px',
257            overflowY: 'auto',
258            overflowX: 'hidden',
259            WebkitOverflowScrolling: 'touch',
260            overscrollBehavior: 'contain',
261            touchAction: 'pan-y'
262        });
263    }
264
265    function wpbot_sync_mobile_chat_scroll() {
266        if (!window.matchMedia('(max-width: 768px)').matches || typeof insideIframe !== 'undefined') {
267            return;
268        }
269
270        var isOpen = $('.active-chat-board').length > 0;
271        wpbot_set_mobile_body_scroll_lock(isOpen);
272
273        if (isOpen) {
274            wpbot_apply_native_chat_scroll();
275        } else {
276            wpbot_destroy_chat_slimscroll();
277            $('.wp-chatbot-ball-inner').css({
278                overflowY: '',
279                overflowX: '',
280                WebkitOverflowScrolling: '',
281                overscrollBehavior: '',
282                touchAction: ''
283            });
284        }
285    }
286
287    $(document).ready(function () {
288
289        if ($('#wp-chatbot-ball-container').length) {
290            $('#wp-chatbot-ball-container').attr('aria-label', 'Chatbot');
291        }
292
293        var wpbotResizeTimer;
294        $(window).on('resize orientationchange', function () {
295            clearTimeout(wpbotResizeTimer);
296            wpbotResizeTimer = setTimeout(function () {
297                if ($('.active-chat-board').length > 0) {
298                    wpbot_sync_mobile_chat_scroll();
299                }
300            }, 150);
301        });
302
303        if (wpChatBotVar.language == 'ar') {
304            if (!$('#wp-chatbot-chat-container').hasClass('wp-chatbot-rtl')) {
305                $('#wp-chatbot-chat-container').addClass('wp-chatbot-rtl');
306            }
307        }
308
309        jQuery('body').on('click', '#qcld-btn-openai-agentbuilder', function (event) {
310
311            // 👉 SHOW the ChatKit widget
312            var chatkit = $('#my-openai-chatkit');
313            chatkit.css('display', 'block').fadeIn(500);
314
315            // Add active class for animation
316            setTimeout(function () {
317                chatkit.addClass('active');
318            }, 500);
319
320
321        });
322        jQuery('#wp-chatbot-mobile-close, #wp-chatbot-desktop-close, #wp-chatbot-desktop-close1, .wp-chatbot-start-close').on('click', function (event) {
323            var chatkit = $('#my-openai-chatkit');
324            chatkit.css('display', 'none');
325            if ($('.wp-chatbot-start-container').is(':visible')) {
326                $('.wp-chatbot-start-container').hide();
327                $('#wp-chatbot-integration-container .wp-chatbot-integration-button-container').show();
328            }
329            $("#wp-chatbot-board-container").toggleClass('active-chat-board');
330            wpbot_sync_mobile_chat_scroll();
331            $("#wp-chatbot-notification-container").removeClass('wp-chatbot-notification-container-disable').addClass('wp-chatbot-notification-container-sliding');
332
333            $('#wp-chatbot-chat-container').css({
334                'right': wpChatBotVar.wp_chatbot_position_x + 'px',
335                'bottom': wpChatBotVar.wp_chatbot_position_y + 'px',
336                'top': 'auto', 'left': 'auto'
337            });
338            if (window.matchMedia('(max-width: 480px)').matches) {
339                $('#wp-chatbot-chat-container').css({
340                    'right': wpChatBotVar.wp_chatbot_position_mp_x + 'px !important',
341                    'bottom': wpChatBotVar.wp_chatbot_position_mp_y + 'px !important',
342                    'top': 'auto', 'left': 'auto'
343                });
344            };
345            $('.fb_dialog').show();
346            $('#wp-chatbot-ball').show();
347            //Facebook Messenger.
348            if ($('.active-chat-board').length > 0) {
349                $('#wp-chatbot-integration-container').show();
350                if (wpChatBotVar.template == 'template-07') {
351                    $('#wp-chatbot-integration-container-07').hide();
352                }
353
354            } else {
355                $('#wp-chatbot-integration-container').hide();
356                if (wpChatBotVar.template == 'template-07') {
357                    $('#wp-chatbot-integration-container-07').show();
358                }
359                if (wpChatBotVar.template == 'template-06') {
360                    $('#wp-chatbot-ball').show();
361                }
362                $('#wp-chatbot-ball').removeClass('wpbot_chatopen_iconanimation');
363                $('#wp-chatbot-ball').addClass('wpbot_chatclose_iconanimation');
364                $('#wp-chatbot-ball').find('img').attr('src', botimage)
365                $('.wp-chatbot-ball').css('background', '#ffffff');
366            }
367
368            if (wpChatBotVar.wp_keep_chat_window_open == 1) {
369                $.cookie('bot_window_open', 'no', { path: '/' });
370            }
371
372            if ($('.qc_wpbot_floating_main').length > 0) {
373                $('.qc_wpbot_floating_main').show();
374            }
375            setTimeout(function () {
376
377                var json = {
378                    msg: 'chatbot_close',
379                    val: (jQuery('#wp-chatbot-chat-container').height() + 80)
380                }
381                sendMessageIframe(json);
382
383            }, 200)
384            $('#wp-chatbot-ball-container').removeAttr('aria-haspopup');
385            $('#wp-chatbot-ball-container').removeAttr('aria-expanded');
386            $('#wp-chatbot-ball-container').attr('aria-haspopup', '');
387            $('#wp-chatbot-ball-container').attr('aria-expanded', 'false');
388        });
389
390        jQuery('.qc_floating_bottom_notification').css('top', '-' + (jQuery('.qc_floating_bottom_notification').height() + jQuery('.qc_bottom_position').height() + 17) + 'px');
391
392        $(document).keydown(function (e) {
393
394            e = e || window.event;
395            var key = e.which || e.keyCode; // keyCode detection
396            var ctrl = e.ctrlKey ? e.ctrlKey : ((key === 17) ? true : false); // ctrl detection
397
398            if (key == 66 && ctrl) {
399                $('.wp-chatbot-ball').trigger("click");
400            }
401            if (e.key === "Escape") {
402                $('.wp-chatbot-ball').trigger("click");
403            }
404
405        })
406
407        //image popup script
408
409        $(document).on('click', '.wpbot_img_popup', function (e) {
410            e.preventDefault();
411            $('#qcwpbotModal').show();
412            $('#qcwpbotimg01').attr('src', $(this).attr('src'));
413        })
414
415        $(document).on('click', '.qcwpbotclose', function (e) {
416            e.preventDefault();
417            $('#qcwpbotModal').hide();
418        })
419
420        function handle_language(obj) {
421            if (typeof (obj) == 'object' && obj.hasOwnProperty(wpChatBotVar.language)) {
422                return obj[wpChatBotVar.language];
423            }
424            return obj;
425        }
426
427        function dailogAIOAction(text) {
428
429            //=========
430
431            if (!localStorage.getItem('botsessionid')) {
432
433                var number = Math.random() // 0.9394456857981651
434                number.toString(36); // '0.xtis06h6'
435                var id = number.toString(36).substr(2); // 'xtis06h6'
436
437                localStorage.setItem('botsessionid', id);
438
439            }
440
441            if (wpChatBotVar.df_api_version == 'v1') {
442                return jQuery.ajax({
443                    type: "POST",
444                    url: "https://api.dialogflow.com/v1/query?v=20170712",
445                    contentType: "application/json; charset=utf-8",
446                    dataType: "json",
447                    headers: {
448                        "Authorization": "Bearer " + wpChatBotVar.obj.ai_df_token
449                    },
450
451                    data: JSON.stringify({
452                        query: text,
453
454                        lang: wpChatBotVar.df_agent_lan,
455                        sessionId: localStorage.getItem('botsessionid') ? localStorage.getItem('botsessionid') : 'wpwBot_df_2018071'
456                    })
457                });
458            } else {
459                return jQuery.post(wpChatBotVar.ajax_url, {
460                    'action': 'qcld_wp_df_api_call',
461                    'dfquery': text,
462                    'sessionid': localStorage.getItem('botsessionid') ? localStorage.getItem('botsessionid') : 'wpwBot_df_2018071'
463                });
464            }
465
466            //=========
467        }
468
469
470
471        function df_reply(response) {
472
473            //checking for facebook platform
474            var i = 0;
475            var html = '';
476            var responses = [];
477
478            if (wpChatBotVar.df_api_version == 'v1') {
479                var messages = response.result.fulfillment.messages;
480                var action = response.result.actionIncomplete;
481                jQuery.each(messages, function (key, message) {
482                    html = '';
483                    i += 1;
484                    if (message.type == 2) {
485
486                        html += "<p>" + message.title + "</p>";
487                        var index = 0;
488                        for (index; index < message.replies.length; index++) {
489                            html += "<span class=\"wpb-quick-reply qcld-chat-common\">" + message.replies[index] + "</span>";
490                        }
491
492
493                    }
494                    //check for default reply
495                    else if (message.type == 0 && message.speech != '') {
496
497                        html += message.speech;
498
499                    } else if (message.type == 1) {
500
501                        html += '<div class="wpbot_card_wraper">';
502                        html += '<div class="wpbot_card_image">';
503                        if (message.imageUrl != '') {
504                            html += '<img src="' + message.imageUrl + '" />';
505                        }
506                        html += '<div class="wpbot_card_caption">';
507                        if (message.title != '') {
508                            html += '<h2>' + message.title + '</h2>';
509                        }
510                        if (message.subtitle != '') {
511                            html += '<p>' + message.subtitle + '</p>';
512                        }
513                        html += '</div>';
514                        html += '</div>';
515                        if (typeof message.buttons !== 'undefined') {
516                            if (message.buttons.length > 0) {
517                                jQuery.each(message.buttons, function (k, btn) {
518                                    html += '<a href="' + btn.postback + '" target="_blank"><i class="fa fa-external-link"></i> ' + btn.text + '</a>';
519                                })
520                            }
521                        }
522
523                        html += '</div>';
524
525                    } else if (message.type == 'simple_response') {
526                        html += message.textToSpeech;
527                    }
528
529                    if (html != '') {
530                        responses.push(html);
531                    }
532
533                })
534            } else {
535
536
537
538                var messages = response.queryResult.fulfillmentMessages;
539                var actioncomplete = response.queryResult.allRequiredParamsPresent;
540
541                jQuery.each(messages, function (key, message) {
542
543                    html = '';
544                    i += 1;
545                    //handeling quickreplies
546                    if (typeof message.quickReplies !== "undefined") {
547                        if (typeof message.quickReplies.title !== "undefined") {
548                            html += "<p>" + message.quickReplies.title + "</p>";
549                        }
550                        if (typeof message.quickReplies.quickReplies !== "undefined") {
551
552                            var index = 0;
553                            for (index; index < message.quickReplies.quickReplies.length; index++) {
554                                html += "<span class=\"wpb-quick-reply qcld-chat-common\">" + message.quickReplies.quickReplies[index] + "</span>";
555                            }
556
557                        }
558
559                    }
560                    //handleing default response
561                    else if (typeof message.text !== "undefined") {
562                        if (typeof message.text.text !== "undefined" && message.text.text.length > 0) {
563                            html += message.text.text[0];
564                        }
565                    }
566                    else if (typeof message.card !== "undefined") {
567
568                        html += '<div class="wpbot_card_wraper">';
569                        html += '<div class="wpbot_card_image">';
570                        if (message.card.imageUri !== "undefined" && message.card.imageUri != '') {
571                            html += '<img src="' + message.card.imageUri + '" />';
572                        }
573                        html += '<div class="wpbot_card_caption">';
574                        if (message.card.title !== "undefined" && message.card.title != "") {
575                            html += '<h2>' + message.card.title + '</h2>';
576                        }
577                        if (message.card.subtitle !== "undefined" && message.card.subtitle != "") {
578                            html += '<p>' + message.card.subtitle + '</p>';
579                        }
580                        html += '</div>';
581                        html += '</div>';
582
583                        if (typeof message.card.buttons !== 'undefined') {
584                            if (message.card.buttons.length > 0) {
585                                jQuery.each(message.card.buttons, function (k, btn) {
586                                    html += '<a href="' + btn.postback + '" target="_blank"><i class="fa fa-external-link"></i> ' + btn.text + '</a>';
587                                })
588                            }
589                        }
590
591                        html += '</div>';
592
593                    }
594
595                    if (html != '') {
596                        responses.push(html);
597                    }
598
599                })
600
601            }
602
603
604            return responses;
605
606        }
607
608
609        function qcwp_auto_hide_floating_buttons() {
610            setTimeout(function () {
611
612                if (!OnchatWindow) {
613                    $('#wp-chatbot-integration-container').fadeOut(500);
614                    $('#wp-chatbot-desktop-close').fadeOut(500);
615                    $('#wp-chatbot-desktop-reload').fadeOut(500);
616
617                } else {
618                    $('#wp-chatbot-integration-container').fadeIn();
619                    $('#wp-chatbot-desktop-close').fadeIn();
620                    $('#wp-chatbot-desktop-reload').fadeIn();
621                }
622                justOpen = false;
623            }, 3000)
624        }
625
626        $(document).on('click', '#wpbot_back_to_home', function (event) {
627            $('.wp-chatbot-container').show();
628            $("#wp-chatbot-board-container").addClass('active-chat-board');
629            $(".wpbot-saas-live-chat").hide();
630
631            $('.floatingbot_delay').hide();
632            showfloatinicon();
633
634        })
635        var delay_floating_icon = wpChatBotVar.delay_wp_chatbot_floating_icon;
636        var delay_notification = parseInt(delay_floating_icon) + parseInt(wpChatBotVar.delay_floating_notification_box);
637        var chatbot_open_status = '';
638
639        // var chatbot_window_open = wpChatBotVar.chatbot_window_open;
640
641        // if(chatbot_window_open == 1){
642        //     console.log('check');
643        //     setTimeout(function () {
644        //         $('.wp-chatbot-ball').trigger( "click" )
645        //     },1500);
646        // }
647        function showfloatinicon() {
648            $('.floatingbot_delay').show();
649        }
650        function shownotificationcontainer() {
651            var eventMethod = window.addEventListener ? "addEventListener" : "attachEvent";
652            var eventer = window[eventMethod];
653            var messageEvent = eventMethod == "attachEvent" ? "onmessage" : "message";
654            var aria_status = jQuery('#wp-chatbot-ball').attr('class');
655            if (((wpChatBotVar.enable_wp_chatbot_open_initial != 1) || ($.cookie("auto_open_cookie") == 'yes')) && (aria_status != 'wpbot_chatopen_iconanimation') && (sessionStorage.getItem('wpChatbotNotification') != 'removed') && wpChatBotVar.template != 'template-05') {
656                $('.wp-chatbot-notification-container').show();
657            }
658            eventer(messageEvent, function (e) {
659                if (e.data.msg == 'chatbot_open') {
660                    $('.wp-chatbot-notification-container').hide();
661                }
662                if (e.data.msg == 'chatbot_close') {
663                    if (sessionStorage.getItem('wpChatbotNotification') != 'removed' && wpChatBotVar.template != 'template-05') {
664                        $('.wp-chatbot-notification-container').show();
665
666                    }
667                }
668
669            }, false);
670        }
671
672        if ((wpChatBotVar.enable_floating_icon == 1) && (jQuery('#wp-chatbot-ball').attr('class')) != 'wpbot_chatopen_iconanimation') {
673
674            setTimeout(shownotificationcontainer, delay_notification);
675
676        }
677        if (wpChatBotVar.enable_wp_chatbot_open_initial == 1) {
678            if ($.cookie("auto_open_cookie") != 'yes') {
679                if ($('.active-chat-board').length == 0) {
680                    var delay_chat_window_open = parseInt(wpChatBotVar.delay_chat_window_open) + parseInt(wpChatBotVar.delay_wp_chatbot_floating_icon);
681
682                    jQuery('#wp-chatbot-chat-container').removeClass('wpbot_hide_floating_icon');
683                    setTimeout(function () {
684                        $('.wp-chatbot-ball').trigger("click");
685                    }, delay_chat_window_open)
686                    var date = new Date();
687                    date.setTime(date.getTime() + 12 * 60 * 60 * 1000);
688                    $.cookie('auto_open_cookie', 'yes', {
689                        expires: date
690                    });
691                }
692            }
693        }
694        $('.wp-chatbot-notification-container').hide();
695        $('.floatingbot_delay').hide();
696        setTimeout(showfloatinicon, delay_floating_icon);
697        if (wpChatBotVar.disable_wp_chatbot_history == 1) {
698
699            localStorage.removeItem('shopper');
700            localStorage.removeItem('shopperemail');
701            localStorage.removeItem('shopperphone');
702
703            localStorage.removeItem('wpwHitory');
704            localStorage.setItem("wildCard", 0);
705            localStorage.setItem("aiStep", 0);
706            wpwKits.doReset();
707        }
708
709        if (typeof (clickintent) !== "undefined" && clickintent != '') {
710            wpChatBotVar.clickintent = clickintent;
711        }
712
713        if (typeof (wclickintent) !== "undefined" && wclickintent != '') {
714            wpChatBotVar.clickintent = wclickintent;
715        }
716        if (typeof (pclickintent) !== "undefined" && pclickintent != '') {
717            wpChatBotVar.clickintent = pclickintent;
718        }
719
720        if (typeof (wpbot_clear_cache) !== "undefined" && wpbot_clear_cache != '') {
721            //  wpwKits.doReset();
722        }
723
724
725        if (typeof (ldsuggestionObject) !== "undefined") {
726            setTimeout(function () {
727
728                if ($('.active-chat-board').length == 0) {
729                    $('.wp-chatbot-ball').trigger("click");
730                    if (localStorage.getItem('wpwHitory')) {
731                        wpwTree.ldsuggestion();
732                    }
733                }
734
735            }, 3000)
736        }
737
738        $(document).on('click', '.qc_wpbot_chat_link', function (e) {
739            e.preventDefault();
740            var clickintent = $(this).attr('data-intent');
741            var clickassistant = $(this).attr('data-assistant');
742            if ((clickintent) == '') {
743                clickintent = 'start';
744            }
745            if ((clickassistant) != '') {
746                $('#wp-chatbot-chat-container').attr('data-assistant', clickassistant);
747            }
748            if ((clickintent) != '') {
749                $('#wp-chatbot-messages-container').html('');
750                wpChatBotVar.clickintent = clickintent;
751                $('.wp-chatbot-notification-container').hide();
752                $('#wp-chatbot-chat-container').show();
753                $('.fb_dialog').show();
754            }
755            if ($('.active-chat-board').length == 0) {
756                jQuery('#wp-chatbot-chat-container').removeClass('wpbot_hide_floating_icon');
757                $('.wp-chatbot-ball').trigger("click");
758
759                if (clickintent != '') {
760                    jQuery('.wp-chatbot-container').show();
761                    jQuery('.wp-chatbot-start-container').hide();
762                }
763            }
764            // if(localStorage.getItem('wpwHitory')){
765            if (clickintent == 'Faq') {
766                globalwpw.wildCard = 1;
767                globalwpw.supportStep = 'welcome';
768                wpwAction.bot('from wildcard support');
769                //keeping value in localstorage
770                localStorage.setItem("wildCard", globalwpw.wildCard);
771                localStorage.setItem("supportStep", globalwpw.supportStep);
772
773            } else if (clickintent == 'Email Subscription') {
774                globalwpw.wildCard = 3;
775                globalwpw.subscriptionStep = 'welcome';
776                wpwTree.subscription();
777                localStorage.setItem("wildCard", globalwpw.wildCard);
778                localStorage.setItem("supportStep", globalwpw.supportStep);
779
780            } else if (clickintent == handle_language(wp_chatbot_obj.site_search)) {
781
782                if (typeof (globalwpw.hasNameCookie) == 'undefined' || globalwpw.hasNameCookie == '') {
783                    var shopperName = handle_language(wp_chatbot_obj.shopper_demo_name);
784                } else {
785                    var shopperName = globalwpw.hasNameCookie;
786                }
787                var askEmail = wpwKits.randomMsg(wp_chatbot_obj.asking_search_keyword)
788
789                wpwMsg.single(askEmail.replace("#name", shopperName));
790                //Now updating the support part as .
791                globalwpw.supportStep = 'search';
792                globalwpw.wildCard = 1;
793                //keeping value in localstorage
794                localStorage.setItem("wildCard", globalwpw.wildCard);
795                localStorage.setItem("supportStep", globalwpw.supportStep);
796
797            } else if (clickintent == 'Send Us Email') {
798
799                if (typeof (globalwpw.hasNameCookie) == 'undefined' || globalwpw.hasNameCookie == '') {
800                    var shopperName = handle_language(wp_chatbot_obj.shopper_demo_name);
801                } else {
802                    var shopperName = globalwpw.hasNameCookie;
803                }
804                var askEmail = wpwKits.randomMsg(wp_chatbot_obj.asking_email);
805                wpwMsg.single(askEmail);
806                //Now updating the support part as .
807                globalwpw.supportStep = 'email';
808                globalwpw.wildCard = 1;
809                //keeping value in localstorage
810                localStorage.setItem("wildCard", globalwpw.wildCard);
811                localStorage.setItem("supportStep", globalwpw.supportStep);
812
813            } else if (clickintent == 'Leave A Feedback') {
814
815                if (typeof (globalwpw.hasNameCookie) == 'undefined' || globalwpw.hasNameCookie == '') {
816                    var shopperName = handle_language(wp_chatbot_obj.shopper_demo_name);
817                } else {
818                    var shopperName = globalwpw.hasNameCookie;
819                }
820                var askEmail = wpwKits.randomMsg(wp_chatbot_obj.asking_email);
821                wpwMsg.single(askEmail);
822                //Now updating the support part as .
823                globalwpw.supportStep = 'email';
824                globalwpw.wildCard = 1;
825                //keeping value in localstorage
826                localStorage.setItem("wildCard", globalwpw.wildCard);
827                localStorage.setItem("supportStep", globalwpw.supportStep);
828
829            } else if (clickintent == 'Request Callback') {
830                if (typeof (globalwpw.hasNameCookie) == 'undefined' || globalwpw.hasNameCookie == '') {
831                    var shopperName = handle_language(globalwpw.settings.obj.shopper_demo_name);
832                } else {
833                    var shopperName = globalwpw.hasNameCookie;
834                }
835                var askEmail = wpwKits.randomMsg(wp_chatbot_obj.asking_phone);
836                setTimeout(function () {
837                    wpwMsg.single(askEmail);
838                    //Now updating the support part as .
839                    globalwpw.supportStep = 'phone';
840                    globalwpw.wildCard = 1;
841                    //keeping value in localstorage
842                    localStorage.setItem("wildCard", globalwpw.wildCard);
843                    localStorage.setItem("supportStep", globalwpw.supportStep);
844                }, 1000)
845            } else if (clickintent != '') {
846
847                globalwpw.initialize = 1;
848                globalwpw.ai_step = 1;
849                globalwpw.wildCard = 0;
850                wpwAction.bot(clickintent);
851
852            }
853
854            // }
855
856
857        })
858
859        $(document).on('click', '.wp-chatbot-notification-navigation', function (e) {
860            e.preventDefault();
861            if (e.target.className == 'wp-chatbot-notification-close') {
862                $('#wp-chatbot-notification-container').addClass('wp-chatbot-notification-container-disable');
863                //clearInterval(notificationInterval);
864                sessionStorage.setItem('wpChatbotNotification', 'removed');
865            } else {
866
867
868                var clickintent = $(this).attr('data-intent');
869                if (e.target.className == 'qcwp_notification_nav') {
870                    if (e.target.innerText.trim() == wp_chatbot_obj.wildcard_product[wp_chatbot_obj.default_language][0]) {
871
872                        clickintent = wp_chatbot_obj.sys_key_product[wp_chatbot_obj.default_language];
873                    } else if (e.target.innerText.trim() == wp_chatbot_obj.featured_products[wp_chatbot_obj.default_language][0]) {
874                        globalwpw.wildCard = 20;
875                        globalwpw.productStep = 'featured';
876                        clickintent = 'featured';
877                        // wpwKits.render('featured')
878                        // wpwKits.trigger_intent( 'featured' );
879                    }
880                    else {
881                        clickintent = e.target.innerText.trim();
882                    }
883                }
884                if (e.target.className == 'qc_kbx_custom_buddypress') {
885
886                    window.open(e.target.attributes[1].nodeValue, '_blank');
887                    return;
888                }
889                if (clickintent != '' && typeof clickintent != 'undefined') {
890                    globalwpw.initialize = 0;
891                    wpChatBotVar.clickintent = clickintent;
892                    $('.wp-chatbot-notification-container').hide();
893                    $('#wp-chatbot-chat-container').show();
894                    $('.fb_dialog').show();
895
896                    if ($('.active-chat-board').length == 0) {
897                        jQuery('#wp-chatbot-chat-container').removeClass('wpbot_hide_floating_icon');
898                        jQuery('.wp-chatbot-ball').trigger("click");
899                        jQuery('.wp-chatbot-container').show();
900                        jQuery('.wp-chatbot-start-container').hide();
901                        jQuery('#wp-chatbot-integration-container .wp-chatbot-integration-button-container').show();
902                        //  if(localStorage.getItem('wpwHitory')){
903                        if (clickintent.toLowerCase() == 'faq') {
904                            globalwpw.wildCard = 1;
905                            globalwpw.supportStep = 'welcome';
906                            wpwAction.bot('from wildcard support');
907                            //keeping value in localstorage
908                            localStorage.setItem("wildCard", globalwpw.wildCard);
909                            localStorage.setItem("supportStep", globalwpw.supportStep);
910
911                        }else if (clickintent == 'Send Us Email') {
912
913                                if (typeof (globalwpw.hasNameCookie) == 'undefined' || globalwpw.hasNameCookie == '') {
914                                    var shopperName = handle_language(wp_chatbot_obj.shopper_demo_name);
915                                } else {
916                                    var shopperName = globalwpw.hasNameCookie;
917                                }
918                                var askEmail = wpwKits.randomMsg(wp_chatbot_obj.asking_email);
919                                wpwMsg.single(askEmail);
920                                //Now updating the support part as .
921                                globalwpw.supportStep = 'email';
922                                globalwpw.wildCard = 1;
923                                //keeping value in localstorage
924                                localStorage.setItem("wildCard", globalwpw.wildCard);
925                                localStorage.setItem("supportStep", globalwpw.supportStep);
926
927                        } else if (clickintent.toLowerCase() == 'email Subscription') {
928                            globalwpw.wildCard = 3;
929                            globalwpw.subscriptionStep = 'welcome';
930                            wpwTree.subscription();
931                            localStorage.setItem("wildCard", globalwpw.wildCard);
932                            localStorage.setItem("supportStep", globalwpw.supportStep);
933
934                        } else if (clickintent.toLowerCase() == handle_language(wp_chatbot_obj.site_search).toLowerCase()) {
935                            if (typeof (globalwpw.hasNameCookie) == 'undefined' || globalwpw.hasNameCookie == '') {
936                                var shopperName = handle_language(wp_chatbot_obj.shopper_demo_name);
937                            } else {
938                                var shopperName = globalwpw.hasNameCookie;
939                            }
940                            var askEmail = wpwKits.randomMsg(wp_chatbot_obj.asking_search_keyword)
941                            
942                            wpwMsg.single(askEmail.replace("#name", shopperName));
943                            //Now updating the support part as .
944                            globalwpw.supportStep = 'search';
945                            globalwpw.wildCard = 1;
946                            //keeping value in localstorage
947                            localStorage.setItem("wildCard", globalwpw.wildCard);
948                            localStorage.setItem("supportStep", globalwpw.supportStep);
949
950                        }else if(clickintent.toLowerCase()=='leave a feedback'){
951
952                            if(typeof(globalwpw.hasNameCookie)=='undefined'|| globalwpw.hasNameCookie==''){
953                                var shopperName= handle_language(wp_chatbot_obj.shopper_demo_name);
954                            }else{
955                                var shopperName=globalwpw.hasNameCookie;
956                            }
957                            var askEmail = wpwKits.randomMsg(wp_chatbot_obj.asking_email);
958                            wpwMsg.single(askEmail);
959                            //Now updating the support part as .
960                            globalwpw.supportStep='email';
961                            globalwpw.wildCard=1;
962                            //keeping value in localstorage
963                            localStorage.setItem("wildCard",  globalwpw.wildCard);
964                            localStorage.setItem("supportStep",  globalwpw.supportStep);
965
966                        }else if(clickintent.toLowerCase() == 'request callback'){
967                            if(typeof(globalwpw.hasNameCookie)=='undefined'|| globalwpw.hasNameCookie==''){
968                                var shopperName= handle_language(globalwpw.settings.obj.shopper_demo_name);
969                            }else{
970                                var shopperName=globalwpw.hasNameCookie;
971                            }
972                            var askEmail = wpwKits.randomMsg(wp_chatbot_obj.asking_phone);
973                            setTimeout(function(){
974                                wpwMsg.single(askEmail);
975                                //Now updating the support part as .
976                                globalwpw.supportStep='phone';
977                                globalwpw.wildCard=1;
978                                //keeping value in localstorage
979                                localStorage.setItem("wildCard",  globalwpw.wildCard);
980                                localStorage.setItem("supportStep",  globalwpw.supportStep);
981                            },1000)
982                        }else if(clickintent.toLowerCase()=='featured products'){
983                            globalwpw.wildCard = 20;
984                            globalwpw.productStep = "featured";
985                            wpwAction.bot("from wildcard product");
986                            //keeping value in localstorage
987                            localStorage.setItem("wildCard", globalwpw.wildCard);
988                            localStorage.setItem("productStep", globalwpw.productStep);
989                            globalwpw.initialize = 0;
990                            globalwpw.ai_step = 1;
991                        }else if(clickintent.toLowerCase()=='product search'){
992                            globalwpw.wildCard = 20;
993                            globalwpw.productStep = "asking";
994                            wpwAction.bot("from wildcard product");
995                            localStorage.setItem("wildCard", globalwpw.wildCard);
996                            localStorage.setItem("productStep", globalwpw.productStep);
997                            globalwpw.initialize = 0;
998                            globalwpw.ai_step = 1;
999                        }else if(clickintent.toLowerCase()=='products on  sale'){
1000                            globalwpw.wildCard = 20;
1001                            globalwpw.productStep = "sale";
1002                            wpwAction.bot("from wildcard product");
1003                            localStorage.setItem("wildCard", globalwpw.wildCard);
1004                            localStorage.setItem("productStep", globalwpw.productStep);
1005
1006                            globalwpw.initialize = 0;
1007                            globalwpw.ai_step = 1;
1008                     
1009                        } else if (clickintent.toLowerCase() == 'leave a feedback') {
1010
1011                            if (typeof (globalwpw.hasNameCookie) == 'undefined' || globalwpw.hasNameCookie == '') {
1012                                var shopperName = handle_language(wp_chatbot_obj.shopper_demo_name);
1013                            } else {
1014                                var shopperName = globalwpw.hasNameCookie;
1015                            }
1016                            var askEmail = wpwKits.randomMsg(wp_chatbot_obj.asking_email);
1017                            wpwMsg.single(askEmail);
1018                            //Now updating the support part as .
1019                            globalwpw.supportStep = 'email';
1020                            globalwpw.wildCard = 1;
1021                            //keeping value in localstorage
1022                            localStorage.setItem("wildCard", globalwpw.wildCard);
1023                            localStorage.setItem("supportStep", globalwpw.supportStep);
1024
1025                        } else if (clickintent.toLowerCase() == 'request callback') {
1026                            if (typeof (globalwpw.hasNameCookie) == 'undefined' || globalwpw.hasNameCookie == '') {
1027                                var shopperName = handle_language(globalwpw.settings.obj.shopper_demo_name);
1028                            } else {
1029                                var shopperName = globalwpw.hasNameCookie;
1030                            }
1031                            var askEmail = wpwKits.randomMsg(wp_chatbot_obj.asking_phone);
1032                            setTimeout(function () {
1033                                wpwMsg.single(askEmail);
1034                                //Now updating the support part as .
1035                                globalwpw.supportStep = 'phone';
1036                                globalwpw.wildCard = 1;
1037                                //keeping value in localstorage
1038                                localStorage.setItem("wildCard", globalwpw.wildCard);
1039                                localStorage.setItem("supportStep", globalwpw.supportStep);
1040                            }, 1000)
1041                        } else if (clickintent.toLowerCase() != '') {
1042
1043                            globalwpw.initialize = 0;
1044                            globalwpw.ai_step = 1;
1045                            globalwpw.wildCard = 0;
1046                            if (e.target.innerText.trim() == wp_chatbot_obj.featured_products[wp_chatbot_obj.default_language][0]) {
1047                                globalwpw.wildCard = 20;
1048                            }
1049                            wpwAction.bot(clickintent);
1050
1051                        }
1052
1053                        //    }
1054                    }
1055                } else {
1056                    $('.wp-chatbot-ball').trigger("click");
1057                }
1058
1059            }
1060        })
1061
1062        if ($('#wp-chatbot-shortcode-template-container').length == 0 && $('#wp-chatbot-chat-app-shortcode-container').length == 0) {
1063            //Main wpwbot area.
1064            //show it
1065            $('#wp-chatbot-ball-wrapper').css({
1066                'display': 'block',
1067            });
1068            //wpChatBot icon  position.
1069            if (!window.matchMedia('(max-width: 480px)').matches) {
1070                $('#wp-chatbot-chat-container').css({
1071                    'right': wpChatBotVar.wp_chatbot_position_x + wpChatBotVar.wp_chatbot_position_in,
1072                    'bottom': wpChatBotVar.wp_chatbot_position_y + wpChatBotVar.wp_chatbot_position_in
1073                })
1074            }
1075            if (window.matchMedia('(max-width: 480px)').matches) {
1076                $('#wp-chatbot-chat-container').css({
1077                    'right': wpChatBotVar.wp_chatbot_position_mp_x + wpChatBotVar.wp_chatbot_position_mp_in,
1078                    'bottom': wpChatBotVar.wp_chatbot_position_mp_y + wpChatBotVar.wp_chatbot_position_mp_in
1079                });
1080            };
1081            //Facebook Messenger desktop
1082            setTimeout(function () {
1083                $('.fb_dialog').css({
1084                    'right': parseInt(55 + parseInt(wpChatBotVar.wp_chatbot_position_x)) + wpChatBotVar.wp_chatbot_position_in,
1085                    'bottom': parseInt(17 + parseInt(wpChatBotVar.wp_chatbot_position_y)) + wpChatBotVar.wp_chatbot_position_in,
1086                    'visibility': 'visible'
1087                });
1088                $('.fb_dialog_content iframe').css({
1089                    'right': parseInt(55 + parseInt(wpChatBotVar.wp_chatbot_position_x)) + wpChatBotVar.wp_chatbot_position_in,
1090                    'bottom': parseInt(17 + parseInt(wpChatBotVar.wp_chatbot_position_y)) + wpChatBotVar.wp_chatbot_position_in
1091                });
1092            }, 3000);
1093
1094            //wpchatbot icon animation disable or enable
1095            //Disable wpwBot icon Animation
1096
1097            if (wpChatBotVar.disable_icon_animation == 1) {
1098                $('.wp-chatbot-ball').addClass('wp-chatbot-animation-deactive');
1099            } else {
1100                $('.wp-chatbot-ball').addClass('wp-chatbot-animation-active');
1101
1102
1103                var itemHide = function () {
1104                    $('.wp-chatbot-animation-active .wp-chatbot-ball-animation-switch').fadeOut(1000);
1105                };
1106                setTimeout(function () {
1107                    itemHide()
1108                }, 1000);
1109
1110                //Click Animation
1111                $('.wp-chatbot-animation-active').on('click', function () {
1112                    $('.wp-chatbot-animation-active .wp-chatbot-ball-animation-switch').fadeIn(100);
1113                    setTimeout(function () {
1114                        itemHide();
1115                        showfloatinicon();
1116                    }, 1000);
1117                });
1118            }
1119
1120            //window resize.
1121            var widowH = $(window).height() - 50;
1122
1123            var widowW = $(window).width();
1124            if (widowW > 767 && typeof (iframe_exists) === "undefined") {
1125                if (wpChatBotVar.template == 'template-06' || wpChatBotVar.template == 'template-07') {
1126                    var ballConH = parseInt(widowH * 0.5);
1127                } else {
1128                    var ballConH = parseInt(widowH - 150) * 0.8;
1129                }
1130
1131                if (typeof (iframe_exists) !== "undefined") {
1132                    var widowH1 = $(window).height() - 50;
1133                    if (wpChatBotVar.template == 'template-06' || wpChatBotVar.template == 'template-07') {
1134                        var ballConH = parseInt(widowH1 * 0.5);
1135                    } else {
1136                        var ballConH = parseInt(widowH1 * 0.5) + 73;
1137                    }
1138                }
1139
1140                $('.wp-chatbot-ball-inner').css({ 'height': ballConH + 'px' })
1141                $('.wpbot-saas-live-chat').css({ 'height': (ballConH) + 'px' })
1142
1143                $('.wpbot-saas-live-chat').width('370px');
1144
1145                if ($('.wbcaBody').length > 0) {
1146                    $('.wbcaBody').css("height", (ballConH - 30) + "px")
1147                }
1148                if ($('#wbca_chat_body').length > 0) {
1149                    $('#wbca_chat_body').css("height", (ballConH - 73) + "px")
1150                }
1151
1152                $(window).resize(function () {
1153                    var widowH = $(window).height() - 50;
1154                    if (wpChatBotVar.template == 'template-06' || wpChatBotVar.template == 'template-07') {
1155                        var ballConH = parseInt(widowH * 0.5);
1156                    } else {
1157                        var ballConH = parseInt(widowH - 150) * 0.8;
1158                    }
1159
1160                    if (typeof (iframe_exists) !== "undefined") {
1161                        var widowH1 = $(window).height() - 50;
1162                        if (wpChatBotVar.template == 'template-06' || wpChatBotVar.template == 'template-07') {
1163                            var ballConH = parseInt(widowH1 * 0.5);
1164                        } else {
1165                            var ballConH = parseInt(widowH1 * 0.5) + 73;
1166                        }
1167                    }
1168
1169                    $('.wp-chatbot-ball-inner').css({ 'height': ballConH + 'px' })
1170                    $('.wpbot-saas-live-chat').css({ 'height': (ballConH) + 'px' })
1171
1172                    $('.wpbot-saas-live-chat').width('370px');
1173
1174                    if ($('.wbcaBody').length > 0) {
1175                        $('.wbcaBody').css("height", (ballConH - 30) + "px")
1176                    }
1177                    if ($('#wbca_chat_body').length > 0) {
1178                        $('#wbca_chat_body').css("height", (ballConH - 73) + "px")
1179                    }
1180                });
1181            };
1182
1183
1184            if (typeof (iframe_exists) !== "undefined") {
1185                // Embed iframe layout is CSS-driven so the footer stays visible.
1186            }
1187
1188
1189            if (widowH == 0) {
1190                $('.wp-chatbot-ball-inner').css({ 'height': 450 + 'px' })
1191            }
1192            $(window).resize(function () {
1193                if (widowH == 0) {
1194                    $('.wp-chatbot-ball-inner').css({ 'height': 450 + 'px' })
1195                }
1196            });
1197
1198            var botimage = jQuery('#wp-chatbot-ball').find('img').attr('qcld_agent');
1199
1200            $(document).on('click', '.qc-new-conversation-button', function (e) {
1201                e.preventDefault();
1202                $('.wp-chatbot-container').show();
1203                $('.wp-chatbot-start-container').hide();
1204                $('#wp-chatbot-integration-container .wp-chatbot-integration-button-container').show();
1205                wpwbot_board_action();
1206                if (!globalwpw.settings.obj.is_mobile) {
1207                    $("#wp-chatbot-editor").attr('disabled', false).focus();
1208                }
1209            })
1210            $(document).on('click', '.qcld_back_to_start_menu', function (e) {
1211                e.preventDefault();
1212                var maincontainerwidth = $('.wp-chatbot-board-container').width();
1213                var maincontainerheight = $('.wp-chatbot-container').height();
1214                if (typeof (iframe_exists) !== "undefined") {
1215                    maincontainerwidth = document.documentElement.classList.contains('wpbot-embed-host-mobile') ? '100%' : '350px';
1216                }
1217                var widowW = $(window).width();
1218                if (widowW <= 768 && wpChatBotVar.mobile_full_screen == 1 && typeof (iframe_exists) === "undefined") {
1219                    $('.wp-chatbot-start-container').width($(window).width());
1220                    $('.wp-chatbot-start-container').height($(window).height() - 50);
1221                    $('.wp-chatbot-start-screen').slimScroll({
1222                        height: $(window).height() - 50,
1223                        start: 'top'
1224                    })
1225                    wpbotEnableStartMenuNativeScroll();
1226                } else {
1227                    $('.wp-chatbot-start-container').width(maincontainerwidth);
1228                    $('.wp-chatbot-start-container').height(maincontainerheight);
1229                    $('.wp-chatbot-start-screen').slimScroll({
1230                        height: maincontainerheight,
1231                        start: 'top'
1232                    })
1233                    wpbotEnableStartMenuNativeScroll();
1234                }
1235                $('.wp-chatbot-container').hide();
1236                $('.wp-chatbot-start-container').show();
1237                wpbotEnableStartMenuNativeScroll();
1238                $('#wp-chatbot-integration-container .wp-chatbot-integration-button-container').hide();
1239            })
1240            $(document).on('click', '.qcld_new_start_button', function (e) {
1241                $('.wp-chatbot-container').show();
1242                $('.wp-chatbot-start-container').hide();
1243                $('#wp-chatbot-integration-container .wp-chatbot-integration-button-container').show();
1244            })
1245
1246            $(document).on('click', '#wp-chatbot-ball', function (event) {
1247                event.preventDefault();
1248                if ($('.wpbot-saas-live-chat').is(':visible')) {
1249                    $('#wpbot_back_to_home').trigger("click");
1250                }
1251
1252                if (widowW <= 1024 && wpChatBotVar.mobile_full_screen == 1 && typeof insideIframe === 'undefined') {
1253                    $('.fb_dialog').hide();
1254                }
1255
1256                if ($('.active-chat-board').length > 0) {
1257                    $('.wp-chatbot-notification-container').hide();
1258                    if ($('.qc_wpbot_floating_main').length > 0) {
1259                        $('.qc_wpbot_floating_main').show();
1260                    }
1261
1262                    if (wpChatBotVar.template == 'template-06' || wpChatBotVar.template == 'template-07') {
1263                        $('#wp-chatbot-ball').show();
1264                    }
1265                    $('#wp-chatbot-ball').removeClass('wpbot_chatopen_iconanimation');
1266                    $('#wp-chatbot-ball').addClass('wpbot_chatclose_iconanimation');
1267                    $('#wp-chatbot-ball').find('img').attr('src', botimage)
1268                    $('.wp-chatbot-ball').css('background', '#ffffff');
1269                    if (wpChatBotVar.wp_keep_chat_window_open == 1) {
1270                        $.cookie('bot_window_open', 'no', { path: '/' });
1271                    }
1272                    setTimeout(function () {
1273
1274                        var json = {
1275                            msg: 'chatbot_close',
1276                            val: (jQuery('#wp-chatbot-chat-container').height() + 80)
1277                        }
1278                        sendMessageIframe(json);
1279                    }, 500)
1280                    $('#wp-chatbot-ball-container').removeAttr('aria-haspopup');
1281                    $('#wp-chatbot-ball-container').removeAttr('aria-expanded');
1282                    $('#wp-chatbot-ball-container').attr('aria-haspopup', '');
1283                    $('#wp-chatbot-ball-container').attr('aria-expanded', 'false');
1284
1285
1286                } else {
1287
1288                    if ($('.qc_wpbot_floating_main').length > 0) {
1289                        $('.qc_wpbot_floating_main').hide();
1290                    }
1291                    if (wpChatBotVar.auto_hide_floating_button == 1) {
1292                        justOpen = true;
1293                        qcwp_auto_hide_floating_buttons();
1294                    }
1295
1296                    if (wpChatBotVar.template == 'template-06' || wpChatBotVar.template == 'template-07') {
1297                        $('#wp-chatbot-ball').hide();
1298                    }
1299                    $('#wp-chatbot-ball').removeClass('wpbot_chatclose_iconanimation');
1300                    $('#wp-chatbot-ball').addClass('wpbot_chatopen_iconanimation');
1301                    $('#wp-chatbot-ball').find('img').attr('src', wpChatBotVar.imgurl + 'wpbot-close-icon.png');
1302                    //$('.wp-chatbot-ball').css('background', 'unset');
1303                    if (wpChatBotVar.wp_keep_chat_window_open == 1) {
1304                        $.cookie('bot_window_open', 'yes', { path: '/' });
1305                    }
1306
1307                    $('.wp-chatbot-notification-container').hide();
1308                    setTimeout(function () {
1309                        var json = {
1310                            msg: 'chatbot_open',
1311                            val: (jQuery('#wp-chatbot-chat-container').height() + 80)
1312                        }
1313                        sendMessageIframe(json);
1314                        $('#wp-chatbot-ball-container').removeAttr('aria-haspopup');
1315                        $('#wp-chatbot-ball-container').removeAttr('aria-expanded');
1316                        $('#wp-chatbot-ball-container').attr('aria-expanded', 'true');
1317                        $('#wp-chatbot-ball-container').attr('aria-haspopup', '');
1318                    }, 500)
1319                }
1320                function togglecahtwindow() {
1321                    $("#wp-chatbot-board-container").toggleClass('active-chat-board');
1322                    $('#wp-chatbot-notification-container').removeClass('wp-chatbot-notification-container-sliding');
1323                    $('#wp-chatbot-notification-container').addClass('wp-chatbot-notification-container-disable');
1324                }
1325                togglecahtwindow();
1326                //  setTimeout(
1327                //     togglecahtwindow,
1328                //     delay_chat_window_open);
1329
1330                //chatbox will be open and notificaion will be closed
1331
1332                if (wpChatBotVar.start_menu_installed && wpChatBotVar.template != 'template-05' && (typeof (wpbotshortcodetemplate) === "undefined" || wpbotshortcodetemplate != 'template-05')) {
1333                    if ($('.active-chat-board').length > 0) {
1334                        var maincontainerwidth = $('.wp-chatbot-board-container').width();
1335                        var maincontainerheight = $('.wp-chatbot-container').height();
1336
1337                        if (typeof (iframe_exists) !== "undefined") {
1338                            maincontainerwidth = document.documentElement.classList.contains('wpbot-embed-host-mobile') ? '100%' : '350px';
1339                        }
1340
1341                        var widowW = $(window).width();
1342                        if (widowW <= 768 && wpChatBotVar.mobile_full_screen == 1 && typeof (iframe_exists) === "undefined") {
1343                            $('.wp-chatbot-start-container').width($(window).width());
1344                            $('.wp-chatbot-start-container').height($(window).height());
1345                            $('.wp-chatbot-start-screen').slimScroll({
1346                                height: $(window).height(),
1347                                start: 'top'
1348                            })
1349                            wpbotEnableStartMenuNativeScroll();
1350                            $('.wpbot-saas-live-chat').width($(window).width());
1351                            $('.wpbot-saas-live-chat').height($(window).height() - 50);
1352                            if ($('.wbcaBody').length > 0) {
1353                                $('.wbcaBody').css("height", ($(window).height() - 50 - 30) + "px")
1354                            }
1355                            if ($('#wbca_chat_body').length > 0) {
1356                                $('#wbca_chat_body').css("height", ($(window).height() - 50 - 73) + "px")
1357                            }
1358                        } else {
1359
1360                            $('.wp-chatbot-start-container').width(maincontainerwidth);
1361                            $('.wp-chatbot-start-container').height(maincontainerheight);
1362                            $('.wp-chatbot-start-screen').slimScroll({
1363                                height: maincontainerheight,
1364                                start: 'top'
1365                            })
1366                            wpbotEnableStartMenuNativeScroll();
1367
1368
1369
1370                            $('.wpbot-saas-live-chat').width(maincontainerwidth);
1371                            $('.wpbot-saas-live-chat').height(maincontainerheight);
1372                            if ($('.wbcaBody').length > 0) {
1373                                $('.wbcaBody').css("height", (maincontainerheight - 30) + "px")
1374                            }
1375                            if ($('#wbca_chat_body').length > 0) {
1376                                $('#wbca_chat_body').css("height", (maincontainerheight - 73) + "px")
1377                            }
1378                        }
1379
1380                        if (typeof (iframe_exists) !== "undefined") {
1381                            $('.wp-chatbot-start-container').css({ width: '100%', height: '' });
1382                            wpbotEnableStartMenuNativeScroll();
1383                        }
1384
1385
1386                        $('.wp-chatbot-container').hide();
1387                        $('.wp-chatbot-start-container').show();
1388                        wpbotEnableStartMenuNativeScroll();
1389                        $('#wp-chatbot-integration-container .wp-chatbot-integration-button-container').hide();
1390                    } else {
1391                        $('.wp-chatbot-start-container').hide();
1392                        $('#wp-chatbot-integration-container .wp-chatbot-integration-button-container').show();
1393                    }
1394                }
1395                if ((wpChatBotVar.template == 'template-horizontal') && !($('.wp-chatbot-start-container').is(':visible'))) {
1396
1397                    $('.wp-chatbot-container').show();
1398
1399                }
1400                wpwbot_board_action();
1401
1402
1403
1404                if (wpChatBotVar.is_operator_online == 1 && wpChatBotVar.open_livechat_window_first == 1) {
1405                    if ($('.active-chat-board').length > 0) {
1406
1407                        if (wpChatBotVar.livechat_autopopulation != '1') {
1408                            if ($('#wbca_signup_fullname').length > 0) {
1409                                if (localStorage.getItem('shopper') !== null) {
1410                                    $('#wbca_signup_fullname').val(localStorage.getItem('shopper'));
1411                                }
1412                                if (localStorage.getItem('shopperemail') !== null) {
1413                                    $('#wbca_signup_email').val(localStorage.getItem('shopperemail'));
1414                                }
1415                            }
1416                        }
1417                        var maincontainerwidth = $('.wp-chatbot-container').width();
1418                        var maincontainerheight = $('.wp-chatbot-container').height();
1419
1420                        $("#wp-chatbot-board-container").removeClass('active-chat-board');
1421                        $('.wp-chatbot-container').hide();
1422                        $('.wp-chatbot-start-container').hide();
1423                        $('.wpbot-saas-live-chat').show();
1424
1425                    }
1426                }
1427
1428
1429            });
1430            //wpwBot proActive start
1431            $("#wp-chatbot-board-container").on("click", ".qcld_voice_audio_control", function (e) {
1432                e.preventDefault();
1433                var $icon = $(this).find(".fa");
1434                if ($icon.attr('class') == "fa fa-volume-up") {
1435                    $icon.removeClass("fa-volume-up").addClass("fa-volume-mute");
1436                    if (typeof wpwKits !== 'undefined' && wpwKits.stopBotAudio) {
1437                        wpwKits.stopBotAudio();
1438                    }
1439                    return;
1440                }
1441                if ($icon.attr('class') == "fa fa-volume-mute") {
1442                    $icon.removeClass("fa-volume-mute").addClass("fa-volume-up");
1443                    if (typeof wpwKits !== 'undefined' && wpwKits.handleAudio) {
1444                        wpwKits.handleAudio();
1445                    }
1446                    return;
1447                }
1448            })
1449            //Attention on
1450            if (wpChatBotVar.enable_meta_title == 1 && handle_language(wpChatBotVar.meta_label) != "") {
1451                var MetaTitleInterval;
1452                var orginalTitle = document.title;
1453                $(document).on("mouseover", 'body', function (e) {
1454                    document.title = orginalTitle;
1455                    clearInterval(MetaTitleInterval);
1456                });
1457            }
1458
1459            //Exit Intent
1460            if (wpChatBotVar.exit_intent_bargain_pro_single_page == 1 && wpChatBotVar.exit_intent_bargain_is_product_page) {
1461                window.addEventListener("mouseout", function (e) {
1462                    e = e ? e : window.event;
1463
1464                    // If this is an autocomplete element.
1465                    if (e.target && typeof e.target.tagName === 'string' && e.target.tagName.toLowerCase() == "input")
1466                        return;
1467
1468                    // Get the current viewport width.
1469                    var vpWidth = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
1470
1471                    // If the current mouse X position is within 50px of the right edge
1472                    // of the viewport, return.
1473                    if (e.clientX >= (vpWidth - 50))
1474                        return;
1475
1476                    // If the current mouse Y position is not within 50px of the top
1477                    // edge of the viewport, return.
1478                    if (e.clientY >= 50)
1479                        return;
1480
1481                    // Reliable, works on mouse exiting window and
1482                    // user switching active program
1483                    var from = e.relatedTarget || e.toElement;
1484                    if (!from)
1485                        //if will open once if setup from backend.
1486                        var exitIntentOpen = true;
1487                    if ($.cookie('exit_intent') == 'yes' && wpChatBotVar.exit_intent_once == 1) {
1488                        exitIntentOpen = false;
1489                    }
1490                    if (exitIntentOpen == true) {
1491                        if (wpChatBotVar.exit_intent_handler == 0) {
1492
1493                            if ($('.wp-saas-live-chat').is(':visible')) {
1494                                return;
1495                            }
1496
1497                            if ($('.active-chat-board').length == 0) {
1498
1499                                wpChatBotVar.re_target_handler = 9;
1500
1501                                $('#wp-chatbot-ball').removeClass('wpbot_chatclose_iconanimation');
1502                                $('#wp-chatbot-ball').addClass('wpbot_chatopen_iconanimation');
1503                                $('#wp-chatbot-ball').find('img').attr('src', wpChatBotVar.imgurl + 'wpbot-close-icon.png');
1504                                //$('.wp-chatbot-ball').css('background', 'unset');
1505                                $("#wp-chatbot-board-container").addClass('active-chat-board');
1506                                if ($('.chat_active').length > 1) {
1507                                    $('.wp-chatbot-ball').trigger("click");
1508                                }
1509                                if ($('.wp-chatbot-tpl-4-chat-trigger').length > 0) {
1510                                    $('.wp-chatbot-tpl-4-chat-trigger').trigger("click");
1511                                }
1512                                if (wpChatBotVar.template == 'template-06' || wpChatBotVar.template == 'template-07') {
1513                                    $('#wp-chatbot-ball').hide();
1514                                    $(".wp-chatbot-container").animate({ left: '-340px' });
1515                                }
1516                                if ($('.qc_wpbot_floating_main').length > 0) {
1517                                    $('.qc_wpbot_floating_main').hide();
1518                                }
1519
1520                            }
1521
1522                            if ($('.wp-chatbot-start-container').is(':visible')) {
1523                                $('.wp-chatbot-container').show();
1524                                $('.wp-chatbot-start-container').hide();
1525                                $('#wp-chatbot-integration-container .wp-chatbot-integration-button-container').show();
1526                            } else {
1527                                $('.wp-chatbot-container').show();
1528                                $('#wp-chatbot-integration-container .wp-chatbot-integration-button-container').show();
1529                            }
1530
1531
1532
1533                            setTimeout(function () {
1534                                $('.active-chat-board').addClass('animated tada');
1535                                setTimeout(function () {
1536                                    $('.active-chat-board').removeClass('animated tada');
1537                                }, 1000)
1538                            }, 200)
1539
1540
1541                            wpChatBotVar.exit_intent_handler++;
1542                            wpChatBotVar.re_target_handler = 9;
1543                            wpwbot_board_action();
1544                            //Shopper Name
1545                            if (localStorage.getItem('shopper')) {
1546                                var shopper = localStorage.getItem('shopper');
1547                            } else {
1548                                var shopper = handle_language(wpChatBotVar.shopper_demo_name);
1549                            }
1550                            setTimeout(function () {
1551                                if (localStorage.getItem("wpwHitory")) {
1552                                    var confirmBtn = '<span class="qcld-modal-bargin-confirm-exit-intent-btn"><span class="qcld-modal-bargin-bot-confirm-exit-intent" confirm-data="yes" >' + handle_language(wpChatBotVar.yes) + '</span> <span> ' + handle_language(wpChatBotVar.or) + ' </span><span class="qcld-chatbot-reset-btn qcld-chatbot-reset-btn-bargain"  reset-data="no">' + handle_language(wpChatBotVar.no) + '</span></span>';
1553
1554                                    showing_proactive_msg(handle_language(wpChatBotVar.ret_greet) + ' ' + shopper + ', ' + handle_language(wpChatBotVar.exit_intent_bargain_msg) + '<br><br>' + confirmBtn)
1555
1556                                } else {
1557                                    var confirmBtn = '<span class="qcld-modal-bargin-confirm-exit-intent-btn"><span class="qcld-modal-bargin-bot-confirm-exit-intent" confirm-data="yes" >' + handle_language(wpChatBotVar.yes) + '</span> <span> ' + handle_language(wpChatBotVar.or) + ' </span><span class="qcld-chatbot-reset-btn qcld-chatbot-reset-btn-bargain"  reset-data="no">' + handle_language(wpChatBotVar.no) + '</span></span>';
1558
1559                                    showing_proactive_double_msg(handle_language(wpChatBotVar.ret_greet) + ' ' + shopper + ', ' + handle_language(wpChatBotVar.exit_intent_bargain_msg) + '<br><br>' + confirmBtn)
1560
1561                                }
1562                                $.cookie('exit_intent', 'yes');
1563                                //pro active sound
1564                                proactive_retargeting_sound();
1565                                //Window foucus meta title change.
1566                                window_focus_change_meta_title();
1567                            }, 1000)
1568                        }
1569                    }
1570                });
1571            } else if (wpChatBotVar.enable_exit_intent == 1 && (wpChatBotVar.exitintent_all_page == 'on' || (wpChatBotVar.exitintent_all_page == 'off' && wpChatBotVar.exitintent_pages.indexOf(wpChatBotVar.current_pageid) > -1) || (wpChatBotVar.exitintent_all_page == 'pagewise' && wpChatBotVar.exit_pagewise.page.indexOf(wpChatBotVar.current_pageid) > -1))) {
1572                window.addEventListener("mouseout", function (e) {
1573                    e = e ? e : window.event;
1574
1575
1576                    // If this is an autocomplete element.
1577                    if (e.target && e.target.tagName && e.target.tagName.toLowerCase() == "input")
1578                        return;
1579
1580                    // Get the current viewport width.
1581                    var vpWidth = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
1582
1583                    // If the current mouse X position is within 50px of the right edge
1584                    // of the viewport, return.
1585                    if (e.clientX >= (vpWidth - 50))
1586                        return;
1587
1588                    // If the current mouse Y position is not within 50px of the top
1589                    // edge of the viewport, return.
1590                    if (e.clientY >= 50)
1591                        return;
1592
1593                    // Reliable, works on mouse exiting window and
1594                    // user switching active program
1595                    var from = e.relatedTarget || e.toElement;
1596                    if (!from)
1597                        //if will open once if setup from backend.
1598                        var exitIntentOpen = true;
1599                    if ($.cookie('exit_intent') == 'yes' && wpChatBotVar.exit_intent_once == 1) {
1600                        exitIntentOpen = false;
1601                    }
1602
1603                    var exitcustomintent = wpChatBotVar.exit_intent_custom_intent;
1604                    var exitmessage = handle_language(wpChatBotVar.exit_intent_msg);
1605
1606                    if (wpChatBotVar.exitintent_all_page == 'pagewise') {
1607                        var epages = wpChatBotVar.exit_pagewise.page;
1608                        var emessages = wpChatBotVar.exit_pagewise.message;
1609                        var eintent = wpChatBotVar.exit_pagewise.intent;
1610                        if (epages.indexOf(wpChatBotVar.current_pageid) > -1) {
1611                            var eindex = epages.indexOf(wpChatBotVar.current_pageid);
1612                        }
1613                        if (eintent[eindex] != '') {
1614                            exitcustomintent = eintent[eindex];
1615                        }
1616                        if (emessages[eindex] != '') {
1617                            exitmessage = emessages[eindex];
1618                        }
1619
1620                    }
1621                    exitcustomintent = exitcustomintent.trim();
1622
1623                    if (exitIntentOpen == true) {
1624
1625                        if (wpChatBotVar.exit_intent_handler == 0 && $('.active-chat-board').length == 0) {
1626
1627                            if ($('.active-chat-board').length == 0) {
1628
1629                                wpChatBotVar.re_target_handler = 1;
1630
1631                                $('#wp-chatbot-ball').removeClass('wpbot_chatclose_iconanimation');
1632                                $('#wp-chatbot-ball').addClass('wpbot_chatopen_iconanimation');
1633                                $('#wp-chatbot-ball').find('img').attr('src', wpChatBotVar.imgurl + 'wpbot-close-icon.png');
1634                                //$('.wp-chatbot-ball').css('background', 'unset');
1635                                if ($('#wp-chatbot-chat-container').hasClass('qcchatbot-template-05')) {
1636                                    jQuery('#wp-chatbot-ball').addClass('chat_active');
1637                                }
1638
1639
1640                                $("#wp-chatbot-board-container").addClass('active-chat-board');
1641
1642
1643                                if ($('.wp-chatbot-tpl-4-chat-trigger').length > 0) {
1644                                    $('.wp-chatbot-tpl-4-chat-trigger').trigger("click");
1645                                }
1646                                if (wpChatBotVar.template == 'template-06' || wpChatBotVar.template == 'template-07') {
1647                                    $('#wp-chatbot-ball').hide();
1648                                    $(".wp-chatbot-container").animate({ left: '-340px' });
1649                                }
1650
1651                                if ($('.qc_wpbot_floating_main').length > 0) {
1652                                    $('.qc_wpbot_floating_main').hide();
1653                                }
1654                            }
1655
1656                            if ($('.wp-chatbot-start-container').is(':visible')) {
1657                                $('.wp-chatbot-container').show();
1658                                $('.wp-chatbot-start-container').hide();
1659                                $('#wp-chatbot-integration-container .wp-chatbot-integration-button-container').show();
1660                            } else {
1661                                $('.wp-chatbot-container').show();
1662                                $('#wp-chatbot-integration-container .wp-chatbot-integration-button-container').show();
1663                            }
1664
1665                            setTimeout(function () {
1666                                $('.active-chat-board').addClass('animated tada');
1667                                setTimeout(function () {
1668                                    $('.active-chat-board').removeClass('animated tada');
1669                                }, 1000)
1670                            }, 200)
1671
1672                            wpChatBotVar.exit_intent_handler++;
1673                            wpChatBotVar.re_target_handler = 1;
1674                            wp_chatbot_obj.re_target_handler = 1;
1675                            wpwbot_board_action();
1676
1677                            setTimeout(function () {
1678                                var json = {
1679                                    msg: 'chatbot_open',
1680                                    val: (jQuery('#wp-chatbot-chat-container').height() + 80)
1681                                }
1682                                sendMessageIframe(json);
1683                            }, 200)
1684                            //Shopper Name
1685                            if (localStorage.getItem('shopper')) {
1686                                var shopper = localStorage.getItem('shopper');
1687                            } else {
1688                                var shopper = handle_language(wpChatBotVar.shopper_demo_name);
1689                            }
1690
1691
1692                            setTimeout(function () {
1693
1694                                if (exitcustomintent != '') {
1695
1696                                    if (exitcustomintent == 'Faq') {
1697                                        globalwpw.wildCard = 1;
1698                                        globalwpw.supportStep = 'welcome';
1699                                        wpwAction.bot('from wildcard support');
1700                                        //keeping value in localstorage
1701                                        localStorage.setItem("wildCard", globalwpw.wildCard);
1702                                        localStorage.setItem("supportStep", globalwpw.supportStep);
1703
1704                                    } else if (exitcustomintent == 'Email Subscription') {
1705                                        globalwpw.wildCard = 3;
1706                                        globalwpw.subscriptionStep = 'welcome';
1707                                        wpwTree.subscription();
1708                                        localStorage.setItem("wildCard", globalwpw.wildCard);
1709                                        localStorage.setItem("supportStep", globalwpw.supportStep);
1710
1711                                    } else if (exitcustomintent == handle_language(wp_chatbot_obj.site_search)) {
1712
1713                                        if (typeof (globalwpw.hasNameCookie) == 'undefined' || globalwpw.hasNameCookie == '') {
1714                                            var shopperName = wp_chatbot_obj.shopper_demo_name;
1715                                        } else {
1716                                            var shopperName = globalwpw.hasNameCookie;
1717                                        }
1718                                        var askEmail = wpwKits.randomMsg(wp_chatbot_obj.asking_search_keyword)
1719
1720                                        wpwMsg.single(askEmail.replace("#name", shopperName));
1721                                        //Now updating the support part as .
1722                                        globalwpw.supportStep = 'search';
1723                                        globalwpw.wildCard = 1;
1724                                        //keeping value in localstorage
1725                                        localStorage.setItem("wildCard", globalwpw.wildCard);
1726                                        localStorage.setItem("supportStep", globalwpw.supportStep);
1727
1728                                    } else if (exitcustomintent == 'Send Us Email') {
1729
1730                                        if (typeof (globalwpw.hasNameCookie) == 'undefined' || globalwpw.hasNameCookie == '') {
1731                                            var shopperName = wp_chatbot_obj.shopper_demo_name;
1732                                        } else {
1733                                            var shopperName = globalwpw.hasNameCookie;
1734                                        }
1735                                        var askEmail = wpwKits.randomMsg(wp_chatbot_obj.asking_email);
1736                                        wpwMsg.single(askEmail);
1737                                        //Now updating the support part as .
1738                                        globalwpw.supportStep = 'email';
1739                                        globalwpw.wildCard = 1;
1740                                        //keeping value in localstorage
1741                                        localStorage.setItem("wildCard", globalwpw.wildCard);
1742                                        localStorage.setItem("supportStep", globalwpw.supportStep);
1743
1744                                    } else if (exitcustomintent == 'Leave A Feedback') {
1745
1746                                        if (typeof (globalwpw.hasNameCookie) == 'undefined' || global
1746wpw.hasNameCookie == '') {
1747                                            var shopperName = wp_chatbot_obj.shopper_demo_name;
1748                                        } else {
1749                                            var shopperName = globalwpw.hasNameCookie;
1750                                        }
1751                                        var askEmail = wpwKits.randomMsg(wp_chatbot_obj.asking_email);
1752                                        wpwMsg.single(askEmail);
1753                                        //Now updating the support part as .
1754                                        globalwpw.supportStep = 'email';
1755                                        globalwpw.wildCard = 1;
1756                                        //keeping value in localstorage
1757                                        localStorage.setItem("wildCard", globalwpw.wildCard);
1758                                        localStorage.setItem("supportStep", globalwpw.supportStep);
1759
1760                                    } else if (exitcustomintent == 'Request Callback') {
1761                                        if (typeof (globalwpw.hasNameCookie) == 'undefined' || globalwpw.hasNameCookie == '') {
1762                                            var shopperName = globalwpw.settings.obj.shopper_demo_name;
1763                                        } else {
1764                                            var shopperName = globalwpw.hasNameCookie;
1765                                        }
1766                                        var askEmail = wpwKits.randomMsg(wp_chatbot_obj.asking_phone);
1767                                        setTimeout(function () {
1768                                            wpwMsg.single(askEmail);
1769                                            //Now updating the support part as .
1770                                            globalwpw.supportStep = 'phone';
1771                                            globalwpw.wildCard = 1;
1772                                            //keeping value in localstorage
1773                                            localStorage.setItem("wildCard", globalwpw.wildCard);
1774                                            localStorage.setItem("supportStep", globalwpw.supportStep);
1775                                        }, 1000)
1776                                    } else if (exitcustomintent != '') {
1777
1778                                        globalwpw.initialize = 1;
1779                                        globalwpw.ai_step = 1;
1780                                        globalwpw.wildCard = 0;
1781                                        wpwAction.bot(exitcustomintent);
1782
1783                                    }
1784
1785                                    proactive_retargeting_sound();
1786                                    //Window foucus meta title change.
1787                                    window_focus_change_meta_title();
1788
1789                                } else if (wpChatBotVar.exit_intent_email == 1 && wpChatBotVar.exitintent_all_page != 'pagewise') {
1790                                    globalwpw.wildCard = 3;
1791                                    globalwpw.subscriptionStep = 'welcome';
1792                                    wpwTree.subscription('test');
1793                                    $.cookie('scroll_open', 'yes');
1794                                    //pro active sound
1795                                    proactive_retargeting_sound();
1796                                    //Window foucus meta title change.
1797                                    window_focus_change_meta_title();
1798                                } else {
1799
1800                                    if (localStorage.getItem("wpwHitory")) {
1801                                        showing_proactive_msg(handle_language(wpChatBotVar.ret_greet) + ' ' + shopper + ', ' + exitmessage);
1802                                    } else {
1803                                        showing_proactive_double_msg(handle_language(wpChatBotVar.ret_greet) + ' ' + shopper + ', ' + exitmessage)
1804                                    }
1805                                    $.cookie('exit_intent', 'yes');
1806                                    //pro active sound
1807                                    proactive_retargeting_sound();
1808                                    //Window foucus meta title change.
1809                                    window_focus_change_meta_title();
1810
1811                                }
1812
1813                            }, 1000)
1814                        }
1815                    }
1816                });
1817            }
1818            if (wpChatBotVar.enable_scroll_open == 1 && (wpChatBotVar.scrollintent_all_page == 'on' || (wpChatBotVar.scrollintent_all_page == 'off' && wpChatBotVar.scrollintent_pages.indexOf(wpChatBotVar.current_pageid) > -1) || (wpChatBotVar.scrollintent_all_page == 'pagewise' && wpChatBotVar.scroll_pagewise.page.indexOf(wpChatBotVar.current_pageid) > -1) || (wpChatBotVar.trigger_url_scroll != null))) {
1819
1820
1821                $(document).on('scroll', function (event) {
1822                    var OpenScroll = true;
1823                    //if will open once if setup from backend.
1824                    if ($.cookie('scroll_open') == 'yes' && wpChatBotVar.scroll_open_once == 1) {
1825                        OpenScroll = false;
1826                    }
1827                    //it will be open only for single time.
1828
1829                    var scrollcustomintent = wpChatBotVar.scroll_open_custom_intent;
1830                    var scrollmessage = handle_language(wpChatBotVar.scroll_open_msg);
1831                    var spagesurl = wpChatBotVar.trigger_url_scroll;
1832
1833                    if (spagesurl) {
1834                        var sindex = spagesurl.indexOf(wpChatBotVar.current_pageid);
1835                        var smessages = wpChatBotVar.exit_pagewise.message;
1836                        var sintent = wpChatBotVar.exit_pagewise.intent;
1837                        if (spagesurl.indexOf(wpChatBotVar.current_pageid) > -1) {
1838                            var eindex = spagesurl.indexOf(wpChatBotVar.current_pageid);
1839                        }
1840                        if (sintent[sindex] != '') {
1841                            scrollcustomintent = sintent[sindex];
1842                        }
1843                        if (smessages[sindex] != '') {
1844                            scrollmessage = smessages[sindex];
1845                        }
1846                    }
1847                    if (wpChatBotVar.scrollintent_all_page == 'pagewise') {
1848
1849                        var epages = wpChatBotVar.scroll_pagewise.page;
1850                        var emessages = wpChatBotVar.scroll_pagewise.message;
1851                        var eintent = wpChatBotVar.scroll_pagewise.intent;
1852                        if (wpChatBotVar.scroll_pagewise.page.indexOf(wpChatBotVar.current_pageid) > -1) {
1853                            var eindex = wpChatBotVar.scroll_pagewise.page.indexOf(wpChatBotVar.current_pageid);
1854                        }
1855                        if (eintent[eindex] != '') {
1856                            scrollcustomintent = eintent[eindex];
1857                        }
1858                        if (emessages[eindex] != '') {
1859                            scrollmessage = emessages[eindex];
1860                        }
1861
1862                    }
1863                    if (typeof scrollcustomintent !== "undefined") {
1864                        scrollcustomintent = scrollcustomintent.trim();
1865
1866                    }
1867
1868                    if ((OpenScroll == true) && (document.getElementsByClassName("wpbot-saas-live-chat")[0].style.display != 'block')) {
1869
1870                        if (wpChatBotVar.scroll_open_handler == 0 && $('.active-chat-board').length == 0) {
1871
1872                            var scrollOpenVal = parseInt(($(document).height() * wpChatBotVar.scroll_open_percent) / 100);
1873                            if ($(window).scrollTop() + screen.height - 50 > scrollOpenVal) {
1874
1875                                if ($('.active-chat-board').length == 0) {
1876                                    wpChatBotVar.re_target_handler = 2;
1877                                    wp_chatbot_obj.re_target_handler = 1;
1878
1879                                    $('#wp-chatbot-ball').removeClass('wpbot_chatclose_iconanimation');
1880                                    $('#wp-chatbot-ball').addClass('wpbot_chatopen_iconanimation');
1881                                    $('#wp-chatbot-ball').find('img').attr('src', wpChatBotVar.imgurl + 'wpbot-close-icon.png');
1882                                    //$('.wp-chatbot-ball').css('background', 'unset');
1883                                    $("#wp-chatbot-board-container").addClass('active-chat-board');
1884                                    if ($('.chat_active').length > 1) {
1885                                        $('.wp-chatbot-ball').trigger("click");
1886                                    }
1887                                    if ($('.wp-chatbot-tpl-4-chat-trigger').length > 0) {
1888                                        $('.wp-chatbot-tpl-4-chat-trigger').trigger("click");
1889                                    }
1890                                    if (wpChatBotVar.template == 'template-06' || wpChatBotVar.template == 'template-07') {
1891                                        $('#wp-chatbot-ball').hide();
1892                                        $(".wp-chatbot-container").animate({ left: '-340px' });
1893                                    }
1894
1895                                    if ($('.qc_wpbot_floating_main').length > 0) {
1896                                        $('.qc_wpbot_floating_main').hide();
1897                                    }
1898                                }
1899
1900                                if ($('.wp-chatbot-start-container').is(':visible')) {
1901                                    $('.wp-chatbot-container').show();
1902                                    $('.wp-chatbot-start-container').hide();
1903                                    $('#wp-chatbot-integration-container .wp-chatbot-integration-button-container').show();
1904                                } else {
1905                                    $('.wp-chatbot-container').show();
1906                                    $('#wp-chatbot-integration-container .wp-chatbot-integration-button-container').show();
1907                                }
1908
1909                                setTimeout(function () {
1910                                    $('.active-chat-board').addClass('animated tada');
1911                                    setTimeout(function () {
1912                                        $('.active-chat-board').removeClass('animated tada');
1913                                    }, 1000)
1914                                }, 200)
1915
1916                                wpChatBotVar.scroll_open_handler++;
1917                                wpChatBotVar.re_target_handler = 2;
1918                                wp_chatbot_obj.re_target_handler = 1;
1919                                wpwbot_board_action();
1920                                setTimeout(function () {
1921                                    var json = {
1922                                        msg: 'chatbot_open',
1923                                        val: (jQuery('#wp-chatbot-chat-container').height() + 80)
1924                                    }
1925                                    sendMessageIframe(json);
1926                                }, 200)
1927                                //Shopper Name
1928                                if (localStorage.getItem('shopper')) {
1929                                    var shopper = localStorage.getItem('shopper');
1930                                } else {
1931                                    var shopper = handle_language(wpChatBotVar.shopper_demo_name);
1932                                }
1933                                setTimeout(function () {
1934
1935                                    if (scrollcustomintent != '') {
1936
1937                                        if (scrollcustomintent == 'Faq') {
1938                                            globalwpw.wildCard = 1;
1939                                            globalwpw.supportStep = 'welcome';
1940                                            wpwAction.bot('from wildcard support');
1941                                            //keeping value in localstorage
1942                                            localStorage.setItem("wildCard", globalwpw.wildCard);
1943                                            localStorage.setItem("supportStep", globalwpw.supportStep);
1944
1945                                        } else if (scrollcustomintent == 'Email Subscription') {
1946                                            globalwpw.wildCard = 3;
1947                                            globalwpw.subscriptionStep = 'welcome';
1948                                            wpwTree.subscription();
1949                                            localStorage.setItem("wildCard", globalwpw.wildCard);
1950                                            localStorage.setItem("supportStep", globalwpw.supportStep);
1951
1952                                        } else if (scrollcustomintent == handle_language(wp_chatbot_obj.site_search)) {
1953
1954                                            if (typeof (globalwpw.hasNameCookie) == 'undefined' || globalwpw.hasNameCookie == '') {
1955                                                var shopperName = wp_chatbot_obj.shopper_demo_name;
1956                                            } else {
1957                                                var shopperName = globalwpw.hasNameCookie;
1958                                            }
1959                                            var askEmail = wpwKits.randomMsg(wp_chatbot_obj.asking_search_keyword)
1960
1961                                            wpwMsg.single(askEmail.replace("#name", shopperName));
1962                                            //Now updating the support part as .
1963                                            globalwpw.supportStep = 'search';
1964                                            globalwpw.wildCard = 1;
1965                                            //keeping value in localstorage
1966                                            localStorage.setItem("wildCard", globalwpw.wildCard);
1967                                            localStorage.setItem("supportStep", globalwpw.supportStep);
1968
1969                                        } else if (scrollcustomintent == 'Send Us Email') {
1970
1971                                            if (typeof (globalwpw.hasNameCookie) == 'undefined' || globalwpw.hasNameCookie == '') {
1972                                                var shopperName = wp_chatbot_obj.shopper_demo_name;
1973                                            } else {
1974                                                var shopperName = globalwpw.hasNameCookie;
1975                                            }
1976                                            var askEmail = wpwKits.randomMsg(wp_chatbot_obj.asking_email);
1977                                            wpwMsg.single(askEmail);
1978                                            //Now updating the support part as .
1979                                            globalwpw.supportStep = 'email';
1980                                            globalwpw.wildCard = 1;
1981                                            //keeping value in localstorage
1982                                            localStorage.setItem("wildCard", globalwpw.wildCard);
1983                                            localStorage.setItem("supportStep", globalwpw.supportStep);
1984
1985                                        } else if (scrollcustomintent == 'Leave A Feedback') {
1986
1987                                            if (typeof (globalwpw.hasNameCookie) == 'undefined' || globalwpw.hasNameCookie == '') {
1988                                                var shopperName = wp_chatbot_obj.shopper_demo_name;
1989                                            } else {
1990                                                var shopperName = globalwpw.hasNameCookie;
1991                                            }
1992                                            var askEmail = wpwKits.randomMsg(wp_chatbot_obj.asking_email);
1993                                            wpwMsg.single(askEmail);
1994                                            //Now updating the support part as .
1995                                            globalwpw.supportStep = 'email';
1996                                            globalwpw.wildCard = 1;
1997                                            //keeping value in localstorage
1998                                            localStorage.setItem("wildCard", globalwpw.wildCard);
1999                                            localStorage.setItem("supportStep", globalwpw.supportStep);
2000
2001                                        } else if (scrollcustomintent == 'Request Callback') {
2002                                            if (typeof (globalwpw.hasNameCookie) == 'undefined' || globalwpw.hasNameCookie == '') {
2003                                                var shopperName = globalwpw.settings.obj.shopper_demo_name;
2004                                            } else {
2005                                                var shopperName = globalwpw.hasNameCookie;
2006                                            }
2007                                            var askEmail = wpwKits.randomMsg(wp_chatbot_obj.asking_phone);
2008                                            setTimeout(function () {
2009                                                wpwMsg.single(askEmail);
2010                                                //Now updating the support part as .
2011                                                globalwpw.supportStep = 'phone';
2012                                                globalwpw.wildCard = 1;
2013                                                //keeping value in localstorage
2014                                                localStorage.setItem("wildCard", globalwpw.wildCard);
2015                                                localStorage.setItem("supportStep", globalwpw.supportStep);
2016                                            }, 1000)
2017                                        } else if (scrollcustomintent != '') {
2018
2019                                            globalwpw.initialize = 1;
2020                                            globalwpw.ai_step = 1;
2021                                            globalwpw.wildCard = 0;
2022                                            wpwAction.bot(scrollcustomintent);
2023
2024                                        }
2025
2026                                        proactive_retargeting_sound();
2027                                        //Window foucus meta title change.
2028                                        window_focus_change_meta_title();
2029
2030                                    } else if (wpChatBotVar.scroll_open_email == 1 && wpChatBotVar.scrollintent_all_page != 'pagewise') {
2031                                        globalwpw.wildCard = 3;
2032                                        globalwpw.subscriptionStep = 'welcome';
2033                                        wpwTree.subscription('test');
2034                                        $.cookie('scroll_open', 'yes');
2035                                        //pro active sound
2036                                        proactive_retargeting_sound();
2037                                        //Window foucus meta title change.
2038                                        window_focus_change_meta_title();
2039                                    } else {
2040
2041                                        if (localStorage.getItem("wpwHitory")) {
2042                                            showing_proactive_msg(handle_language(wpChatBotVar.ret_greet) + ' ' + shopper + ', ' + scrollmessage);
2043                                        } else {
2044                                            showing_proactive_double_msg(handle_language(wpChatBotVar.ret_greet) + ' ' + shopper + ', ' + scrollmessage)
2045                                        }
2046                                        $.cookie('scroll_open', 'yes');
2047                                        //pro active sound
2048                                        proactive_retargeting_sound();
2049                                        //Window foucus meta title change.
2050                                        window_focus_change_meta_title();
2051                                    }
2052
2053                                }, 1000)
2054                            }
2055                        }
2056                    }
2057
2058                });
2059            }
2060            if (wpChatBotVar.enable_auto_open == 1 && (wpChatBotVar.autointent_all_page == 'on' || (wpChatBotVar.autointent_all_page == 'off' && wpChatBotVar.autointent_pages.indexOf(wpChatBotVar.current_pageid) > -1) || (wpChatBotVar.autointent_all_page == 'pagewise' && wpChatBotVar.auto_pagewise.page.indexOf(wpChatBotVar.current_pageid) > -1) || (wpChatBotVar.trigger_url_auto != null))) {
2061                //if will open once if setup from backend.
2062                var autoOpen = true;
2063                if ($.cookie('auto_open') == 'yes' && wpChatBotVar.auto_open_once == 1) {
2064                    autoOpen = false;
2065                }
2066
2067
2068                var autocustomintent = wpChatBotVar.auto_open_custom_intent;
2069                var automessage = handle_language(wpChatBotVar.auto_open_msg);
2070                var apagesurl = wpChatBotVar.trigger_url_auto;
2071
2072                if (apagesurl) {
2073                    var aindex = apagesurl.indexOf(wpChatBotVar.current_pageid);
2074                    var amessages = wpChatBotVar.auto_pagewise.message;
2075                    var aintent = wpChatBotVar.auto_pagewise.intent;
2076                    if (apagesurl.indexOf(wpChatBotVar.current_pageid) > -1) {
2077                        var aindex = apagesurl.indexOf(wpChatBotVar.current_pageid);
2078                    }
2079                    if (aintent[aindex] != '') {
2080                        autocustomintent = aintent[aindex];
2081                    }
2082                    if (aintent[aindex] != '') {
2083                        automessage = amessages[eindex];
2084                    }
2085                }
2086                if (wpChatBotVar.autointent_all_page == 'pagewise') {
2087                    var epages = wpChatBotVar.auto_pagewise.page;
2088                    var emessages = wpChatBotVar.auto_pagewise.message;
2089                    var eintent = wpChatBotVar.auto_pagewise.intent;
2090                    if (wpChatBotVar.auto_pagewise.page.indexOf(wpChatBotVar.current_pageid) > -1) {
2091                        var eindex = wpChatBotVar.auto_pagewise.page.indexOf(wpChatBotVar.current_pageid);
2092                    }
2093                    if (eintent[eindex] != '') {
2094                        autocustomintent = eintent[eindex];
2095                    }
2096                    if (emessages[eindex] != '') {
2097                        automessage = emessages[eindex];
2098                    }
2099
2100                }
2101                if (typeof autocustomintent !== "undefined") {
2102                    autocustomintent = autocustomintent.trim();
2103
2104                }
2105
2106                if (autoOpen == true) {
2107                    setTimeout(function (e) {
2108                        if (document.getElementsByClassName("wpbot-saas-live-chat")[0].style.display != 'block') {
2109                            if (wpChatBotVar.auto_open_handler == 0 && $('.active-chat-board').length == 0) {
2110                                if ($('.active-chat-board').length == 0) {
2111                                    $('#wp-chatbot-ball').removeClass('wpbot_chatclose_iconanimation');
2112                                    $('#wp-chatbot-ball').addClass('wpbot_chatopen_iconanimation');
2113                                    $('#wp-chatbot-ball').find('img').attr('src', wpChatBotVar.imgurl + 'wpbot-close-icon.png');
2114                                    //$('.wp-chatbot-ball').css('background', 'unset');
2115
2116                                    $("#wp-chatbot-board-container").addClass('active-chat-board');
2117                                    if ($('.chat_active').length > 1) {
2118                                        $('.wp-chatbot-ball').trigger("click");
2119                                    }
2120                                    if ($('.wp-chatbot-tpl-4-chat-trigger').length > 0) {
2121                                        $('.wp-chatbot-tpl-4-chat-trigger').trigger("click");
2122                                    }
2123                                    if (wpChatBotVar.template == 'template-06' || wpChatBotVar.template == 'template-07') {
2124                                        $('#wp-chatbot-ball').hide();
2125                                        $(".wp-chatbot-container").animate({ left: '-340px' });
2126                                    }
2127                                    if ($('.qc_wpbot_floating_main').length > 0) {
2128                                        $('.qc_wpbot_floating_main').hide();
2129                                    }
2130                                }
2131
2132                                if ($('.wp-chatbot-start-container').is(':visible')) {
2133                                    $('.wp-chatbot-container').show();
2134                                    $('.wp-chatbot-start-container').hide();
2135                                    $('#wp-chatbot-integration-container .wp-chatbot-integration-button-container').show();
2136                                } else {
2137                                    $('.wp-chatbot-container').show();
2138                                    $('#wp-chatbot-integration-container .wp-chatbot-integration-button-container').show();
2139                                }
2140
2141                                setTimeout(function () {
2142                                    $('.active-chat-board').addClass('animated tada');
2143                                    setTimeout(function () {
2144                                        $('.active-chat-board').removeClass('animated tada');
2145                                    }, 1000)
2146                                }, 200)
2147
2148                                wpChatBotVar.auto_open_handler++;
2149                                wpChatBotVar.re_target_handler = 3;
2150                                wp_chatbot_obj.re_target_handler = 1;
2151                                wpwbot_board_action();
2152                                setTimeout(function () {
2153                                    var json = {
2154                                        msg: 'chatbot_open',
2155                                        val: (jQuery('#wp-chatbot-chat-container').height() + 80)
2156                                    }
2157                                    sendMessageIframe(json);
2158                                }, 200)
2159                                //Shopper Name
2160                                if (localStorage.getItem('shopper')) {
2161                                    var shopper = localStorage.getItem('shopper');
2162                                } else {
2163                                    var shopper = handle_language(wpChatBotVar.shopper_demo_name);
2164                                }
2165                                setTimeout(function () {
2166
2167                                    if ((typeof autocustomintent != 'undefined') && (autocustomintent != '')) {
2168
2169                                        if (autocustomintent == 'Faq') {
2170                                            globalwpw.wildCard = 1;
2171                                            globalwpw.supportStep = 'welcome';
2172                                            wpwAction.bot('from wildcard support');
2173                                            //keeping value in localstorage
2174                                            localStorage.setItem("wildCard", globalwpw.wildCard);
2175                                            localStorage.setItem("supportStep", globalwpw.supportStep);
2176
2177                                        } else if (autocustomintent == 'Email Subscription') {
2178                                            globalwpw.wildCard = 3;
2179                                            globalwpw.subscriptionStep = 'welcome';
2180                                            wpwTree.subscription();
2181                                            localStorage.setItem("wildCard", globalwpw.wildCard);
2182                                            localStorage.setItem("supportStep", globalwpw.supportStep);
2183
2184                                        } else if (autocustomintent == handle_language(wp_chatbot_obj.site_search)) {
2185
2186                                            if (typeof (globalwpw.hasNameCookie) == 'undefined' || globalwpw.hasNameCookie == '') {
2187                                                var shopperName = wp_chatbot_obj.shopper_demo_name;
2188                                            } else {
2189                                                var shopperName = globalwpw.hasNameCookie;
2190                                            }
2191                                            var askEmail = wpwKits.randomMsg(wp_chatbot_obj.asking_search_keyword)
2192
2193                                            wpwMsg.single(askEmail.replace("#name", shopperName));
2194                                            //Now updating the support part as .
2195                                            globalwpw.supportStep = 'search';
2196                                            globalwpw.wildCard = 1;
2197                                            //keeping value in localstorage
2198                                            localStorage.setItem("wildCard", globalwpw.wildCard);
2199                                            localStorage.setItem("supportStep", globalwpw.supportStep);
2200
2201                                        } else if (autocustomintent == 'Send Us Email') {
2202
2203                                            if (typeof (globalwpw.hasNameCookie) == 'undefined' || globalwpw.hasNameCookie == '') {
2204                                                var shopperName = wp_chatbot_obj.shopper_demo_name;
2205                                            } else {
2206                                                var shopperName = globalwpw.hasNameCookie;
2207                                            }
2208                                            var askEmail = wpwKits.randomMsg(wp_chatbot_obj.asking_email);
2209                                            wpwMsg.single(askEmail);
2210                                            //Now updating the support part as .
2211                                            globalwpw.supportStep = 'email';
2212                                            globalwpw.wildCard = 1;
2213                                            //keeping value in localstorage
2214                                            localStorage.setItem("wildCard", globalwpw.wildCard);
2215                                            localStorage.setItem("supportStep", globalwpw.supportStep);
2216
2217                                        } else if (autocustomintent == 'Leave A Feedback') {
2218
2219                                            if (typeof (globalwpw.hasNameCookie) == 'undefined' || globalwpw.hasNameCookie == '') {
2220                                                var shopperName = wp_chatbot_obj.shopper_demo_name;
2221                                            } else {
2222                                                var shopperName = globalwpw.hasNameCookie;
2223                                            }
2224                                            var askEmail = wpwKits.randomMsg(wp_chatbot_obj.asking_email);
2225                                            wpwMsg.single(askEmail);
2226                                            //Now updating the support part as .
2227                                            globalwpw.supportStep = 'email';
2228                                            globalwpw.wildCard = 1;
2229                                            //keeping value in localstorage
2230                                            localStorage.setItem("wildCard", globalwpw.wildCard);
2231                                            localStorage.setItem("supportStep", globalwpw.supportStep);
2232
2233                                        } else if (autocustomintent == 'Request Callback') {
2234                                            if (typeof (globalwpw.hasNameCookie) == 'undefined' || globalwpw.hasNameCookie == '') {
2235                                                var shopperName = globalwpw.settings.obj.shopper_demo_name;
2236                                            } else {
2237                                                var shopperName = globalwpw.hasNameCookie;
2238                                            }
2239                                            var askEmail = wpwKits.randomMsg(wp_chatbot_obj.asking_phone);
2240                                            setTimeout(function () {
2241                                                wpwMsg.single(askEmail);
2242                                                //Now updating the support part as .
2243                                                globalwpw.supportStep = 'phone';
2244                                                globalwpw.wildCard = 1;
2245                                                //keeping value in localstorage
2246                                                localStorage.setItem("wildCard", globalwpw.wildCard);
2247                                                localStorage.setItem("supportStep", globalwpw.supportStep);
2248                                            }, 1000)
2249                                        } else if ((autocustomintent != '')) {
2250
2251                                            globalwpw.initialize = 1;
2252                                            globalwpw.ai_step = 1;
2253                                            globalwpw.wildCard = 0;
2254                                            wpwAction.bot(autocustomintent);
2255
2256                                        }
2257
2258                                        proactive_retargeting_sound();
2259                                        //Window foucus meta title change.
2260                                        window_focus_change_meta_title();
2261
2262                                    } else if (wpChatBotVar.auto_open_email == 1 && wpChatBotVar.autointent_all_page != 'pagewise') {
2263                                        globalwpw.wildCard = 3;
2264                                        globalwpw.subscriptionStep = 'welcome';
2265                                        wpwTree.subscription('test');
2266                                        $.cookie('auto_open', 'yes');
2267                                        //pro active sound
2268                                        proactive_retargeting_sound();
2269                                        //Window foucus meta title change.
2270                                        window_focus_change_meta_title();
2271                                    } else {
2272                                        var automessage = handle_language(wpChatBotVar.auto_open_msg);
2273                                        if (localStorage.getItem("wpwHitory")) {
2274                                            showing_proactive_msg(handle_language(wpChatBotVar.ret_greet) + ' ' + shopper + ', ' + automessage);
2275                                        } else {
2276                                            showing_proactive_double_msg(handle_language(wpChatBotVar.ret_greet) + ' ' + shopper + ', ' + automessage)
2277                                        }
2278                                        $.cookie('auto_open', 'yes');
2279                                        //pro active sound
2280                                        proactive_retargeting_sound();
2281                                        //Window foucus meta title change.
2282                                        window_focus_change_meta_title();
2283                                    }
2284
2285
2286
2287                                }, 1000)
2288                            }
2289                        }
2290                    }, parseInt(wpChatBotVar.auto_open_time * 1000));
2291                }
2292            }
2293            //Retargeting for Cart to complete checkout.
2294            if (wpChatBotVar.enable_ret_user_show == 1 && localStorage.getItem("wpwHitory") && $.cookie('return_user') != 'yes') {
2295
2296                $.cookie('return_user', 'yes');
2297                var data = { 'action': 'qcld_wb_chatbot_only_cart' };
2298                jQuery.post(wpChatBotVar.ajax_url, data, function (response) {
2299                    if (response.items > 0) {
2300                        if ($('.active-chat-board').length == 0) {
2301                            setTimeout(function () {
2302                                $('#wp-chatbot-ball').removeClass('wpbot_chatclose_iconanimation');
2303                                $('#wp-chatbot-ball').addClass('wpbot_chatopen_iconanimation');
2304                                $('#wp-chatbot-ball').find('img').attr('src', wpChatBotVar.imgurl + 'wpbot-close-icon.png');
2305                                //$('.wp-chatbot-ball').css('background', 'unset');
2306                                $("#wp-chatbot-board-container").addClass('active-chat-board');
2307                                if (wpChatBotVar.template == 'template-06' || wpChatBotVar.template == 'template-07') {
2308                                    $('#wp-chatbot-ball').hide();
2309                                    $(".wp-chatbot-container").animate({ left: '-340px' });
2310                                }
2311
2312                                if ($('.wp-chatbot-start-container').is(':visible')) {
2313                                    $('.wp-chatbot-container').show();
2314                                    $('.wp-chatbot-start-container').hide();
2315                                    $('#wp-chatbot-integration-container .wp-chatbot-integration-button-container').show();
2316                                } else {
2317                                    $('.wp-chatbot-container').show();
2318                                    $('#wp-chatbot-integration-container .wp-chatbot-integration-button-container').show();
2319                                }
2320
2321                                setTimeout(function () {
2322                                    $('.active-chat-board').addClass('animated tada');
2323                                    setTimeout(function () {
2324                                        $('.active-chat-board').removeClass('animated tada');
2325                                    }, 1000)
2326                                }, 200)
2327                                wp_chatbot_obj.re_target_handler = 1;
2328                                wpwbot_board_action();
2329                                setTimeout(function () {
2330                                    var json = {
2331                                        msg: 'chatbot_open',
2332                                        val: (jQuery('#wp-chatbot-chat-container').height() + 80)
2333                                    }
2334                                    sendMessageIframe(json);
2335                                }, 200)
2336                                showing_proactive_msg(handle_language(wpChatBotVar.checkout_msg));
2337                                setTimeout(function () {
2338                                    showing_proactive_msg(response.html);
2339                                    //Window foucus meta title change.
2340                                    window_focus_change_meta_title();
2341                                }, 2000);
2342                            }, 1000);
2343
2344
2345                        }
2346                    }
2347                });
2348            }
2349
2350            if (wpChatBotVar.enable_inactive_time_show == 1 && localStorage.getItem("wpwHitory")) {
2351                var timeoutID;
2352
2353                function setup() {
2354                    /*jQuery(document).on("mousemove", resetTimer, false);
2355                    jQuery(document).on("mousedown", resetTimer, false);
2356                    jQuery(document).on("keypress", resetTimer, false);
2357                    jQuery(document).on("DOMMouseScroll", resetTimer, false);
2358                    jQuery(document).on("mousewheel", resetTimer, false);
2359                    jQuery(document).on("touchmove", resetTimer, false);
2360                    jQuery(document).on("MSPointerMove", resetTimer, false);
2361                    */
2362                    startTimer();
2363                }
2364                setup();
2365
2366                function startTimer() {
2367                    // wait as set from admin seconds before calling goInactive
2368                    timeoutID = window.setTimeout(goInactive, parseInt(wpChatBotVar.inactive_time * 1000));
2369                }
2370
2371                function resetTimer(e) {
2372                    window.clearTimeout(timeoutID);
2373
2374                    goActive();
2375                }
2376
2377                function goInactive() {
2378                    if (wpChatBotVar.ret_inactive_user_once == 1 && $.cookie('return_inactive_user') != 'yes') {
2379                        $.cookie('return_inactive_user', 'yes');
2380                        var data = { 'action': 'qcld_wb_chatbot_only_cart' };
2381                        jQuery.post(wpChatBotVar.ajax_url, data, function (response) {
2382                            if (response.items > 0) {
2383                                if ($('.active-chat-board').length == 0) {
2384                                    setTimeout(function () {
2385                                        $('#wp-chatbot-ball').removeClass('wpbot_chatclose_iconanimation');
2386                                        $('#wp-chatbot-ball').addClass('wpbot_chatopen_iconanimation');
2387                                        $('#wp-chatbot-ball').find('img').attr('src', wpChatBotVar.imgurl + 'wpbot-close-icon.png');
2388                                        //$('.wp-chatbot-ball').css('background', 'unset');
2389                                        $("#wp-chatbot-board-container").addClass('active-chat-board');
2390
2391                                        if ($('.wp-chatbot-start-container').is(':visible')) {
2392                                            $('.wp-chatbot-container').show();
2393                                            $('.wp-chatbot-start-container').hide();
2394                                            $('#wp-chatbot-integration-container .wp-chatbot-integration-button-container').show();
2395                                        } else {
2396                                            $('.wp-chatbot-container').show();
2397                                            $('#wp-chatbot-integration-container .wp-chatbot-integration-button-container').show();
2398                                        }
2399
2400                                        setTimeout(function () {
2401                                            $('.active-chat-board').addClass('animated tada');
2402                                            setTimeout(function () {
2403                                                $('.active-chat-board').removeClass('animated tada');
2404                                            }, 1000)
2405                                        }, 200)
2406
2407                                        wpwbot_board_action();
2408                                        showing_proactive_msg(handle_language(wpChatBotVar.checkout_msg));
2409                                        setTimeout(function () {
2410                                            showing_proactive_msg(response.html);
2411                                            //Window foucus meta title change.
2412                                            window_focus_change_meta_title();
2413                                        }, 2000);
2414                                    }, 2000);
2415                                }
2416                            }
2417                        });
2418                    }
2419                }
2420
2421                function goActive() {
2422                    // do something
2423
2424                    startTimer();
2425                }
2426            }
2427            //Proactive retargeting sound for auto open. scroll open and
2428            function proactive_retargeting_sound() {
2429                if (wpChatBotVar.enable_ret_sound == 1) {
2430                    var promise = document.querySelector('#wp-chatbot-proactive-audio').play();
2431                    if (promise !== undefined) {
2432                        promise.then(function (success) {
2433                            //success to play
2434                        }).catch(function (error) {
2435                            //some error
2436
2437                        });
2438                    }
2439                }
2440            }
2441
2442            //When user will be out of window and news retargetting will be shown. where opening hour, title and meta need to be set.
2443            function window_focus_change_meta_title() {
2444                if (wpChatBotVar.enable_meta_title == 1 && handle_language(wpChatBotVar.meta_label) != "" && openingHourIs == 0) {
2445                    var showInactive = 0;
2446                    MetaTitleInterval = setInterval(function () {
2447                        if (showInactive == 0) {
2448                            document.title = handle_language(wpChatBotVar.meta_label);
2449                            showInactive = 1;
2450                        } else {
2451                            document.title = orginalTitle;
2452                            showInactive = 0;
2453                        }
2454                    }, 1000);
2455                }
2456            }
2457
2458            //wpwBot proActive end
2459            function wpwbot_board_action() {
2460                if (window.matchMedia('(max-width: 768px)').matches && typeof insideIframe === 'undefined') {
2461                    if (widowW <= 1024 && wpChatBotVar.mobile_full_screen == 1 && $('.active-chat-board').length > 0) {
2462                        $('#wp-chatbot-chat-container').css({ 'bottom': '0', 'left': '0', 'right': '0' });
2463                        $('#wp-chatbot-ball').hide();
2464                    }
2465
2466                    wpbot_sync_mobile_chat_scroll();
2467                } else if (widowW <= 1024 && wpChatBotVar.mobile_full_screen == 1 && typeof insideIframe === 'undefined') {//For mobile tablet without native scroll path
2468                    if ($('#wp-chatbot-mobile-close').length <= 0 && wpChatBotVar.template != 'template-05' && (typeof (wpbotshortcodetemplate) === "undefined" || wpbotshortcodetemplate != 'template-05')) {
2469                        //$('.wp-chatbot-board-container').append('<div id="wp-chatbot-mobile-close">X</div>');
2470                        //$('.wp-chatbot-header').hide();
2471                    }
2472                    if (wpChatBotVar.template == 'template-05' || (typeof (wpbotshortcodetemplate) !== "undefined" && wpbotshortcodetemplate == 'template-05')) {
2473
2474                        $('.wp-chatbot-ball-inner').slimScroll({
2475                            height: '70vh',
2476                            start: 'bottom'
2477                        }).parent().find('.slimScrollBar').css({ 'top': $('.wp-chatbot-ball-inner').height() + 'px' });
2478
2479                    } else {
2480
2481                        $('.wp-chatbot-ball-inner').slimScroll({
2482                            height: '100vh',
2483                            start: 'bottom'
2484                        }).parent().find('.slimScrollBar').css({ 'top': $('.wp-chatbot-ball-inner').height() + 'px' });
2485
2486                        $('#wp-chatbot-chat-container').css({ 'bottom': '0', 'left': '0', 'right': '0' });
2487                        $('#wp-chatbot-ball').hide();
2488                        //Maintain inner chat box height
2489                        var widowH = $(window).height();
2490                        var headerH = $('.wp-chatbot-header').outerHeight();
2491                        var footerH = $('.wp-chatbot-footer').outerHeight();
2492                        var AppContentInner = widowH - footerH - headerH;
2493
2494                        if (wpChatBotVar.template == 'template-07') {
2495                            AppContentInner = (parseFloat(AppContentInner) + 2) - (parseFloat($('.wp-bot-header').height() * 2));
2496                        }
2497
2498                        if (wpChatBotVar.template == 'template-06') {
2499                            AppContentInner = (parseFloat(AppContentInner) + 2) - (parseFloat($('.wp-bot-header').height()));
2500                        }
2501
2502
2503                        $('.wp-chatbot-ball-inner').css({ 'height': AppContentInner + 'px' })
2504                        $(this).hide();
2505
2506                    }
2507
2508                } else if (typeof iframe_exists === 'undefined' && typeof insideIframe === 'undefined') {
2509                    //$('.wp-chatbot-header').append('<div id="wp-chatbot-desktop-close">X</div>');
2510                    $('.wp-chatbot-ball-inner').slimScroll({
2511                        height: '70vh',
2512                        start: 'bottom'
2513                    }).parent().find('.slimScrollBar').css({ 'top': $('.wp-chatbot-ball-inner').height() + 'px' });
2514                }
2515
2516                if (typeof (iframe_exists) !== "undefined") {
2517                    // Embed iframe layout is CSS-driven so the footer stays visible.
2518                }
2519
2520
2521
2522                //Here is the Plugin  to be load only for once.
2523
2524                if (LoadwpwBotPlugin == 0) {
2525                    jQuery.wpwbot({ obj: wpChatBotVar, editor_handler: textEditorHandler, preLoadingTime: wpChatBotVar.botpreloadingtime });
2526                    LoadwpwBotPlugin++;
2527
2528                    var data = { 'action': 'qcld_wb_chatbot_session_count' };
2529                    jQuery.post(wpChatBotVar.ajax_url, data, function (response) {
2530                        //
2531                    });
2532                } else {
2533                    if (localStorage.getItem("wpwHitory") == null && jQuery('#wp-chatbot-messages-container').html() == '') {
2534                        wpwWelcome.greeting();
2535                    }
2536                }
2537
2538                if (typeof wpwKits !== 'undefined' && typeof wpwKits.initAiFileUpload === 'function') {
2539                    wpwKits.initAiFileUpload();
2540                }
2541                //If product detials is open then it will be closed.
2542                $('.wp-chatbot-product-container').removeClass('active-chatbot-product-details');
2543                //Show and close notification message on ball click
2544
2545
2546                if ($('.active-chat-board').length != 0) {
2547                    $('#wp-chatbot-notification-container').removeClass('wp-chatbot-notification-container-sliding');
2548                    //chatbox will be open and notificaion will be closed
2549                    $('#wp-chatbot-notification-container').addClass('wp-chatbot-notification-container-disable');
2550                    //clearInterval(notificationInterval);
2551                } else {
2552                    if (!sessionStorage.getItem('wpChatbotNotification')) {
2553                        $('#wp-chatbot-notification-container').removeClass('wp-chatbot-notification-container-disable');
2554                        $('#wp-chatbot-notification-container').addClass('wp-chatbot-notification-container-sliding');
2555
2556                    }
2557                    /// clearInterval(notificationInterval);
2558                }
2559                //Messenger handling.
2560                if ($('.active-chat-board').length > 0) {
2561                    $('#wp-chatbot-integration-container').show();
2562                    if (wpChatBotVar.template == 'template-07') {
2563                        $('#wp-chatbot-integration-container-07').hide();
2564                    }
2565                } else {
2566                    $('#wp-chatbot-integration-container').hide();
2567                    if (wpChatBotVar.template == 'template-07') {
2568                        $('#wp-chatbot-integration-container-07').show();
2569                    }
2570                }
2571            }
2572            function showing_proactive_msg(msg) {
2573                //first open then chatboard
2574                if (localStorage.getItem("wpwHitory") && !$('.wp-ch
2574atbot-operation-option[data-option="chat"]').parent().hasClass('wp-chatbot-operation-active')) {
2575                    $('.wp-chatbot-messages-wrapper').html(localStorage.getItem("wpwHitory"));
2576                    $('.wp-chatbot-operation-option').each(function () {
2577                        if ($(this).attr('data-option') == 'chat') {
2578                            $(this).parent().addClass('wp-chatbot-operation-active');
2579                        } else {
2580                            $(this).parent().removeClass('wp-chatbot-operation-active');
2581                        }
2582                    });
2583                }
2584                var msgContent = '<li class="wp-chatbot-msg">' +
2585                    '<div class="wp-chatbot-avatar">' +
2586                    '<img src="' + wpChatBotVar.agent_image_path + '" alt="">' +
2587                    '</div>' +
2588                    '<div class="wp-chatbot-agent">' + handle_language(wpChatBotVar.agent) + '</div>'
2589                    + '<div class="wp-chatbot-paragraph"><img class="wp-chatbot-comment-loader" src="' + wpChatBotVar.image_path + 'comment.gif" alt="Typing..." /></div></li>';
2590                if ($('.wp-chatbot-comment-loader').length < 1) {
2591                    $('#wp-chatbot-messages-container').append(msgContent);
2592                }
2593                //Scroll to the last message
2594                $('.wp-chatbot-ball-inner').animate({ scrollTop: $('.wp-chatbot-messages-wrapper').prop("scrollHeight") }, 'slow').parent().find('.slimScrollBar').css({ 'top': $('.wp-chatbot-ball-inner').height() + 'px' });
2595                msg += '<span class="qcwpbot_close_ret">X</span>';
2596                setTimeout(function () {
2597                    $('#wp-chatbot-messages-container li:last .wp-chatbot-paragraph').html(msg).css({ 'background-color': wpChatBotVar.proactive_bg_color });
2598                    //scroll to the last message
2599                    $('.wp-chatbot-ball-inner').animate({ scrollTop: $('.wp-chatbot-messages-wrapper').prop("scrollHeight") }, 'slow').parent().find('.slimScrollBar').css({ 'top': $('.wp-chatbot-ball-inner').height() + 'px' });
2600
2601                    setTimeout(function () {
2602                        wp_chatbot_obj.re_target_handler = 0;
2603                    }, 1000);
2604
2605                }, 2000);
2606            }
2607            function showing_proactive_double_msg(secondMsg) {
2608                //first open then chatboard
2609                if (localStorage.getItem("wpwHitory")) {
2610                    $('.wp-chatbot-messages-wrapper').html(localStorage.getItem("wpwHitory"));
2611                    $('.wp-chatbot-operation-option').each(function () {
2612                        if ($(this).attr('data-option') == 'chat') {
2613                            $(this).parent().addClass('wp-chatbot-operation-active');
2614                        } else {
2615                            $(this).parent().removeClass('wp-chatbot-operation-active');
2616                        }
2617                    });
2618                }
2619
2620                var fristMsg = "<strong>" + handle_language(wpChatBotVar.agent) + " </strong> " + handle_language(wpChatBotVar.agent_join);
2621                var msgContent = '<li class="wp-chatbot-msg">' +
2622                    '<div class="wp-chatbot-avatar">' +
2623                    '<img src="' + wpChatBotVar.agent_image_path + '" alt="">' +
2624                    '</div>' +
2625                    '<div class="wp-chatbot-agent">' + handle_language(wpChatBotVar.agent) + '</div>'
2626                    + '<div class="wp-chatbot-paragraph"><img class="wp-chatbot-comment-loader" src="' + wpChatBotVar.image_path + 'comment.gif" alt="Typing..." />' +
2627
2628                    '</div></div></li>';
2629                $('#wp-chatbot-messages-container').append(msgContent);
2630                //Scroll to the last message
2631                $('.wp-chatbot-ball-inner').animate({ scrollTop: $('.wp-chatbot-messages-wrapper').prop("scrollHeight") }, 'slow').parent().find('.slimScrollBar').css({ 'top': $('.wp-chatbot-ball-inner').height() + 'px' });
2632                secondMsg += '<span class="qcwpbot_close_ret">X</span>';
2633                setTimeout(function () {
2634                    $('#wp-chatbot-messages-container li:last .wp-chatbot-paragraph').html(fristMsg);
2635                    //Second Message with interval
2636                    $('#wp-chatbot-messages-container').append(msgContent);
2637                    //Scroll to the last message
2638                    $('.wp-chatbot-ball-inner').animate({ scrollTop: $('.wp-chatbot-messages-wrapper').prop("scrollHeight") }, 'slow').parent().find('.slimScrollBar').css({ 'top': $('.wp-chatbot-ball-inner').height() + 'px' });
2639                    setTimeout(function () {
2640                        $('#wp-chatbot-messages-container li:last .wp-chatbot-paragraph').html(secondMsg).css({ 'background-color': wpChatBotVar.proactive_bg_color });
2641                        //Scroll to the last message
2642                        $('.wp-chatbot-ball-inner').animate({ scrollTop: $('.wp-chatbot-messages-wrapper').prop("scrollHeight") }, 'slow').parent().find('.slimScrollBar').css({ 'top': $('.wp-chatbot-ball-inner').height() + 'px' });
2643
2644                        setTimeout(function () {
2645                            wpwWelcome.greeting();
2646                            setTimeout(function () {
2647                                wp_chatbot_obj.re_target_handler = 0;
2648                            }, 1000);
2649                        }, 2000)
2650                        //localStorage.getItem("wpwHitory") && globalwpw.initialize==0
2651                    }, 2000);
2652
2653                }, 2000);
2654            }
2655
2656
2657            $("#qcld-wp-chatbot-shortcode-style-css").attr("disabled", "disabled");
2658            /***
2659             * Notification Message
2660             */
2661            if ($('#wp-chatbot-notification-container').length > 0) {
2662                if (sessionStorage.getItem('wpChatbotNotification') && (sessionStorage.getItem('wpChatbotNotification') == 'removed')) {
2663
2664                    //if remove on the session.
2665                    $('#wp-chatbot-notification-container').addClass('wp-chatbot-notification-container-disable');
2666                } else {
2667                    //Notification comes with slideIn effect
2668                    $('#wp-chatbot-notification-container').addClass('wp-chatbot-notification-container-sliding');
2669                    //handling welcome & return user welcome msg.
2670
2671                    var welcomeMsg = '';
2672
2673                    if ($.cookie("shopper") && wpChatBotVar.disable_wp_chatbot_history != 1) {
2674                        var shopper = $.cookie("shopper");
2675                        welcomeMsg = wpChatBotVar.welcome_back[wpChatBotVar.language][0] + ' <strong>' + shopper + '!</strong>';
2676                    } else {
2677                        welcomeMsg = wpChatBotVar.welcome[wpChatBotVar.language][0] + ' <strong>' + handle_language(wpChatBotVar.host) + '!</strong>';
2678
2679                    }
2680                    $('.wp-chatbot-notification-welcome').html(welcomeMsg);
2681                    //Notifications msgs handling.
2682
2683                    var notifications = wpChatBotVar.notifications[wpChatBotVar.language];
2684                    var notification_intents = wpChatBotVar.notification_intents[wpChatBotVar.language]
2685                    if (notifications.length > 1) {
2686                        var totalNotMsg = wpChatBotVar.notifications[wpChatBotVar.language].length;
2687                        var notMsgIndex = 0;
2688                        var intervalTime = parseInt(wpChatBotVar.notification_interval) * 1000;
2689                        var notificationInterval = setInterval(function (e) {
2690                            notMsgIndex++;
2691                            if (totalNotMsg <= notMsgIndex) {
2692                                notMsgIndex = 0;
2693                            }
2694                            //show new notification time after every intervalTime
2695
2696                            if (typeof (globalwpw.hasNameCookie) == 'undefined' || globalwpw.hasNameCookie == '') {
2697                                var shopperName = wp_chatbot_obj.shopper_demo_name;
2698                            } else {
2699                                var shopperName = globalwpw.hasNameCookie;
2700                            }
2701
2702                            $('.wp-chatbot-notification-message').css({ 'opacity': 1 }).html(notifications[notMsgIndex].replace("%%username%%", '<strong>' + shopperName + '</strong>'));
2703                            if (notification_intents[notMsgIndex] != '' && typeof notification_intents[notMsgIndex] != 'undefined') {
2704                                $('#wp-chatbot-notification-container').attr('data-intent', notification_intents[notMsgIndex]);
2705                            } else {
2706                                $('#wp-chatbot-notification-container').removeAttr('data-intent');
2707                            }
2708
2709
2710                        }, intervalTime);
2711                    } else {
2712
2713                        if (typeof (globalwpw.hasNameCookie) == 'undefined' || global
2713wpw.hasNameCookie == '') {
2714                            var shopperName = wp_chatbot_obj.shopper_demo_name;
2715                        } else {
2716                            var shopperName = globalwpw.hasNameCookie;
2717                        }
2718
2719
2720                        $('.wp-chatbot-notification-message').css({ 'opacity': 1 }).html($('.wp-chatbot-notification-message').html().replace("%%username%%", '<strong>' + shopperName + '</strong>'));
2721                    }
2722
2723                    $(".wp-chatbot-notification-close").on('click', function () {
2724                        $('#wp-chatbot-notification-container').addClass('wp-chatbot-notification-container-disable');
2725                        //clearInterval(notificationInterval);
2726                        sessionStorage.setItem('wpChatbotNotification', 'removed');
2727                    });
2728                }
2729            }
2730        }
2731        else if ($('#wp-chatbot-shortcode-template-container').length > 0) { //Page shortcode area.
2732            $('#wp-chatbot-chat-container').css({ 'display': 'none' });
2733            $('#wp-chatbot-ball').hide();
2734            //Add Scroll to chat ui
2735            $('.wp-chatbot-ball-inner').slimScroll({
2736                height: '70vh',
2737                start: 'bottom'
2738            }).parent().find('.slimScrollBar').css({ 'top': $('.wp-chatbot-ball-inner').height() + 'px' });
2739            //Add scroll to cart part
2740            var recentViewHeight = $('.wp-chatbot-container').outerHeight();
2741            if ($('.chatbot-shortcode-template-02').length == 0) {
2742                $('.wp-chatbot-cart-body').slimScroll({ height: '200px', start: 'top' });
2743                $('.wp-chatbot-widget .wp-chatbot-products').slimScroll({ height: '435px', start: 'top' });
2744            }
2745
2746            //Remove style of template
2747            $("#qcld-wp-chatbot-style-css").attr("disabled", "disabled");
2748            //Here is the Plugin  to be load only for once.
2749            if (LoadwpwBotPlugin == 0) {
2750                $.wpwbot({ obj: wpChatBotVar, editor_handler: textEditorHandler, preLoadingTime: wpChatBotVar.botpreloadingtime });
2751                LoadwpwBotPlugin++;
2752                var data = { 'action': 'qcld_wb_chatbot_session_count' };
2753                jQuery.post(wpChatBotVar.ajax_url, data, function (response) {
2754                    //
2755                });
2756            }
2757
2758
2759        }
2760        else if ($('#wp-chatbot-chat-app-shortcode-container').length > 0) {  //App shortcode area.
2761
2762            textEditorHandler = 1;
2763            //App UI (ball inner)
2764            setTimeout(function () {
2765                var widowH = screen.height - 50;
2766
2767                var footerH = $('.wp-chatbot-footer').outerHeight();
2768
2769                var AppContentInner = widowH - footerH;
2770
2771                $('#wp-chatbot-chat-app-shortcode-container .wp-chatbot-ball-inner').css({ 'height': AppContentInner + 'px' })
2772            }, 300);
2773            $(window).resize(function () {
2774                setTimeout(function () {
2775                    var widowH = screen.height - 50;
2776
2777                    var footerH = $('.wp-chatbot-footer').outerHeight();
2778                    var AppContentInner = widowH - footerH;
2779
2780                    $('#wp-chatbot-chat-app-shortcode-container .wp-chatbot-ball-inner').css({ 'height': AppContentInner + 'px' })
2781                }, 300)
2782            });
2783
2784            $('#wp-chatbot-ball').hide();
2785            //Add Scroll to chat ui
2786            $("#qcld-wp-chatbot-shortcode-style-css").attr("disabled", "disabled");
2787            $("#wp-chatbot-board-container").addClass('active-chat-board');
2788            $('.wp-chatbot-ball-inner').slimScroll({
2789                height: '55vh',
2790                start: 'bottom'
2791            }).parent().find('.slimScrollBar').css({ 'top': screen.height - 50 + 'px' });
2792            if (LoadwpwBotPlugin == 0) {
2793                $.wpwbot({ obj: wpChatBotVar, editor_handler: textEditorHandler, preLoadingTime: wpChatBotVar.botpreloadingtime });
2794                LoadwpwBotPlugin++;
2795                var data = { 'action': 'qcld_wb_chatbot_session_count' };
2796                jQuery.post(wpChatBotVar.ajax_url, data, function (response) {
2797                    //
2798                });
2799            }
2800            //Handling app cart and checkout
2801            $('#wp-chatbot-cart-short-code').hide();
2802            $('#wp-chatbot-checkout-short-code').hide();
2803            $(document).on('click', '.wp-chatbot-cart-link', function (event) {
2804                $('.wp-chatbot-messages-wrapper').hide();
2805                $('#wp-chatbot-checkout-short-code').hide();
2806                $('#wp-chatbot-cart-short-code').show();
2807                event.preventDefault();
2808                $('#wp-chatbot-cart-short-code').html('<img class="wp-chatbot-comment-loader" src="' + wpChatBotVar.image_path + 'comment.gif" alt="..." />');
2809                var data = { 'action': 'qcld_wb_chatbot_cart_page' };
2810                jQuery.post(wpChatBotVar.ajax_url, data, function (response) {
2811                    $("#wp-chatbot-cart-short-code").html(response);
2812                });
2813            });
2814            $(document).on('click', '.wp-chatbot-checkout-link, .checkout-button', function (event) {
2815                event.preventDefault();
2816                $('.wp-chatbot-messages-wrapper').hide();
2817                $('#wp-chatbot-cart-short-code').hide();
2818                $('#wp-chatbot-checkout-short-code').show();
2819
2820
2821                $('#wp-chatbot-checkout-short-code').html('<img class="wp-chatbot-comment-loader" src="' + wpChatBotVar.image_path + 'comment.gif" alt="..." />');
2822                var data = { 'action': 'qcld_wb_chatbot_checkout_page' };
2823                jQuery.post(wpChatBotVar.ajax_url, data, function (response) {
2824                    if (response.status == 'yes') {
2825                        window.location.href = response.html;
2826                    } else {
2827                        $("#wp-chatbot-checkout-short-code").html(response.html);
2828                    }
2829
2830                });
2831            });
2832            //Preventing url redirect from cart page.
2833            $(document).on('click', '#wp-chatbot-chat-app-shortcode-container .woocommerce-cart-form a', function (e) {
2834                e.preventDefault();
2835            });
2836        }
2837        //For variable product configuration
2838        var current_price_html = '';
2839        $(document).on('change', "#wp-chatbot-product-variable select ", function () {
2840            var variations = JSON.parse($("#wp-chatbot-variation-data").attr('data-product-variation'));
2841            var item_conditions = [];
2842            if (current_price_html == '') {
2843                current_price_html = $('#wp-chatbot-product-price').html();
2844            }
2845            var totalAttr = $("#wp-chatbot-product-variable select").length;
2846            var i = 1;
2847            $("#wp-chatbot-product-variable select").each(function (index, element) {
2848                var myVal = $(this).find('option:selected').val();
2849                if (myVal != "") {
2850                    item_conditions.push({
2851                        'left': 'item["variation_data"]["' + $(this).attr('name') + '"][0]',
2852                        'right': myVal
2853                    })
2854                }
2855            });
2856            var newVariation = [];
2857            for (var a = 0; variations.length > a; a++) {
2858                var item = variations[a];
2859                var item_condition = "";
2860                for (var i = 0; item_conditions.length > i; i++) {
2861                    if (i > 0) {
2862                        if (typeof (item["variation_data"][$(this).attr('name')]) != 'undefined') {
2863                            var leftValue = eval(item_conditions[i].left);
2864                            var rightValue = item_conditions[i].right;
2865                            item_condition += ' && ' + (
2866                                (typeof leftValue === 'string' && typeof rightValue === 'string')
2867                                    ? (leftValue.toLowerCase() == rightValue.toLowerCase())
2868                                    : (leftValue == rightValue)
2869                            );
2870                        } else {
2871                            item_condition += ' && ' + false;
2872                        }
2873                    } else {
2874                        var leftEval = eval(item_conditions[i].left);
2875                        var rightEval = item_conditions[i].right;
2876                        if (typeof leftEval === 'string' && typeof rightEval === 'string') {
2877                            item_condition += leftEval.toLowerCase() == rightEval.toLowerCase();
2878                        } else {
2879                            item_condition += leftEval == rightEval;
2880                        }
2881                    }
2882                }
2883                if (eval(item_condition)) {
2884                    newVariation[0] = item;
2885                }
2886            }
2887            if (newVariation.length > 0) {
2888                $('#wp-chatbot-variation-add-to-cart').attr('variation_id', newVariation[0]['variation_id']);
2889                var priceSets = "";
2890                if (typeof newVariation[0]['variation_data']['_sale_price'] !== "undefined") {
2891                    priceSets += '<strong>' + newVariation[0]['variation_price'] + '</strong>';
2892                } else {
2893                    priceSets += '<strong>' + newVariation[0]['variation_price'] + '</strong>';
2894                }
2895                $('#wp-chatbot-product-price').html(priceSets);
2896            } else {
2897                $('#wp-chatbot-product-price').html(current_price_html);
2898            }
2899        });
2900
2901        if ($('.active-chat-board').length > 0) {
2902            $('#wp-chatbot-integration-container').show();
2903            if (wpChatBotVar.template == 'template-07') {
2904                $('#wp-chatbot-integration-container-07').hide();
2905            }
2906        } else {
2907            $('#wp-chatbot-integration-container').hide();
2908            if (wpChatBotVar.template == 'template-07') {
2909                $('#wp-chatbot-integration-container-07').show();
2910            }
2911        }
2912        //Facebook Messenger Integration
2913
2914        //skype
2915        if (wpChatBotVar.enable_skype == 1) {
2916            $(document).on('click', '.inetegration-skype-btn', function (e) {
2917                $('#wp-chatbot-board-container').removeClass('active-chat-board');
2918
2919                $('#wp-chatbot-integration-container').hide();
2920                if (wpChatBotVar.template == 'template-07') {
2921                    $('#wp-chatbot-integration-container-07').show();
2922                }
2923            });
2924
2925        }
2926
2927
2928    });
2929
2930    // Create IE + others compatible event handler
2931    var eventMethod = window.addEventListener ? "addEventListener" : "attachEvent";
2932    var eventer = window[eventMethod];
2933    var messageEvent = eventMethod == "attachEvent" ? "onmessage" : "message";
2934
2935    // Listen to message from child window
2936    eventer(messageEvent, function (e) {
2937        if (e.data.msg == 'chatbot_open') {
2938            $('.wp-chatbot-notification-container').hide();
2939            //$('.wpbot-saas-live-chat').hide();
2940        }
2941        if (e.data.msg == 'chatbot_close') {
2942            if (sessionStorage.getItem('wpChatbotNotification') != 'removed' && wpChatBotVar.template != 'template-05') {
2943                $('.wp-chatbot-notification-container').show();
2944            }
2945        }
2946        // if(e.data.msg == 'parent'){
2947        //     $('#wp-chatbot-chat-container').css({
2948        //         'right': '50px',
2949        //         'bottom': '50px'
2950        //     })
2951        // }
2952
2953    }, false);
2954
2955    function sendMessageIframe(json) {
2956        if (json && typeof json === 'object') {
2957            json.notify = jQuery('.wp-chatbot-notification-container:visible')
2958                .not('.wp-chatbot-notification-container-disable').length > 0;
2959        }
2960        parent.postMessage(json, "*");
2961    }
2962
2963
2964    var lp, rp, mItems, menu, sc, pos;
2965    lp = $(".left-pointer");
2966    rp = $(".right-pointer");
2967    mItems = $(".qcld-bottom-menu-item");
2968    lp.click(function () {
2969        sc = mItems.width() - 60;
2970        pos = mItems.scrollLeft() - sc;
2971        mItems.animate({ scrollLeft: pos }, "slow");
2972    });
2973    rp.click(function () {
2974        sc = mItems.width() - 60;
2975        pos = mItems.scrollLeft() + sc;
2976        mItems.animate({ scrollLeft: pos }, "slow");
2977    });
2978    var scrollLeftPrev = 0;
2979    mItems.scroll(function () {
2980        var newScrollLeft = mItems.scrollLeft(),
2981            width = mItems.width(),
2982            scrollWidth = mItems.get(0).scrollWidth;
2983        var offset = 8;
2984        if (scrollWidth - newScrollLeft - width < offset) {
2985            $(".right-pointer").addClass("dis");
2986        } else {
2987            $(".right-pointer").removeClass("dis");
2988        }
2989        if ($(this).scrollLeft() == 0) {
2990            $(".left-pointer").addClass("dis");
2991        } else {
2992            $(".left-pointer").removeClass("dis");
2993        }
2994        scrollLeftPrev = newScrollLeft;
2995    });
2996
2997
2998
2999    let mouseDown = false;
3000    let startX, scrollLeft;
3001    const slider = document.querySelector('.qcld-bottom-menu-wrapper');
3002    if (slider) {
3003        const startDragging = (e) => {
3004            mouseDown = true;
3005            startX = e.pageX - slider.offsetLeft;
3006            scrollLeft = slider.scrollLeft;
3007        }
3008
3009        const stopDragging = (e) => {
3010            mouseDown = false;
3011        }
3012
3013        const move = (e) => {
3014            e.preventDefault();
3015            if (!mouseDown) { return; }
3016            const x = e.pageX - slider.offsetLeft;
3017            const scroll = x - startX;
3018            slider.scrollLeft = scrollLeft - scroll;
3019        }
3020
3021        // Add the event listeners
3022        slider.addEventListener('mousemove', move, false);
3023        slider.addEventListener('mousedown', startDragging, false);
3024        slider.addEventListener('mouseup', stopDragging, false);
3025        slider.addEventListener('mouseleave', stopDragging, false);
3026    }
3027
3028
3029});
3030
3031jQuery(document).ready(function ($) {
3032
3033    let reportedMessage = "";
3034    let modalElements = {}; // Store references to modal elements
3035    let isModalInitialized = false; // Flag to prevent re-attaching listeners
3036
3037    /**
3038     * Initializes the report modal by finding its elements and attaching event listeners.
3039     * This function is designed to be called only once, the first time the report icon is clicked,
3040     * to ensure all DOM elements are available.
3041     * @returns {boolean} True if initialization was successful, false otherwise.
3042     */
3043    function setupReportModal() {
3044        if (isModalInitialized) {
3045            return true; // Already initialized
3046        }
3047
3048        const modal = document.getElementById("wpbot-report-modal");
3049        const emailInput = document.getElementById("wpbot-report-email");
3050        const textInput = document.getElementById("wpbot-report-text");
3051        const cancelBtn = document.getElementById("wpbot-report-cancel");
3052        const reportForm = document.getElementById("wpbot-report-form");
3053
3054        if (!modal || !emailInput || !textInput || !cancelBtn || !reportForm) {
3055            console.error("❌ One or more modal elements missing in DOM. Cannot initialize report modal.");
3056            return false; // Initialization failed
3057        }
3058
3059        // Store references to the elements
3060        modalElements = { modal, emailInput, textInput, cancelBtn, reportForm };
3061
3062        // Attach event listener for the cancel button
3063        modalElements.cancelBtn.addEventListener("click", function () {
3064            modalElements.modal.style.display = "none";
3065        });
3066
3067        // Attach event listener for the form submission
3068        modalElements.reportForm.addEventListener("submit", function (e) {
3069            e.preventDefault();
3070
3071            let email = modalElements.emailInput.value.trim();
3072            let reportText = modalElements.textInput.value.trim();
3073
3074            if (!email || !reportText) {
3075                alert("Please fill in both fields.");
3076                return;
3077            }
3078
3079            // Save email to localStorage
3080            localStorage.setItem("shopperemail", email);
3081
3082            // Build meta info for the report
3083            let meta = "Source URL: " + window.location.href + " | User Agent: " + navigator.userAgent;
3084
3085            // Send report via AJAX
3086            $.post(wp_chatbot_obj.ajax_url, {
3087                action: "wpbot_save_report",
3088                user_id: globalwpw.settings.obj.current_user_id,
3089                conversation_id: 3,
3090                message: reportedMessage, // Use the message captured when the icon 
3090was clicked
3091                report_text: reportText,
3092                email: email,
3093                meta_info: meta
3094            }, function (response) {
3095                if (response.success) {
3096                    console.log("Report sent successfully.");
3097                    // The original line `jQuery(e.target.closest(".fa fa-commenting-o")).addClass("submitted");`
3098                    // was incorrect as `e.target` here refers to the form, not the original icon.
3099                    // To mark the icon, a reference to it would need to be stored when it was clicked.
3100                } else {
3101                    console.log("Failed to send report.");
3102                }
3103                modalElements.modal.style.display = "none"; // Hide modal after submission
3104            });
3105        });
3106
3107        isModalInitialized = true; // Mark as initialized
3108        return true; // Initialization successful
3109    }
3110
3111    // Event listener for clicks on the document to detect report icon clicks
3112    document.addEventListener("click", function (e) {
3113        if (e.target.closest(".fa-commenting-o")) {
3114            e.preventDefault();
3115            console.log("Report icon clicked");
3116
3117            // Attempt to initialize the modal elements and listeners if not already done.
3118            // This ensures elements are looked up only when needed, making it more robust
3119            // against timing issues if the modal HTML is loaded asynchronously or late.
3120            if (!setupReportModal()) {
3121                return; // If initialization failed (elements not found), stop here.
3122            }
3123
3124            // Now that we are sure modal elements are available, proceed to open the modal.
3125            let msgItem = e.target.closest(".wp-chatbot-msg");
3126            if (msgItem) {
3127                reportedMessage = msgItem.querySelector(".wp-chatbot-paragraph").innerText.trim();
3128            } else {
3129                reportedMessage = ""; // Fallback if message item not found
3130            }
3131
3132            // Prefill email from localStorage if available
3133            let shopperEmail = localStorage.getItem("shopperemail");
3134            modalElements.emailInput.value = shopperEmail ? shopperEmail : "";
3135
3136            // Clear previous report text
3137            modalElements.textInput.value = "";
3138
3139            // Display the modal
3140            modalElements.modal.style.display = "block";
3141        }
3142    });
3143});
3144
3145document.addEventListener("click", function (e) {
3146    const likeIcon = e.target.closest(".fa-thumbs-o-up");
3147    const dislikeIcon = e.target.closest(".fa-thumbs-o-down");
3148
3149    if (!likeIcon && !dislikeIcon) return; // only handle like/dislike clicks
3150    e.preventDefault();
3151
3152    const msgItem = e.target.closest(".wp-chatbot-msg");
3153    const feedbackContainer = jQuery(msgItem).find(".qcld-like-dislike-icon");
3154    const likeAnchor = jQuery(msgItem).find(".fa-thumbs-o-up").parent("a");
3155    const dislikeAnchor = jQuery(msgItem).find(".fa-thumbs-o-down").parent("a");
3156
3157    let feedbackType = "";
3158    let isToggleOff = false;
3159
3160    if (likeIcon) {
3161        // If like is already active → toggle it off
3162        if (likeAnchor.hasClass("liked")) {
3163            likeAnchor.removeClass("liked");
3164            likeIcon.classList.remove("liked");
3165            isToggleOff = true;
3166        } else {
3167            // Activate like, deactivate dislike
3168            likeAnchor.addClass("liked");
3169            likeIcon.classList.add("liked");
3170            dislikeAnchor.removeClass("disliked");
3171            jQuery(msgItem).find(".fa-thumbs-o-down").removeClass("disliked");
3172            feedbackType = "like";
3173        }
3174    } else if (dislikeIcon) {
3175        // If dislike is already active → toggle it off
3176        if (dislikeAnchor.hasClass("disliked")) {
3177            dislikeAnchor.removeClass("disliked");
3178            dislikeIcon.classList.remove("disliked");
3179            isToggleOff = true;
3180        } else {
3181            // Activate dislike, deactivate like
3182            dislikeAnchor.addClass("disliked");
3183            dislikeIcon.classList.add("disliked");
3184            likeAnchor.removeClass("liked");
3185            jQuery(msgItem).find(".fa-thumbs-o-up").removeClass("liked");
3186            feedbackType = "dislike";
3187        }
3188    }
3189
3190    // 🔹 Only send feedback if toggled ON
3191    if (!isToggleOff && feedbackType) {
3192        let message = msgItem.querySelector(".wp-chatbot-paragraph").innerText.trim();
3193        let meta =
3194            "Source URL: " +
3195            window.location.href +
3196            " | User Agent: " +
3197            navigator.userAgent;
3198
3199        jQuery.post(
3200            wp_chatbot_obj.ajax_url,
3201            {
3202                action: "wpbot_save_feedback",
3203                user_id: globalwpw.settings.obj.current_user_id,
3204                conversation_id: 3,
3205                message: message,
3206                feedback: feedbackType,
3207                meta_info: meta,
3208            },
3209            function (response) {
3210                if (response.success) {
3211                    console.log("Feedback saved:", feedbackType);
3212                } else {
3213                    console.log("Failed to save feedback.");
3214                }
3215            }
3216        );
3217    } else {
3218        console.log("Feedback toggled off, not saving.");
3219    }
3220
3221    var checkInterval = setInterval(function() {
3222
3223 
3224
3225    var current_lang = document.getElementsByTagName('html')[0].getAttribute('lang');
3226
3227    var languageSelect = document.getElementById('wpbot_language');
3228
3229    
3230
3231    if (!languageSelect || languageSelect.options.length === 0) {
3232
3233    return;
3234
3235    }
3236
3237 
3238
3239if (current_lang === 'es' || current_lang === 'es_ES') {
3240
3241    clearInterval(checkInterval);
3242
3243    return;
3244
3245}
3246
3247 
3248
3249    var langCode = current_lang.substring(0, 2).toLowerCase();
3250
3251    var matchingOption = null;
3252
3253 
3254
3255for (var i = 0; i < languageSelect.options.length; i++) {
3256
3257    var optionValue = languageSelect.options[i].value;
3258
3259    var optionLangCode = optionValue.substring(0, 2).toLowerCase();
3260
3261    
3262
3263    if (optionLangCode === langCode && optionValue.length > 2) {
3264
3265    matchingOption = languageSelect.options[i];
3266
3267    break;
3268
3269    }
3270
3271}
3272
3273 
3274
3275if (!matchingOption) {
3276
3277for (var i = 0; i < languageSelect.options.length; i++) {
3278
3279var optionValue = languageSelect.options[i].value;
3280
3281var optionLangCode = optionValue.substring(0, 2).toLowerCase();
3282
3283 
3284
3285if (optionLangCode === langCode) {
3286
3287matchingOption = languageSelect.options[i];
3288
3289break;
3290
3291}
3292
3293}
3294
3295}
3296
3297 
3298
3299if (matchingOption) {
3300
3301languageSelect.value = matchingOption.value;
3302
3303 
3304
3305var changeEvent = new Event('change', { bubbles: true });
3306
3307languageSelect.dispatchEvent(changeEvent);
3308
3309 
3310
3311var inputEvent = new Event('input', { bubbles: true });
3312
3313languageSelect.dispatchEvent(inputEvent);
3314
3315 
3316
3317clearInterval(checkInterval);
3318
3319}
3320
3321 
3322
3323}, 1000);
3324
3325});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.