PageSourceSearch

https://www.lillotheworker.com/wp-content/plugins/wp-live-chat-support/js/wplc_u.js?ver=8.0.34

js lillotheworker.com collected 2026-09-25 03:35:21 UTC 35,048 bytes, 915 lines download raw bytes

1/*
2 * Cookie Status
3 *
4 * 1 - complete - user has left site
5 * 2 - pending - user waiting for chat to be answered by admin
6 * 3 - active chat - user and admin are chatting
7 * 4 - deleted
8 * 5 - browsing - no data has been inputted
9 * 6 - requesting chat - admin has requested a chat with user
10 * 7 - timed out - visitor has timed out
11 * 8 - complete but now browsing again
12 * 9 - user closed chat before starting chat
13 * 10 - user minimized active chat
14 * 11 - user moved on to another page (session variable is different)
15 * 12 - user has not been answered after sending chat request and is still active
16 *
17 */
18var wplc_is_chat_open = false;
19var wplc_online = false;
20var wplc_agent_name = "";
21var msg_history = new Array();
22var wplc_is_minimized = false; /* global to hold whether or not the chat box is minimized */
23
24var wplc_retry_interval = null;
25
26var wplc_run = true;
27
28var wplc_server = null;
29wplc_server = new WPLCServer();
30
31var wplc_server_last_loop_data = null;
32
33var wplc_shown_welcome = false;
34
35var wplc_current_agent = false;
36
37/* node support */
38var ns_obj = {};
39
40
41/* node variable mapping */
42var welcome_message = '';
43
44var wplc_session_variable = new Date().getTime();
45var wplc_cid;
46var wplc_check_hide_cookie;
47var wplc_chat_status = "";
48var wplc_cookie_name = "";
49var wplc_cookie_email = "";
50var wplc_init_chat_box_check = true;
51var wplc_cid = null;
52
53var initial_data = {};
54var wplc_fist_run = true;
55var wplc_long_poll_delay = 1500;
56 
57jQuery(function() {
58
59    /* Gutenberg functions */
60    jQuery('.wp-block-wp-live-chat-support-wplc-chat-box').on('click',function(){
61        jQuery("#wplc_hovercard").fadeOut("fast");
62        jQuery("#wplc-chat-alert").removeClass('is-active');
63        wplc_is_chat_open = true;
64        jQuery.event.trigger({type: "wplc_open_chat"});
65    });
66
67    wplc_map_node_variables();
68
69    /* preload the images */
70    wplc_preload();
71
72    wplc_cid = Cookies.get('wplc_cid');
73
74    if(typeof wplc_cid === 'undefined'){
75        wplc_cid = null;
76    } else {
77        wplc_cid = Cookies.get('wplc_cid');
78    }
79
80    wplc_check_hide_cookie = Cookies.get('wplc_hide');
81    wplc_check_minimize_cookie = Cookies.get('wplc_minimize');
82    wplc_chat_status = Cookies.get('wplc_chat_status');
83    wplc_cookie_name = Cookies.get('wplc_name');
84    wplc_cookie_email = Cookies.get('wplc_email');
85    // Always start on 5 - ajax will then return chat status if active
86
87    Cookies.set('wplc_chat_status', 5, { expires: 1, path: '/' });
88    wplc_chat_status = 5;
89    //if (typeof wplc_chat_status !== "undefined" && parseInt(wplc_chat_status) === 3) { } else {
90
91    //}
92
93    //Preflight check for WPML integration
94    var wplc_wpml_body_language = jQuery("html").attr("lang");
95    if(typeof wplc_wpml_body_language !== "undefined"){
96        if(wplc_wpml_body_language.indexOf("-") !== -1){
97            wplc_wpml_body_language = wplc_wpml_body_language.substr(0, wplc_wpml_body_language.indexOf("-"));
98        }
99        Cookies.set('_icl_current_language', wplc_wpml_body_language, { expires: 1, path: '/' });
100    }
101
102    var data = {
103        action: 'wplc_get_chat_box',
104        security: wplc_nonce,
105        cid: wplc_cid
106    };
107
108    jQuery.ajax({
109        url: wplc_ajaxurl_site,
110        data:data,
111        type:"POST",
112        success: function(response) {
113            /* inject html */
114            if(response){
115                if (response === "0") { if (window.console) { console.log('WP Live Chat Support Return Error'); } wplc_run = false;  return; }
116                response = JSON.parse(response);
117
118
119                jQuery( "body" ).append( response['cbox']);
120
121                wplc_listenForScrollEvent(jQuery("#wplc_chatbox"));
122
123                if( typeof wplc_cookie_name == 'undefined' || typeof wplc_cookie_email == 'undefined' ){
124
125                    var wplc_cookie_name =  jQuery( jQuery.parseHTML( response['cbox'] ) ).find( "#wplc_name" ).val();
126                    var wplc_cookie_email =  jQuery( jQuery.parseHTML( response['cbox'] ) ).find( "#wplc_email" ).val();
127
128                }
129
130
131
132                /* is an agent online? */
133                if (response['online'] === false) {
134                    wplc_run = false;
135                    wplc_online = false;
136                    ns_obj.o = '0';
137
138                } else {
139                    wplc_online = true;
140                    ns_obj.o = '1';
141                }
142
143
144
145                if (wplc_filter_run_override !== "1" || wplc_online === false) { wplc_run = false; } else { /* we can run */ }
146
147
148                /* has this user been assigned an agent? */
149                if (typeof response['type'] === "undefined") {
150                    wplc_shown_welcome = false;
151                } else {
152                    if (response['type'] === "returning") {
153                        wplc_shown_welcome = true;
154                        /* set the agent vars so we can access them on the fly */
155                        if (typeof response['agent_data'] !== "undefined") {
156                            wplc_current_agent = response['agent_data'];
157                        }
158                    } else {
159                        wplc_shown_welcome = false;
160                    }
161
162                }
163
164
165                /*Support mobile loggin*/
166                var wplc_mobile_check = false;
167                if(typeof wplc_is_mobile !== "undefined" && (wplc_is_mobile === "true" || wplc_is_mobile === true)){
168                    wplc_mobile_check = true;
169                }
170
171                /* start long polling */
172                var data = {
173                    action: 'wplc_call_to_server_visitor',
174                    security: wplc_nonce,
175                    cid:wplc_cid,
176                    wplc_name: wplc_cookie_name,
177                    wplc_email: wplc_cookie_email,
178                    status:wplc_chat_status,
179                    wplcsession:wplc_session_variable,
180                    wplc_is_mobile: wplc_mobile_check,
181                    wplc_extra_data:wplc_extra_data
182                };
183
184                if(wplc_server.browserIsSocketReady()){
185                    data.socket = true;
186                    
187                    /** DEPRECATED - Removed for better script loading */
188                    /* 
189                    // load node relay common code 
190                    var nc = document.createElement("script");
191                    nc.type = "text/javascript";
192                    nc.async = true;
193                    nc.src = wplc_baseurl + "/js/wplc_common_node.js";
194                    document.getElementsByTagName("head")[0].appendChild(nc);                
195                    //load node relay code 
196                    nc = document.createElement("script");
197                    nc.type = "text/javascript";
198                    nc.async = true;
199                    nc.src = wplc_baseurl + "/js/wplc_node.js";
200                    document.getElementsByTagName("head")[0].appendChild(nc);
201                    */
202
203                    /* Event added for start chat binding in wplc_node.js */
204                    jQuery.event.trigger({type: 'wplc_sockets_ready'});
205                }
206
207                initial_data = data;
208                // ajax long polling function
209                if (wplc_filter_run_override !== "1" || wplc_online === false) {
210
211                    wplc_call_to_server_chat(data,true,true);
212                } else {
213
214                    wplc_call_to_server_chat(data,true,false);
215                }
216
217                if(wplc_cid !== null   && wplc_init_chat_box_check == true && wplc_init_chat_box !== false){
218
219                    wplc_init_chat_box(wplc_cid,wplc_chat_status);
220                } else {
221                    //Node and offline
222                    if(typeof wplc_use_node_server !== "undefined" && (wplc_use_node_server === "true" || wplc_use_node_server  === true)){
223
224						if(wplc_check_hide_cookie != "yes"){
225							wplc_dc = setTimeout(function (){
226								wplc_cbox_animation();
227							}, parseInt(window.wplc_delay));
228						}
229                    }
230                }
231
232
233            }
234
235        }
236
237    });
238
239    /**
240     * Preload images from the localized variable
241     * @return void
242     */
243    function wplc_preload() {
244        var images = [];
245        if (typeof wplc_preload_images !== "undefined" && typeof wplc_preload_images === "object" ) {
246            var wplc_i = 0;
247            for (var key in wplc_preload_images) {
248                if (wplc_preload_images.hasOwnProperty(key)) {
249                    images[wplc_i] = new Image();
250                    images[wplc_i].src = wplc_preload_images[key];
251                    wplc_i++;
252                }
253            }
254        }
255    }
256
257
258    /**
259     * Detect if the chatbox is being scrolled.
260     *
261     * This had to be created as jQuery does not allow the scroll event to bubble up the DOM tree.
262     *
263     * Thank you Bikal Basnet (https://stackoverflow.com/questions/16505182/bind-scroll-event-to-dynamic-div)
264     *
265     * @param  object el The element in question
266     */
267    function wplc_listenForScrollEvent(el) {
268        el.on("scroll", function(){
269            el.trigger("wplc-custom-scroll");
270        })
271
272    }
273
274
275
276   jQuery("body").on('keyup', '#wplc_email, #wplc_name', function (e) {
277        if (e.keyCode == 13) {
278            jQuery("#wplc_start_chat_btn").trigger("click")
279        }
280    });
281
282   jQuery("body").on("click", "#wplc_end_chat_button", function(e){
283        var data = {
284            security: wplc_nonce,
285            chat_id: wplc_cid,
286            agent_id: 0
287        };
288
289        jQuery(this).hide();
290
291        if(jQuery(this).attr('wplc_disable') === undefined && jQuery(this).attr('wplc_disable') !== 'true'){
292            wplc_rest_api('end_chat', data, 12000, null);
293            jQuery.event.trigger({type: "wplc_end_chat_as_user"});
294        }
295        
296        jQuery(this).attr('wplc_disable', 'true');
297   });
298
299
300   jQuery(document).on("wplc_update_gdpr_last_chat_id", function(e) {
301        jQuery('#wplc_gdpr_remove_data_button,#wplc_gdpr_download_data_button').attr('data-wplc-last-cid', wplc_cid);
302   });
303
304   
305
306    // Fix conflict with Responsive Lighbox plugin
307    setTimeout(function () {
308        if (jQuery('html').hasClass('nivo-lightbox-notouch') || jQuery('a[rel*="lightbox"]').length) {
309            jQuery("body").on("keyup", function (event) {
310                if (event.keyCode === 13) {
311                    jQuery("#wplc_send_msg").trigger("click");
312                }
313            });
314        }
315    }, 5000);
316
317    if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
318        setTimeout(function () {
319            var liveChat4 = jQuery('#wp-live-chat-4');
320            var liveChat = jQuery('#wp-live-chat');
321            if (!liveChat.hasClass('classic')) {
322                jQuery('body').on('click', function (event) {
323                    if (liveChat.hasClass('mobile-active')) {
324                        if (event.target.id !== 'wplc_chatmsg' && event.target.className !== 'wdt-emoji-picker') {
325                            liveChat4.removeClass('is-full-height');
326                        } else {
327                            liveChat4.addClass('is-full-height');
328                        }
329                    }
330                });
331            } else {
332                jQuery('body').on('click', function (event) {
333                    if (liveChat.hasClass('mobile-active')) {
334                        if (event.target.id !== 'wplc_chatmsg' && event.target.className !== 'wdt-emoji-picker') {
335                            liveChat.removeClass('is-full-height');
336                        } else {
337                            liveChat.addClass('is-full-height');
338                        }
339                    }
340                });
341            }
342        }, 500);
343    }
344});
345
346
347function wplc_map_node_variables() {
348    if (typeof wplc_welcome_msg !== "undefined") {
349        welcome_message = wplc_welcome_msg;
350    }
351}
352
353/**
354 * This instantly sends the user the welcome message (i.e. to wait for any agent and start typing so long)
355 *
356 *
357 */
358function wplc_send_welcome_message() {
359    if(wplc_welcome_msg !== "" && !wplc_shown_welcome){
360        message_class = "wplc_system_notification wplc-color-4";
361        var concatenated_message = "<span class='" + message_class + "'>";
362        concatenated_message += wplc_welcome_msg;
363        concatenated_message += "</span>";
364
365        if(typeof wplcFormatParser !== "undefined"){
366            jQuery("#wplc_chatbox").append(wplcFormatParser(concatenated_message));
367        } else{
368            jQuery("#wplc_chatbox").append(concatenated_message);
369        }
370        wplc_scroll_to_bottom();
371
372        wplc_shown_welcome = true;
373    }
374
375}
376
377jQuery(function(){
378    if (wplc_online) {
379        jQuery(document).on('click', '#wp-live-chat-header', function() {
380            jQuery('#speeching_button').html(wplc_pro_sst1);
381            jQuery('#wplc_name').val(wplc_user_default_visitor_name);
382        })
383    } else {
384        jQuery('#wplc_na_msg_btn').val(wplc_pro_offline_btn_send);
385    }
386})
387
388/**
389 * Scrolls the chat box to the bottom
390 *
391 */
392function wplc_scroll_to_bottom() {
393    var height = jQuery('#wplc_chatbox')[0].scrollHeight;
394    jQuery('#wplc_chatbox').scrollTop(height);
395}
396
397
398
399function wplc_user_message_receiver(data){
400    if(typeof wplc_loop_response_handler !== "undefined" && typeof wplc_loop_response_handler === "function"){
401        wplc_loop_response_handler(data, wplc_server_last_loop_data);
402        data = JSON.parse(data);
403        if(typeof data['status'] !== "undefined"){
404            delete wplc_server_last_loop_data.status;
405        }
406
407        if(data.keep_alive === true){
408
409            setTimeout(function(){
410                wplc_server_last_loop_data.status = wplc_chat_status;
411                wplc_call_to_server_chat(wplc_server_last_loop_data);
412            },100);
413        }
414    }
415}
416
417function wplc_user_retry_handler(data){
418    var tstatus = Cookies.get("wplc_chat_status");
419
420    if (tstatus !== "undefined") {
421        if(tstatus !== 8 || tstatus !== 1){
422            wplc_retry_interval = setTimeout(function(){
423
424                wplc_server.prepareTransport(function(){
425                    //Transport ready...
426                    wplc_server_last_loop_data.status = parseInt(tstatus); //Set to existing status
427                    wplc_call_to_server_chat(wplc_server_last_loop_data);
428                }, wplc_user_message_receiver, wplc_user_retry_handler, wplc_log_connection_error);
429
430
431            },500);
432        }
433
434    }
435}
436
437function wplc_call_to_server_chat(data,first_run,short_poll) {
438
439    if (typeof wplc_use_node_server !== "undefined" && wplc_use_node_server === "true") {
440        //not sending to WP
441        return;
442    } else {
443
444
445        if (typeof first_run === "undefined") { first_run = false; };
446        if (typeof short_poll === "undefined") { short_poll = false; };
447        data.first_run = first_run;
448        data.short_poll = short_poll;
449
450        if(typeof Cookies.get('wplc_name') !== "undefined"){
451            data.msg_from_print = Cookies.get('wplc_name');
452        }
453
454        wplc_server_last_loop_data = data;
455
456        wplc_server.send(wplc_ajaxurl, data, "POST", 120000,
457            function(response) {
458                wplc_long_poll_delay = 1500;
459                wplc_loop_response_handler(response, data);
460            },
461            function(jqXHR, exception) {
462                wplc_long_poll_delay = 5000;
463
464                if (jqXHR.status == 404) {
465                    wplc_log_connection_error('Error: Requested page not found. [404]');
466                    wplc_run = false;
467                } else if (jqXHR.status == 500) {
468                    wplc_log_connection_error('Error: Internal Server Error [500].');
469                    wplc_log_connection_error('Retrying in 5 seconds...');
470                    wplc_run = true;
471                } else if (exception === 'parsererror') {
472                    wplc_log_connection_error('Error: Requested JSON parse failed.');
473                    wplc_run = false;
474                } else if (exception === 'abort') {
475                    wplc_log_connection_error('Error: Ajax request aborted.');
476                    wplc_run = false;
477                } else {
478                    wplc_log_connection_error('Error: Uncaught Error.\n' + jqXHR.responseText);
479                    wplc_log_connection_error('Retrying in 5 seconds...');
480                    wplc_run = true;
481                }
482            },
483            function(response){
484                if (wplc_run) {
485                    if(wplc_server.isInSocketMode() === false && wplc_server.isPreparingSocketMode() === false){
486                        setTimeout(function() {
487                            wplc_call_to_server_chat(data,false,false);
488                        }, wplc_long_poll_delay);
489                    } else if ((wplc_server.isInSocketMode() === false && wplc_server.isPreparingSocketMode() === true) && (typeof wplc_transport_prepared !== "undefined" && wplc_transport_prepared === false)) {
490                        /* Allows for initiate chat to work on the node server */
491                        if (typeof wplc_use_node_server !== "undefined" && wplc_use_node_server === "true") {
492                            /* do not run this if using not the node jedi */
493                            setTimeout(function() {
494                                wplc_call_to_server_chat(data,false,true);
495                            }, 7500);
496                        }
497                    } else {
498                        if(typeof response !== "undefined" && typeof response.responseText !== "undefined" && response.responseText !== ""){
499                            var response_data = JSON.parse(response.responseText);
500                            if (typeof wplc_transport_prepared !== "undefined") {
501                                if(wplc_transport_prepared !== true && (parseInt(response_data.status) === 3 || parseInt(response_data.status) === 2)){
502                                    //Transport is unprepared and the user has returned to the page with a status 3/2
503                                    wplc_server.prepareTransport(function(){
504                                        wplc_call_to_server_chat(data,false,false);
505                                    }, wplc_user_message_receiver, wplc_user_retry_handler, wplc_log_connection_error);
506                                }
507                            }
508                        }
509                    }
510                }
511            }
512        );
513    }
514
515};
516
517function wplc_loop_response_handler(response, data){
518    if(response){
519        if (response === "0") { if (window.console) { console.log('WP Live Chat Support Return Error'); } wplc_run = false;  return; }
520        if (typeof response !== "object") {
521            response = JSON.parse(response);
522        }
523
524        data['action_2'] = "";
525        if(typeof response['wplc_name'] !== "undefined"){ data['wplc_name'] = response['wplc_name']; /* Cookies.set('wplc_name', response['wplc_name'], { expires: 1, path: '/' });*/ }
526        if(typeof response['wplc_email'] !== "undefined"){ data['wplc_email'] = response['wplc_email']; /* Cookies.set('wplc_email', response['wplc_email'], { expires: 1, path: '/' }); */ }
527        if(typeof response['cid'] !== "undefined"){ data['cid'] = response['cid']; Cookies.set('wplc_cid', response['cid'], { expires: 1, path: '/' }); }
528        if(typeof response['aname'] !== "undefined") { wplc_agent_name = response['aname']; }
529        if(typeof response['cid'] !== "undefined" && wplc_cid !== jQuery.trim(response['cid'])){ wplc_cid = jQuery.trim(response['cid']);  jQuery("#wplc_cid").val(wplc_cid); }
530        if(typeof response['status'] !== "undefined" && parseInt(wplc_chat_status) !== parseInt(response['status'])){
531            wplc_chat_status = response['status'];
532            Cookies.set('wplc_chat_status', null, { path: '/' });
533            Cookies.set('wplc_chat_status', wplc_chat_status, { expires: 1, path: '/' });
534        }
535
536        /* Trigger for handling responses */
537        jQuery.event.trigger({type: "wplc_user_chat_loop",response:response});
538
539        /* Process status changes */
540        if(data['status'] == response['status']){
541
542            if(data['status'] == 5 && wplc_init_chat_box_check === true && wplc_init_chat_box !== false){ // open chat box on load
543                wplc_init_chat_box(data['cid'], data['status']);
544            }
545            if((response['status'] == 3 || response['status'] == 2) && response['data'] != null){ // if active and data is returned
546                wplc_run = true;
547                var wplc_new_message_sound = false;
548                if (typeof response['data'] === "object") {
549
550                    for (var index in response['data']) {
551                        if(typeof response['data'][index] !== "object"){
552                            if (typeof msg_history[index] === "undefined") {
553                                //Not from node
554                                /* we dont have this message */
555                                msg_history[index] = true;
556
557                                msg_to_parse = response['data'][index].wplcStripSlashes();
558
559                                if(typeof wplcFormatParser !== "undefined"){
560                                    jQuery("#wplc_chatbox").append(wplcFormatParser(msg_to_parse));
561                                } else{
562
563                                    jQuery("#wplc_chatbox").append(response['data'][index].wplcStripSlashes());
564                                }
565
566                                wplc_new_message_sound = true;
567
568                            } else {
569                                /* we already have this message */
570                            }
571                        } else {
572                            var the_message = response['data'][index];
573                            the_message.mid = index;
574                            wplc_push_message_to_chatbox(the_message,'u', function() {
575                                wplc_scroll_to_bottom();
576                            });
577
578							wplc_new_message_sound = true;
579                        }
580                    }
581                }
582                else {
583                    /* backwards compatibility - response['data'] is a string */
584                    if(typeof wplcFormatParser !== "undefined"){
585                        jQuery("#wplc_chatbox").append(wplcFormatParser(response['data'].wplcStripSlashes()));
586                    } else{
587                        jQuery("#wplc_chatbox").append(response['data'].wplcStripSlashes());
588
589                    }
590                    wplc_new_message_sound = true;
591                }
592
593                if(wplc_new_message_sound){
594                    wplc_scroll_to_bottom();
595                    if (typeof wplc_enable_ding !== 'undefined' && wplc_enable_ding === "1") {
596                        new Audio(wplc_plugin_url+'includes/sounds/general/ding.mp3').play();
597                    }
598                }
599            }
600
601        } else {
602            data['status'] = wplc_chat_status;
603            Cookies.set('wplc_chat_status', wplc_chat_status, { expires: 1, path: '/' });
604            if(response['status'] == 0 || response['status'] == 12){ // no answer from admin
605                jQuery("#wp-live-chat-3").hide();
606                if (typeof response['data'] !== "undefined") {
607                    jQuery("#wplc_chatbox").append(response['data'].wplcStripSlashes()+"<hr />");
608                }
609
610            }
611            else if(response['status'] == 8){ // chat has been ended by admin
612                wplc_run = false;
613
614                document.getElementById('wplc_chatmsg').disabled = true;
615                wplc_shown_welcome = false;
616
617                the_message = wplc_generate_system_notification_object(wplc_error_messages.chat_ended_by_operator, {}, 0);
618                wplc_push_message_to_chatbox(the_message,'u', function() {
619                    wplc_scroll_to_bottom();
620                });
621
622
623                jQuery.event.trigger({type: "wplc_end_chat"});
624
625           }
626            else if(parseInt(response['status']) == 11){ /* use moved on to another page (perhaps in another tab so close this instance */
627                jQuery("#wp-live-chat").css({ "display" : "none" });
628                wplc_run = false;
629            }
630            else if(parseInt(response['status']) == 3 || parseInt(response['status']) == 2 || parseInt(response['status']) == 10){ // re-initialize chat
631                wplc_run = true;
632                if(parseInt(response['status']) == 3) { // only if not minimized open aswell
633                    /* HERE NODE */
634
635                    if (typeof wplc_use_node_server !== "undefined" && wplc_use_node_server === "true") {
636                        /* do not run this if using not the node jedi */
637
638                        if (typeof wplc_transport_prepared !== "undefined" && wplc_transport_prepared === false) {
639                           wplc_server.prepareTransport(function(){
640                                wplc_call_to_server_chat(wplc_server_last_loop_data,false,false);
641                            }, wplc_user_message_receiver, wplc_user_retry_handler, wplc_log_connection_error);
642                        }
643                    }
644                    if (!wplc_is_minimized) {
645                        if (!wplc_is_chat_open) {
646                            wplc_cbox_animation();
647                            setTimeout(function() {
648                                open_chat(0);
649                            },1500);
650                        }
651                    }
652
653
654                    if(jQuery('#wp-live-chat').hasClass('wplc_left') === true || jQuery('#wp-live-chat').hasClass('wplc_right') === true){
655                        //jQuery('#wp-live-chat').height("400px");
656                    }
657                }
658                if(parseInt(response['status']) == 10) { // only if not minimized open aswell
659                    wplc_run = true;
660                    open_chat(0);
661
662                }
663                if(response['data'] != null){ // append messages to chat area
664                    if (typeof response['data'] === "object") {
665
666                        for (var index in response['data']) {
667                            wplc_new_message_sound = false;
668                            if(typeof response['data'][index] !== "object"){
669
670                                if (typeof msg_history[index] === "undefined") {
671                                    /* we dont have this message */
672                                    msg_history[index] = true;
673                                    if(typeof wplcFormatParser !== "undefined"){
674                                        jQuery("#wplc_chatbox").append(wplcFormatParser(response['data'][index].wplcStripSlashes()));
675                                    } else{
676                                        jQuery("#wplc_chatbox").append(response['data'][index].wplcStripSlashes());
677                                    }
678
679                                    wplc_new_message_sound = true;
680                                } else {
681                                        /* we already have this message */
682                                }
683                            } else {
684                                var the_message = response['data'][index];
685                                the_message.mid = index;
686                                wplc_push_message_to_chatbox(the_message,'u', function() {
687                                    wplc_scroll_to_bottom();
688                                });
689
690
691                            }
692
693                            if(wplc_new_message_sound){
694                                if (response['alert']) {
695                                    jQuery('#wplc-chat-alert').addClass('is-active');
696                                }
697                                wplc_scroll_to_bottom();
698                                if (typeof wplc_enable_ding !== 'undefined' && wplc_enable_ding === "1") {
699                                    new Audio(wplc_plugin_url+'ding.mp3').play();
700                                }
701                            }
702                        }
703                    }
704                    else {
705                        /* backwards compatibility - response['data'] is a string */
706                        if(typeof wplcFormatParser !== "undefined"){
707                            jQuery("#wplc_chatbox").append(wplcFormatParser(response['data'].wplcStripSlashes()));
708                        } else{
709                            jQuery("#wplc_chatbox").append(response['data'].wplcStripSlashes());
710
711                        }
712                    }
713
714                    if(response['data']){
715                        wplc_scroll_to_bottom();
716
717                    }
718                }
719            }
720        }
721    }
722}
723
724
725
726function wplc_log_connection_error(error){
727    if (window.console) { console.log(error); }
728
729    jQuery("#wplc_chatbox").append("<small>" + error + "</small><br>");
730    wplc_scroll_to_bottom();
731}
732
733function wplc_display_error(error) {
734
735    the_message = {};
736    the_message.originates = 2;
737    the_message.msg = error;
738    the_message.other = {};
739    var wplc_d = new Date();
740    the_message.other.datetime = Math.round( wplc_d.getTime() / 1000 );
741    wplc_push_message_to_chatbox(the_message,'u', function() {
742        wplc_scroll_to_bottom();
743    });
744
745
746
747}
748
749var wplc_init_chat_box = function(cid, status){
750    if(wplc_chat_status == 9 && wplc_check_hide_cookie == "yes"){
751    } else if (wplc_chat_status === 3) {
752        wplc_cbox_animation();
753    } else {
754
755        if(wplc_check_hide_cookie != "yes"){
756            wplc_dc = setTimeout(function (){
757                wplc_cbox_animation();
758            }, parseInt(window.wplc_delay));
759        }
760    }
761    wplc_init_chat_box = false;
762    jQuery.event.trigger({type: "wplc_init_complete"});
763}
764
765function wplc_cbox_animation() {
766    /*
767     * 1- Slide Up
768     * 2- Slide Across (Left/Right)
769     * 3- Slide Down
770     * 4- Fade In
771     */
772
773
774    var wplc_window_id = jQuery("#wp-live-chat");
775
776    var wplc_theme_chosen = jQuery(wplc_window_id).attr('wplc_animation');
777
778    switch(wplc_theme_chosen){
779        case 'none':
780            jQuery(wplc_window_id).css('display', 'block');
781            break;
782        case 'animation-1':
783            // Slide Up
784            jQuery(wplc_window_id).animate({'marginBottom' : '0px'}, 1000);
785            break;
786        case 'animation-2-bl':
787            // Slide Accross from left
788            jQuery(wplc_window_id).animate({'left' : '20px'}, 1000);
789            break;
790        case 'animation-2-br':
791            // Slide Accross from right
792            jQuery(wplc_window_id).animate({'right' : '20px'}, 1000);
793            break;
794        case 'animation-2-l':
795            // Slide Accross from left
796            jQuery(wplc_window_id).animate({"left" : '0px'}, 1000);
797            break;
798        case 'animation-2-r':
799
800            // Slide Accross from right
801            jQuery(wplc_window_id).animate({'right' : '0px'}, 1000);
802            break;
803        case 'animation-3':
804            // Fade In
805            jQuery(wplc_window_id).fadeIn('slow');
806        case 'animation-4':
807            jQuery(wplc_window_id).css('display', 'block');
808            break;
809        default:
810            jQuery(wplc_window_id).css('display', 'block');
811            break;
812    }
813
814    //jQuery("#wp-live-chat").css({ "display" : "block" });
815    if(jQuery("#wp-live-chat").attr('wplc-auto-pop-up') === "1"){
816
817        var wplc_force_must_min = Cookies.get('wplc_minimize');
818        if(wplc_force_must_min === 'yes'){
819            /* User has actively chosen to minimize the chat, leave it alone */
820        } else {
821            setTimeout(function(){
822                open_chat(0);
823            },1000);
824            /**
825             * Adding this fixes the bug that stops the chat window from opening when an agent initialises a chat with a user
826             *
827             * Reasoning: when running open_chat(), wplc_is_chat_open is set to TRUE at the end of the function, and stops any future request to open_chat();
828             *
829             */
830            wplc_is_chat_open = false;
831        }
832    }
833
834    jQuery.event.trigger({type: "wplc_animation_done"});
835}
836
837
838function wplc_sound(source,volume,loop) {
839    this.source=source;
840    this.volume=volume;
841    this.loop=loop;
842    var son;
843    this.son=son;
844    this.finish=false;
845    this.stop=function()
846    {
847        document.body.removeChild(this.son);
848    }
849    this.start=function()
850    {
851        if(this.finish)return false;
852        this.son=document.createElement("embed");
853        this.son.setAttribute("src",this.source);
854        this.son.setAttribute("hidden","true");
855        this.son.setAttribute("volume",this.volume);
856        this.son.setAttribute("autostart","true");
857        this.son.setAttribute("loop",this.loop);
858        document.body.appendChild(this.son);
859    }
860    this.remove=function()
861    {
862        document.body.removeChild(this.son);
863        this.finish=true;
864    }
865    this.init=function(volume,loop)
866    {
867        this.finish=false;
868        this.volume=volume;
869        this.loop=loop;
870    }
871}
872
873
874function wplc_strip(str) {
875    str=str.replace(/<br>/gi, "\n");
876    str=str.replace(/<p.*>/gi, "\n");
877    str=str.replace(/<a.*href="(.*?)".*>(.*?)<\/a>/gi, " $2 ($1) ");
878    str=str.replace(/<(?:.|\s)*?>/g, "");
879
880    str=str.replace('iframe', "");
881    str=str.replace('src', "");
882    str=str.replace('href', "");
883    str=str.replace('<', "");
884    str=str.replace('>', "");
885
886    /* remove the last carriage return from the text area output */
887    str=str.replace(/\n$/, "")
888
889    return str;
890}
891
892(function($) {
893
894	$(function(event) {
895
896		if(!window.wdtEmojiBundle)
897			return;
898
899		$(document.body).on("click", function(event) {
900
901			// If click event isn't on the emoji window, or the emoji open button, close the emoji window
902			if($(event.target).closest(".wdt-emoji-picker, .wdt-emoji-popup").length == 0 && !(
903				event.target.parentNode == null && $(event.target).hasClass("fa-smile-o")
904				))
905				wdtEmojiBundle.close();
906
907		});
908
909		// Close emoji window on scroll
910		$(window).scroll(function(event) {
911			wdtEmojiBundle.close();
912		});
913	});
914
915})(jQuery);

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.