PageSourceSearch

https://bennevis.co.uk/wp-content/plugins/wp-listings-directory/assets/js/main.js?ver=20131022

js bennevis.co.uk collected 2026-10-02 12:15:16 UTC 65,605 bytes, 1,420 lines download raw bytes

1(function ($) {
2    "use strict";
3
4    if (!$.wpldExtensions)
5        $.wpldExtensions = {};
6    
7    function WPLDMainCore() {
8        var self = this;
9        self.init();
10    };
11
12    WPLDMainCore.prototype = {
13        /**
14         *  Initialize
15         */
16        init: function() {
17            var self = this;
18
19            self.fileUpload($('.label-can-drag'));
20            
21            self.recaptchaCallback();
22
23            self.submitListing();
24
25            self.userLoginRegister();
26
27            self.userChangePass();
28            
29            self.removeListing();
30
31            // favorite
32            self.addListingFavorite();
33
34            self.removeListingFavorite();
35            
36
37            // compare
38            self.addListingCompare();
39
40            self.removeListingCompare();
41
42            self.reviewInit();
43
44            self.listingSavedSearch();
45
46            self.select2Init();
47            
48            self.filterListing();
49
50            // listing detail
51            self.listingChartInit();
52
53            self.listingNearbyYelp();
54
55            self.listingNearbyGooglePlaces();
56
57            self.listingWalkScore();
58
59            // mixes
60            self.mixesFn();
61
62            self.loadExtension();
63        },
64        loadExtension: function() {
65            var self = this;
66            
67            // if ($.wpldExtensions.ajax_upload) {
68            //     $.wpldExtensions.ajax_upload.call(self);
69            // }
70        },
71        recaptchaCallback: function() {
72            if ( wp_listings_directory_opts.recaptcha_enable ) {
73                if (!window.grecaptcha) {
74                } else {
75                    setTimeout(function(){
76                        var recaptchas = document.getElementsByClassName("ga-recaptcha");
77                        for(var i=0; i<recaptchas.length; i++) {
78                            var recaptcha = recaptchas[i];
79                            var sitekey = recaptcha.dataset.sitekey;
80
81                            grecaptcha.render(recaptcha, {
82                                'sitekey' : sitekey
83                            });
84                        }
85                    }, 500);
86                }
87            }
88        },
89        fileUpload: function($el){
90            
91            var isAdvancedUpload = function() {
92                var div = document.createElement('div');
93                return (('draggable' in div) || ('ondragstart' in div && 'ondrop' in div)) && 'FormData' in window && 'FileReader' in window;
94            }();
95
96            if (isAdvancedUpload) {
97
98                var droppedFiles = false;
99                $el.each(function(){
100                    var label_self = $(this);
101                    label_self.on('drag dragstart dragend dragover dragenter dragleave drop', function(e) {
102                        e.preventDefault();
103                        e.stopPropagation();
104                    }).on('dragover dragenter', function() {
105                        label_self.addClass('is-dragover');
106                    }).on('dragleave dragend drop', function() {
107                        label_self.removeClass('is-dragover');
108                    }).on('drop', function(e) {
109                        droppedFiles = e.originalEvent.dataTransfer.files;
110                        label_self.parent().find('input[type="file"]').prop('files', droppedFiles).trigger('change');
111                    });
112                });
113            }
114            $(document).on('click', '.label-can-drag', function(){
115                $(this).parent().find('input[type="file"]').trigger('click');
116            });
117        },
118        submitListing: function() {
119            var self = this;
120            $('.cmb-repeatable-group').on('cmb2_add_row', function (event, newRow) {
121
122                // Reinitialise the field we previously destroyed
123                $(newRow).find('.label-can-drag').each(function () {
124                    self.fileUpload($(this));
125                });
126
127            });
128        },
129        userLoginRegister: function() {
130            var self = this;
131            
132            // sign in proccess
133            $('body').on('submit', 'form.login-form', function(){
134                var $this = $(this);
135                $('.alert', this).remove();
136                $this.addClass('loading');
137                $.ajax({
138                    url: wp_listings_directory_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_listings_directory_ajax_login' ),
139                    type:'POST',
140                    dataType: 'json',
141                    data:  $(this).serialize()+"&action=wp_listings_directory_ajax_login"
142                }).done(function(data) {
143                    $this.removeClass('loading');
144                    if ( data.status ) {
145                        $this.prepend( '<div class="alert alert-info">' + data.msg + '</div>' );
146                        setTimeout(function(){
147                            window.location.href = wp_listings_directory_opts.after_login_page_user_url;
148                            
149                        }, 500);
150                    } else {
151                        $this.prepend( '<div class="alert alert-warning">' + data.msg + '</div>' );
152                    }
153                });
154                return false; 
155            } );
156            $('body').on('click', '.back-link', function(e){
157                e.preventDefault();
158                var $con = $(this).closest('.login-form-wrapper');
159                $con.find('.form-container').hide();
160                $($(this).attr('href')).show(); 
161                return false;
162            } );
163
164             // lost password in proccess
165            $('body').on('submit', 'form.forgotpassword-form', function(){
166                var $this= $(this);
167                $('.alert', this).remove();
168                $this.addClass('loading');
169                $.ajax({
170                  url: wp_listings_directory_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_listings_directory_ajax_forgotpass' ),
171                  type:'POST',
172                  dataType: 'json',
173                  data:  $(this).serialize()+"&action=wp_listings_directory_ajax_forgotpass"
174                }).done(function(data) {
175                     $this.removeClass('loading');
176                    if ( data.status ) {
177                        $this.prepend( '<div class="alert alert-info">'+data.msg+'</div>' );
178                        setTimeout(function(){
179                            window.location.reload(true);
180                        }, 500);
181                    } else {
182                        $this.prepend( '<div class="alert alert-warning">'+data.msg+'</div>' );
183                    }
184                });
185                return false; 
186            } );
187            $('body').on('click', '#forgot-password-form-wrapper form .btn-cancel', function(e){
188                e.preventDefault();
189                $('#forgot-password-form-wrapper').hide();
190                $('#login-form-wrapper').show();
191            } );
192
193
194            // register
195            var register_step = '1';
196            $('body').on('submit', 'form.register-form', function(){
197                var $this = $(this),
198                    $parent_div = $this.closest('.register-form-wrapper');
199                $('.alert', this).remove();
200                if ( $this.hasClass('loading') ) {
201                    return;
202                }
203                $this.addClass('loading');
204
205                var action = 'wp_listings_directory_ajax_register';
206                if ( wp_listings_directory_opts.approval_type === 'phone_approve' ) {
207                    if ( register_step == '1' ) {
208                        action = 'wp_listings_directory_ajax_get_opt'
209                    }
210                }
211                $.ajax({
212                    url: wp_listings_directory_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', action ),
213                    type:'POST',
214                    dataType: 'json',
215                    data:  $(this).serialize()+"&action=" + action
216                }).done(function(data) {
217                    $this.removeClass('loading');
218                    if ( data.status ) {
219                        if ( wp_listings_directory_opts.approval_type === 'phone_approve' ) {
220                            if ( register_step == '1' ) {
221                                $this.hide();
222                                var $otp_form = $parent_div.find('form.register-form-otp');
223                                $otp_form.find('.sent-txt .no-txt').html(data.msg);
224                                $otp_form.show();
225
226                                var $resendLink     = $otp_form.find('.resend-link'),
227                                    $timer          = $otp_form.find('.resend-timer'),
228                                    resendTime      = parseInt( wp_listings_directory_opts.resend_otp_wait_time );
229
230                                if( resendTime > 0 ) {
231                                    $resendLink.addClass('disabled');
232                                    var resendTimer;
233                                    clearInterval( resendTimer );
234
235                                    resendTimer = setInterval(function(){
236                                        $timer.html('('+resendTime+')');
237                                        if( resendTime <= 0 ){
238                                            clearInterval( resendTimer );
239                                            $resendLink.removeClass('disabled');
240                                            $timer.html('');
241                                        }
242                                        resendTime--;
243                                    },1000);
244                                }
245
246                            } else if ( register_step == '2' ) {
247                                $this.prepend( '<div class="alert alert-info">'+data.msg+'</div>' );
248                                if ( data.redirect ) {
249                                    setTimeout(function(){
250                                        window.location.href = wp_listings_directory_opts.after_login_page_user_url;
251                                    }, 500);
252                                }
253                            }
254                        } else {
255                            $this.prepend( '<div class="alert alert-info">'+data.msg+'</div>' );
256                            if ( data.redirect ) {
257                                setTimeout(function(){
258                                    window.location.href = wp_listings_directory_opts.after_login_page_user_url;
259                                }, 500);
260                            }
261                        }
262                    } else {
263                        $this.prepend( '<div class="alert alert-warning">'+data.msg+'</div>' );
264                        if ( wp_listings_directory_opts.recaptcha_enable ) {
265                            if (!window.grecaptcha) {
266                            } else {
267                                grecaptcha.reset();
268                            }
269                        }
270                    }
271                });
272                return false;
273            } );
274            
275            // verify otp
276            $('body').on('submit', 'form.register-form-otp', function(){
277                var $this = $(this),
278                    $parent_div = $this.closest('.register-form-wrapper'),
279                    $register_form = $parent_div.find('form.register-form');
280
281                if ( $this.hasClass('loading') ) {
282                    return;
283                }
284                $('.alert', this).remove();
285                $this.addClass('loading');
286
287                var otp = '';
288                $this.find('.otp-input-cont input').each( function( index, input ){
289                    otp += $(this).val();
290                });
291
292                var form_data = {
293                    'otp': otp,
294                    'token': $register_form.find('.register-form-token').val(),
295                }
296
297                $.ajax({
298                    url: wp_listings_directory_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_listings_directory_ajax_verify_opt' ),
299                    type:'POST',
300                    dataType: 'json',
301                    data: form_data
302                }).done(function(data) {
303                    $this.removeClass('loading');
304                    if ( data.status ) {
305                        register_step = '2';
306                        $this.hide();
307                        $register_form.show().trigger('submit');
308                    } else {
309                        $this.prepend( '<div class="alert alert-warning">'+data.msg+'</div>' );
310                    }
311                });
312                return false;
313            } );
314
315            //Switch Input
316            $('.otp-input-cont input.otp-input').on('keyup', function(){
317                console.log('aaa');
318                if( $(this).val().length === parseInt( $(this).attr('maxlength') ) && $(this).next('input.otp-input').length !== 0 ){
319                    $(this).next('input.otp-input').focus();
320                }
321
322                //Backspace is pressed
323                if( $(this).val().length === 0 && event.keyCode == 8 && $(this).prev('input.otp-input').length !== 0 ){
324                    $(this).prev('input.otp-input').focus().val('');
325                }
326            });
327
328            // resend otp
329            $('body').on('click', '.resend-link:not(.disabled)', function(){
330                var $this = $(this),
331                    $parent_div = $this.closest('.register-form-wrapper'),
332                    $otp_form = $this.closest('form');
333
334                if ( $otp_form.hasClass('loading') ) {
335                    return;
336                }
337                $('.alert', this).remove();
338                $otp_form.addClass('loading');
339
340                $.ajax({
341                    url: wp_listings_directory_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_listings_directory_ajax_resend_opt' ),
342                    type:'POST',
343                    dataType: 'json',
344                }).done(function(data) {
345                    $otp_form.removeClass('loading');
346                    if ( data.status ) {
347
348                        var $resendLink     = $otp_form.find('.resend-link'),
349                            $timer          = $otp_form.find('.resend-timer'),
350                            resendTime      = parseInt( wp_listings_directory_opts.resend_otp_wait_time );
351
352                        if( resendTime > 0 ) {
353                            $resendLink.addClass('disabled');
354                            var resendTimer;
355                            clearInterval( resendTimer );
356
357                            resendTimer = setInterval(function(){
358                                $timer.html('('+resendTime+')');
359                                if( resendTime <= 0 ){
360                                    clearInterval( resendTimer );
361                                    $resendLink.removeClass('disabled');
362                                    $timer.html('');
363                                }
364                                resendTime--;
365                            },1000);
366                        }
367
368                    } else {
369                        $this.prepend( '<div class="alert alert-warning">'+data.msg+'</div>' );
370                    }
371                });
372                return false;
373            } );
374
375            $(document).on('click', 'form.register-form-otp .no-change', function(){
376                var $this = $(this);
377                var $parent_div = $this.closest('.register-form-wrapper');
378                $this.closest('form').hide();
379                register_step = '1';
380                $parent_div.find('form.register-form').show();
381            });
382
383            // wp-listings-directory-resend-approve-account-btn
384            $(document).on('click', '.wp-listings-directory-resend-approve-account-btn', function(e) {
385                e.preventDefault();
386                var $this = $(this),
387                    $container = $(this).parent();
388                $this.addClass('loading');
389                $.ajax({
390                    url: wp_listings_directory_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_listings_directory_ajax_resend_approve_account' ),
391                    type:'POST',
392                    dataType: 'json',
393                    data: {
394                        action: 'wp_listings_directory_ajax_resend_approve_account',
395                        login: $this.data('login'),
396                    }
397                }).done(function(data) {
398                    $this.removeClass('loading');
399                    if ( data.status ) {
400                        $container.html( data.msg );
401                    } else {
402                        $container.html( data.msg );
403                    }
404                });
405            });
406
407        },
408        userChangePass: function() {
409            var self = this;
410            $('body').on('submit', 'form.change-password-form', function(){
411                var $this = $(this);
412                $('.alert', this).remove();
413                $this.addClass('loading');
414                $.ajax({
415                    url: wp_listings_directory_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_listings_directory_ajax_change_password' ),
416                    type:'POST',
417                    dataType: 'json',
418                    data:  $(this).serialize()+"&action=wp_listings_directory_ajax_change_password"
419                }).done(function(data) {
420                    $this.removeClass('loading');
421                    if ( data.status ) {
422                        $this.prepend( '<div class="alert alert-info">' + data.msg + '</div>' );
423                        setTimeout(function(){
424                            window.location.href = wp_listings_directory_opts.login_register_url;
425                        }, 500);
426                    } else {
427                        $this.prepend( '<div class="alert alert-warning">' + data.msg + '</div>' );
428                    }
429                });
430                return false; 
431            } );
432        },
433        removeListing: function() {
434            var self = this;
435            $('.listing-button-delete').on('click', function() {
436                var $this = $(this);
437                var r = confirm( wp_listings_directory_opts.rm_item_txt );
438                if ( r == true ) {
439                    $this.addClass('loading');
440                    var listing_id = $(this).data('listing_id');
441                    var nonce = $(this).data('nonce');
442                    $.ajax({
443                        url: wp_listings_directory_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_listings_directory_ajax_remove_listing' ),
444                        type:'POST',
445                        dataType: 'json',
446                        data: {
447                            'listing_id': listing_id,
448                            'nonce': nonce,
449                            'action': 'wp_listings_directory_ajax_remove_listing',
450                        }
451                    }).done(function(data) {
452                        $this.removeClass('loading');
453                        if ( data.status ) {
454                            $this.closest('.my-listings-item').remove();
455                        }
456                        self.showMessage(data.msg, data.status);
457                    });
458                }
459            });
460        },
461        addListingFavorite: function() {
462            var self = this;
463            $(document).on('click', '.btn-add-listing-favorite', function() {
464                var $this = $(this);
465                $this.addClass('loading');
466                var listing_id = $(this).data('listing_id');
467                var nonce = $(this).data('nonce');
468                $.ajax({
469                    url: wp_listings_directory_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_listings_directory_ajax_add_listing_favorite' ),
470                    type:'POST',
471                    dataType: 'json',
472                    data: {
473                        'listing_id': listing_id,
474                        'nonce': nonce,
475                        'action': 'wp_listings_directory_ajax_add_listing_favorite',
476                    }
477                }).done(function(data) {
478                    $this.removeClass('loading');
479                    if ( data.status ) {
480                        $this.removeClass('btn-add-listing-favorite').addClass('btn-added-listing-favorite');
481                        $this.data('nonce', data.nonce);
482
483                        $(document).trigger( "after_add_listing_favorite", [$this, data] );
484                    }
485                    self.showMessage(data.msg, data.status);
486                });
487            });
488        },
489        removeListingFavorite: function() {
490            var self = this;
491            $(document).on('click', '.btn-added-listing-favorite', function() {
492                var $this = $(this);
493                $this.addClass('loading');
494                var listing_id = $(this).data('listing_id');
495                var nonce = $(this).data('nonce');
496                $.ajax({
497                    url: wp_listings_directory_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_listings_directory_ajax_remove_listing_favorite' ),
498                    type:'POST',
499                    dataType: 'json',
500                    data: {
501                        'listing_id': listing_id,
502                        'nonce': nonce,
503                        'action': 'wp_listings_directory_ajax_remove_listing_favorite',
504                    }
505                }).done(function(data) {
506                    $this.removeClass('loading');
507                    if ( data.status ) {
508                        $this.removeClass('btn-added-listing-favorite').addClass('btn-add-listing-favorite');
509                        $this.data('nonce', data.nonce);
510
511                        $(document).trigger( "after_remove_listing_favorite", [$this, data] );
512                    }
513                    self.showMessage(data.msg, data.status);
514                });
515            });
516
517            $('.btn-remove-listing-favorite').on('click', function() {
518                var $this = $(this);
519                $this.addClass('loading');
520                var listing_id = $(this).data('listing_id');
521                var nonce = $(this).data('nonce');
522                $.ajax({
523                    url: wp_listings_directory_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_listings_directory_ajax_remove_listing_favorite' ),
524                    type:'POST',
525                    dataType: 'json',
526                    data: {
527                        'listing_id': listing_id,
528                        'nonce': nonce,
529                        'action': 'wp_listings_directory_ajax_remove_listing_favorite',
530                    }
531                }).done(function(data) {
532                    $this.removeClass('loading');
533                    if ( data.status ) {
534                        $this.closest('.listing-favorite-wrapper').remove();
535
536                        $(document).trigger( "after_remove_listing_favorite", [$this, data] );
537                    }
538                    self.showMessage(data.msg, data.status);
539                });
540            });
541        },
542        // compare
543        addListingCompare: function() {
544            var self = this;
545            $(document).on('click', '.btn-add-listing-compare', function() {
546                var $this = $(this);
547                $this.addClass('loading');
548                var listing_id = $(this).data('listing_id');
549                var nonce = $(this).data('nonce');
550                $.ajax({
551                    url: wp_listings_directory_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_listings_directory_ajax_add_listing_compare' ),
552                    type:'POST',
553                    dataType: 'json',
554                    data: {
555                        'listing_id': listing_id,
556                        'nonce': nonce,
557                        'action': 'wp_listings_directory_ajax_add_listing_compare',
558                    }
559                }).done(function(data) {
560                    $this.removeClass('loading');
561                    if ( data.status ) {
562                        $this.removeClass('btn-add-listing-compare').addClass('btn-added-listing-compare');
563                        $this.data('nonce', data.nonce);
564
565                        $(document).trigger( "after_add_listing_compare", [$this, data] );
566                    }
567                    self.showMessage(data.msg, data.status);
568                });
569            });
570        },
571        removeListingCompare: function() {
572            var self = this;
573            $(document).on('click', '.btn-added-listing-compare', function() {
574                var $this = $(this);
575                $this.addClass('loading');
576                var listing_id = $(this).data('listing_id');
577                var nonce = $(this).data('nonce');
578                $.ajax({
579                    url: wp_listings_directory_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_listings_directory_ajax_remove_listing_compare' ),
580                    type:'POST',
581                    dataType: 'json',
582                    data: {
583                        'listing_id': listing_id,
584                        'nonce': nonce,
585                        'action': 'wp_listings_directory_ajax_remove_listing_compare',
586                    }
587                }).done(function(data) {
588                    $this.removeClass('loading');
589                    if ( data.status ) {
590                        $this.removeClass('btn-added-listing-compare').addClass('btn-add-listing-compare');
591                        $this.data('nonce', data.nonce);
592
593                        $(document).trigger( "after_remove_listing_compare", [$this, data] );
594                    }
595                    self.showMessage(data.msg, data.status);
596                });
597            });
598
599            $('.btn-remove-listing-compare').on('click', function() {
600                var $this = $(this);
601                $this.addClass('loading');
602                var listing_id = $(this).data('listing_id');
603                var nonce = $(this).data('nonce');
604                $.ajax({
605                    url: wp_listings_directory_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_listings_directory_ajax_remove_listing_compare' ),
606                    type:'POST',
607                    dataType: 'json',
608                    data: {
609                        'listing_id': listing_id,
610                        'nonce': nonce,
611                        'action': 'wp_listings_directory_ajax_remove_listing_compare',
612                    }
613                }).done(function(data) {
614                    $this.removeClass('loading');
615                    if ( data.status ) {
616                        location.reload();
617                    }
618                    self.showMessage(data.msg, data.status);
619                });
620            });
621        },
622        reviewInit: function() {
623            var self = this;
624            
625            if ( $('.comment-form-rating').length > 0 ) {
626                $('.comment-form-rating .rating-inner').each(function(){
627                    var e_this = $(this);
628                    var $star = e_this.find('.review-stars');
629                    var $review = e_this.find('input.rating');
630                    $star.find('li').on('mouseover',
631                        function () {
632                            $(this).nextAll().find('span').removeClass('active');
633                            $(this).prevAll().find('span').removeClass('active').addClass('active');
634                            $(this).find('span').removeClass('active').addClass('active');
635                        }
636                    );
637                    $star.on('mouseout', function(){
638                        var current = $review.val() - 1;
639                        var current_e = $star.find('li').eq(current);
640
641                        current_e.nextAll().find('span').removeClass('active');
642                        current_e.prevAll().find('span').removeClass('active').addClass('active');
643                        current_e.find('span').removeClass('active').addClass('active');
644                    });
645
646                    $star.find('li').on('click', function () {
647                        $(this).nextAll().find('span').removeClass('active');
648                        $(this).prevAll().find('span').removeClass('active').addClass('active');
649                        $(this).find('span').removeClass('active').addClass('active');
650                        
651                        $review.val($(this).index() + 1);
652                    } );
653
654                });
655            }
656
657            // images
658            var self = this;
659            // file attachments
660            $('#field_attachments_cover').on('click', function(){
661                $("#field_attachments").trigger('click');
662            });
663            $('#field_attachments').on('change', function() {
664                $('.group-upload-preview').html('');
665                self.imagesPreview(this, 'div.group-upload-preview');
666                $('.group-upload-preview').css("display","block");
667            });
668
669            var isAdvancedUpload = function() {
670                var div = document.createElement('div');
671                return (('draggable' in div) || ('ondragstart' in div && 'ondrop' in div)) && 'FormData' in window && 'FileReader' in window;
672            }();
673
674            if (isAdvancedUpload) {
675                var droppedFiles = false;
676                
677                $('#field_attachments_cover').on('drag dragstart dragend dragover dragenter dragleave drop', function(e) {
678                    e.preventDefault();
679                    e.stopPropagation();
680                }).on('dragover dragenter', function() {
681                    $('#field_attachments_cover').addClass('is-dragover');
682                }).on('dragleave dragend drop', function() {
683                    $('#field_attachments_cover').removeClass('is-dragover');
684                }).on('drop', function(e) {
685                    droppedFiles = e.originalEvent.dataTransfer.files;
686                    $('#field_attachments').prop('files', droppedFiles).trigger('change');
687                });
688            }
689
690            $('.comment-attactments').each(function(){
691                var $this = $(this);
692                $('.show-more-images', $this).on('click', function(){
693                    $('.attachment', $this).removeClass('hidden');
694                    $(this).addClass('hidden');
695                    // initProductImageLoad();
696                });
697            });
698        },
699        imagesPreview: function(input, placeToInsertImagePreview) {
700            if (input.files) {
701                var filesAmount = input.files.length;
702                
703                for (var i = 0; i < filesAmount; i++) {
704                    var reader = new FileReader();
705                    reader.onload = function(event) {
706                        $($.parseHTML('<img>')).attr('src', event.target.result).appendTo(placeToInsertImagePreview);
707                    }
708                    reader.readAsDataURL(input.files[i]);
709                }
710            }
711        },
712        listingSavedSearch: function() {
713            var self = this;
714            $('.btn-saved-search').magnificPopup({
715                mainClass: 'wp-listings-directory-mfp-container',
716                type:'inline',
717                midClick: true
718            });
719            
720            $(document).on('submit', 'form.saved-search-form', function() {
721                var $this = $(this);
722                if ( $this.hasClass('loading') ) {
723                    return false;
724                }
725                
726                $this.find('.alert').remove();
727                
728                $this.addClass('loading');
729                var url_vars = self.getUrlVars();
730                $.ajax({
731                    url: wp_listings_directory_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_listings_directory_ajax_add_saved_search' ),
732                    type:'POST',
733                    dataType: 'json',
734                    data: $this.serialize() + '&action=wp_listings_directory_ajax_add_saved_search' + url_vars
735                }).done(function(data) {
736                    $this.removeClass('loading');
737                    if ( data.status ) {
738                        $this.prepend( '<div class="alert alert-info">'+data.msg+'</div>' );
739                        setTimeout(function(){
740                            $.magnificPopup.close();
741                        }, 1500);
742                    } else {
743                        $this.prepend( '<div class="alert alert-warning">'+data.msg+'</div>' );
744                    }
745                });
746
747                return false;
748            });
749
750            // Remove listing alert
751            $(document).on('click', '.btn-remove-saved-search', function() {
752                var $this = $(this);
753                $this.addClass('loading');
754                var saved_search_id = $(this).data('saved_search_id');
755                var nonce = $(this).data('nonce');
756                $.ajax({
757                    url: wp_listings_directory_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_listings_directory_ajax_remove_saved_search' ),
758                    type:'POST',
759                    dataType: 'json',
760                    data: {
761                        'saved_search_id': saved_search_id,
762                        'nonce': nonce,
763                        'action': 'wp_listings_directory_ajax_remove_saved_search',
764                    }
765                }).done(function(data) {
766                    $this.removeClass('loading');
767                    if ( data.status ) {
768                        $this.closest('.saved-search-wrapper').remove();
769                    }
770                    self.showMessage(data.msg, data.status);
771                });
772            });
773        },
774        getUrlVars: function() {
775            var self = this;
776            var vars = '';
777            var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
778            for(var i = 0; i < hashes.length; i++) {
779                vars += '&' +hashes[i];
780            }
781            return vars;
782        },
783        select2Init: function() {
784            var self = this;
785            if ( $.isFunction( $.fn.select2 ) && typeof wp_listings_directory_select2_opts !== 'undefined' ) {
786                var select2_args = wp_listings_directory_select2_opts;
787                select2_args['allowClear']              = false;
788                select2_args['minimumResultsForSearch'] = 10;
789                select2_args['width'] = 'auto';
790
791                select2_args['language'] = {
792                    noResults: function(){
793                        return wp_listings_directory_select2_opts.language_result;
794                    }
795                };
796
797                if($('select').hasClass('orderby')){
798                    select2_args.theme = 'default orderby';
799                    $('select.orderby').select2( select2_args );
800                }
801                $('select.listing_id').select2( select2_args );
802            }
803        },
804        filterListing: function() {
805            var self = this;
806
807            $(document).on('click', 'form .toggle-field .heading-label', function(){
808                var container = $(this).closest('.form-group');
809                container.find('.form-group-inner').slideToggle();
810                if ( container.hasClass('hide-content') ) {
811                    container.removeClass('hide-content');
812                } else {
813                    container.addClass('hide-content');
814                }
815
816                $(document).trigger( "after-toggle-filter-field", [$(this), container] );
817            });
818            $(document).on('click', '.toggle-filter-list', function() {
819                var $this = $(this);
820                var container = $(this).closest('.form-group');
821                container.find('.terms-list .more-fields').each(function(){
822                    if ( $(this).hasClass('active') ) {
823                        $(this).removeClass('active');
824                        $this.find('.text').text(wp_listings_directory_opts.show_more);
825                    } else {
826                        $(this).addClass('active');
827                        $this.find('.text').text(wp_listings_directory_opts.show_less);
828                    }
829                });
830            });
831
832            if ( $.isFunction( $.fn.slider ) ) {
833                $('.search-distance-slider').each(function(){
834                    var $this = $(this);
835                    var search_distance = $this.closest('.search-distance-wrapper').find('input[name^=filter-distance]');
836                    var search_wrap = $this.closest('.search_distance_wrapper');
837                    $(this).slider({
838                        range: "min",
839                        value: search_distance.val(),
840                        min: 0,
841                        max: 100,
842                        slide: function( event, ui ) {
843                            search_distance.val( ui.value );
844                            $('.text-distance', search_wrap).text( ui.value );
845                            $('.distance-custom-handle', $this).attr( "data-value", ui.value );
846                            search_distance.trigger('change');
847                        },
848                        create: function() {
849                            $('.distance-custom-handle', $this).attr( "data-value", $( this ).slider( "value" ) );
850                        }
851                    } );
852                } );
853
854                $('.main-range-slider').each(function(){
855                    var $this = $(this);
856                    $this.slider({
857                        range: true,
858                        min: $this.data('min'),
859                        max: $this.data('max'),
860                        values: [ $this.parent().find('.filter-from').val(), $this.parent().find('.filter-to').val() ],
861                        slide: function( event, ui ) {
862                            $this.parent().find('.from-text').text( ui.values[ 0 ] );
863                            $this.parent().find('.filter-from').val( ui.values[ 0 ] )
864                            $this.parent().find('.to-text').text( ui.values[ 1 ] );
865                            $this.parent().find('.filter-to').val( ui.values[ 1 ] );
866                            $this.parent().find('.filter-to').trigger('change');
867                        }
868                    } );
869                });
870
871                $('.price-range-slider').each(function(){
872                    var $this = $(this);
873                    $this.slider({
874                        range: true,
875                        min: $this.data('min'),
876                        max: $this.data('max'),
877                        values: [ $this.parent().find('.filter-from').val(), $this.parent().find('.filter-to').val() ],
878                        slide: function( event, ui ) {
879                            var $from_price = ui.values[ 0 ];
880                            var $to_price = ui.values[ 1 ];
881                            if ( wp_listings_directory_opts.enable_multi_currencies === 'yes' ) {
882                                $from_price = self.shortenNumber($from_price);
883                                $to_price = self.shortenNumber($to_price);
884                            } else {
885                                $from_price = self.addCommas($from_price);
886                                $to_price = self.addCommas($to_price);
887                            }
888                            $this.parent().find('.from-text .price-text').text( $from_price );
889                            $this.parent().find('.filter-from').val( ui.values[ 0 ] )
890                            $this.parent().find('.to-text .price-text').text( $to_price );
891                            $this.parent().find('.filter-to').val( ui.values[ 1 ] );
892                            $this.parent().find('.filter-to').trigger('change');
893                        }
894                    } );
895                });
896            }
897
898            $('.find-me').on('click', function() {
899                $(this).addClass('loading');
900                var this_e = $(this);
901                var container = $(this).closest('.form-group');
902
903                navigator.geolocation.getCurrentPosition(function (position) {
904                    container.find('input[name="filter-center-latitude"]').val(position.coords.latitude);
905                    container.find('input[name="filter-center-longitude"]').val(position.coords.longitude);
906                    container.find('input[name="filter-center-location"]').val('Location');
907                    container.find('.clear-location').removeClass('hidden');
908
909                    var position = [position.coords.latitude, position.coords.longitude];
910
911                    if ( typeof L.esri.Geocoding.geocodeService != 'undefined' ) {
912                    
913                        var geocodeService = L.esri.Geocoding.geocodeService();
914                        geocodeService.reverse().latlng(position).run(function(error, result) {
915                            container.find('input[name="filter-center-location"]').val(result.address.Match_addr);
916                        });
917                    }
918
919                    return this_e.removeClass('loading');
920                }, function (e) {
921                    return this_e.removeClass('loading');
922                }, {
923                    enableHighAccuracy: true
924                });
925            });
926
927            $('.clear-location').on('click', function() {
928                var container = $(this).closest('.form-group');
929
930                container.find('input[name="filter-center-latitude"]').val('');
931                container.find('input[name="filter-center-longitude"]').val('');
932                container.find('input[name="filter-center-location"]').val('');
933                container.find('.clear-location').addClass('hidden');
934                container.find('.leaflet-geocode-container').html('');
935            });
936            $('input[name="filter-center-location"]').on('keyup', function(){
937                var container = $(this).closest('.form-group');
938                var val = $(this).val();
939                if ( $(this).val() !== '' ) {
940                    container.find('.clear-location').removeClass('hidden');
941                } else {
942                    container.find('.clear-location').removeClass('hidden').addClass('hidden');
943                }
944            });
945            $('input[name="filter-center-location"]').each(function(){
946                var container = $(this).closest('.form-group');
947                var val = $(this).val();
948                if ( $(this).val() !== '' ) {
949                    container.find('.clear-location').removeClass('hidden');
950                } else {
951                    container.find('.clear-location').removeClass('hidden').addClass('hidden');
952                }
953            });
954
955            // search autocomplete location
956            if ( wp_listings_directory_opts.map_service == 'google-map' ) {
957                if (typeof google === 'object' && typeof google.maps === 'object') {
958                    function search_location_initialize() {
959                        
960                        $('input[name="filter-center-location"]').each(function(){
961                            var $id = $(this).attr('id');
962                            
963                            if ( typeof $id !== 'undefined' ) {
964                                var container = $('#'+$id).closest('.form-group-inner');
965                                var input = document.getElementById($id);
966                                var autocomplete = new google.maps.places.Autocomplete(input);
967                                autocomplete.setTypes([]);
968
969                                if ( wp_listings_directory_opts.geocoder_country ) {
970                                    autocomplete.setComponentRestrictions({
971                                        country: [wp_listings_directory_opts.geocoder_country],
972                                    });
973                                }
974
975                                autocomplete.addListener( 'place_changed', function () {
976                                    var place = autocomplete.getPlace();
977                                    place.toString();
978
979                                    if (!place.geometry) {
980                                        window.alert("No details available for input: '" + place.name + "'");
981                                        return;
982                                    }
983
984                                    container.find('input[name=filter-center-latitude]').val(place.geometry.location.lat());
985                                    container.find('input[name=filter-center-longitude]').val(place.geometry.location.lng());
986                                    
987                                });
988                            }
989                        });
990                    }
991                    google.maps.event.addDomListener(window, 'load', search_location_initialize);
992                }
993            } else {
994                if ( typeof L.Control.Geocoder.Nominatim != 'undefined' ) {
995                    if ( wp_listings_directory_opts.geocoder_country ) {
996                        var geocoder = new L.Control.Geocoder.Nominatim({
997                            geocodingQueryParams: {countrycodes: wp_listings_directory_opts.geocoder_country}
998                        });
999                    } else {
1000                        var geocoder = new L.Control.Geocoder.Nominatim();
1001                    }
1002
1003                    function delay(fn, ms) {
1004                        let timer = 0
1005                        return function(...args) {
1006                            clearTimeout(timer)
1007                            timer = setTimeout(fn.bind(this, ...args), ms || 0)
1008                        }
1009                    }
1010
1011                    $("input[name=filter-center-location]").attr('autocomplete', 'off').after('<div class="leaflet-geocode
1011-container"></div>');
1012                    $("input[name=filter-center-location]").on("keyup", delay(function (e) {
1013                        var s = $(this).val(), $this = $(this), container = $(this).closest('.form-group-inner');
1014                        if (s && s.length >= 2) {
1015                            
1016                            $this.parent().addClass('loading');
1017                            geocoder.geocode(s, function(results) {
1018                                var output_html = '';
1019                                for (var i = 0; i < results.length; i++) {
1020                                    output_html += '<li class="result-item" data-latitude="'+results[i].center.lat+'" data-longitude="'+results[i].center.lng+'" ><i class="fas fa-map-marker-alt" aria-hidden="true"></i> '+results[i].name+'</li>';
1021                                }
1022                                if ( output_html ) {
1023                                    output_html = '<ul>'+ output_html +'</ul>';
1024                                }
1025
1026                                container.find('.leaflet-geocode-container').html(output_html).addClass('active');
1027
1028                                var highlight_texts = s.split(' ');
1029
1030                                highlight_texts.forEach(function (item) {
1031                                    container.find('.leaflet-geocode-container').highlight(item);
1032                                });
1033
1034                                $this.parent().removeClass('loading');
1035                            });
1036                        } else {
1037                            container.find('.leaflet-geocode-container').html('').removeClass('active');
1038                        }
1039                    }, 500));
1040                    $('.form-group-inner').on('click', '.leaflet-geocode-container ul li', function() {
1041                        var container = $(this).closest('.form-group-inner');
1042                        container.find('input[name=filter-center-latitude]').val($(this).data('latitude'));
1043                        container.find('input[name=filter-center-longitude]').val($(this).data('longitude'));
1044                        container.find('input[name=filter-center-location]').val($(this).text());
1045                        container.find('.leaflet-geocode-container').removeClass('active').html('');
1046                    });
1047                }
1048            }
1049
1050            // advance
1051            $('.filter-toggle-adv').on('click', function(e){
1052                $('.filter-advance-fields').slideToggle();
1053                return false;
1054            });
1055        },
1056        listingChartInit: function() {
1057            var $this = $('#listing_chart_wrapper');
1058            if( $this.length <= 0 ) {
1059                return;
1060            }
1061            if ( $this.hasClass('loading') ) {
1062                return;
1063            }
1064            $this.addClass('loading');
1065
1066            $.ajax({
1067                url: wp_listings_directory_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_listings_directory_get_listing_chart' ),
1068                type:'POST',
1069                dataType: 'json',
1070                data: {
1071                    action: 'wp_listings_directory_get_listing_chart',
1072                    listing_id: $this.data('listing_id'),
1073                    nonce: $this.data('nonce'),
1074                }
1075            }).done(function(response) {
1076                if (response.status == 'error') {
1077                    $this.remove();
1078                } else {
1079                    var ctx = $this.get(0).getContext("2d");
1080                    var myNewChart = new Chart(ctx);
1081                    var data = {
1082                        labels: response.stats_labels,
1083                        datasets: [
1084                            {
1085                                label: response.stats_view,
1086                                backgroundColor: response.bg_color,
1087                                borderColor: response.border_color,
1088                                borderWidth: 1,
1089                                data: response.stats_values
1090                            },
1091                        ]
1092                    };
1093
1094                    var options = {
1095                        //Boolean - Whether the scale should start at zero, or an order of magnitude down from the lowest value
1096                        scaleBeginAtZero : true,
1097                        //Boolean - Whether grid lines are shown across the chart
1098                        scaleShowGridLines : false,
1099                        //String - Colour of the grid lines
1100                        scaleGridLineColor : "rgba(0,0,0,.05)",
1101                        //Number - Width of the grid lines
1102                        scaleGridLineWidth : 1,
1103                        //Boolean - Whether to show horizontal lines (except X axis)
1104                        scaleShowHorizontalLines: true,
1105                        //Boolean - Whether to show vertical lines (except Y axis)
1106                        scaleShowVerticalLines: true,
1107                        //Boolean - If there is a stroke on each bar
1108                        barShowStroke : false,
1109                        //Number - Pixel width of the bar stroke
1110                        barStrokeWidth : 2,
1111                        //Number - Spacing between each of the X value sets
1112                        barValueSpacing : 5,
1113                        //Number - Spacing between data sets within X values
1114                        barDatasetSpacing : 1,
1115                        legend: { display: false },
1116
1117                        tooltips: {
1118                            enabled: true,
1119                            mode: 'x-axis',
1120                            cornerRadius: 4
1121                        },
1122                    }
1123
1124                    var myBarChart = new Chart(ctx, {
1125                        type: response.chart_type,
1126                        data: data,
1127                        options: options
1128                    });
1129                }
1130                $this.removeClass('loading');
1131            });
1132        },
1133        listingNearbyYelp: function() {
1134            var $this = $('#listing-section-nearby_yelp');
1135            if ( $this.length <= 0 ) {
1136                return;
1137            }
1138            if ( $this.hasClass('loading') ) {
1139                return;
1140            }
1141            $this.addClass('loading');
1142
1143            $.ajax({
1144                url: wp_listings_directory_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_listings_directory_get_nearby_yelp' ),
1145                type:'POST',
1146                dataType: 'json',
1147                data: {
1148                    action: 'wp_listings_directory_get_nearby_yelp',
1149                    listing_id: $this.data('listing_id'),
1150                    nonce: $this.data('nonce'),
1151                }
1152            }).done(function(response) {
1153                if (response.status) {
1154                    $this.html( response.html );
1155                } else {
1156                    $this.remove();
1157                }
1158                $(document).trigger( "after_nearby_yelp_content", [$this, response] );
1159                $this.removeClass('loading');
1160            });
1161        },
1162        listingNearbyGooglePlaces: function() {
1163            var $this = $('#listing-section-google-places');
1164            if ( $this.length <= 0 ) {
1165                return;
1166            }
1167            if ( $this.hasClass('loading') ) {
1168                return;
1169            }
1170            $this.addClass('loading');
1171
1172            $.ajax({
1173                url: wp_listings_directory_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_listings_directory_get_nearby_google_places' ),
1174                type:'POST',
1175                dataType: 'json',
1176                data: {
1177                    action: 'wp_listings_directory_get_nearby_google_places',
1178                    listing_id: $this.data('listing_id'),
1179                    nonce: $this.data('nonce'),
1180                }
1181            }).done(function(response) {
1182                if (response.status) {
1183                    $this.find('.listing-section-content').html( response.html );
1184                } else {
1185                    $this.remove();
1186                }
1187                $(document).trigger( "after_nearby_google_place_content", [$this, response] );
1188                $this.removeClass('loading');
1189            });
1190        },
1191        listingWalkScore: function() {
1192            var $this = $('#listing-section-walk_score');
1193            if ( $this.length <= 0 ) {
1194                return;
1195            }
1196            if ( $this.hasClass('loading') ) {
1197                return;
1198            }
1199            $this.addClass('loading');
1200
1201            $.ajax({
1202                url: wp_listings_directory_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_listings_directory_get_walk_score' ),
1203                type:'POST',
1204                dataType: 'json',
1205                data: {
1206                    action: 'wp_listings_directory_get_walk_score',
1207                    listing_id: $this.data('listing_id'),
1208                    nonce: $this.data('nonce'),
1209                }
1210            }).done(function(response) {
1211                if (response.status) {
1212                    $this.html( response.html );
1213                } else {
1214                    $this.remove();
1215                }
1216                $(document).trigger( "after_walk_score_content", [$this, response] );
1217                $this.removeClass('loading');
1218            });
1219        },
1220        mixesFn: function() {
1221            var self = this;
1222            
1223            $( '.my-listings-ordering' ).on( 'change', 'select.orderby', function() {
1224                $( this ).closest( 'form' ).submit();
1225            });
1226
1227            $('.contact-form-wrapper').on('submit', function(){
1228                var $this = $(this);
1229                $this.addClass('loading');
1230                $this.find('.alert').remove();
1231                $.ajax({
1232                    url: wp_listings_directory_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_listings_directory_ajax_contact_form' ),
1233                    type:'POST',
1234                    dataType: 'json',
1235                    data: $this.serialize() + '&action=wp_listings_directory_ajax_contact_form'
1236                }).done(function(data) {
1237                    $this.removeClass('loading');
1238                    if ( data.status ) {
1239                        $this.prepend( '<div class="alert alert-info">'+data.msg+'</div>' );
1240                    } else {
1241                        $this.prepend( '<div class="alert alert-warning">'+data.msg+'</div>' );
1242                    }
1243                });
1244
1245                return false;
1246            });
1247
1248            $(document).on( 'submit', 'form.delete-profile-form', function() {
1249                var $this = $(this);
1250                $this.addClass('loading');
1251                $(this).find('.alert').remove();
1252                $.ajax({
1253                    url: wp_listings_directory_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_listings_directory_ajax_delete_profile' ),
1254                    type:'POST',
1255                    dataType: 'json',
1256                    data: $this.serialize() + '&action=wp_listings_directory_ajax_delete_profile'
1257                }).done(function(data) {
1258                    $this.removeClass('loading');
1259                    if ( data.status ) {
1260                        $this.prepend( '<div class="alert alert-info">'+data.msg+'</div>' );
1261                        window.location.href = wp_listings_directory_opts.home_url;
1262                    } else {
1263                        $this.prepend( '<div class="alert alert-warning">'+data.msg+'</div>' );
1264                    }
1265                });
1266
1267                return false;
1268            });
1269
1270            if ( $( 'input.field-datetimepicker' ).length > 0 && $.isFunction( $.fn.datetimepicker ) ) {
1271                $('input.field-datetimepicker').datetimepicker({
1272                    timepicker: false,
1273                    format: 'Y-m-d'
1274                });
1275            }
1276            
1277            // Location Change
1278            $('body').on('change', 'select.select-field-region', function(){
1279                var val = $(this).val();
1280                var next = $(this).data('next');
1281                var main_select = 'select.select-field-region' + next;
1282                if ( $(main_select).length > 0 ) {
1283                    
1284                    var select2_args = wp_listings_directory_select2_opts;
1285                        select2_args['allowClear'] = true;
1286                        select2_args['minimumResultsForSearch'] = 10;
1287                        select2_args['width'] = '100%';
1288
1289                    select2_args['language'] = {
1290                        noResults: function(){
1291                            return wp_listings_directory_select2_opts.language_result;
1292                        }
1293                    };
1294
1295                    $(main_select).prop('disabled', true);
1296                    $(main_select).val('').trigger('change');
1297
1298                    if ( val ) {
1299                        $(main_select).parent().addClass('loading');
1300                        $.ajax({
1301                            url: wp_listings_directory_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wpld_process_change_location' ),
1302                            type:'POST',
1303                            dataType: 'json',
1304                            data:{
1305                                'action': 'wpld_process_change_location',
1306                                'parent': val,
1307                                'taxonomy': $(main_select).data('taxonomy'),
1308                                'security': wp_listings_directory_opts.ajax_nonce,
1309                            }
1310                        }).done(function(data) {
1311                            $(main_select).parent().removeClass('loading');
1312                            
1313                            $(main_select).find('option').remove();
1314                            if ( data ) {
1315                                $.each(data, function(i, item) {
1316                                    var option = new Option(item.name, item.id, true, true);
1317                                    $(main_select).append(option);
1318                                });
1319                            }
1320                            $(main_select).prop("disabled", false);
1321                            $(main_select).val(null).select2("destroy").select2(select2_args);
1322                        });
1323                    } else {
1324                        $(main_select).find('option').remove();
1325                        $(main_select).prop("disabled", false);
1326                        $(main_select).val(null).select2("destroy").select2(select2_args);
1327                    }
1328                }
1329            });
1330
1331            $('body').on('change', '.listings-currencies input', function(){
1332                $(this).closest('form').trigger('submit');
1333            });
1334        },
1335        shortenNumber: function($number) {
1336            var self = this;
1337            
1338            var divisors = wp_listings_directory_opts.divisors;
1339
1340            $.each(divisors, function( $index, $value ) {
1341                if ($number < ($value['divisor'] * 1000)) {
1342                    $number = $number / $value['divisor'];
1343                    return self.addCommas($number) + $value['key'];
1344                }
1345            });
1346
1347            return $number;
1348        },
1349        addCommas: function(str) {
1350            var parts = (str + "").split("."),
1351                main = parts[0],
1352                len = main.length,
1353                output = "",
1354                first = main.charAt(0),
1355                i;
1356            
1357            if (first === '-') {
1358                main = main.slice(1);
1359                len = main.length;    
1360            } else {
1361                first = "";
1362            }
1363            i = len - 1;
1364            while(i >= 0) {
1365                output = main.charAt(i) + output;
1366                if ((len - i) % 3 === 0 && i > 0) {
1367                    output = wp_listings_directory_opts.money_thousands_separator + output;
1368                }
1369                --i;
1370            }
1371            // put sign back
1372            output = first + output;
1373            // put decimal part back
1374            if (parts.length > 1) {
1375                output += wp_listings_directory_opts.money_dec_point + parts[1];
1376            }
1377            return output;
1378        },
1379        showMessage: function(msg, status) {
1380            if ( msg ) {
1381                var classes = 'alert bg-warning';
1382                if ( status ) {
1383                    classes = 'alert bg-info';
1384                }
1385                var $html = '<div id="wp-listings-directory-popup-message" class="animated fadeInRight"><div class="message-inner '+ classes +'">'+ msg +'</div></div>';
1386                $('body').find('#wp-listings-directory-popup-message').remove();
1387                $('body').append($html).fadeIn(500);
1388                setTimeout(function() {
1389                    $('body').find('#wp-listings-directory-popup-message').removeClass('fadeInRight').addClass('delay-2s fadeOutRight');
1390                }, 1500);
1391            }
1392        },
1393        setCookie: function(cname, cvalue, exdays) {
1394            var d = new Date();
1395            d.setTime(d.getTime() + (exdays*24*60*60*1000));
1396            var expires = "expires="+d.toUTCString();
1397            document.cookie = cname + "=" + cvalue + "; " + expires+";path=/";
1398        },
1399        getCookie: function(cname) {
1400            var name = cname + "=";
1401            var ca = document.cookie.split(';');
1402            for(var i=0; i<ca.length; i++) {
1403                var c = ca[i];
1404                while (c.charAt(0)==' ') c = c.substring(1);
1405                if (c.indexOf(name) == 0) return c.substring(name.length,c.length);
1406            }
1407            return "";
1408        },
1409    }
1410
1411    $.wpldMainCore = WPLDMainCore.prototype;
1412    
1413    $(document).ready(function() {
1414        // Initialize script
1415        new WPLDMainCore();
1416
1417    });
1418    
1419})(jQuery);
1420

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.