PageSourceSearch

https://fida.org.ng/wp-content/plugins/chatbot/js/qcld-wp-chatbot-front.js?ver=8.7.9

js fida.org.ng collected 2026-09-24 19:38:28 UTC 52,812 bytes, 979 lines download raw bytes

1jQuery(function ($) {
2    //Global object passed by admin
3    var wpChatBotVar = wp_chatbot_obj;
4	
5    var LoadwpwBotPlugin = 0;
6    var textEditorHandler = 0;
7    if( typeof(openingHourIsFn) !='undefined'){
8        var openingHourIs = openingHourIsFn;
9    }else{
10        var openingHourIs = 0;
11    }
12
13    /**
14     * Hide slimScroll bar when content fits; otherwise pin bar to the bottom correctly.
15     * slimScroll shows the bar when scrollHeight < clientHeight due to its size math.
16     */
17    window.wpbotSyncSlimScrollBar = function ($inner) {
18        $inner = ($inner && $inner.jquery) ? $inner : $('.wp-chatbot-ball-inner');
19        $inner.each(function () {
20            var el = this;
21            var $el = $(el);
22            var $wrap = $el.parent();
23            if (!$wrap.hasClass('slimScrollDiv')) {
24                return;
25            }
26            var $bar = $wrap.children('.slimScrollBar');
27            var $rail = $wrap.children('.slimScrollRail');
28            if (!$bar.length) {
29                return;
30            }
31            if (el.scrollHeight <= el.clientHeight + 2) {
32                $wrap.addClass('wpbot-no-scroll');
33                $bar.stop(true, true).hide().css({ opacity: 0 });
34                $rail.stop(true, true).hide();
35                return;
36            }
37            $wrap.removeClass('wpbot-no-scroll');
38            var barH = Math.max(($el.outerHeight() / el.scrollHeight) * $el.outerHeight(), 30);
39            barH = Math.min(barH, $el.outerHeight());
40            var maxTop = Math.max(0, $el.outerHeight() - barH);
41            var ratio = el.scrollHeight > el.clientHeight
42                ? el.scrollTop / (el.scrollHeight - el.clientHeight)
43                : 1;
44            $bar.css({
45                height: barH + 'px',
46                top: (ratio * maxTop) + 'px',
47                display: 'block',
48                opacity: 0.4
49            });
50            clearTimeout($bar.data('wpbotBarHideTimer'));
51            $bar.data('wpbotBarHideTimer', setTimeout(function () {
52                if (!$bar.is(':hover')) {
53                    $bar.fadeOut('slow');
54                }
55            }, 1000));
56        });
57    };
58
59    wpChatBotVar.exit_intent_handler = 0;
60    wpChatBotVar.scroll_open_handler = 0;
61    wpChatBotVar.auto_open_handler = 0;
62    wpChatBotVar.re_target_handler = 0;
63    
64    $(document).ready(function () {
65        if(typeof(wpbot_clear_cache) !=="undefined" && wpbot_clear_cache !=''){
66            wpwKits.reset();
67            LoadwpwBotPlugin = 0;
68        }
69		var botimage = jQuery('#wp-chatbot-ball').find('img').attr('qcld_agent');
70
71		// Custom Icon Video / YouTube: start playback after configured delay
72		var wpbotIconVideo = wpChatBotVar.icon_video || '';
73		var wpbotVideoDelay = parseInt(wpChatBotVar.icon_video_delay, 10) || 0;
74		if (wpbotIconVideo !== '') {
75			var $wpbotVidEl = $('#wp-chatbot-ball-icon-video');
76			if ($wpbotVidEl.length) {
77				if (wpbotVideoDelay > 0) {
78					$wpbotVidEl.hide();
79					setTimeout(function () {
80						$wpbotVidEl.show();
81						if ($wpbotVidEl.is('video')) {
82							try { $wpbotVidEl[0].play(); } catch(e){}
83						}
84					}, wpbotVideoDelay * 1000);
85				} else {
86					if ($wpbotVidEl.is('video')) {
87						try { $wpbotVidEl[0].play(); } catch(e){}
88					}
89				}
90			}
91		}
92
93        if ($('#wp-chatbot-shortcode-template-container').length == 0 && $('#wp-chatbot-chat-app-shortcode-container').length == 0) {
94            //Main wpwbot area.
95            //show it
96            $('#wp-chatbot-ball-wrapper').css({
97                'display': 'block',
98            });
99            //wpChatBot icon  position.
100            $('#wp-chatbot-chat-container').css({
101                'right': wpChatBotVar.wp_chatbot_position_x + 'px',
102                'bottom': wpChatBotVar.wp_chatbot_position_y + 'px'
103            })
104            //Facebook Messenger desktop
105            setTimeout(function () {
106                $('.fb_dialog').css({
107                    'right': parseInt(55 + parseInt(wpChatBotVar.wp_chatbot_position_x)) + 'px',
108                    'bottom': parseInt(17 + parseInt(wpChatBotVar.wp_chatbot_position_y)) + 'px',
109                    'visibility': 'visible'
110                });
111            }, 3000);
112
113            //wpchatbot icon animation disable or enable
114            //Disable wpwBot icon Animation
115            if (wpChatBotVar.disable_icon_animation == 1) {
116                $('.wp-chatbot-ball').addClass('wp-chatbot-animation-deactive');
117            } else {
118                $('.wp-chatbot-ball').addClass('wp-chatbot-animation-active');
119
120                //wpchatbot icon animation timing
121                //var itemHide = function(){
122                //    $('.wp-chatbot-animation-active .wp-chatbot-ball-animation-switch').css({
123                //        "opacity": 0,
124                //    })
125                //};
126                var itemHide = function () {
127                    $('.wp-chatbot-animation-active .wp-chatbot-ball-animation-switch').fadeOut(1000);
128                };
129                setTimeout(function () {
130                    itemHide()
131                }, 1000);
132
133                //Click Animation
134                $('.wp-chatbot-animation-active').click(function () {
135                    $('.wp-chatbot-animation-active .wp-chatbot-ball-animation-switch').fadeIn(100);
136                    setTimeout(function () {
137                        itemHide()
138                    }, 1000);
139                });
140            }
141
142            //window resize.
143            var widowH = $(window).height();
144            var widowW = $(window).width();
145            if (widowW > 767) {
146                var ballConH = parseInt(widowH * 0.5)+ parseInt(114);
147                //$('.wp-chatbot-ball-inner').css({'height': ballConH + 'px'})
148
149                $(window).resize(function () {
150                    var widowH = $(window).height();
151                    var ballConH = parseInt(widowH * 0.5)+ parseInt(114);
152                    //$('.wp-chatbot-ball-inner').css({'height': ballConH + 'px'})
153                });
154            };
155
156            $(document).on('click', '#wp-chatbot-ball', function (event) {
157				
158				if($('.active-chat-board').length>0){
159                    if(wpChatBotVar.template=='template-06' || wpChatBotVar.template=='template-07'){
160                        $('#wp-chatbot-ball').show();
161                    }
162					$('#wp-chatbot-ball').removeClass('wpbot_chatopen_iconanimation');
163					$('#wp-chatbot-ball').addClass('wpbot_chatclose_iconanimation');
164					// Restore: hide close icon, show video OR image
165					$('#wp-chatbot-ball').find('img#wp-chatbot-ball-icon-img').attr('src', botimage);
166					if (wpbotIconVideo !== '') {
167						$('#wp-chatbot-ball-icon-video').show();
168						$('#wp-chatbot-ball').find('img#wp-chatbot-ball-icon-img').hide();
169						$('#wp-chatbot-ball').find('img.wpbot-close-icon-overlay').hide();
170					} else {
171						$('#wp-chatbot-ball').find('img#wp-chatbot-ball-icon-img').show();
172					}
173                    $('.wp-chatbot-ball').css('background', '#ffffff');
174
175
176				}else{
177
178					$('#wp-chatbot-ball').removeClass('wpbot_chatclose_iconanimation');
179					$('#wp-chatbot-ball').addClass('wpbot_chatopen_iconanimation');
180					// Show close icon; hide video OR image
181					if (wpbotIconVideo !== '') {
182						$('#wp-chatbot-ball-icon-video').hide();
183						$('#wp-chatbot-ball').find('img#wp-chatbot-ball-icon-img').attr('src', wpChatBotVar.imgurl+'wpbot-close-icon.png').show();
184					} else {
185						$('#wp-chatbot-ball').find('img').attr('src', wpChatBotVar.imgurl+'wpbot-close-icon.png');
186					}
187                    //$('.wp-chatbot-ball').css('background', 'unset');
188
189
190				}
191				
192                var $boardContainer = $("#wp-chatbot-board-container");
193                var animationDuration = 280;
194                var isOpening = !$boardContainer.hasClass('active-chat-board');
195                $boardContainer.removeClass('wp-chatbot-open-anim wp-chatbot-close-anim');
196                if (isOpening) {
197                    $boardContainer.addClass('active-chat-board');
198                    void $boardContainer[0].offsetWidth;
199                    $boardContainer.addClass('wp-chatbot-open-anim');
200                    wpwbot_board_action();
201                    setTimeout(function () {
202                        $boardContainer.removeClass('wp-chatbot-open-anim');
203                    }, 360);
204                } else {
205                    void $boardContainer[0].offsetWidth;
206                    $boardContainer.addClass('wp-chatbot-close-anim');
207                    setTimeout(function () {
208                        $boardContainer.removeClass('active-chat-board wp-chatbot-close-anim');
209                        wpwbot_board_action();
210                    }, animationDuration);
211                }
212
213            });
214            //wpwBot proActive start
215            //Attention on
216            if(wpChatBotVar.enable_meta_title==1 && wpChatBotVar.meta_label!="") {
217                var MetaTitleInterval;
218                var orginalTitle = document.title;
219                $(document).on("mouseover", 'body', function (e) {
220                    document.title = orginalTitle;
221                    clearInterval(MetaTitleInterval);
222                });
223            }
224            //Exit Intent
225            if(wpChatBotVar.enable_exit_intent == 1){
226                window.addEventListener("mouseout", function (e) {
227                    e = e ? e : window.event;
228
229                    // If this is an autocomplete element.
230                    if (e.target.tagName.toLowerCase() == "input")
231                        return;
232
233                    // Get the current viewport width.
234                    var vpWidth = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
235
236                    // If the current mouse X position is within 50px of the right edge
237                    // of the viewport, return.
238                    if (e.clientX >= (vpWidth - 50))
239                        return;
240
241                    // If the current mouse Y position is not within 50px of the top
242                    // edge of the viewport, return.
243                    if (e.clientY >= 50)
244                        return;
245
246                    // Reliable, works on mouse exiting window and
247                    // user switching active program
248                    var from = e.relatedTarget || e.toElement;
249                    if (!from)
250                       //if will open once if setup from backend.
251                        var exitIntentOpen=true;
252                        if($.cookie('exit_intent')=='yes' && wpChatBotVar.exit_intent_once==1) {
253                            exitIntentOpen=false;
254                        }
255                            if ($('.active-chat-board').length == 0 && exitIntentOpen==true) {
256                                if (wpChatBotVar.exit_intent_handler == 0) {
257                                    $("#wp-chatbot-board-container").addClass('active-chat-board');
258                                    wpChatBotVar.exit_intent_handler++;
259                                    wpChatBotVar.re_target_handler = 1;
260                                    wpwbot_board_action();
261                                    //Shopper Name
262                                    if(localStorage.getItem('shopper')){
263                                        var shopper=localStorage.getItem('shopper');
264                                    }else{
265                                        var shopper=wpChatBotVar.shopper_demo_name;
266                                    }
267                                    setTimeout(function () {
268                                        if (localStorage.getItem("wpwHitory")) {
269                                            showing_proactive_msg( wpChatBotVar.ret_greet+' '+shopper +', '+wpChatBotVar.exit_intent_msg);
270                                        } else {
271                                            showing_proactive_double_msg(wpChatBotVar.ret_greet+' '+shopper+', '+wpChatBotVar.exit_intent_msg)
272                                        }
273                                        $.cookie('exit_intent','yes');
274                                       //pro active sound
275                                        proactive_retargeting_sound();
276                                        //Window foucus meta title change.
277                                        window_focus_change_meta_title();
278                                    }, 1000)
279                                }
280                            }
281                });
282            }
283            if(wpChatBotVar.enable_scroll_open==1){
284
285                $(document).on('scroll', function (event) {
286                        var OpenScroll=true;
287                        //if will open once if setup from backend.
288                       if( $.cookie('scroll_open')=='yes' && wpChatBotVar.scroll_open_once==1) {
289                           OpenScroll=false;
290                       }
291                        //it will be open only for single time.
292                        if ($('.active-chat-board').length ==0 && OpenScroll==true) {
293                            if (wpChatBotVar.scroll_open_handler == 0) {
294                                var scrollOpenVal = parseInt(($(document).height() * wpChatBotVar.scroll_open_percent) / 100);
295                                if ($(window).scrollTop() + $(window).height() > scrollOpenVal) {
296                                   $("#wp-chatbot-board-container").addClass('active-chat-board');
297                                    wpChatBotVar.scroll_open_handler++;
298                                    wpChatBotVar.re_target_handler = 2;
299                                    wpwbot_board_action();
300                                    //Shopper Name
301                                    if(localStorage.getItem('shopper')){
302                                        var shopper=localStorage.getItem('shopper');
303                                    }else{
304                                        var shopper=wpChatBotVar.shopper_demo_name;
305                                    }
306                                    setTimeout(function () {
307                                        if (localStorage.getItem("wpwHitory")) {
308                                            showing_proactive_msg(wpChatBotVar.ret_greet+' '+ shopper+', '+wpChatBotVar.scroll_open_msg);
309                                        } else {
310                                            showing_proactive_double_msg(wpChatBotVar.ret_greet+' '+ shopper+', '+wpChatBotVar.scroll_open_msg)
311                                        }
312                                        $.cookie('scroll_open','yes');
313                                        //pro active sound
314                                        proactive_retargeting_sound();
315                                        //Window foucus meta title change.
316                                        window_focus_change_meta_title();
317                                    }, 1000)
318                                }
319                            }
320                        }
321
322                });
323            }
324            if(wpChatBotVar.enable_auto_open==1 ){
325                //if will open once if setup from backend.
326                var autoOpen=true;
327                if($.cookie('auto_open')=='yes' && wpChatBotVar.auto_open_once==1) {
328                    autoOpen=false;
329                }
330                if( wpChatBotVar.auto_open_handler == 0 && autoOpen==true) {
331                    setTimeout(function (e) {
332                        if ($('.active-chat-board').length == 0) {
333                            $("#wp-chatbot-board-container").addClass('active-chat-board');
334                            wpChatBotVar.auto_open_handler++;
335                            wpChatBotVar.re_target_handler = 3;
336                            wpwbot_board_action();
337                            //Shopper Name
338                            if(localStorage.getItem('shopper')){
339                                var shopper=localStorage.getItem('shopper');
340                            }else{
341                                var shopper=wpChatBotVar.shopper_demo_name;
342                            }
343                            setTimeout(function () {
344                                if (localStorage.getItem("wpwHitory")) {
345                                    showing_proactive_msg(wpChatBotVar.ret_greet+' '+ shopper+', '+wpChatBotVar.auto_open_msg);
346                                } else {
347                                    showing_proactive_double_msg(wpChatBotVar.ret_greet+' '+shopper+', '+wpChatBotVar.auto_open_msg)
348                                }
349                                $.cookie('auto_open','yes');
350                                //pro active sound
351                                proactive_retargeting_sound();
352                                //Window foucus meta title change.
353                                window_focus_change_meta_title();
354                            }, 1000)
355                        }
356                    }, parseInt(wpChatBotVar.auto_open_time * 1000));
357                }
358            }
359            //Retargeting for Cart to complete checkout.
360            if(wpChatBotVar.enable_ret_user_show==1 && localStorage.getItem("wpwHitory") && $.cookie('return_user')!='yes') {
361
362                $.cookie('return_user','yes');
363                var data = {'action': 'qcld_wb_chatbot_only_cart'};
364                jQuery.post(wpChatBotVar.ajax_url, data, function (response) {
365                    if (response.items > 0) {
366                        if ($('.active-chat-board').length == 0) {
367                            setTimeout(function () {
368                                $("#wp-chatbot-board-container").addClass('active-chat-board');
369                                wpwbot_board_action();
370                                showing_proactive_msg(wpChatBotVar.checkout_msg);
371                                setTimeout(function () {
372                                    showing_proactive_msg(response.html);
373                                    //Window foucus meta title change.
374                                    window_focus_change_meta_title();
375                                }, 2000);
376                            }, 1000);
377                        }
378                    }
379                });
380            }else{
381                $.cookie('return_user','yes');
382            }
383
384            if(wpChatBotVar.enable_inactive_time_show==1 && localStorage.getItem("wpwHitory") ) {
385                var timeoutID;
386
387                function setup() {
388                    this.addEventListener("mousemove", resetTimer, false);
389                    this.addEventListener("mousedown", resetTimer, false);
390                    this.addEventListener("keypress", resetTimer, false);
391                    this.addEventListener("DOMMouseScroll", resetTimer, false);
392                    this.addEventListener("mousewheel", resetTimer, false);
393                    this.addEventListener("touchmove", resetTimer, false);
394                    this.addEventListener("MSPointerMove", resetTimer, false);
395
396                    startTimer();
397                }
398                setup();
399
400                function startTimer() {
401                    // wait as set from admin seconds before calling goInactive
402                    timeoutID = window.setTimeout(goInactive, parseInt(wpChatBotVar.inactive_time*1000));
403                }
404
405                function resetTimer(e) {
406                    window.clearTimeout(timeoutID);
407
408                    goActive();
409                }
410
411                function goInactive() {
412                    if(wpChatBotVar.ret_inactive_user_once==1 && $.cookie('return_inactive_user')!='yes') {
413                        $.cookie('return_inactive_user','yes');
414                        var data = {'action': 'qcld_wb_chatbot_only_cart'};
415                        jQuery.post(wpChatBotVar.ajax_url, data, function (response) {
416                            if (response.items > 0) {
417                                if ($('.active-chat-board').length == 0) {
418                                    setTimeout(function () {
419										$('#wp-chatbot-ball').removeClass('wpbot_chatclose_iconanimation');
420									$('#wp-chatbot-ball').addClass('wpbot_chatopen_iconanimation');
421									if (wpbotIconVideo !== '') {
422										$('#wp-chatbot-ball-icon-video').hide();
423										$('#wp-chatbot-ball').find('img#wp-chatbot-ball-icon-img').attr('src', wpChatBotVar.imgurl+'wpbot-close-icon.png').show();
424	
424								} else {
425										$('#wp-chatbot-ball').find('img').attr('src', wpChatBotVar.imgurl+'wpbot-close-icon.png');
426									}
427                                        $("#wp-chatbot-board-container").addClass('active-chat-board');
428                                        wpwbot_board_action();
429                                        showing_proactive_msg(wpChatBotVar.checkout_msg);
430                                        setTimeout(function () {
431                                            showing_proactive_msg(response.html);
432                                            //Window foucus meta title change.
433                                            window_focus_change_meta_title();
434                                        }, 2000);
435                                    }, 2000);
436                                }
437                            }
438                        });
439                    }else{
440                        $.cookie('return_inactive_user','yes');
441                    }
442                }
443
444                function goActive() {
445                    // do something
446
447                    startTimer();
448                }
449            }
450            //Proactive retargeting sound for auto open. scroll open and
451            function proactive_retargeting_sound() {
452                if(wpChatBotVar.enable_ret_sound==1){
453                    var promise = document.querySelector('#wp-chatbot-proactive-audio').play();
454                    if (promise !== undefined) {
455                        promise.then(function (success) {
456                            //success to play
457                        }).catch(function (error) {
458                            //some error
459                            //console.log(error);
460                        });
461                    }
462                }
463            }
464
465            //When user will be out of window and news retargetting will be shown. where opening hour, title and meta need to be set.
466            function window_focus_change_meta_title() {
467                if(wpChatBotVar.enable_meta_title==1 && wpChatBotVar.meta_label!=""  && openingHourIs==0) {
468                    var showInactive = 0;
469                    MetaTitleInterval = setInterval(function () {
470                        if (showInactive == 0) {
471                            document.title = wpChatBotVar.meta_label;
472                            showInactive = 1;
473                        } else {
474                            document.title = orginalTitle;
475                            showInactive = 0;
476                        }
477                    }, 1000);
478                }
479            }
480
481            //wpwBot proActive end
482            function wpwbot_board_action() {
483                var currentW = $(window).width();
484                var isBoardOpen = $('#wp-chatbot-board-container').hasClass('active-chat-board');
485                if (currentW <= 480 && wpChatBotVar.mobile_full_screen==1 && isBoardOpen) {//For mobile
486                    if ($('#wp-chatbot-mobile-close').length <= 0) {
487                        $('.wp-chatbot-board-container').append('<div id="wp-chatbot-mobile-close">X</div>');
488                    }
489                    $('.wp-chatbot-ball-inner').slimScroll({
490                        height: '100hv',
491                        start: 'bottom'
492                    });
493                    wpbotSyncSlimScrollBar($('.wp-chatbot-ball-inner'));
494                    $('#wp-chatbot-chat-container').addClass('wp-chatbot-mobile-fs-open').css({
495                        'bottom': '0',
496                        'left': '0',
497                        'right': '0',
498                        'width': '100%',
499                        'max-width': '100%'
500                    });
501                    $('#wp-chatbot-board-container').css({'width': '100%', 'max-width': '100%'});
502                    $('#wp-chatbot-ball').hide();
503                    //Maintain inner chat box height
504                    var widowH = $(window).height();
505                    var headerH = $('.wp-chatbot-header').outerHeight();
506                    var footerH = $('.wp-chatbot-footer').outerHeight();
507                    var AppContentInner = widowH - footerH - headerH;
508                    //alert(footerH);
509                    $('.wp-chatbot-ball-inner').css({'height': AppContentInner + 'px'})
510                    $('.wp-chatbot-ball-inner').css({'max-height': AppContentInner + 'px'})
511                    $(this).hide();
512                } else {
513                    if (!isBoardOpen) {
514                        $('#wp-chatbot-chat-container').removeClass('wp-chatbot-mobile-fs-open');
515                    }
516                //    $('.wp-chatbot-header').append('<div id="wp-chatbot-desktop-close"><span class="dashicons dashicons-no"></span></div>');
517                    $('.wp-chatbot-ball-inner').slimScroll({
518                        height: '55hv',
519                        start: 'bottom'
520                    });
521                    wpbotSyncSlimScrollBar($('.wp-chatbot-ball-inner'));
522                }
523
524
525                //Here is the Plugin  to be load only for once.
526                if (LoadwpwBotPlugin == 0) {
527                    $.wpwbot({obj: wpChatBotVar, editor_handler: textEditorHandler, preLoadingTime: wpChatBotVar.botpreloadingtime});
528                    LoadwpwBotPlugin++;
529					var data = {'action': 'qcld_wb_chatbot_session_count', 'nonce': wpChatBotVar.session_nonce};
530                    jQuery.post(wpChatBotVar.ajax_url, data, function (response) {
531                       //
532                    });
533                }
534                //If product detials is open then it will be closed.
535                $('.wp-chatbot-product-container').removeClass('active-chatbot-product-details');
536                //Show and close notification message on ball click
537                if ($('.active-chat-board').length != 0) {
538                    $('#wp-chatbot-notification-container').removeClass('wp-chatbot-notification-container-sliding');
539                    //chatbox will be open and notificaion will be closed
540                    $('#wp-chatbot-notification-container').addClass('wp-chatbot-notification-container-disable');
541                    //clearInterval(notificationInterval);
542                } else {
543                    if (!sessionStorage.getItem('wpChatbotNotification')) {
544                        $('#wp-chatbot-notification-container').removeClass('wp-chatbot-notification-container-disable');
545                        $('#wp-chatbot-notification-container').addClass('wp-chatbot-notification-container-sliding');
546
547                    }
548                    /// clearInterval(notificationInterval);
549                }
550                //Messenger handling.
551                if ($('.active-chat-board').length > 0) {
552                    $('#wp-chatbot-integration-container').show();
553                } else {
554                    $('#wp-chatbot-integration-container').hide();
555                }
556            }
557            function showing_proactive_msg(msg){
558                var enableleReactions = globalwpw.settings.obj.skip_chat_reactions_menu;
559                var eanleeReport = globalwpw.settings.obj.enable_chat_report_menu;
560                var enableshare = globalwpw.settings.obj.enable_chat_share_menu;
561                var likeTxt = globalwpw.settings.obj.qlcd_wp_chatbot_like_text;
562                var disLikeTxt = globalwpw.settings.obj.qlcd_wp_chatbot_dislike_text;
563                var reportTxt = globalwpw.settings.obj.qlcd_wp_chatbot_report_text;
564                var sharetTxt = globalwpw.settings.obj.qlcd_wp_chatbot_share_text;
565                console.log(globalwpw.settings);
566                console.log(enableleReactions);
567                //first open then chatboard
568                if(localStorage.getItem("wpwHitory") && ! $('.wp-chatbot-operation-option[data-option="chat"]').parent().hasClass('wp-chatbot-operation-active')){
569                        $('.wp-chatbot-messages-wrapper').html(localStorage.getItem("wpwHitory"));
570                        $('.wp-chatbot-operation-option').each(function(){
571                            if($(this).attr('data-option')=='chat'){
572                                $(this).parent().addClass('wp-chatbot-operation-active');
573                            }else{
574                                $(this).parent().removeClass('wp-chatbot-operation-active');
575                            }
576                        });
577                    }
578                    var msgContent='<li class="wp-chatbot-msg">' +
579                        '<div class="wp-chatbot-avatar">'+
580                        '<img src="'+wpChatBotVar.agent_image_path+'" alt="">'+
581                        '</div>'+
582                        '<div class="wp-chatbot-agent">'+ wpChatBotVar.agent+'</div>'
583                        +'<div class="wp-chatbot-paragraph"><img class="wp-chatbot-comment-loader" src="'+wpChatBotVar.image_path+'comment.gif" alt="Typing..." /></div>'+
584                            '<div class="qcld-like-dislike-icon">' +
585                (enableleReactions == 1 
586                    ? '<a href="#" title="' + (disLikeTxt?.en_US || 'Dislike') + '"><i class="dashicons dashicons-thumbs-down"></i></a>' +
587                    '<a href="#" title="' + (likeTxt?.en_US || 'Like') + '"><i class="dashicons dashicons-thumbs-up" ></i></a>' 
588                    : '') +
589
590                (eanleeReport == 1 
591                    ? '<a href="#" title="' + (reportTxt?.en_US || 'Report') + '"><i class="dashicons dashicons-admin-comments"></i></a>'
592                    : '') +
593
594                (enableshare == 1 
595                    ? '<div class="qcld-share">' +
596                        '<a href="#" class="share-toggle" title="' + (sharetTxt?.en_US || 'Share') + '"><i class="dashicons dashicons-share" aria-hidden="true"></i></a>' +
597                        '<div class="share-menu" style="display:none;">' +
598                            '<a href="#" class="share-fb"><i class="dashicons dashicons-facebook"></i></a>' +
599                            '<a href="#" class="share-wa"><i class="dashicons dashicons-whatsapp"></i></a>' +
600                            '<a href="#" class="share-x"><i class="dashicons dashicons-twitter"></i></a>' +
601                            '<a href="#" class="share-email"><i class="dashicons dashicons-email-alt"></i></a>' +
602                        '</div>' +
603                    '</div>'
604                    : '') +
605            '</div>' +
606                    '</li>';
607                    
608                    $('#wp-chatbot-messages-container').append(msgContent);
609                //Scroll to the last message
610                $('.wp-chatbot-ball-inner').animate({ scrollTop: $('.wp-chatbot-messages-wrapper').prop("scrollHeight")}, 'slow', function () { wpbotSyncSlimScrollBar($('.wp-chatbot-ball-inner')); });
611                setTimeout(function(){
612                    $('#wp-chatbot-messages-container li:last .wp-chatbot-paragraph').html(msg).css({'background-color':wpChatBotVar.proactive_bg_color});
613                    //scroll to the last message
614                    $('.wp-chatbot-ball-inner').animate({ scrollTop: $('.wp-chatbot-messages-wrapper').prop("scrollHeight")}, 'slow', function () { wpbotSyncSlimScrollBar($('.wp-chatbot-ball-inner')); });
615                }, 2000);
616            }
617            function  showing_proactive_double_msg(secondMsg) {
618                var enableleReactions = globalwpw.settings.obj.skip_chat_reactions_menu;
619                var eanleeReport = globalwpw.settings.obj.enable_chat_report_menu;
620                var enableshare = globalwpw.settings.obj.enable_chat_share_menu;
621                var likeTxt = globalwpw.settings.obj.qlcd_wp_chatbot_like_text;
622                var disLikeTxt = globalwpw.settings.obj.qlcd_wp_chatbot_dislike_text;
623                var reportTxt = globalwpw.settings.obj.qlcd_wp_chatbot_report_text;
624                var sharetTxt = globalwpw.settings.obj.qlcd_wp_chatbot_share_text;
625                console.log(globalwpw.settings);
626                console.log(enableleReactions);
627                //first open then chatboard
628                if(localStorage.getItem("wpwHitory")){
629                    $('.wp-chatbot-messages-wrapper').html(localStorage.getItem("wpwHitory"));
630                    $('.wp-chatbot-operation-option').each(function(){
631                        if($(this).attr('data-option')=='chat'){
632                            $(this).parent().addClass('wp-chatbot-operation-active');
633                        }else{
634                            $(this).parent().removeClass('wp-chatbot-operation-active');
635                        }
636                    });
637                }
638                var fristMsg="<strong>"+wpChatBotVar.agent+" </strong> "+wpChatBotVar.agent_join[0];
639                var msgContent='<li class="wp-chatbot-msg">' +
640                    '<div class="wp-chatbot-avatar">'+
641                    '<img src="'+wpChatBotVar.agent_image_path+'" alt="">'+
642                    '</div>'+
643                    '<div class="wp-chatbot-agent">'+ wpChatBotVar.agent+'</div>'
644                    +'<div class="wp-chatbot-paragraph"><img class="wp-chatbot-comment-loader" src="'+wpChatBotVar.image_path+'comment.gif" alt="Typing..." /></div>'+
645                     '<div class="qcld-like-dislike-icon">' +
646              (enableleReactions == 1 
647                  ? '<a href="#" title="' + (disLikeTxt?.en_US || 'Dislike') + '"><i class="dashicons dashicons-thumbs-down"></i></a>' +
648                    '<a href="#" title="' + (likeTxt?.en_US || 'Like') + '"><i class="dashicons dashicons-thumbs-up"></i></a>'
649                  : '') +
650
651              (eanleeReport == 1 
652                  ? '<a href="#" title="' + (reportTxt?.en_US || 'Report') + '"><i class="dashicons dashicons-admin-comments"></i></a>'
653                  : '') +
654
655              (enableshare == 1 
656                  ? '<div class="qcld-share">' +
657                      '<a href="#" class="share-toggle" title="' + (sharetTxt?.en_US || 'Share') + '"><i class="dashicons dashicons-share"></i></a>' +
658                      '<div class="share-menu" style="display:none;">' +
659                          '<a href="#" class="share-fb"><i class="dashicons dashicons-facebook"></i></a>' +
660                          '<a href="#" class="share-wa"><i class="dashicons dashicons-whatsapp"></i></a>' +
661                          '<a href="#" class="share-x"><i class="dashicons dashicons-twitter"></i></a>' +
662                          '<a href="#" class="share-email"><i class="dashicons dashicons-email-alt"></i></a>' +
663                      '</div>' +
664                  '</div>'
665                  : '') +
666          '</div>' +
667          '</li>';
668                $('#wp-chatbot-messages-container').append(msgContent);
669                //Scroll to the last message
670                $('.wp-chatbot-ball-inner').animate({ scrollTop: $('.wp-chatbot-messages-wrapper').prop("scrollHeight")}, 'slow', function () { wpbotSyncSlimScrollBar($('.wp-chatbot-ball-inner')); });
671
672                setTimeout(function(){
673                    $('#wp-chatbot-messages-container li:last .wp-chatbot-paragraph').html(fristMsg);
674                    //Second Message with interval
675                    $('#wp-chatbot-messages-container').append(msgContent);
676                    //Scroll to the last message
677                    $('.wp-chatbot-ball-inner').animate({ scrollTop: $('.wp-chatbot-messages-wrapper').prop("scrollHeight")}, 'slow', function () { wpbotSyncSlimScrollBar($('.wp-chatbot-ball-inner')); });
678                     setTimeout(function(){
679                        $('#wp-chatbot-messages-container li:last .wp-chatbot-paragraph').html(secondMsg).css({'background-color':wpChatBotVar.proactive_bg_color});
680                        //Scroll to the last message
681                         $('.wp-chatbot-ball-inner').animate({ scrollTop: $('.wp-chatbot-messages-wrapper').prop("scrollHeight")}, 'slow', function () { wpbotSyncSlimScrollBar($('.wp-chatbot-ball-inner')); });
682
683                    }, 2000);
684
685                }, 2000);
686            }
687            $(document).on('click', '#wp-chatbot-mobile-close, #wp-chatbot-desktop-close', function (event) {
688                var $boardContainer = $("#wp-chatbot-board-container");
689                if ($boardContainer.hasClass('active-chat-board')) {
690                    $boardContainer.removeClass('wp-chatbot-open-anim wp-chatbot-expand-anim wp-chatbot-collapse-anim');
691                    void $boardContainer[0].offsetWidth;
692                    $boardContainer.addClass('wp-chatbot-close-anim');
693                    setTimeout(function () {
694                        $boardContainer.removeClass('active-chat-board wp-chatbot-close-anim');
695                    }, 280);
696                }
697                $("#wp-chatbot-notification-container").removeClass('wp-chatbot-notification-container-disable').addClass('wp-chatbot-notification-container-sliding');
698                $('#wp-chatbot-chat-container').removeClass('wp-chatbot-mobile-fs-open').css({
699                    'right': wpChatBotVar.wp_chatbot_position_x + 'px',
700                    'bottom': wpChatBotVar.wp_chatbot_position_y + 'px',
701                    'top': 'auto', 'left': 'auto',
702                    'width': '', 'max-width': ''
703                });
704                $('#wp-chatbot-board-container').css({'width': '', 'max-width': ''});
705				// Restore icon: show video OR image when chat is closed via X button
706				if (wpbotIconVideo !== '') {
707					$('#wp-chatbot-ball').find('img#wp-chatbot-ball-icon-img').attr('src', botimage).hide();
708					$('#wp-chatbot-ball-icon-video').show();
709				} else {
710					$('#wp-chatbot-ball').find('img').attr('src', botimage);
711				}
712                $('.wp-chatbot-ball').css('background', '#ffffff');
713                $('#wp-chatbot-ball').show();
714                //Facebook Messenger.
715                if ($('.active-chat-board').length > 0) {
716                    $('#wp-chatbot-integration-container').show();
717                } else {
718                    $('#wp-chatbot-integration-container').hide();
719                }
720            });
721            function wpbotSyncExpandIconState() {
722                var $boardContainer = $('#wp-chatbot-board-container');
723                var isExpanded = $boardContainer.hasClass('wp-chatbot-expanded');
724                $('#wp-chatbot-desktop-expand').attr('title', isExpanded ? 'Collapse' : 'Expand').find('span')
725                    .removeClass('dashicons dashicons-fullscreen-exit-alt')
726                    .addClass('dashicons ' + (isExpanded ? 'dashicons-editor-contract' : 'dashicons-editor-expand'));
727            }
728
729            wpbotSyncExpandIconState();
730
731            $(document).on('click', '#wp-chatbot-desktop-expand', function (event) {
732                event.preventDefault();
733                var $boardContainer = $('#wp-chatbot-board-container');
734                // Size toggle only — CSS width/height transition. No opacity/scale anims (they flash white).
735                $boardContainer.removeClass('wp-chatbot-open-anim wp-chatbot-expand-anim wp-chatbot-collapse-
735anim wp-chatbot-close-anim');
736                $boardContainer.toggleClass('wp-chatbot-expanded');
737                wpbotSyncExpandIconState();
738                // Keep slimScroll in sync after height change
739                setTimeout(function () {
740                    var $inner = $boardContainer.find('.wp-chatbot-ball-inner');
741                    if (!$inner.length || !$inner[0]) {
742                        return;
743                    }
744                    var computedH = window.getComputedStyle($inner[0]).height;
745                    if (computedH) {
746                        $inner.slimScroll({ height: computedH, start: 'bottom' });
747                        wpbotSyncSlimScrollBar($inner);
748                    }
749                }, 40);
750            });
751         
752
753            $("#qcld-wp-chatbot-shortcode-style-css").attr("disabled", "disabled");
754            /***
755             * Notification Message
756             */
757            if ($('#wp-chatbot-notification-container').length > 0) {
758                if (sessionStorage.getItem('wpChatbotNotification') && sessionStorage.getItem('wpChatbotNotification') == 'removed') {
759                    //if remove on the session.
760                    $('#wp-chatbot-notification-container').addClass('wp-chatbot-notification-container-disable');
761                } else {
762                    //Notification comes with slideIn effect
763                    $('#wp-chatbot-notification-container').addClass('wp-chatbot-notification-container-sliding');
764                    //handling welcome & return user welcome msg.
765                    if ($.cookie("shopper")) {
766                        var shopper = $.cookie("shopper");
767                        var welcomeMsg = wpChatBotVar.welcome_back[0] + ' <strong>' + shopper + '!</strong>';
768                    } else {
769                        var welcomeMsg = wpChatBotVar.welcome[0] + ' <strong>' + wpChatBotVar.host + '!</strong>';
770
771                    }
772                    $('.wp-chatbot-notification-welcome').html(welcomeMsg);
773                    //Notifications msgs handling.
774                    var notifications = wpChatBotVar.notifications;
775                    if (notifications.length > 1) {
776                        var totalNotMsg = wpChatBotVar.notifications.length;
777                        var notMsgIndex = 0;
778                        var intervalTime = parseInt(wpChatBotVar.notification_interval) * 1000;
779                        var notificationInterval = setInterval(function (e) {
780                            notMsgIndex++;
781                            if (totalNotMsg <= notMsgIndex) {
782                                notMsgIndex = 0;
783                            }
784                            //show new notification time after every intervalTime
785                            $('.wp-chatbot-notification-message').css({'opacity': 1}).html(notifications[notMsgIndex]);
786                        }, intervalTime);
787                    }
788
789                    $(".wp-chatbot-notification-close").click(function () {
790                        $('#wp-chatbot-notification-container').addClass('wp-chatbot-notification-container-disable');
791                        //clearInterval(notificationInterval);
792                        sessionStorage.setItem('wpChatbotNotification', 'removed');
793                    });
794                }
795            }
796        }
797        else if ($('#wp-chatbot-shortcode-template-container').length > 0) { //Page shortcode area.
798            $('#wp-chatbot-chat-container').css({'display': 'none'});
799            $('#wp-chatbot-ball').hide();
800            //Add Scroll to chat ui
801            $('.wp-chatbot-ball-inner').slimScroll({
802                height: '60hv',
803                start: 'bottom'
804            });
805                    wpbotSyncSlimScrollBar($('.wp-chatbot-ball-inner'));
806            //Add scroll to cart part
807            var recentViewHeight = $('.wp-chatbot-container').outerHeight();
808            if ($('.chatbot-shortcode-template-02').length == 0) {
809                $('.wp-chatbot-cart-body').slimScroll({height: '200px', start: 'top'});
810                $('.wp-chatbot-widget .wp-chatbot-products').slimScroll({height: '435px', start: 'top'});
811            }
812
813            //Remove style of template
814            $("#qcld-wp-chatbot-style-css").attr("disabled", "disabled");
815            //Here is the Plugin  to be load only for once.
816            if (LoadwpwBotPlugin == 0) {
817                $.wpwbot({obj: wpChatBotVar, editor_handler: textEditorHandler});
818                LoadwpwBotPlugin++;
819				var data = {'action': 'qcld_wb_chatbot_session_count', 'nonce': wpChatBotVar.session_nonce};
820                    jQuery.post(wpChatBotVar.ajax_url, data, function (response) {
821                       //
822                    });
823            }
824
825
826        }
827        else if ($('#wp-chatbot-chat-app-shortcode-container').length > 0) {  //App shortcode area.
828
829            textEditorHandler = 1;
830            //App UI (ball inner)
831            setTimeout(function () {
832                var widowH = $(window).height();
833                //var headerH = $('.wp-chatbot-header').outerHeight();
834                var footerH = $('.wp-chatbot-footer').outerHeight();
835
836                var AppContentInner = widowH - footerH;
837                //alert(footerH);
838                $('#wp-chatbot-chat-app-shortcode-container .wp-chatbot-ball-inner').css({'height': AppContentInner + 'px'})
839            }, 300);
840            $(window).resize(function () {
841                setTimeout(function () {
842                    var widowH = $(window).height();
843                    //var headerH = $('.wp-chatbot-header').outerHeight();
844                    var footerH = $('.wp-chatbot-footer').outerHeight();
845                    var AppContentInner = widowH - footerH;
846                    //alert(footerH);
847                    $('#wp-chatbot-chat-app-shortcode-container .wp-chatbot-ball-inner').css({'height': AppContentInner + 'px'})
848                }, 300)
849            });
850
851            $('#wp-chatbot-ball').hide();
852            //Add Scroll to chat ui
853            $("#qcld-wp-chatbot-shortcode-style-css").attr("disabled", "disabled");
854            $("#wp-chatbot-board-container").addClass('active-chat-board');
855            $('.wp-chatbot-ball-inner').slimScroll({
856                height: '55hv',
857                start: 'bottom'
858            }).parent();
859            wpbotSyncSlimScrollBar($('.wp-chatbot-ball-inner'));
860            if (LoadwpwBotPlugin == 0) {
861                $.wpwbot({obj: wpChatBotVar, editor_handler: textEditorHandler});
862                LoadwpwBotPlugin++;
863				var data = {'action': 'qcld_wb_chatbot_session_count', 'nonce': wpChatBotVar.session_nonce};
864                    jQuery.post(wpChatBotVar.ajax_url, data, function (response) {
865                       //
866                    });
867            }
868            //Handling app cart and checkout
869            $('#wp-chatbot-cart-short-code').hide();
870            $('#wp-chatbot-checkout-short-code').hide();
871            $(document).on('click', '.wp-chatbot-cart-link', function (event) {
872                $('.wp-chatbot-messages-wrapper').hide();
873                $('#wp-chatbot-checkout-short-code').hide();
874                $('#wp-chatbot-cart-short-code').show();
875                event.preventDefault();
876                $('#wp-chatbot-cart-short-code').html('<img class="wp-chatbot-comment-loader" src="' + wpChatBotVar.image_path + 'comment.gif" alt="..." />');
877                var data = {'action': 'qcld_wb_chatbot_cart_page'};
878                jQuery.post(wpChatBotVar.ajax_url, data, function (response) {
879                    $("#wp-chatbot-cart-short-code").html(response);
880                });
881            });
882            $(document).on('click', '.wp-chatbot-checkout-link, .checkout-button', function (event) {
883                event.preventDefault();
884                $('.wp-chatbot-messages-wrapper').hide();
885                $('#wp-chatbot-cart-short-code').hide();
886                $('#wp-chatbot-checkout-short-code').show();
887
888
889                $('#wp-chatbot-checkout-short-code').html('<img class="wp-chatbot-comment-loader" src="' + wpChatBotVar.image_path + 'comment.gif" alt="..." />');
890                var data = {'action': 'qcld_wb_chatbot_checkout_page'};
891                jQuery.post(wpChatBotVar.ajax_url, data, function (response) {
892                    if (response.status == 'yes') {
893                        window.location.href = response.html;
894                    } else {
895                        $("#wp-chatbot-checkout-short-code").html(response.html);
896                    }
897
898                });
899            });
900            //Preventing url redirect from cart page.
901            $(document).on('click', '#wp-chatbot-chat-app-shortcode-container .wpcommerce-cart-form a', function (e) {
902                e.preventDefault();
903            });
904        }
905        //For variable product configuration
906        $(document).on('change', "#wp-chatbot-product-variable select ", function () {
907            var variations = JSON.parse($("#wp-chatbot-variation-data").attr('data-product-variation'));
908            var item_conditions = [];
909
910            var totalAttr = $("#wp-chatbot-product-variable select").length;
911            var i = 1;
912            $("#wp-chatbot-product-variable select").each(function (index, element) {
913                var myVal = $(this).find('option:selected').val();
914                if (myVal != "") {
915                    item_conditions.push({
916                        'left': 'item["variation_data"]["' + $(this).attr('name') + '"][0]',
917                        'right': myVal
918                    })
919                }
920            });
921            var newVariation = [];
922            for (var a = 0; variations.length > a; a++) {
923                var item = variations[a];
924                var item_condition = "";
925                for (var i = 0; item_conditions.length > i; i++) {
926
927                    if (i > 0) {
928                        item_condition += ' && ' + '"' + eval(item_conditions[i].left).toLowerCase() + '"' + '==' + '"' + item_conditions[i].right.toLowerCase() + '"';
929                    } else {
930                        item_condition += '"' + eval(item_conditions[i].left).toLowerCase() + '"' + '==' + '"' + item_conditions[i].right.toLowerCase() + '"';
931                    }
932                }
933                if (eval(item_condition)) {
934                    newVariation[0] = item;
935                }
936            }
937            if (newVariation.length > 0) {
938                $('#wp-chatbot-variation-add-to-cart').attr('variation_id', newVariation[0]['variation_id']);
939                var priceSets = "";
940                if (newVariation[0]['variation_data']['_sale_price'][0] != "") {
941                    priceSets += '<strike>' + wpChatBotVar.currency_symbol + newVariation[0]['variation_data']['_regular_price'][0] + '</strike>  <strong>' + wpChatBotVar.currency_symbol + newVariation[0]['variation_data']['_sale_price'][0] + '</strong>'
942                } else {
943                    priceSets += '<strong>' + wpChatBotVar.currency_symbol + newVariation[0]['variation_data']['_regular_price'][0] + '</strong>';
944                }
945                $('#wp-chatbot-product-price').html(priceSets);
946            }
947        });
948
949        if ($('.active-chat-board').length > 0) {
950            $('#wp-chatbot-integration-container').show();
951        } else {
952            $('#wp-chatbot-integration-container').hide();
953        }
954        //Facebook Messenger Integration
955        /* if(wpChatBotVar.enable_messenger == 1){
956         $(document).on('click','.fb_dialog',function (e) {
957         $('#wp-chatbot-board-container').removeClass('active-chat-board');
958         $('.fb_dialog').css({'display': 'inline'});
959         setTimeout(function (e) {
960         $('.fb-customerchat >span').css({'display': 'inline'});
961         $('.fb_dialog').trigger('click'); //.css({'display': 'none'});
962         },300);
963         $('#wp-chatbot-integration-container').hide();
964         });
965         }*/
966        //skype
967        if (wpChatBotVar.enable_skype == 1) {
968            $(document).on('click', '.inetegration-skype-btn', function (e) {
969                $('#wp-chatbot-board-container').removeClass('active-chat-board');
970                // $('.lwc-button-icon').trigger('click');
971                $('#wp-chatbot-integration-container').hide();
972            });
973
974        }
975
976
977    });
978
979});

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.