PageSourceSearch

https://www.therodgers-team.com/resources/assets/themes/asset-comm…/mylistingscontroller.js?v=1789109828

js therodgers-team.com collected 2026-09-27 13:27:04 UTC 199,549 bytes, 4,320 lines download raw bytes

1"use strict";
2
3angular
4    .module("dpiApp")
5    .controller(
6        "MyListingsController",
7        function (
8            $scope,
9            $timeout,
10            $http,
11            configService,
12            $rootScope,
13            $location,
14            $route,
15            $routeParams,
16            $localStorage,
17            $window,
18            location,
19            BookingService, // for slot booking
20            $compile, // for slot booking
21            polygonFilter
22        ) {
23            $scope.member_details = {};
24            $scope.search_by_polygon = 0;
25            $rootScope.using_saved_zip = true; //use it skip saved search zip if user enter in location
26            $rootScope.ignore_watcher = false;
27            $scope.is_coming_from_home = 0;
28            $scope.shareMail = { subject: "", msg: "" };
29            $scope.show_advanced_text = "Show Advanced Search";
30            $scope.page_heading = "";
31            $scope.userid = isNaN(current_theme) ? user_id : current_theme;
32            $scope.mls_ids = mls_ids != undefined ? mls_ids : [];
33            $scope.show_default = 1; // For default website show  default list
34            $scope.property_list = {};
35            $scope.recordLimit = 20;
36            $scope.currentPage = 1;
37            $scope.newCurrentPage = 1;
38            $scope.property_found = 0;
39            $scope.visible_property_found = 0;
40            $scope.totalItemsProp = 0;
41            $scope.search_but_show_hide = 1;
42            $scope.fb_button_visible = 0; // Facebook Share button
43            $scope.visited = {};
44            $scope.search = {};
45            $scope.bedrating = 0;
46            $scope.bathrating = 0;
47            $scope.search.property_type = "";
48            $scope.property_types_array = [];
49            $scope.pageChanged = false;
50            $scope.propertyTypeDropdownText = "";
51            $scope.nextPropertyMl = null;
52            $scope.previousPropertyMl = null;
53            // Modal close with route handling
54            $scope.goingToLogin = false;
55            //$scope.search.min_price = '150000'; // For V2 Release no default search is required as per client thats why commented and set those fields value ='' below
56            //$scope.search.max_price = '500000'; // For V2 Release no default search is required as per client thats why commented and set those fields value ='' below
57            $scope.search.min_price = "";
58            $scope.search.max_price = "";
59            $scope.search_listing_sort = "listprice_asc";
60            $rootScope.my_listing_page_sort = "listprice_asc";
61            $scope.sethbaths = {};
62            $scope.all_bound = {}; // lat lng boundary
63            $scope.front_spinner = 0;
64            $scope.search_loader = 0;
65            $scope.advance_open = 0;
66            $scope.fivehundred_msg_status = 0;
67            $scope.property_ml_id = $routeParams.property_ml_id;
68            $scope.latitude = 27.6648;
69            $scope.longitude = -81.5158;
70            $scope.address = "";
71            $scope.filter_data = {};
72            $scope.furnished_active =
73            $scope.water_front_active =
74            $scope.water_access_active =
75            $scope.view_active =
76            $scope.pool_active =
77            $scope.pet_active =
78            $scope.hbaths_active =
79            $scope.complex_name_active =
80            $scope.subdivision_name_active =
81            $scope.development_name_active =
82            $scope.county_active =
83            $scope.zip_code_active =
84            $scope.foreclosure_active =
85            $scope.short_sale_active =
86            "";
87            $scope.hopa = "";
88            $scope.advanced_search = {};
89            $scope.optionsFromQuery = []; // Filter Value array
90            $scope.show_loader = 1; // Search property loader
91            $scope.searchLoaderCount = 0;
92            $scope.sqft_footage_active = "";
93            $scope.polygoncount = 0;
94            $scope.modal_loader = 1; // Modal Pop up loader
95            $scope.price_view_value = "Enter Price";
96            $scope.hitsavedsearch = 0;
97            $scope.copyright = Date.now();
98            $scope.priceRanges = [
99                0, 100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000,
100                900000, 1000000, 1250000, 1500000, 1750000, 2000000, 2250000, 2500000,
101                2750000,
102            ];
103            $scope.priceRangesLabel = [
104                "$0",
105                "100,000",
106                "$200,000",
107                "$300,000",
108                "$400,000",
109                "$500,000",
110                "$600,000",
111                "$700,000",
112                "$800,000",
113                "$900,000",
114                "$1M",
115                "$1.25M",
116                "$1.5M",
117                "$1.75M",
118                "$2M",
119                "$2.25M",
120                "$2.5M",
121                "$2.75M",
122            ];
123            $scope.minSelectedIndex = 0;
124            $scope.maxSelectedIndex = 0;
125            $scope.priceMinLimitStart = 0;
126            $scope.priceMinLimitTotal = 10;
127            $scope.priceMaxLimitTotal = 10;
128            $scope.showMinPriceList = true;
129            $scope.showMaxPriceList = false;
130            $scope.realtorMedias = [];
131            $scope.realtorSlides = [];
132            $scope.slideDescription = "";
133            $scope.activeFolderSlide = null;
134            $scope.activeFileSlide = null;
135            $scope.menu_id =
136                typeof $routeParams.menu_id == "undefined" ? 2 : $routeParams.menu_id;
137            $scope.searchCondition = "";
138            $scope.quickSearchCalled = false;
139
140            // Image category search
141            $scope.image_category = "";
142            $rootScope.image_category = "";
143            $scope.image_category_options = [];
144            $scope.fetchImageCategories = function() {
145                var httpRequest = $http({
146                    method: "POST",
147                    url: base_url + "/shared/image-categories",
148                }).success(function (data, status) {
149                    $scope.image_category_options = data.image_categories;
150                }).error(function (data, status) {
151                    console.error(data);
152                });
153            }
154
155            $scope.fetchImageCategories();
156
157            // Property Details Map
158            $scope.mapLoaded = false;
159
160            $scope.captchaRegistry = {};
161            // $scope.selectedBedRating = 0;
162
163            // PIT for pagination
164            $scope.pit = {};
165            $scope.propertyDetailsFetching = true;
166            $scope.property_det = {};
167            $scope.callingSearchProperty = false;
168
169            $scope.request = {};
170
171            $scope.relatedPropertiesLoaded = false;
172            $scope.makeToFavClicked = false;
173            $scope.hasPolygon = false;
174            $scope.localBedRating = 0;
175            $scope.localBathRating = 0;
176            $scope.localHbathRating = 0;
177            // $rootScope.firstSearchLoading = true;
178            $rootScope.advanceSearchWatcherEnabled = true;
179            $scope.bedStarRating = 4;
180            $scope.bathStarRating = 4;
181            $scope.hBathStarRating = 4;
182            $scope.resetFilterTimeThreshold = 30; // In minutes
183
184            $scope.page_name = $rootScope.page_name;
185            $scope.menu_id = $rootScope.menu_id;
186            $scope.criteria_id = $rootScope.criteria_id;
187
188            /****** Get Current Route Name ******/
189            $scope.location = $location.path();
190            $scope.routeName = $route.current.$$route.name;
191
192            $scope.currentRoute = $scope.routeName;
193            $scope.markerPopupOpened = false;
194
195            // Sorting
196            $scope.sortingSet = false;
197            // get specific parts of the URL like search parameters
198            var searchParamsUrlCopy = $location.search();
199            // Check if searchParams is an empty object
200            var isEmpty =
201                Object.keys(searchParamsUrlCopy).length === 0 &&
202                searchParamsUrlCopy.constructor === Object;
203
204
205
206            $scope.$on("$locationChangeStart", function (event, next, current) {
207
208
209
210
211
212                const urlString = current;
213                const searchTerm = "property-details";
214                var browserUrl = window.location.href;
215
216                if (urlString.includes(searchTerm)) {
217                    $rootScope.doNotCallZipCode = true;
218
219                } else {
220                    $rootScope.doNotCallZipCode = false;
221
222                    if (
223                        browserUrl.includes("11/search/11") &&
224                        !urlString.includes("11/search/11")
225                    ) {
226
227                        //$window.location.href = current; // Change the URL to the specified one
228                        // Extract path from the full URL
229                        var path = new URL(current).pathname;
230                        $timeout(function () {
231                            $location.path(path); // Redirect to the specified partial path
232                        }, 100); // Delay in milliseconds
233                    }
234                }
235            });
236
237            $scope.setSortOrder = function () {
238                var agent_id = $scope.userid;
239                var httpRequest = $http({
240                    method: "POST",
241                    url: base_url + "/firsthometheme/get-agent-details",
242                    data: {
243                        agent_id: agent_id,
244                    },
245                }).success(function (data, status) {
246                    $scope.agentDetails = data.agent_details;
247
248                    $rootScope.our_listing_page_sort = $scope.agentDetails.our_listing_page_sort;
249
250
251                    $scope.search_listing_sort = $rootScope.our_listing_page_sort;
252
253                    $scope.sortingSet = true;
254
255                    if ($scope.callingSearchProperty) {
256                        $scope.searchProperty();
257                    }
258                });
259            };
260            $scope.setSortOrder();
261
262            $scope.registerCaptcha = function(formName, refreshFn, loadFn) {
263                $scope.captchaRegistry[formName] = { refresh: refreshFn, load: loadFn };
264            };
265            
266            $scope.reloadAllCaptchas = function() {
267                angular.forEach($scope.captchaRegistry, function(captcha) {
268                    if (captcha.load) captcha.load();
269                });
270            };
271
272            // Form Submit handler
273            $scope.initForm = function (formId, param, reloadCaptchas = true) {
274                if (reloadCaptchas) {
275                    $scope.reloadAllCaptchas();
276                }
277                // Reset the form
278                $scope.resetJsForm(formId);
279                var form = document.getElementById(formId);
280                if (!form) return;
281
282                var isValid = true;
283            }
284
285            $scope.resetJsForm = function (formId) {
286                var form = document.getElementById(formId);
287                
288                if (!form) return;
289
290                // Remove booking CTA inserted after a previous successful form submit.
291                var bookingContainer = form.querySelector('.slot-booking-container');
292                if (bookingContainer && bookingContainer.parentNode) {
293                    bookingContainer.parentNode.removeChild(bookingContainer);
294                }
295
296                // 1. Reset the form
297                form.reset();
298
299                // Repopulate logged user's email
300                var emailField = form.querySelector("[logged-user-email]");
301
302                if (emailField) {
303
304                    var fn = angular.element(emailField).data("populateLoggedUserEmail");
305
306                    if (fn) {
307                        fn();
308                    }
309
310                }
311
312                // 2. Hide all error messages
313                form.querySelectorAll('.error').forEach(el => {
314                    el.style.display = 'none';
315                });
316
317                // 3. Clear message text
318                const msg = form.querySelector('.form-message');
319                if (msg) msg.innerText = '';
320
321                // 4. OPTIONAL: reset Angular scope (important for your setup)
322                const scope = angular.element(form).scope();
323                if (scope) {
324                    scope.$applyAsync(() => {
325                        scope.contact = {};
326
327                        // reset captcha if exists
328                        if (scope.captchaRegistry && scope.captchaRegistry['buyer']) {
329                            scope.captchaRegistry['buyer'].refresh();
330                        }
331                    });
332                }
333            }
334
335            function validateEmail(email) {
336                const regex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
337                return regex.test(email);
338            }
339
340            $scope.resetPropertyDetailBookingState = function () {
341                $scope.resetJsForm("expertForm");
342                $scope.resetJsForm("adviceForm");
343                $scope.resetJsForm("requestForm");
344
345                if (BookingService && angular.isFunction(BookingService.resetUiState)) {
346                    BookingService.resetUiState();
347                }
348                $rootScope.$broadcast('slotBooking:resetUi');
349            }
350
351            $scope.submitJsForm = function (formId, param) {
352                var form = document.getElementById(formId);
353                if (!form) return;
354                var isValid = true;
355                // reset errors
356                form.querySelectorAll(".error").forEach(el => el.style.display = "none");
357
358                // validation
359                if (!form.name.value.trim()) {
360                    form.querySelector(".name-error").style.display = "block";
361                    isValid = false;
362                }
363
364                if (!form.email.value.trim()) {
365                    form.querySelector(".email-error").style.display = "block";
366                    isValid = false;
367                }
368
369                if (!form.msg.value.trim()) {
370                    form.querySelector(".msg-error").style.display = "block";
371                    isValid = false;
372                }
373
374                // phone regex
375                var phone = form.phone.value.trim();
376                // var regex = /^$|^([\+][0-9]{1,3}[ \.\-])?([\(]{1}[0-9]{2,6}[\)])?([0-9 \.\-\/]{3,20})((x|ext|extension)[ ]?[0-9]{1,4})?$/;
377                // To accept em-dashes
378                var regex = /^$|^([\+][0-9]{1,3}[ \.\-–—])?([\(]{1}[0-9]{2,6}[\)])?([0-9 \.\-–—\/]{3,20})((x|ext|extension)[ ]?[0-9]{1,4})?$/;
379
380                if (phone && !regex.test(phone)) {
381                    form.querySelector(".phone-error").style.display = "block";
382                    isValid = false;
383                }
384                // Phone number should be greater than or equal to 10 digits
385                if (phone && phone.length < 10) {
386                    form.querySelector(".phone-error").style.display = "block";
387                    isValid = false;
388                }
389
390                if (!validateEmail(form.email.value)) {
391                    form.querySelector(".email-error").innerHTML = "Invalid email address";
392                    form.querySelector(".email-error").style.display = "block";
393                    isValid = false;
394                }
395
396                if (!isValid) return;
397
398                var scope = $scope;
399
400                var captchaObj = scope.request &&
401                    scope.request.captcha &&
402                    scope.request.captcha[param];
403
404                if (!captchaObj || !captchaObj.value) {
405                    alert("Please enter captcha");
406                    return;
407                }
408
409                var payload = {
410                    request: {
411                        name: form.name.value,
412                        phone: form.phone.value,
413                        email: form.email.value,
414                        msg: form.msg.value,
415                        captcha: {
416                            id: captchaObj.id,
417                            value: captchaObj.value
418                        }
419                    },
420                    member_id: user_id,
421                    param: param,
422                    property_url: window.location.href
423                };
424
425                fetch(base_url + "/firsthometheme/send-request-mail", {
426                    method: "POST",
427                    headers: { "Content-Type": "application/json" },
428                    body: JSON.stringify(payload)
429                })
430                    .then(res => res.json())
431                    .then(function (data) {
432
433                        if (data.success == 1) {
434
435                            // Fire custom event for successful form submission
436                            window.dispatchEvent(new CustomEvent("dpi:formSubmitSuccess", {
437                                detail: {
438                                    formId: formId,
439                                    param: param,
440                                    data: data
441                                }
442                            }));
443
444                            // Same as contact_me setupBookingAfterContact()
445                            BookingService.setInitialData({
446                                member_id: user_id   // same as contact_me; or use $scope.userid
447                            });
448                            BookingService.setAfterContact(data);
449                            var hasBooking = BookingService.isBookingLinkVisible();
450                            var messageEl = form.querySelector(".form-message");
451                            if(formId == 'adviceForm' || formId == 'requestForm') {
452                                messageEl.innerHTML =
453                                    "<span style='color:green'>Your query has been sent successfully. We will contact you soon.</span>";
454                            } else {
455                                messageEl.innerHTML =
456                                    "<span style='color:white'>Your query has been sent successfully. We will contact you soon.</span>";
457                            }
458                            // Only show slot-booking when client booking info exists (same as contact_me)
459                            var existing = form.querySelector('.slot-booking-container');
460                            if (existing) {
461                                existing.parentNode.removeChild(existing);
462                            }
463                            if (hasBooking) {
464                                var slotAttrs = 'member-details="member_details"';
465                                if (formId === 'adviceForm' || formId === 'requestForm') {
466                                    slotAttrs += ' close-parent-modal-on-open="true"';
467                                }
468                                if (formId === 'expertForm') {
469                                    slotAttrs += ' append-modal-to-body="true" book-button-dark="true" banner-highlight="false" banner-center-align="false"';
470                                }
471                                var el = angular.element('<div class="slot-booking-container"><slot-booking ' + slotAttrs + '></slot-booking></div>');
472                                messageEl.parentNode.insertBefore(el[0], messageEl.nextSibling);
473                                $compile(el)($scope);
474
475                                $scope.$applyAsync(); // Apply the changes to the scope so the directive renders correctly
476                            }
477                            
478                            // log the user in
479                            $rootScope.is_front_logged = 1;
480                            localStorage.setItem("usr_info", data.usr_info);
481                            localStorage.setItem("access_token", data.token);
482
483                            $rootScope.refreshLoggedUser();
484                            
485                            var client_details = [];
486                            client_details = $scope.loggedUserDetails();
487                            $rootScope.logged_user_id = client_details[0];
488                            $rootScope.logged_user_name = client_details[1];
489
490                            //
491                            // if (scope.reloadAllCaptchas) {
492                            //    scope.reloadAllCaptchas();
493                            // }
494
495                            form.reset();
496
497                            // Repopulate email
498                            var emailField = form.querySelector("[logged-user-email]");
499
500                            if (emailField) {
501
502                                var fn = angular.element(emailField).data("populateLoggedUserEmail");
503
504                                if (fn) {
505                                    fn();
506                                }
507
508                            }
509
510                            // Hide form successfully message after 2 seconds
511                            setTimeout(function () {
512                                form.querySelector(".form-message").innerHTML = "";
513                            }, 10000);
514
515                        } else {
516                            form.querySelector(".form-message").innerHTML =
517                                "<span style='color:red'>" + (data.message || "Error") + "</span>";
518                        }
519                        $scope.reloadAllCaptchas();
520                        scope.$apply();
521
522                    })
523                    .catch(function (error) {
524                        // Log the error
525                        console.error(error);
526                        form.querySelector(".form-message").innerHTML =
527                            "<span style='color:red'>Some error occurred</span>";
528
529                    });
530            }
531
532            // Reset filters based on time
533            $scope.resetFilterBasedOnTime = function () {
534                const timeNow = Date.now(); // In milliseconds
535                const filterExpirationTime =
536                    $localStorage.filter_expiration_time != undefined
537                        ? $localStorage.filter_expiration_time
538                        : 0;
539                // 
540                if (
541                    filterExpirationTime != 0 &&
542                    filterExpirationTime <= timeNow &&
543                    $localStorage.agent_zip_search != undefined
544                ) {
545                    // Call reset search if agent zip code is not undefined
546                    // 
547                    $scope.resetSearch();
548                }
549            };
550
551            // Hide if any modal backdrop still remains on page load
552            $scope.hideModalBackdrop = function () {
553                jQuery(".modal-backdrop").hide();
554            };
555            $scope.hideModalBackdrop();
556
557            $scope.getSelectedBed = function (bedrating, sp) {
558                $scope.bedrating = bedrating;
559                $scope.advanced_search.bedrooms = $scope.bedrating;
560
561                if (!sp) {
562                    $scope.callingSearchProperty = true;
563                    $scope.searchProperty($localStorage.my_listing_search_params, $scope.all_bound);
564                }
565            };
566
567            // Set $scope variables based on $localStorage
568            $scope.setScopeVariablesBasedOnLocalStorage = function () {
569                if (!$scope.sortingSet) {
570                    return;
571                }
572                var allBound = $scope.all_bound;
573
574
575                if (
576                    $localStorage.my_listing_search_params != undefined &&
577                    $localStorage.my_listing_search_params != ""
578                ) {
579                    var localStorageSearchParams = JSON.parse(
580                        $localStorage.my_listing_search_params
581                    );
582                    // 
583                    // 
584                    $scope.search.property_type =
585                        localStorageSearchParams.property_type != undefined
586                            ? localStorageSearchParams.property_type
587                            : "";
588                    $scope.property_types_array =
589                        localStorageSearchParams.property_types != undefined
590                            ? localStorageSearchParams.property_types
591                            : [];
592                    $scope.search.min_price =
593                        localStorageSearchParams.min_price != undefined
594                            ? localStorageSearchParams.min_price
595                            : "";
596                    $scope.search.max_price =
597                        localStorageSearchParams.max_price != undefined
598                            ? localStorageSearchParams.max_price
599                            : "";
600                    // $scope.search_listing_sort =
601                    //     localStorageSearchParams.search_listing_sort != undefined
602                    //         ? localStorageSearchParams.search_listing_sort
603                    //         : "listprice_asc";
604                    $scope.search_listing_sort =
605                        localStorageSearchParams.search_listing_sort != undefined
606                            ? localStorageSearchParams.search_listing_sort
607                            : $rootScope.my_listing_page_sort;
608                    $scope.image_category =
609                        localStorageSearchParams.image_category != undefined
610                        ? localStorageSearchParams.image_category
611                        : "";
612                    $scope.bedrating =
613                        localStorageSearchParams.bedroom != undefined
614                            ? localStorageSearchParams.bedroom
615                            : 0;
616                    $scope.localBedRating =
617                        localStorageSearchParams.bedroom != undefined
618                            ? localStorageSearchParams.bedroom
619                            : 0;
620                    $scope.bathrating =
621                        localStorageSearchParams.bathroom != undefined
622                            ? localStorageSearchParams.bathroom
623                            : 0;
624                    $scope.localBathRating =
625                        localStorageSearchParams.bathroom != undefined
626                            ? localStorageSearchParams.bathroom
627                            : 0;
628                    $scope.recordLimit =
629                        localStorageSearchParams.limit != undefined
630                            ? localStorageSearchParams.limit
631                            : 20;
632                    $scope.currentPage =
633                        localStorageSearchParams.page != undefined
634                            ? localStorageSearchParams.page
635                            : 1;
636                    $scope.all_bound =
637                        localStorageSearchParams.all_bound != undefined
638                            ? localStorageSearchParams.all_bound
639                            : {};
640                    $scope.advanced_search =
641                        localStorageSearchParams.advance_search != undefined
642                            ? localStorageSearchParams.advance_search
643                            : {};
644                    // $scope.bedrating =
645                    //   $scope.advanced_search.bedrooms != undefined
646                    //     ? $scope.advanced_search.bedrooms
647                    //     : 0;
648                    // $scope.bathrating =
649                    //   $scope.advanced_search.bathrooms != undefined
650                    //     ? $scope.advanced_search.bathrooms
651                    //     : 0;
652                    $scope.localHBathRating =
653                        $scope.advanced_search.hbaths != undefined
654                            ? $scope.advanced_search.hbaths
655                            : 0;
656                    $scope.pit =
657                        localStorageSearchParams.pit != undefined
658                            ? localStorageSearchParams.pit
659                            : {};
660                    // 
661                    // 
662                }
663            };
664
665
666            $scope.bedRatingClicked = function (rating) {
667                $scope.bedrating = rating;
668                $scope.advanced_search.bedrooms = $scope.bedrating;
669                jQuery("#bed-star-rating").trigger("click.bs.dropdown");
670            };
671            $scope.bathRatingClicked = function (rating) {
672                $scope.bathrating = rating;
673                $scope.advanced_search.bathrooms = $scope.bathrating;
674                jQuery("#bath-star-rating").trigger("click.bs.dropdown");
675            };
676
677            // $modalInstance.opened.then(function () {
678            //     $state.go(newPath);
679            // });
680            // $modalInstance.result.then(null, function () {
681            //     $state.go(oldPath);
682            // });
683            $scope.$on("$stateChangeSuccess", function () {
684                if ($state.current.name != newPath) {
685                    $modalInstance.dismiss("cancel");
686                }
687            });
688
689            $scope.showPropertyBasedOnMl = function (ml) {
690                // Close the opened modal
691                // jQuery('#propertyProjectDetailModal').modal('hide');
692
693                // Show the property
694                $scope.fetchPropertyDetails(ml);
695            };
696
697            $scope.fetchRelatedProperties = function (ml) {
698                // jQuery('#propertyProjectDetailModal').on('hidden.bs.modal', function () {
699                //     
700                //     $scope.propertyDetailsFetching = false;
701                //     $scope.front_spinner = 0;
702                //     $location.path('/11/search/11', false);
703                //     return;
704                // });
705                // 
706                $scope.relatedPropertiesLoaded = false;
707                var token = localStorage.getItem("access_token"); // If login
708
709                if ($localStorage.my_listing_search_params) {
710                    var search_params = JSON.parse($localStorage.my_listing_search_params);
711                } else {
712                    var search_params = "";
713                }
714
715                var httpRequest = $http({
716                    method: "POST",
717                    // url: base_url + '/firsthometheme/property-details-new',
718                    url: base_url + "/shared/fetch-related-properties",
719                    data: {
720                        property_ml_id: $scope.property_ml_id,
721                        member_id: $scope.userid,
722                        search_params: search_params,
723                    },
724                    headers: {
725                        "Content-Type": "application/json; charset=utf-8",
726                        "Access-Token": token,
727                    },
728                    // ignoreLoadingBar: true
729                }).success(function (data, status) {
730                    $scope.relatedPropertiesLoaded = true;
731                    if (data.related_properties.length === 0) {
732                        // $scope.has_property = 0;
733                        $scope.allRelatedProperty = [];
734                    } else {
735                        $scope.allRelatedProperty = data.related_properties;
736                    }
737                    setTimeout(function () {
738                        // ProjectGallery();
739                        // projectDetailImgVideoSwiperSlider();
740                        // ImageFitCont();
741                        relatedPropertiesSlider();
742                    }, 1000);
743                    setTimeout(function () {
744                        $scope.fixCssBackgoundImageDoubleEncodingIssue();
745                    }, 500);
746                });
747            };
748
749            // $scope.fetchPropertyDetails = function (ml) {
750            //     // $scope.front_spinner = 1;
751
752            //     // Show modal route
753            //     const propertyDetailUrl = "/property-details-2/" + ml;
754            //     
755            //     window.history.pushState("object or string", "Title", propertyDetailUrl);
756            // }
757
758            $scope.fetchPropertyDetails = function (ml) {
759                // Change path on modal close
760                if ($scope.makeToFavClicked == true) {
761                    return;
762                }
763                $scope.resetPropertyDetailBookingState();
764                const userName = $scope.agentDetails.user_name;
765                const browserUrl = window.location.href;
766                const urlParts = browserUrl.split('/');
767                if (urlParts[3] == userName) {
768                    history.pushState({}, "", window.location.origin + '/' + userName + '/property-details/' + ml);
769                } else {
770                    history.pushState({}, "", window.location.origin + '/property-details/' + ml);
771                }
772                jQuery("#propertyProjectDetailModal").on(
773                    "hidden.bs.modal",
774                    function () {
775                        $scope.propertyDetailsFetching = false;
776                        $rootScope.propertyDetailsModalClosed = true;
777                        $scope.front_spinner = 0;
778                        $scope.resetPropertyDetailBookingState();
779                        if ($scope.goingToLogin == false) {
780                            // $location.path('/11/search/11', false);
781                            // Making dynamic /11/search/11 & /11/search-property/11
782                            if ($scope.routeName == "mylisting") {
783                                var searchUrl = "/our_listings";
784                            } else if ($scope.routeName == "my_listings") {
785                                var searchUrl = "/my_listings";
786                            } else {
787                                var searchUrl =
788                                    "/11/" + $routeParams.page_name + "/" + $routeParams.menu_id;
789                            }
790                            location.skipReload().path(searchUrl).replace();
791                            // Relative path
792                            var relativePath = "/my_listings";
793
794                            // Combine with current domain
795                            if (urlParts[3] == userName) {
796                                var newUrl = window.location.origin + '/' + userName + relativePath;
797                            } else {
798                                var newUrl = window.location.origin + relativePath;
799                            }
800
801
802                            // Push the new URL to the browser history
803                            history.pushState({}, "", newUrl);
804                        } else {
805                            $scope.goingToLogin == false;
806                        }
807                        // window.history.pushState("object or string", "Search Page Title", '/11/search/11');
808                        return;
809                    }
810                );
811
812                // Add event listener to the form modal close
813                jQuery("#contactAgent").on(
814                    "hidden.bs.modal",
815                    function () {
816                        $scope.resetJsForm("adviceForm");
817                    }
818                );
819                jQuery("#requestShowing").on(
820                    "hidden.bs.modal",
821                    function () {
822                        $scope.resetJsForm("requestForm");
823                    }
824                );
825
826                $scope.front_spinner = 1;
827                $scope.propertyDetailsFetching = true;
828                // $scope.propertyDetailsFetching = true;
829
830                // Change route
831                // 
832                $location.path("/property-details/" + ml, false);
833
834                // Show the modal
835                jQuery("#propertyProjectDetailModal").on(
836                    "shown.bs.modal",
837                    function (e) {
838                        // Reload all captchas
839                        // $scope.reloadAllCaptchas();
840                        $scope.initForm("expertForm", "expert", true);
841                        $scope.initForm("adviceForm", "advice", false);
842                        $scope.initForm("requestForm", "request", false);
843                        // 
844                        // jQuery('#propertyProjectDetailModal .modal-body').mCustomScrollbar("scrollTo", ".propertyProjectDetail-content-wrap");
845                        jQuery(
846                            "#propertyProjectDetailModal .modal-body"
847                        ).mCustomScrollbar();
848
849                        // Scroll to top
850                        // $('#propertyProjectDetailModal').animate({ scrollTop: 0 }, 'fast');
851                    }
852                );
853
854                jQuery("#propertyProjectDetailModal").modal();
855
856                $scope.property_ml_id = ml;
857                var fb_app_id = $rootScope.fb_app_id;
858
859                // Find previous and next index
860                const mlIndex = $rootScope.propertyMlsIds.indexOf(ml);
861                if (mlIndex == -1) {
862                    $scope.previousPropertyMl = null;
863                    $scope.nextPropertyMl = null;
864                } else {
865                    if (mlIndex > 0) {
866                        $scope.previousPropertyMl = $rootScope.propertyMlsIds[mlIndex - 1];
867                    } else {
868                        $scope.previousPropertyMl = null;
869                    }
870                    if (mlIndex + 1 < $rootScope.propertyMlsIds.length) {
871                        $scope.nextPropertyMl = $rootScope.propertyMlsIds[mlIndex + 1];
872                    } else {
873                        $scope.nextPropertyMl = null;
874                    }
875                }
876
877                // IF FACEBOOK APP ID  NOT  PUTED FACEBOOK SHARE NOT VISIBLE BUTTON START//
878                if (fb_app_id != "") {
879                    $scope.fb_button_visible = 1;
880                }
881                // IF FACEBOOK APP ID  NOT  PUTED FACEBOOK SHARE NOT VISIBLE BUTTON END//
882
883                var token = localStorage.getItem("access_token"); // If login
884                if ($localStorage.my_listing_search_params) {
885                    var search_params = JSON.parse($localStorage.my_listing_search_params);
886                } else {
887                    var search_params = "";
888                }
889
890                var $httpRequest = $http({
891                    method: "POST",
892                    // url: base_url + '/firsthometheme/property-details-updated',
893                    url: base_url + "/shared/property-details",
894                    data: {
895                        property_ml_id: $scope.property_ml_id,
896                        member_id: $scope.userid,
897                        search_params: search_params,
898                    },
899                    headers: {
900                        "Content-Type": "application/json; charset=utf-8",
901                        "Access-Token": token,
902                    },
903                }).success(function (data, status) {
904                    $scope.front_spinner = 0;
905                    $rootScope.propertyDetailsModalClosed = false;
906                    if (data.property_det.length === 0) {
907                        $scope.has_property = 0;
908                    } else {
909                        // if ($localStorage.mls_id) {
910                        //     var storeMlsIds = JSON.parse($localStorage.mls_id);
911                        //     var indexofMlsId = storeMlsIds.indexOf($scope.property_ml_id);
912                        //     if (indexofMlsId > -1) {
913                        //         $rootScope.all_property_search_list = storeMlsIds;
914                        //         $rootScope.currentPropertyIndex = indexofMlsId;
915                        //     }
916                        // }
917                        $scope.property_det = data.property_det;
918                        // Set shareMail subject and message
919                        let propertyUrl =
920                            base_url + "/property-details/" + $scope.property_det.ml;
921                        $scope.shareMail["msg"] = "Check out this property " + propertyUrl;
922                        $scope.shareMail["subject"] =
923                            $scope.property_det.address +
924                            "-" +
925                            $scope.property_det.city_name +
926                            ", " +
927                            $scope.property_det.state +
928                            ", " +
929                            $scope.property_det.zip_code;
930
931                        $scope.allRelatedProperty = [];
932                        $scope.has_property = 1;
933                        
934                        $scope.property_ml_id = $scope.property_det.ml;
935
936                        $scope.latitude = parseFloat(data.property_det.lat);
937                        $scope.longitude = parseFloat(data.property_det.lng);
938
939                        $scope.address = data.property_det.address;
940                        fb_app_id = data.user_fb_app_id;
941
942                        if (data.logged_user_fav_property > 0) {
943                            // For Checking user fav property
944                            $scope.fav_status = 1;
945                        } else {
946                            $scope.fav_status = 0;
947                        }
948
949                        $scope.property_image_url = ""; // image share url for FB
950
951                        if (data.property_det.getimage.length > 0) {
952                            // check property images.. In which position get image set for the facebook share
953                            for (var i = 0; i < data.property_det.getimage.length; i++) {
954                                if (
955                                    typeof data.property_det.getimage[i].image_path != "undefined"
956                                ) {
957                                    var last = data.property_det.getimage[i].image_path
958                                        .split("/")
959                                        .pop(); // no_image.png
960                                    var no_image_last = last.split("."); // no_image
961
962                                    if (no_image_last[0] != "no_image") {
963                                        $scope.property_image =
964                                            theme_image_url +
965                                            data.property_det.getsisdetails.getmlsdetails.name.toLowerCase() +
966                                            "/" +
967                                            data.property_det.getimage[i].image_path;
968                                        $scope.property_image_url = base_url + $scope.property_image;
969                                        break;
970                                    }
971                                }
972                            }
973                        }
974                        $scope.property_url = $location.absUrl();
975
976                        setTimeout(function () {
977                            ProjectGallery();
978                            projectDetailImgVideoSwiperSlider();
979                            ImageFitCont();
980
981                            // FOR FACE BOOK INITILIZATION //
982                            window.fbAsyncInit = function () {
983                                FB.init({
984                                    appId: fb_app_id,
985                                    status: true,
986                                    cookie: true,
987                                    xfbml: true,
988                                });
989                            };
990                            (function () {
991                                var e = document.createElement("script");
992                                e.async = true;
993                                e.src =
994                                    document.location.protocol +
995                                    "//connect.facebook.net/en_US/all.js";
996                                document.getElementById("fb-root").appendChild(e);
997                            })();
998                            // FOR FACE BOOK INITILIZATION //
999
1000                            // Remove map loading call, it'll only be called when we click the "Load Map" button
1001                            // Wasim 29-01-2026
1002                            // initMap(); // init map call
1003
1004                            const homeProjectSliderSwiper = new Swiper(
1005                                ".home-project-slider",
1006                                {
1007                                    navigation: {
1008                                        nextEl: ".home-project-slider .swiper-button-next",
1009                                        prevEl: ".home-project-slider .swiper-button-prev",
1010                                    },
1011                                    slidesPerView: 1,
1012                                    spaceBetween: 30,
1013                                    breakpoints: {
1014                                        320: {
1015                                            slidesPerView: 1,
1016                                        },
1017                                        768: {
1018                                            slidesPerView: 2,
1019                                        },
1020                                        992: {
1021                                            slidesPerView: 3,
1022                                        },
1023                                        1200: {
1024                                            slidesPerView: 4,
1025                                        },
1026                                    },
1027                                }
1028                            );
1029                        }, 1000);
1030
1031                        setTimeout(() => {
1032                            jQuery(
1033                                "#propertyProjectDetailModal .modal-body"
1034                            ).mCustomScrollbar("scrollTo", ["top", null]);
1035                        }, 500);
1036
1037                        $scope.propertyDetailsFetching = false;
1038                        // fetch related properties
1039                        $scope.fetchRelatedProperties(ml);
1040                    }
1041                    setTimeout(function () {
1042                        if ($rootScope.is_front_logged == 1) {
1043                            $rootScope.checkLastServieCallTimeAfterLogin(); // To continuous update date time for logged user
1044                            $rootScope.$apply();
1045                        } else {
1046                            $rootScope.$broadcast("visitedPropertyPage"); // For Dpi-V2 requirement
1047                        }
1048                    }, 500);
1049                });
1050            };
1051            // $scope.fetchPropertyDetailsAfterStateChanged = function (ml) {
1052            //     $scope.front_spinner = 1;
1053            //     $scope.propertyDetailsFetching = true;
1054            //     // Show the modal
1055            //     jQuery('#propertyProjectDetailModal').on('shown.bs.modal', function (e) {
1056            //         // 
1057            //         // jQuery('#propertyProjectDetailModal .modal-body').mCustomScrollbar("scrollTo", ".propertyProjectDetail-content-wrap");
1058            //         jQuery('#propertyProjectDetailModal .modal-body').mCustomScrollbar();
1059
1060            //         // Scroll to top
1061            //         // $('#propertyProjectDetailModal').animate({ scrollTop: 0 }, 'fast');
1062            //     });
1063
1064            //     jQuery('#propertyProjectDetailModal').modal();
1065
1066            //     $scope.property_ml_id = ml;
1067            //     var fb_app_id = $rootScope.fb_app_id;
1068
1069            //     // Find previous and next index
1070            //     const mlIndex = $rootScope.propertyMlsIds.indexOf(ml);
1071            //     if (mlIndex == -1) {
1072            //         $scope.previousPropertyMl = null;
1073            //         $scope.nextPropertyMl = null;
1074            //     } else {
1075            //         if (mlIndex > 0) {
1076            //             $scope.previousPropertyMl = $rootScope.propertyMlsIds[mlIndex - 1];
1077            //         } else {
1078            //             $scope.previousPropertyMl = null;
1079            //         }
1080            //         if ((mlIndex + 1) < $rootScope.propertyMlsIds.length) {
1081            //             $scope.nextPropertyMl = $rootScope.propertyMlsIds[mlIndex + 1];
1082            //         } else {
1083            //             $scope.nextPropertyMl = null;
1084            //         }
1085            //     }
1086
1087            //     // IF FACEBOOK APP ID  NOT  PUTED FACEBOOK SHARE NOT VISIBLE BUTTON START//
1088            //     if (fb_app_id != '') {
1089            //         $scope.fb_button_visible = 1;
1090            //     }
1091            //     // IF FACEBOOK APP ID  NOT  PUTED FACEBOOK SHARE NOT VISIBLE BUTTON END//
1092
1093            //     var token = localStorage.getItem("access_token"); // If login
1094            //     if ($localStorage.my_listing_search_params) {
1095            //         var search_params = JSON.parse($localStorage.my_listing_search_params)
1096            //     } else {
1097            //         var search_params = '';
1098            //     }
1099
1100            //     var $httpRequest = $http({
1101            //         method: 'POST',
1102            //         url: base_url + '/firsthometheme/property-details-updated',
1103            //         data: {
1104            //             property_ml_id: $scope.property_ml_id,
1105            //             member_id: $scope.userid,
1106            //             search_params: search_params
1107            //         },
1108            //         headers: {
1109            //             'Content-Type': 'application/json; charset=utf-8',
1110            //             'Access-Token': token,
1111            //         }
1112            //     }).success(function (data, status) {
1113            //         $scope.front_spinner = 0;
1114            //         
1115            //         if (data.property_det.length === 0) {
1116            //             $scope.has_property = 0;
1117            //         } else {
1118            //             // if ($localStorage.mls_id) {
1119            //             //     var storeMlsIds = JSON.parse($localStorage.mls_id);
1120            //             //     var indexofMlsId = storeMlsIds.indexOf($scope.property_ml_id);
1121            //             //     if (indexofMlsId > -1) {
1122            //             //         $rootScope.all_property_search_list = storeMlsIds;
1123            //             //         $rootScope.currentPropertyIndex = indexofMlsId;
1124            //             //     }
1125            //             // }
1126            //             $scope.allRelatedProperty = [];
1127            //             $scope.has_property = 1;
1128            //             $scope.property_det = data.property_det;
1129            //             $scope.property_ml_id = $scope.property_det.ml
1130
1131            //             $scope.latitude = parseFloat(data.property_det.lat);
1132            //             $scope.longitude = parseFloat(data.property_det.lng);
1133
1134            //             $scope.address = data.property_det.address;
1135            //             fb_app_id = data.user_fb_app_id;
1136
1137            //             if (data.logged_user_fav_proerty > 0) // For Checking user fav property
1138            //             {
1139            //                 $scope.fav_status = 1;
1140            //             } else {
1141            //                 $scope.fav_status = 0;
1142            //             }
1143
1144            //             $scope.property_image_url = ''; // image share url for FB
1145
1146            //             if (data.property_det.getimage.length > 0) // check property images.. In which position get image set for the facebook share
1147            //             {
1148            //                 for (var i = 0; i < data.property_det.getimage.length; i++) {
1149            //                     if (typeof data.property_det.getimage[i].image_path != 'undefined') {
1150            //                         var last = data.property_det.getimage[i].image_path.split("/").pop(); // no_image.png
1151            //                         var no_image_last = last.split("."); // no_image
1152
1153            //                         if (no_image_last[0] != 'no_image') {
1154            //                             $scope.property_image = theme_image_url + data.property_det.getsisdetail
1154s.getmlsdetails.name.toLowerCase() + '/' + data.property_det.getimage[i].image_path;
1155            //                             $scope.property_image_url = base_url + $scope.property_image;
1156            //                             break;
1157            //                         }
1158            //                     }
1159            //                 }
1160            //             }
1161            //             $scope.property_url = $location.absUrl();
1162
1163            //             setTimeout(function () {
1164            //                 ProjectGallery();
1165            //                 projectDetailImgVideoSwiperSlider();
1166            //                 ImageFitCont();
1167
1168            //                 // FOR FACE BOOK INITILIZATION //
1169            //                 window.fbAsyncInit = function () {
1170            //                     FB.init({
1171            //                         appId: fb_app_id,
1172            //                         status: true,
1173            //                         cookie: true,
1174            //                         xfbml: true
1175            //                     });
1176            //                 };
1177            //                 (function () {
1178            //                     var e = document.createElement('script');
1179            //                     e.async = true;
1180            //                     e.src = document.location.protocol +
1181            //                         '//connect.facebook.net/en_US/all.js';
1182            //                     document.getElementById('fb-root').appendChild(e);
1183            //                 }());
1184            //                 // FOR FACE BOOK INITILIZATION //
1185
1186            //                 initMap(); // init map call
1187
1188            //                 const homeProjectSliderSwiper = new Swiper('.home-project-slider', {
1189            //                     navigation: {
1190            //                         nextEl: '.home-project-slider .swiper-button-next',
1191            //                         prevEl: '.home-project-slider .swiper-button-prev',
1192            //                     },
1193            //                     slidesPerView: 1,
1194            //                     spaceBetween: 30,
1195            //                     breakpoints: {
1196            //                         320: {
1197            //                             slidesPerView: 1,
1198            //                         },
1199            //                         768: {
1200            //                             slidesPerView: 2
1201            //                         },
1202            //                         992: {
1203            //                             slidesPerView: 3
1204            //                         },
1205            //                         1200: {
1206            //                             slidesPerView: 4
1207            //                         }
1208            //                     }
1209            //                 });
1210            //             }, 1000);
1211
1212            //             setTimeout(() => {
1213            //                 jQuery('#propertyProjectDetailModal .modal-body').mCustomScrollbar('scrollTo', ['top', null]);
1214            //             }, 500);
1215
1216            //             $scope.propertyDetailsFetching = false;
1217            //             // fetch related properties
1218            //             $scope.fetchRelatedProperties(ml);
1219            //         }
1220            //     });
1221            // }
1222
1223            // page heading Setting
1224            if (typeof $scope.meta_heading[$routeParams.page_name] != "undefined") {
1225                $scope.page_heading = $scope.meta_heading[$routeParams.page_name];
1226            } else {
1227                $scope.$on("menudatareceived", function (event, args) {
1228                    $scope.page_heading = $scope.meta_heading[$routeParams.page_name];
1229                });
1230            }
1231
1232            // image fit call on page load
1233            setTimeout(function () {
1234                ImageFitCont();
1235                jQuery(document).on("click", ".dropdown-menu", function (evt) {
1236                    evt.stopPropagation();
1237                });
1238                jQuery(document).on("click", function (event) {
1239                    var clickover = jQuery(event.target);
1240
1241                    clickover = clickover.hasClass("feature_listpanel");
1242                    var _opened = jQuery("#advance_collapse").hasClass("in");
1243                    if (_opened == true && clickover != true) {
1244                        jQuery(".collapse").collapse("hide");
1245                    }
1246                });
1247            }, 500);
1248
1249            /**********************/
1250
1251            $scope.newobject.active_class = $routeParams.page_name; // Active Class Settings
1252
1253            /****** Get Current Route Name ******/
1254            /**
1255              /* Copy search Url
1256              */
1257            $scope.searchUrlCopy = function () {
1258                $scope.searchStorage = $localStorage.my_listing_search_params;
1259
1260                //$scope.curreUrl = document.URL;
1261                $scope.curreUrl = window.location.href.split("?")[0];
1262                var generateSearchUrl = encodeURI(
1263                    $scope.curreUrl + "?search=" + btoa($scope.searchStorage)
1264                );
1265                //var generateSearchUrl = "mailto:?subject=Search Property Link&body="+$scope.curreUrl+'?params='+$scope.searchStorage;
1266
1267                //tiny url api
1268                let query = {
1269                    url: generateSearchUrl,
1270                };
1271                var tinyurl;
1272                $.get("/firsthometheme/generate-tiny-url", query).done(function (data) {
1273                    tinyurl = data.data;
1274
1275                    $("#urlInput").val(tinyurl);
1276                    $scope.myFunction();
1277                });
1278                //window.location = generateSearchUrl;
1279                //window.open(generateSearchUrl, '_blank');
1280            };
1281
1282            $scope.printFlyer = function (ml) {
1283                let data = {
1284                    agent_id: user_id,
1285                    property_ml_id: ml,
1286                    member_id: user_id,
1287                };
1288                let printPath =
1289                    $location.protocol() +
1290                    "://" +
1291                    $location.host() +
1292                    "/firsthometheme/print-flyer?member_id=" +
1293                    user_id +
1294                    "&agent_id=" +
1295                    user_id +
1296                    "&property_ml_id=" +
1297                    ml;
1298                //
1299                //$location.path(printPath);
1300                //window.location.href=printPath;
1301                window.open(printPath, "_blank");
1302            };
1303
1304            $scope.copyToSafari = function () {
1305                var copyText = document.getElementById("urlInput");
1306                var text_to_share = copyText.value;
1307                var range, selection;
1308                var h = document.createElement("DIV");
1309                var t = document.createTextNode(text_to_share);
1310                h.appendChild(t);
1311                document.body.appendChild(h);
1312                var element = h;
1313                if (document.body.createTextRange) {
1314                    range = document.body.createTextRange();
1315                    range.moveToElementText(element);
1316                    range.select();
1317                } else if (window.getSelection) {
1318                    selection = window.getSelection();
1319                    range = document.createRange();
1320                    range.selectNodeContents(element);
1321                    selection.removeAllRanges();
1322                    selection.addRange(range);
1323                }
1324                try {
1325                    document.execCommand("copy");
1326                } catch (err) {
1327                } finally {
1328                    element.remove();
1329                }
1330            };
1331            /**
1332             * Click handler for Copy
1333             */
1334            $scope.myFunction = function () {
1335                /* Get the text field */
1336                var copyText = document.getElementById("urlInput");
1337                /* Select the text field */
1338                copyText.select();
1339                /* Copy the text inside the text field */
1340                document.execCommand("copy");
1341                /* Alert the copied text */
1342                swal({
1343                    title: "Copy Search Settings",
1344                    text: "Click on Copy button to copy the link.  Then paste the link in an email and send it.",
1345                    button: "Copy",
1346                    // closeOnClickOutside: true,
1347                    // showCancelButton: true,
1348                    // cancelButtonText: 'Cancel',
1349                    // buttons: {
1350                    //     cancel: true,
1351                    //     confirm: true,
1352                    // },
1353                    // buttons: {
1354                    //     cancel: {
1355                    //         text: "Cancel",
1356                    //         value: null,
1357                    //         visible: false,
1358                    //         className: "",
1359                    //         closeModal: true,
1360                    //     },
1361                    //     confirm: {
1362                    //         text: "OK",
1363                    //         value: true,
1364                    //         visible: true,
1365                    //         className: "",
1366                    //         closeModal: true
1367                    //     }
1368                    // },
1369                    content: {
1370                        element: "input",
1371                        attributes: {
1372                            value: copyText.value,
1373                            readonly: "true",
1374                        },
1375                    },
1376                }).then((value) => {
1377                    // 
1378                    // 
1379                    if (value == null) {
1380                        // Clicked on the backdrop. Do nothing. Just close the modal
1381                        return;
1382                    }
1383                    $scope.copyToSafari();
1384                    swal("Copied to Clipboard");
1385                });
1386                // .then((value) => {
1387                //     
1388                //     
1389                // }, function (dismiss) {
1390                //     if (dismiss == 'cancel') {
1391                //         
1392                //     }
1393                // });
1394            };
1395
1396            /*
1397              $scope.$on('$viewContentLoaded', function(){
1398                  // console.log('viewContentLoaded')
1399                  var pathArr = $location.path().split('/');
1400                   if(pathArr.indexOf('search')==2)
1401                  {
1402                      setTimeout(()=>{
1403                      
1404                          if (typeof $scope.agent_zip_search != 'undefined' && $scope.agent_zip_search != '' && $scope.is_coming_from_home == 0) {
1405                              // 
1406                              //$rootScope.using_saved_zip=true;
1407      
1408                              if (!$scope.advanced_search.zip_code) {
1409                                  $scope.advanced_search.zip_code = [];
1410                                  $scope.advanced_search.zip_code[0] = $scope.agent_zip_search;
1411                              }
1412                              else {
1413                                  if ($scope.advanced_search.zip_code.indexOf($scope.agent_zip_search) === '-1')
1414                                      $scope.advanced_search.zip_code.push($scope.agent_zip_search);
1415                              }
1416                          }
1417                      },2000);
1418                  }
1419                  //Here your view content is fully loaded !!
1420              });
1421      
1422              */
1423            /////  AGENT WEBSITE DETAILS START /////
1424            $scope.getAgentDetails =
1425                function () // get agent details for home page of his website
1426                {
1427                    var agent_id = $scope.userid;
1428                    var httpRequest = $http({
1429                        method: "POST",
1430                        url: base_url + "/firsthometheme/get-agent-details",
1431                        data: {
1432                            agent_id: agent_id,
1433                        },
1434                    }).success(function (data, status) {
1435                        $scope.agentDetails = data.agent_details;
1436                        $rootScope.my_listing_page_sort = $scope.agentDetails.my_listing_page_sort;
1437                        $scope.search_listing_sort = $rootScope.my_listing_page_sort;
1438                        $scope.agent_zip_search = data.agent_details.zip_search;
1439                        $localStorage.agent_zip_search = data.agent_details.zip_search;
1440                        $scope.agent_set_zip_code = data.agent_details.zip_search; // For only reset search
1441                        $scope.property_details_view_count =
1442                            data.agent_details.property_details_view_count; //property_details_view_count
1443                        localStorage.setItem(
1444                            "prop_view_limit",
1445                            $scope.property_details_view_count
1446                        );
1447                        localStorage.setItem(
1448                            "dev_view_limit",
1449                            $scope.development_view_count
1450                        );
1451
1452                        if ($scope.routeName == "search_property") {
1453                            // $scope.getSelectedBed(0, 1);
1454                            // $scope.getSelectedBath(0, 1);
1455                            $scope.bedrooms[0].current = 0;
1456                            $scope.bathrooms[0].current = 0;
1457                            $scope.advanced_search.bedrooms = 0;
1458                            $scope.advanced_search.bathrooms = 0;
1459                            if (
1460                                typeof $scope.agent_zip_search != "undefined" &&
1461                                $scope.agent_zip_search != "" &&
1462                                $scope.is_coming_from_home == 0
1463                            ) {
1464                                // 
1465                                //$rootScope.using_saved_zip=true;
1466
1467                                if (!$scope.advanced_search.zip_code) {
1468                                    $scope.advanced_search.zip_code = [];
1469                                    $scope.advanced_search.zip_code[0] = $scope.agent_zip_search;
1470                                } else {
1471                                    if (
1472                                        $scope.advanced_search.zip_code.indexOf(
1473                                            $scope.agent_zip_search
1474                                        ) === "-1"
1475                                    )
1476                                        $scope.advanced_search.zip_code.push(
1477                                            $scope.agent_zip_search
1478                                        );
1479                                }
1480                            }
1481                        }
1482                    });
1483                };
1484            /////  AGENT WEBSITE DETAILS START /////
1485
1486            // For Google Map
1487            var markers = [];
1488
1489            $scope.shareFriend = function () {
1490                var property_url = $location.absUrl();
1491                var data = {
1492                    share: $scope.shareMail,
1493                    member_id: $scope.userid, //Agent id Website owner
1494                    property_url: property_url,
1495                    recaptcha_code: document.querySelector(`[name="h-captcha-response"]`)
1496                        .value,
1497                };
1498
1499                var httpRequest = $http({
1500                    method: "POST",
1501                    //url: base_url + '/firsthometheme/send-request-mail',
1502                    url: base_url + "/firsthometheme/send-share-mail",
1503                    data: data,
1504                })
1505                    .success(function (data, status) {
1506                        if (data.success == 1) {
1507                            $scope.showSuccMsg = 1;
1508                            $scope.change_class = "#71b100";
1509                            $scope.show_message =
1510                                "This property has been successfully shared via mail";
1511                            // $scope.shareFriendForm.reset();
1512                            // Close the shareFriend Modal
1513                            jQuery('#shareFriend').modal('hide');
1514                            $scope.shareMail = {};
1515                        } else {
1516                            $scope.showSuccMsg = 1;
1517                            $scope.show_message = "Some error occured.";
1518                            $scope.change_class = "#F00";
1519                        }
1520
1521                        $timeout(function () {
1522                            $scope.showSuccMsg = 0;
1523                            angular.element(".close").trigger("click");
1524                            $scope.$digest();
1525                        }, 3000);
1526                    })
1527                    .error(function (data, status, header, config) {
1528                        $scope.showSuccMsg = 1;
1529                        $scope.show_message = "Some error occured.";
1530                        $scope.change_class = "#F00";
1531
1532                        $timeout(function () {
1533                            $scope.showSuccMsg = 0;
1534                            angular.element(".close").trigger("click");
1535                            $scope.$digest();
1536                        }, 3000);
1537                    });
1538            };
1539            $scope.getAllProperty = function () {
1540                var httpRequest = $http({
1541                    method: "POST",
1542                    url: base_url + "/firsthometheme/all-property",
1543                    data: {},
1544                }).success(function (data, status) {
1545                    $scope.property_type = data.all_property_type;
1546                });
1547            };
1548            if (
1549                $scope.routeName == "search_property" ||
1550                $scope.routeName == "home" ||
1551                $scope.routeName == "mylisting" ||
1552                $scope.routeName == "my_listings"
1553            ) {
1554                $scope.getAllProperty();
1555            }
1556            // if ($scope.routeName == "search_property") {
1557            //     $scope.getAllProperty();
1558            // } else if ($scope.routeName == "property_details") {
1559            //     const ml = $routeParams.property_ml_id;
1560            //     $scope.fetchPropertyDetailsAfterStateChanged(ml);
1561            // }
1562
1563            // The single-active-polygon tracker and the DrawingManager hook now
1564            // live in the shared polygonFilter service (config/config-service.js)
1565            // instead of being copy-pasted into every listing controller.
1566            function trackFilterPolygon(polygon) {
1567                polygonFilter.track(polygon);
1568            }
1569
1570            function clearFilterPolygon() {
1571                polygonFilter.clear();
1572            }
1573
1574            // The user-drawn overlay comes from the view's DrawingManager, so
1575            // hook its polygoncomplete here instead of relying on the view's
1576            // own handler. Re-hooks whenever the view swaps in a new instance.
1577            //
1578            // Also re-asserts the debounced replacement for the view's global
1579            // getLatLng(): the view re-declares that function every time ngView
1580            // re-inserts the template, and its own version scheduled an
1581            // uncancellable 2s bounds search that overwrote polygon results.
1582            function ensurePolygonDrawHook() {
1583                polygonFilter.installBoundsSearchGuard($scope, {
1584                    getMap: function () {
1585                        return typeof map2 !== "undefined" ? map2 : null;
1586                    }
1587                });
1588                if (typeof drawingManager === "undefined" || !drawingManager) return;
1589                polygonFilter.hookDrawingManager(drawingManager);
1590            }
1591
1592            // START NEW FEATURES ADDED FOR POLYGON DRAW //
1593            $scope.drawOrRemovePolygone = function () {
1594                $scope.hasPolygon = true;
1595                $scope.polygoncount++;
1596
1597                $scope.search_by_polygon = 1;
1598                $rootScope.polygon_lat_long = $scope.polygon_lat_long;
1599                // var cond = JSON.parse($localStorage.my_listing_search_params);
1600                var cond =
1601                    $localStorage.my_listing_search_params != undefined &&
1602                        $localStorage.my_listing_search_params != ""
1603                        ? JSON.parse($localStorage.my_listing_search_params)
1604                        : {};
1605                cond.polygon_lat_long = $rootScope.polygon_lat_long;
1606                $scope.currentPage = 1;
1607                cond.currentPage = $scope.currentPage;
1608                $localStorage.my_listing_search_params = JSON.stringify(cond);
1609
1610                var latlngarray = JSON.parse($rootScope.polygon_lat_long);
1611
1612                var newArray = Array();
1613                if (latlngarray.length > 0) {
1614                    for (var i = 0; i < latlngarray.length; i++) {
1615                        var latlng = [latlngarray[i].lat, latlngarray[i].lng];
1616                        newArray.push(latlng);
1617                    }
1618                }
1619
1620                var geoJsonData = {
1621                    type: "Feature",
1622                    properties: {},
1623                    geometry: { type: "Polygon", coordinates: [newArray] },
1624                };
1625
1626                var geoJsonLayer = L.geoJson(geoJsonData);
1627                var bound = geoJsonLayer.getBounds();
1628                var northeastbound = bound.getNorthEast();
1629                var southwastbound = bound.getSouthWest();
1630
1631                var max_lat = northeastbound.lng;
1632                var max_lng = northeastbound.lat;
1633                var min_lat = southwastbound.lng;
1634                var min_lng = southwastbound.lat;
1635                var latlng_arr = {};
1636
1637                latlng_arr["max_lat"] = max_lat;
1638                latlng_arr["max_lng"] = max_lng;
1639                latlng_arr["min_lat"] = min_lat;
1640                latlng_arr["min_lng"] = min_lng;
1641
1642                $scope.all_bound = latlng_arr;
1643                $scope.callingSearchProperty = true;
1644                $scope.searchProperty($localStorage.my_listing_search_params, $scope.all_bound);
1645            };
1646
1647            $scope.clearPolygonOnResetSearch = function () {
1648                clearFilterPolygon();
1649                document.getElementById("specify_by_polygon").value = "";
1650                $scope.polygoncount = 0;
1651                $rootScope.polygon_lat_long = "";
1652                $scope.hasPolygon = false;
1653                $rootScope.hitorybackbtn = 0;
1654                // var cond = JSON.parse($localStorage.my_listing_search_params);
1655                var cond =
1656                    $localStorage.my_listing_search_params != undefined &&
1657                        $localStorage.my_listing_search_params != ""
1658                        ? JSON.parse($localStorage.my_listing_search_params)
1659                        : {};
1660                if (cond.polygon_lat_long) {
1661                    delete cond["polygon_lat_long"];
1662                }
1663            }
1664            $scope.clearPolygonStucture = function () {
1665                clearFilterPolygon();
1666                $scope.polygoncount = 0;
1667                $rootScope.polygon_lat_long = "";
1668                $scope.hasPolygon = false;
1669                $rootScope.hitorybackbtn = 0;
1670                // var cond = JSON.parse($localStorage.my_listing_search_params);
1671                var cond =
1672                    $localStorage.my_listing_search_params != undefined &&
1673                        $localStorage.my_listing_search_params != ""
1674                        ? JSON.parse($localStorage.my_listing_search_params)
1675                        : {};
1676                if (cond.polygon_lat_long) {
1677                    delete cond["polygon_lat_long"];
1678                }
1679                cond.advance_search = typeof cond.advance_search === 'string' ? JSON.parse(cond.advance_search) : cond.advance_search;
1680                // Add zip code after clearing the polygon
1681
1682                cond.advance_search.zip_code = [$localStorage.agent_zip_search];
1683
1684                $scope.currentPage = 1;
1685                cond.currentPage = $scope.currentPage;
1686                $localStorage.my_listing_search_params = JSON.stringify(cond);
1687                $scope.all_bound = {};
1688                $scope.advance_search = cond.advance_search;
1689                $scope.callingSearchProperty = false;
1690                // $scope.searchProperty($localStorage.my_listing_search_params, $scope.all_bound);
1691                $scope.resetSearch();
1692            };
1693
1694            /**
1695             * Water access filter options
1696             */
1697            $scope.waterAccessFilterOptions = function (optionsArray) {
1698                let valuesArray = [];
1699                optionsArray.forEach((option) => {
1700                    let optionValue = parseInt(option) == 1 ? "Yes" : "No";
1701                    valuesArray.push(optionValue);
1702                });
1703                return valuesArray.join(", ");
1704            };
1705
1706            /****** Check All property inside polygon or not ****/
1707            function isPointInPoly(poly, y, x) {
1708                var c = false,
1709                    j = poly.length - 1,
1710                    i;
1711
1712                for (i = 0; i < poly.length; i++) {
1713                    if (
1714                        ((poly[i][0] < y && poly[j][0] >= y) ||
1715                            (poly[j][0] < y && poly[i][0] >= y)) &&
1716                        (poly[i][1] <= x || poly[j][1] <= x)
1717                    ) {
1718                        if (
1719                            poly[i][1] +
1720                            ((y - poly[i][0]) / (poly[j][0] - poly[i][0])) *
1721                            (poly[j][1] - poly[i][1]) <
1722                            x
1723                        ) {
1724                            c = !c;
1725                        }
1726                    }
1727                    j = i;
1728                }
1729                return c;
1730            }
1731            /****** Check All property inside polygon or not ****/
1732
1733            // END NEW FEATURES ADDED FOR POLYGON DRAW //
1734
1735            $scope.getDistinct = function (
1736                params // Filter For Advanced Search
1737            ) {
1738                $scope.modal_loader = 1;
1739                $scope.filter_data = "";
1740                var httpRequest = $http({
1741                    method: "POST",
1742                    url: base_url + "/shared/search-filter",
1743                    data: {
1744                        filter: params,
1745                        advanced_search: typeof $scope.advanced_search === 'string' ? $scope.advanced_search : JSON.stringify($scope.advanced_search),
1746                        member_id: $scope.userid,
1747                    },
1748                }).success(function (data, status) {
1749                    $scope.modal_loader = 0;
1750                    $scope.filter_data = data;
1751                    $scope.optionsFromQuery = data.get_val;
1752
1753                    if (
1754                        $rootScope.polygon_lat_long &&
1755                        $scope.uniquezipcode_array &&
1756                        data.filter_param == "zip_code"
1757                    ) {
1758                        $scope.optionsFromQuery = $scope.uniquezipcode_array;
1759                    }
1760                    if (
1761                        $rootScope.polygon_lat_long &&
1762                        $scope.uniquecounty_array &&
1763                        data.filter_param == "county"
1764                    ) {
1765                        $scope.optionsFromQuery = $scope.uniquecounty_array;
1766                    }
1767                    if (
1768                        $rootScope.polygon_lat_long &&
1769                        $scope.development_Name_array &&
1770                        data.filter_param == "development_name"
1771                    ) {
1772                        $scope.optionsFromQuery = $scope.development_Name_array;
1773                    }
1774                    if (
1775                        $rootScope.polygon_lat_long &&
1776                        $scope.complex_Name_array &&
1777                        data.filter_param == "complex_name"
1778                    ) {
1779                        $scope.optionsFromQuery = $scope.complex_Name_array;
1780                    }
1781                    if (
1782                        $rootScope.polygon_lat_long &&
1783                        $scope.views_Name_array &&
1784                        data.filter_param == "view"
1785                    ) {
1786                        $scope.optionsFromQuery = $scope.views_Name_array;
1787                    }
1788                    if (
1789                        $rootScope.polygon_lat_long &&
1790                        $scope.water_access_array &&
1791                        data.filter_param == "water_access"
1792                    ) {
1793                        $scope.optionsFromQuery = $scope.water_access_array;
1794                    }
1795                    if (
1796                        $rootScope.polygon_lat_long &&
1797                        $scope.subdivision_Name_array &&
1798                        data.filter_param == "subdivision_name"
1799                    ) {
1800                        $scope.optionsFromQuery = $scope.subdivision_Name_array;
1801                    }
1802                });
1803            };
1804
1805            /**** Generate Polygon Boundary ******/
1806            $scope.generateBoundary = function () {
1807                $scope.search_by_polygon = 1;
1808                var latlngarray = JSON.parse($rootScope.polygon_lat_long);
1809
1810                var newArray = Array();
1811                if (latlngarray.length > 0) {
1812                    for (var i = 0; i < latlngarray.length; i++) {
1813                        var latlng = [latlngarray[i].lat, latlngarray[i].lng];
1814                        newArray.push(latlng);
1815                    }
1816                }
1817
1818                var geoJsonData = {
1819                    type: "Feature",
1820                    properties: {},
1821                    geometry: { type: "Polygon", coordinates: [newArray] },
1822                };
1823
1824                var geoJsonLayer = L.geoJson(geoJsonData);
1825                var bound = geoJsonLayer.getBounds();
1826                var northeastbound = bound.getNorthEast();
1827                var southwastbound = bound.getSouthWest();
1828
1829                var max_lat = northeastbound.lng;
1830                var max_lng = northeastbound.lat;
1831                var min_lat = southwastbound.lng;
1832                var min_lng = southwastbound.lat;
1833                var latlng_arr = {};
1834
1835                latlng_arr["max_lat"] = max_lat;
1836                latlng_arr["max_lng"] = max_lng;
1837                latlng_arr["min_lat"] = min_lat;
1838                latlng_arr["min_lng"] = min_lng;
1839
1840                $scope.all_bound = latlng_arr;
1841            };
1842            /**** Generate Polygon Boundary ******/
1843
1844            /*  Bedroom Bathroom icon setup start */
1845
1846            $scope.bedrooms = [
1847                {
1848                    current: 0,
1849                    max: 4,
1850                },
1851            ];
1852            $scope.bathrooms = [
1853                {
1854                    current: 0,
1855                    max: 4,
1856                },
1857            ];
1858            $scope.halfbathrooms = [
1859                {
1860                    current: 0,
1861                    max: 4,
1862                },
1863            ];
1864
1865            $scope.getSelectedBath = function (bathrating, sp) {
1866                $scope.bathrating = bathrating;
1867                $scope.advanced_search.bathrooms = $scope.bathrating;
1868
1869                if (!sp) {
1870                    $scope.callingSearchProperty = true;
1871                    $scope.searchProperty($localStorage.my_listing_search_params, $scope.all_bound);
1872                }
1873            };
1874            $scope.getSelectedHalfBath = function (halfbath) {
1875                $scope.halfbath = halfbath;
1876                $scope.advanced_search.hbaths = $scope.halfbath;
1877                if ($scope.advanced_search["hbaths"] == "undefined") {
1878                    $scope.hbaths_active = "";
1879                } else {
1880                    $scope.hbaths_active = "active";
1881                }
1882            };
1883
1884            /*  Bedroom Bathroom icon setup end */
1885
1886            /******* ADVANCED SEARCH ACTIVE FUNCTION SEARCH *******/
1887
1888            $scope.advance_search_make_green_active = function () {
1889                if (typeof $scope.advanced_search["sqft_footage"] != "undefined") {
1890                    $scope.sqft_footage_active = "active";
1891                } else {
1892                    $scope.sqft_footage_active = "";
1893                }
1894                if (typeof $scope.advanced_search["hopa"] != "undefined") {
1895                    $scope.hopa = "active";
1896                } else {
1897                    $scope.hopa = "";
1898                }
1899                if (
1900                    typeof $scope.advanced_search["membership_fee_required"] !=
1901                    "undefined"
1902                ) {
1903                    $scope.mebership_fee_active = "active";
1904                } else {
1905                    $scope.mebership_fee_active = "";
1906                }
1907
1908                if (typeof $scope.advanced_search["short_sale"] != "undefined") {
1909                    $scope.short_sale_active = "active";
1910                } else {
1911                    $scope.short_sale_active = "";
1912                }
1913                if (typeof $scope.advanced_search["foreclosure"] != "undefined") {
1914                    $scope.foreclosure_active = "active";
1915                } else {
1916                    $scope.foreclosure_active = "";
1917                }
1918                if (
1919                    typeof $scope.advanced_search["zip_code"] != "undefined" &&
1920                    $scope.advanced_search["zip_code"].length > 0
1921                ) {
1922                    $scope.zip_code_active = "active";
1923                } else {
1924                    $scope.zip_code_active = "";
1925                }
1926                if (typeof $scope.advanced_search["county"] != "undefined") {
1927                    $scope.county_active = "active";
1928                } else {
1929                    $scope.county_active = "";
1930                }
1931                if (typeof $scope.advanced_search["development_name"] != "undefined") {
1932                    $scope.development_name_active = "active";
1933                } else {
1934                    $scope.development_name_active = "";
1935                }
1936                if (typeof $scope.advanced_search["subdivision_name"] != "undefined") {
1937                    $scope.subdivision_name_active = "active";
1938                } else {
1939                    $scope.subdivision_name_active = "";
1940                }
1941                if (typeof $scope.advanced_search["complex_name"] != "undefined") {
1942                    $scope.complex_name_active = "active";
1943                } else {
1944                    $scope.complex_name_active = "";
1945                }
1946                if (typeof $scope.advanced_search["hbaths"] != "undefined") {
1947                    $scope.hbaths_active = "active";
1948                } else {
1949                    $scope.hbaths_active = "";
1950                }
1951                if (typeof $scope.advanced_search["pet"] != "undefined") {
1952                    $scope.pet_active = "active";
1953                } else {
1954                    $scope.pet_active = "";
1955                }
1956                if (typeof $scope.advanced_search["pool"] != "undefined") {
1957                    $scope.pool_active = "active";
1958                } else {
1959                    $scope.pool_active = "";
1960                }
1961                if (typeof $scope.advanced_search["view"] != "undefined") {
1962                    $scope.view_active = "active";
1963                } else {
1964                    $scope.view_active = "";
1965                }
1966                if (typeof $scope.advanced_search["water_access"] != "undefined") {
1967                    $scope.water_access_active = "active";
1968                } else {
1969                    $scope.water_access_active = "";
1970                }
1971                if (typeof $scope.advanced_search["water_front"] != "undefined") {
1972                    $scope.water_front_active = "active";
1973                } else {
1974                    $scope.water_front_active = "";
1975                }
1976                if (typeof $scope.advanced_search["furnished"] != "undefined") {
1977                    $scope.furnished_active = "active";
1978                } else {
1979                    $scope.furnished_active = "";
1980                }
1981                if (typeof $scope.advanced_search["hoa_fee"] != "undefined") {
1982                    $scope.hoa_fee_active = "active";
1983                } else {
1984                    $scope.hoa_fee_active = "";
1985                }
1986            };
1987
1988            /******* ADVANCED SEARCH ACTIVE FUNCTION END *******/
1989
1990            $scope.setSearchParamsInLocalStorage = function () {
1991                var agentid = $scope.userid;
1992
1993
1994                var cond = {
1995                    property_type: $scope.search.property_type,
1996                    property_types: $scope.property_types_array,
1997                    bedroom: $scope.bedrating,
1998                    bathroom: $scope.bathrating,
1999                    min_price: $scope.search.min_price,
2000                    max_price: $scope.search.max_price,
2001                    search_listing_sort: $scope.search_listing_sort,
2002                    image_category: $scope.image_category,
2003                    limit: $scope.recordLimit,
2004                    page: $scope.currentPage,
2005                    advance_search: typeof $scope.advanced_search === 'string' ? $scope.advanced_search : JSON.stringify($scope.advanced_search),
2006                    agentid: agentid,
2007                    all_bound: typeof $scope.all_bound === 'string' ? $scope.all_bound : JSON.stringify($scope.all_bound),
2008                    pit: $scope.pit,
2009                    mls_ids: mls_ids,
2010                };
2011
2012
2013                $localStorage.my_listing_search_params = JSON.stringify(cond); // Set search parameters in local storage
2014            };
2015
2016
2017
2018            if (
2019                $scope.currentRoute == "property_details" ||
2020                $rootScope.previousRoute === $scope.currentRoute ||
2021                typeof $rootScope.previousRoute === "undefined"
2022            ) {
2023
2024                $scope.setScopeVariablesBasedOnLocalStorage();
2025            }
2026
2027            if (
2028                $scope.currentRoute == "property_details" ||
2029                $rootScope.previousRoute === $scope.currentRoute
2030            ) {
2031                $scope.setSearchParamsInLocalStorage();
2032            }
2033
2034
2035
2036            $scope.searchConditionIsSame = function (condition) {
2037                var stringCondition = JSON.stringify(condition);
2038                return $scope.searchCondition === stringCondition;
2039            };
2040            $scope.fixCssBackgoundImageDoubleEncodingIssue = function () {
2041                // get all the elements with the thumbnail classes
2042                const thumbnailElements = $('.project-thumb.imageFit');
2043                thumbnailElements.each(function () {
2044                    // Remove background-image inline CSS
2045                    $(this).css("background-image", "");
2046
2047                    // Get the image source
2048                    var imageSource = $(this).find('img').attr('src');
2049                    // Manually encode only the specific characters
2050                    imageSource = imageSource.replace(/\*/g, '%2A')
2051                        .replace(/\(/g, '%28')
2052                        .replace(/\)/g, '%29');
2053
2054                    // add the image source to the background-image
2055                    $(this).css('background-image', 'url(' + imageSource + ')');
2056                });
2057            };
2058            /******* SEARCH PROPERTY BUTTON AJAX START *******/
2059            $scope.searchProperty = function (
2060                cond,
2061                allbound //cond
2062            ) {
2063                if ($scope.pageChanged == false) {
2064                    $scope.currentPage = 1;
2065                }
2066                if (!$scope.sortingSet) {
2067                    return;
2068                }
2069
2070
2071                if (typeof cond === 'undefined') {
2072
2073                } else {
2074
2075
2076                }
2077
2078
2079
2080
2081                if ($rootScope.previousRoute == undefined) {
2082
2083                    $rootScope.previousRoute = $scope.currentRoute;
2084                }
2085                // $rootScope.previousRoute = 'search_property'
2086                // $scope.currentRoute = 'search_property'
2087
2088                $scope.resetFilterBasedOnTime();
2089                if ($scope.routeName == "home" && $scope.quickSearchCalled == false) {
2090                    return;
2091                }
2092                $scope.callingSearchProperty = true;
2093
2094                // Set local storage search from $scope
2095                // if (!$scope.firstSearchLoading) {
2096                if (
2097                    $scope.currentRoute == "property_details" ||
2098                    $rootScope.previousRoute === $scope.currentRoute
2099                ) {
2100                    $scope.setSearchParamsInLocalStorage();
2101                }
2102                // Mls Ids
2103                // 
2104
2105                // Scroll to top of the page
2106                $window.scrollTo(0, 0);
2107                const elmnt = document.getElementById("top_div");
2108                elmnt.scrollIntoView({ behavior: "smooth" });
2109
2110                $scope.searchLoaderCount++;
2111                if (typeof localStorage.getItem("hit_saved_search") !== "undefined") {
2112                    $scope.hitsavedsearch = localStorage.getItem("hit_saved_search");
2113                    localStorage.removeItem("hit_saved_search");
2114                }
2115
2116                $scope.all_bound = allbound;
2117                // var localStorageSearchParams = JSON.parse($localStorage.my_listing_search_params);
2118                // localStorageSearchParams.all_bound = typeof allbound != 'undefined' ? JSON.stringify(allbound) : '{}';
2119                var agentid = $scope.userid; // Site owner
2120                $scope.front_spinner = 1;
2121                var backwards = localStorage.getItem("backwards");
2122                if (
2123                    $rootScope.fromhomesearch == 1 ||
2124                    $scope.hitsavedsearch == 1 ||
2125                    $localStorage.backwards == 1
2126                ) {
2127
2128                    $localStorage.backwards = 0;
2129                    $scope.is_coming_from_home = 1;
2130                    $rootScope.fromhomesearch = 0;
2131                    $scope.hitsavedsearch = 0;
2132
2133                    // var cond = JSON.parse($localStorage.my_listing_search_params);
2134                    var cond =
2135                        $localStorage.my_listing_search_params != undefined &&
2136                            $localStorage.my_listing_search_params != ""
2137                            ? JSON.parse($localStorage.my_listing_search_params)
2138                            : {};
2139
2140
2141
2142
2143                    $scope.search.property_type = cond.property_type;
2144                    $scope.property_types_array = cond.property_types;
2145                    $scope.bedrating = cond.bedroom;
2146                    $scope.bathrating = cond.bathroom;
2147                    $scope.search.min_price = cond.min_price;
2148                    $scope.search.max_price = cond.max_price;
2149                    $scope.search_listing_sort = cond.search_listing_sort;
2150                    $scope.image_category = cond.image_category;
2151                    $scope.recordLimit = cond.limit;
2152                    $scope.currentPage = cond.page;
2153                    $scope.advanced_search = JSON.parse(cond.advance_search);
2154                    $scope.all_bound = JSON.parse(cond.all_bound);
2155                }
2156
2157                if ($rootScope.hitorybackbtn == 1 && $rootScope.polygon_lat_long && $rootScope.polygon_lat_long && $rootScope.polygon_lat_long != "undefined" && $rootScope.polygon_lat_long != "[]" && $rootScope.polygon_lat_long != "{}" && Object.keys($rootScope.polygon_lat_long).length > 2) {
2158                    $scope.generateBoundary();
2159                }
2160                /**
2161                    * loading from copied search param
2162                    If there is query params of search include it in localstorage
2163                    */
2164                if ($routeParams.search) {
2165
2166                    $localStorage.my_listing_search_params = "";
2167                    try {
2168                        var setParams = JSON.parse(atob($routeParams.search));
2169
2170
2171                        $scope.search.property_type = setParams.property_type;
2172                        $scope.property_types_array = setParams.property_types;
2173                        $scope.bedrating = setParams.bedroom;
2174                        $scope.bathrating = setParams.bathroom;
2175                        $scope.search.min_price = setParams.min_price;
2176                        $scope.search.max_price = setParams.max_price;
2177                        $scope.search_listing_sort = setParams.search_listing_sort;
2178                        $scope.image_category = setParams.image_category;
2179                        $rootScope.image_category = $scope.image_category;
2180                        $scope.recordLimit = setParams.limit;
2181                        $scope.currentPage = setParams.page;
2182                        $scope.advanced_search = setParams.advance_search
2183                            ? JSON.parse(setParams.advance_search)
2184                            : [];
2185                        // $scope.all_bound = setParams.all_bound
2186                        //     ? JSON.parse(setParams.all_bound)
2187                        //     : [];
2188                        if (setParams.all_bound) {
2189                            if (typeof setParams.all_bound == 'string') {
2190                                $scope.all_bound = JSON.parse(setParams.all_bound);
2191                            } else {
2192                                $scope.all_bound = setParams.all_bound;
2193                            }
2194                        } else {
2195                            $scope.all_bound = {};
2196                        }
2197                        $scope.polygon_lat_long = setParams.polygon_lat_long
2198                            ? JSON.parse(setParams.polygon_lat_long)
2199                            : [];
2200                        //For map pointer
2201                        $rootScope.polygon_lat_long = setParams.polygon_lat_long;
2202                        $rootScope.hitorybackbtn = 1;
2203                        // $routeParams.search = null;
2204                        $localStorage.my_listing_search_params = JSON.stringify(setParams);
2205
2206                        location.skipReload().url($location.path());
2207                    } catch (e) {
2208                        console.warn("parse error of search params");
2209                    }
2210                }
2211                if ($scope.polygoncount == 1) {
2212                    $rootScope.using_saved_zip = false;
2213                    $scope.advanced_search.zip_code = [];
2214                    $scope.polygoncount++;
2215                }
2216
2217                if (
2218                    $localStorage.my_listing_search_params != undefined &&
2219                    $localStorage.my_listing_search_params != ""
2220                ) {
2221
2222                    var localStorageSearchParams = JSON.parse($localStorage.my_listing_search_params);
2223
2224
2225
2226
2227                    var cond = {
2228                        property_type: localStorageSearchParams.property_type,
2229                        property_types: localStorageSearchParams.property_types,
2230                        bedroom: localStorageSearchParams.bedroom,
2231                        bathroom: localStorageSearchParams.bathroom,
2232                        min_price: localStorageSearchParams.min_price,
2233                        max_price: localStorageSearchParams.max_price,
2234                        search_listing_sort: $scope.search_listing_sort,
2235                        image_category: $scope.image_category,
2236                        limit: $scope.recordLimit,
2237                        page: $scope.currentPage,
2238                        advance_search: localStorageSearchParams.advance_search,
2239                        advance_search_updated: localStorageSearchParams.advance_search,
2240                        agentid: agentid,
2241                        // all_bound: localStorageSearchParams.all_bound,
2242                        all_bound: typeof allbound != 'undefined' ? typeof allbound === 'string' ? allbound : JSON.stringify(allbound) : localStorageSearchParams.all_bound,
2243                        pit: localStorageSearchParams.pit,
2244                        mls_ids: mls_ids,
2245                    };
2246                    // cond["advance_search"] = cond["advance_search_updated"];
2247
2248
2249                    $scope.all_bound = JSON.parse(cond.all_bound);
2250                    $scope.setScopeVariablesBasedOnLocalStorage();
2251                } else {
2252
2253
2254                    var cond = {
2255                        property_type: $scope.search.property_type,
2256                        property_types: $scope.property_types_array,
2257                        bedroom: $scope.bedrating,
2258                        bathroom: $scope.bathrating,
2259                        min_price: $scope.search.min_price,
2260                        max_price: $scope.search.max_price,
2261                        search_listing_sort: $scope.search_listing_sort,
2262                        image_category: $scope.image_category,
2263                        limit: $scope.recordLimit,
2264                        page: $scope.currentPage,
2265                        advance_search: typeof $scope.advanced_search === 'string' ? $scope.advanced_search : JSON.stringify($scope.advanced_search),
2266                        agentid: agentid,
2267                        all_bound: typeof $scope.all_bound === 'string' ? $scope.all_bound : JSON.stringify($scope.all_bound),
2268                        pit: $scope.pit,
2269                        mls_ids: mls_ids,
2270                    };
2271                    // $scope.firstSearchLoading = false;
2272                }
2273
2274                // cond["advance_search"] = cond["advance_search_updated"];
2275
2276
2277
2278
2279                // var cond = JSON.parse($localStorage.my_listing_search_params);
2280
2281                var apiurl = "";
2282                if ($rootScope.polygon_lat_long) {
2283                    cond.polygon_lat_long = $rootScope.polygon_lat_long;
2284                    $scope.hasPolygon = true;
2285                    apiurl = base_url + "/shared/search-property-result-with-polygon";
2286                } else {
2287                    $scope.hasPolygon = false;
2288                    apiurl = base_url + "/shared/search-property-result";
2289                }
2290
2291                var token = localStorage.getItem("access_token"); // If login
2292
2293                $scope.show_loader = 1;
2294                $rootScope.propertyMlsIds = [];
2295                if ($scope.searchConditionIsSame(cond)) {
2296                    return;
2297                }
2298                cond.menu_id = $scope.menu_id;
2299                cond.criteria_id = $scope.criteria_id;
2300                cond.page_name = $scope.page_name;
2301                if (
2302                    $scope.currentRoute == "property_details" ||
2303                    $rootScope.previousRoute === $scope.currentRoute ||
2304                    !isEmpty
2305                ) {
2306
2307
2308
2309
2310                    cond.advance_search = typeof cond.advance_search === 'string' ? JSON.parse(cond.advance_search) : {};
2311                    cond.advance_search.bedrooms = cond.bedroom;
2312                    cond.advance_search.bathrooms = cond.bathroom;
2313                    $rootScope.advanceSearchWatcherEnabled = false;
2314                    $scope.bedrating = cond.bedroom;
2315                    $scope.bathrating = cond.bathroom;
2316                    $scope.advanced_search = cond.advance_search;
2317                    cond.advance_search = typeof cond.advance_search === 'string' ? cond.advance_search : JSON.stringify(cond.advance_search);
2318                    $scope.searchCondition = JSON.stringify(cond);
2319
2320
2321
2322
2323                }
2324                if (allbound !== "{}" && typeof allbound != 'undefined' && Object.keys(allbound).length > 0) {
2325
2326
2327
2328                    $rootScope.using_saved_zip = false;
2329                    delete $scope.advanced_search.zip_code;
2330                    var existingAdvancedSearch = JSON.parse(cond.advance_search);
2331                    delete existingAdvancedSearch.zip_code;
2332                    cond.advance_search = JSON.stringify(existingAdvancedSearch)
2333                }
2334                var httpRequest = $http({
2335                    method: "POST",
2336                    url: apiurl,
2337                    data: cond,
2338                    headers: {
2339                        "Content-Type": "application/json; charset=utf-8",
2340                        "Access-Token": token,
2341                    },
2342                }).success(function (data, status) {
2343                    $scope.pageChanged = false;
2344                    // Set $scope.advanced_search
2345                    $scope.search.put_location = '';
2346                    if (typeof allbound === 'string') {
2347                        allbound = JSON.parse(allbound);
2348                    }
2349                    if (typeof allbound != 'undefined' && Object.keys(allbound).length > 0) {
2350
2351
2352                        var localStorageSearchParams = JSON.parse($localStorage.my_listing_search_params);
2353                        $scope.all_bound = allbound;
2354                        localStorageSearchParams.all_bound = $scope.all_bound;
2355
2356
2357                        localStorageSearchParams.advance_search = JSON.parse(localStorageSearchParams.advance_search);
2358                        delete localStorageSearchParams.advance_search.zip_code;
2359                        delete $scope.advanced_search.zip_code;
2360                        $localStorage.my_listing_search_params = JSON.stringify(localStorageSearchParams);
2361
2362
2363
2364
2365                    }
2366                    if (
2367                        $scope.currentRoute == "property_details" ||
2368                        $rootScope.previousRoute === $scope.currentRoute ||
2369                        !isEmpty
2370                    ) {
2371
2372                        const advancedSearch = JSON.parse(cond.advance_search);
2373                        $scope.advanced_search = advancedSearch;
2374                    }
2375                    $rootScope.previousRoute = $scope.currentRoute;
2376
2377                    $rootScope.firstSearchLoading = false;
2378                    $scope.callingSearchProperty = false;
2379                    $rootScope.advanceSearchWatcherEnabled = true;
2380                    // $scope.searchCondition = JSON.stringify(cond);
2381                    $rootScope.propertyMlsIds = [];
2382                    $scope.front_spinner = 0;
2383                    $scope.show_loader = 0;
2384                    $scope.fivehundred_msg_status = 0;
2385                    $scope.all_property_list = data.all_property;
2386                    $scope.pit = data.pit;
2387                    // Add mls ids in rootscope
2388                    data.all_property.forEach(function (property) {
2389                        $rootScope.propertyMlsIds.push(property.id);
2390                    });
2391                    // $scope.searchLoaderCount--;
2392                    $scope.searchLoaderCount = 0;
2393
2394                    $scope.property_found = data.total_matched_property; // to show all matched property count
2395                    $scope.marker_map_prioperties = data.all_map_property;
2396                    $scope.last_update_corn_time = data.last_update_corn_time; // Last Update Mid Florida Property
2397
2398                    $scope.bedrooms[0].current = cond.bedroom;
2399                    $scope.bathrooms[0].current = cond.bathroom;
2400
2401                    // Set filter_expiration_time
2402                    const currentTimeInMilliseconds = Date.now();
2403                    const expirationTime =
2404                        currentTimeInMilliseconds +
2405                        $scope.resetFilterTimeThreshold * 60 * 1000;
2406                    $localStorage.filter_expiration_time = expirationTime;
2407
2408                    //$rootScope.all_property_search_list = $scope.all_property_list.map(a => a.ml);
2409                    var resultArray = $scope.marker_map_prioperties.map((a) => a.ml);
2410                    $localStorage.mls_id = JSON.stringify(resultArray);
2411
2412                    /* Map and Pagination propety start */
2413                    $scope.visible_property_found = data.total_matched_property;
2414                    if (data.total_matched_property > 500) {
2415                        // $scope.visible_property_found = 500;
2416                        $scope.fivehundred_msg_status = 1;
2417                    } else {
2418                        // $scope.visible_property_found = data.total_matched_property;
2419                        $scope.fivehundred_msg_status = 0;
2420                    }
2421                    /* Map and Pagination propety end */
2422
2423                    setTimeout(function () {
2424                        ImageFitCont();
2425                    }, 500);
2426                    setTimeout(function () {
2427                        $scope.fixCssBackgoundImageDoubleEncodingIssue();
2428                    }, 500);
2429
2430                    //***** Google map integration code here start *****//
2431                    var ip = 0;
2432                    var tmp = {};
2433                    var tmp_arr = [];
2434                    $scope.propertylatlngs = [];
2435
2436                    var latlngArray = Array();
2437                    if ($rootScope.polygon_lat_long) {
2438                        var latngtdata = JSON.parse($rootScope.polygon_lat_long);
2439                        for (var i = 0; i < latngtdata.length; i++) {
2440                            latlngArray[i] = [latngtdata[i].lat, latngtdata[i].lng];
2441                        }
2442                    }
2443
2444                    for (ip = 0; ip < $scope.marker_map_prioperties.length; ip++) {
2445                        tmp = $scope.marker_map_prioperties[ip];
2446                        if (latlngArray.length > 0) {
2447                            var checkPropertyBelongs = isPointInPoly(
2448                                latlngArray,
2449                                tmp.lat,
2450                                tmp.lng
2451                            );
2452                        }
2453
2454                        var prop_image = "";
2455
2456                        if (
2457                            typeof tmp.getimage != "undefined" &&
2458                            tmp.getimage != null &&
2459                            tmp.getimage.length > 0
2460                        ) {
2461                            prop_image = tmp.getimage[0].image_path;
2462                        }
2463
2464                        var mapCurrency = "";
2465                        if (tmp.currency_sign) {
2466                            mapCurrency = tmp.currency_sign;
2467                        } else {
2468                            mapCurrency = "$";
2469                        }
2470
2471                        tmp_arr = [
2472                            tmp.address +
2473                            ", " +
2474                            tmp.city_name +
2475                            ", " +
2476                            tmp.state +
2477                            " - " +
2478                            tmp.zip_code,
2479                            tmp.lat,
2480                            tmp.lng,
2481                            tmp.address +
2482                            ", " +
2483                            tmp.city_name +
2484                            ", " +
2485                            tmp.state +
2486                            " - " +
2487                            tmp.zip_code,
2488                            tmp.list_price,
2489                            tmp.id,
2490                            prop_image,
2491                            tmp.beds,
2492                            tmp.fbaths,
2493                            tmp.hbaths,
2494                            tmp.sqft_liv_area,
2495                            tmp.ml,
2496                            tmp.office_name,
2497                            tmp.mls_id,
2498                            mapCurrency,
2499                            tmp.rent_sale,
2500                            tmp.property_measurement_unit_short
2501                        ];
2502                        $scope.propertylatlngs.push(tmp_arr);
2503                    }
2504
2505                    // Set property type dropdown text
2506
2507
2508
2509                    if ($scope.propertyTypeDropdownText == "") {
2510                        $scope.setPropertyTypeDropdownTextFromAllPropertyTypes();
2511                    }
2512
2513                    setTimeout(function () {
2514                        // 
2515                        var allBound =
2516                            $scope.all_bound != undefined ? $scope.all_bound : {};
2517                        initMap2($scope.propertylatlngs, allBound);
2518                        setTimeout(() => {
2519                            // Centering to the default zip code if property count is 0 and if the there is no polygon lat long
2520                            if ($scope.marker_map_prioperties.length == 0 && !$rootScope.polygon_lat_long) {
2521                                const defaultZipSearch = localStorage.getItem("default_zip_search");
2522                                centerToZipCode(defaultZipSearch);
2523                            }
2524                        }, 500);
2525                        // Setting Map Pointer
2526                        // var firstPropertyMl = $rootScope.propertyMlsIds[0];
2527                        // var anchor = document.getElementById(firstPropertyMl);
2528                        // $('button.gm-ui-hover-effect').trigger('click');
2529                        setTimeout(() => {
2530                            const closeButton = jQuery('button.gm-ui-hover-effect');
2531                            closeButton.trigger("click");
2532
2533                        }, 500);
2534                        // angular.element("button.gm-ui-hover-effect").trigger("click");
2535                    }, 1000);
2536
2537                    // initMap2 is what creates the view's DrawingManager, so the
2538                    // draw hook can only be attached once it has run. Attached
2539                    // here, outside the timer above, so it is in place before the
2540                    // rebuild below and long before the user can draw.
2541                    ensurePolygonDrawHook();
2542
2543                    $rootScope.history = $location.$$path;
2544
2545
2546                    // Close the modal
2547                    // 
2548                    // const closeButton = document.querySelector('.gm-ui-hover-effect');
2549                    // closeButton.click();
2550
2551                    if ($rootScope.polygon_lat_long) {
2552                        var specify_by_polygon = $rootScope.polygon_lat_long;
2553                        if (specify_by_polygon != "" && $rootScope.hitorybackbtn == 1) {
2554                            draw_polygon_change = true;
2555                            var specify_by_polygon_arr = JSON.parse(specify_by_polygon);
2556                            var polygonset = new google.maps.Polygon({
2557                                map: map,
2558                                paths: specify_by_polygon_arr,
2559                                strokeWeight: 2,
2560                                fillColor: "#1aff1a",
2561                                fillOpacity: 0.5,
2562                                draggable: true,
2563                                editable: true,
2564                                geodesic: true,
2565                            });
2566                            polygonset.setMap(map2);
2567                            // Register it so the next rebuild replaces this
2568                            // overlay instead of stacking on top of it.
2569                            trackFilterPolygon(polygonset);
2570                            drawingManager.setDrawingMode(null);
2571
2572                            google.maps.event.addListener(polygonset, "dragend", function () {
2573                                // Polygon was dragged
2574                                isBeingDragged = false;
2575                                draw_polygon_change = true;
2576                                var myJson = JSON.stringify(polygonset.getPath().getArray());
2577                                setPolygonLatLngChnage(myJson);
2578                            });
2579
2580                            google.maps.event.addListener(
2581                                polygonset,
2582                                "dragstart",
2583                                function () {
2584                                    isBeingDragged = true;
2585                                }
2586                            );
2587
2588                            polygonset.getPaths().forEach(function (path, index) {
2589                                google.maps.event.addListener(
2590                                    path,
2591                                    "insert_at",
2592                                    function (markerCoords) {
2593                                        // New point
2594                                        var myJson = JSON.stringify(
2595                                            polygonset.getPath().getArray()
2596                                        );
2597                                        //call polygn value initialize and service call //
2598                                        setPolygonLatLngChnage(myJson);
2599                                        draw_polygon_change = true;
2600                                    }
2601                                );
2602
2603                                google.maps.event.addListener(path, "remove_at", function () {
2604                                    // Point was removed
2605                                    var myJson = JSON.stringify(polygonset.getPath().getArray());
2606                                    //call polygn value initialize and service call //
2607                                    setPolygonLatLngChnage(myJson);
2608                                    draw_polygon_change = true;
2609                                });
2610
2611                                google.maps.event.addListener(path, "set_at", function () {
2612                                    // Point was moved
2613                                    if (!isBeingDragged) {
2614                                        var myJson = JSON.stringify(
2615                                            polygonset.getPath().getArray()
2616                                        );
2617                                        //call polygn value initialize and service call //
2618                                        setPolygonLatLngChnage(myJson);
2619                                        draw_polygon_change = true;
2620                                    }
2621                                });
2622                            });
2623
2624                            setTimeout(function () {
2625                                $(document)
2626                                    .find(".result-blocks .col-sm-6:nth-child(2) a")
2627                                    .trigger("mouseover");
2628                            }, 2000);
2629                        }
2630
2631                        $rootScope.hitorybackbtn = 0;
2632
2633                        if ($rootScope.polygon_lat_long && draw_polygon_change) {
2634                            draw_polygon_change = false;
2635                            // Generate All ZIP code Array From result set //
2636                            $scope.zipcode_array = $scope.all_property_list.map(
2637                                (a) => a.zip_code
2638                            );
2639                            $scope.uniquezipcode_array = $scope.zipcode_array.filter(
2640                                function (item, pos) {
2641                                    return $scope.zipcode_array.indexOf(item) == pos;
2642                                }
2643                            );
2644
2645                            // Generate All County Name Array From result set //
2646                            $scope.county_array = $scope.all_property_list.map(
2647                                (a) => a.county
2648                            );
2649                            $scope.uniquecounty_array = $scope.county_array.filter(function (
2650                                item,
2651                                pos
2652                            ) {
2653                                return $scope.county_array.indexOf(item) == pos;
2654                            });
2655
2656                            // Generate All Development Name Array From result set //
2657                            $scope.development_Name = $scope.all_property_list.map(
2658                                (a) => a.development_name
2659                            );
2660                            $scope.development_Name_array = $scope.development_Name.filter(
2661                                function (item, pos) {
2662                                    return $scope.development_Name.indexOf(item) == pos;
2663                                }
2664                            );
2665
2666                            // Generate All Complex Name Array From result set //
2667                            $scope.complex_Name = $scope.all_property_list.map(
2668                                (a) => a.complex_name
2669                            );
2670                            $scope.complex_Name_array = $scope.complex_Name.filter(function (
2671                                item,
2672                                pos
2673                            ) {
2674                                return $scope.complex_Name.indexOf(item) == pos;
2675                            });
2676
2677                            // Generate All View Array From result set //
2678                            $scope.views_Name = $scope.all_property_list.map((a) => a.view);
2679                            $scope.views_Name_array = $scope.views_Name.filter(function (
2680                                item,
2681                                pos
2682                            ) {
2683                                return $scope.views_Name.indexOf(item) == pos;
2684                            });
2685
2686                            // Generate Water Access Array From result set //
2687                            $scope.water_access = $scope.all_property_list.map(
2688                                (a) => a.water_access
2689                            );
2690                            $scope.water_access_array = $scope.water_access.filter(function (
2691                                item,
2692                                pos
2693                            ) {
2694                                return $scope.water_access.indexOf(item) == pos;
2695                            });
2696
2697                            // Generate All Subdivition Name Array From result set //
2698                            $scope.subdivision_Name = $scope.all_property_list.map(
2699                                (a) => a.subdivision_name
2700                            );
2701                            $scope.subdivision_Name_array = $scope.subdivision_Name.filter(
2702                                function (item, pos) {
2703                                    return $scope.subdivision_Name.indexOf(item) == pos;
2704                                }
2705                            );
2706                        }
2707                    }
2708                });
2709            };
2710
2711            // Call $scope.searchProperty on first page load
2712            // if ($rootScope.firstSearchLoading) {
2713            //     $scope.searchProperty($localStorage.my_listing_search_params, $scope.all_bound);
2714            // }
2715
2716            // Project Details Page Function //
2717
2718            // Project Details Page Function //
2719            $scope.propertyDetails = function () {
2720                $scope.front_spinner = 1;
2721                $scope.property_ml_id = $routeParams.property_ml_id;
2722                var fb_app_id = $rootScope.fb_app_id;
2723                // IF FACEBOOK APP ID  NOT  PUTED FACEBOOK SHARE NOT VISIBLE BUTTON START//
2724                if (fb_app_id != "") {
2725                    $scope.fb_button_visible = 1;
2726                }
2727                // IF FACEBOOK APP ID  NOT  PUTED FACEBOOK SHARE NOT VISIBLE BUTTON END//
2728
2729                var token = localStorage.getItem("access_token"); // If login
2730
2731                if ($localStorage.my_listing_search_params) {
2732                    var search_params = JSON.parse($localStorage.my_listing_search_params);
2733                } else {
2734                    var search_params = "";
2735                }
2736
2737                var httpRequest = $http({
2738                    method: "POST",
2739                    url: base_url + "/firsthometheme/property-details-new",
2740                    data: {
2741                        property_ml_id: $scope.property_ml_id,
2742                        member_id: $scope.userid,
2743                        search_params: search_params,
2744                    },
2745                    headers: {
2746                        "Content-Type": "application/json; charset=utf-8",
2747                        "Access-Token": token,
2748                    },
2749                }).success(function (data, status) {
2750                    $scope.front_spinner = 0;
2751
2752                    if (data.property_det.length === 0) {
2753                        //if property is in database
2754                        $scope.has_property = 0;
2755                    } else {
2756                        if ($localStorage.mls_id) {
2757                            var storeMlsIds = JSON.parse($localStorage.mls_id);
2758                            var indexofMlsId = storeMlsIds.indexOf($scope.property_ml_id);
2759                            if (indexofMlsId > -1) {
2760                                $rootScope.all_property_search_list = storeMlsIds;
2761                                $rootScope.currentPropertyIndex = indexofMlsId;
2762                            }
2763                        }
2764
2765                        $scope.allRelatedProperty = data.realted_property;
2766                        $scope.has_property = 1;
2767                        $scope.property_det = data.property_det;
2768                        $scope.last_update_corn_time = data.last_update_corn_time;
2769                        $scope.latitude = my_lat = parseFloat(data.property_det.lat);
2770                        $scope.longitude = my_lng = parseFloat(data.property_det.lng);
2771                        $scope.address = address = data.property_det.address;
2772                        fb_app_id = data.user_fb_app_id;
2773
2774                        let propertyUrl =
2775                            base_url + "/property-details/" + $scope.property_det.ml;
2776                        $scope.shareMail["msg"] = "Check out this property " + propertyUrl;
2777                        $scope.shareMail["subject"] =
2778                            $scope.property_det.address +
2779                            "-" +
2780                            $scope.property_det.city_name +
2781                            ", " +
2782                            $scope.property_det.state +
2783                            ", " +
2784                            $scope.property_det.zip_code;
2785
2786                        // Set property details page in the local storage //
2787                        localStorage.setItem(
2788                            "prevroute",
2789                            "/property-details/" + $scope.property_det.ml
2790                        );
2791
2792                        if (data.logged_user_fav_proerty > 0) {
2793                            // For Checking user fav property
2794                            $scope.fav_status = 1;
2795                        } else {
2796                            $scope.fav_status = 0;
2797                        }
2798
2799                        // For Meta setting We use below section [Share image and Url] //
2800
2801                        $scope.property_image_url = ""; // image share url for FB
2802
2803                        if (data.property_det.getimage.length > 0) {
2804                            // check property images.. In which position get image set for the facebook share
2805                            for (var i = 0; i < data.property_det.getimage.length; i++) {
2806                                if (
2807                                    typeof data.property_det.getimage[i].image_path != "undefined"
2808                                ) {
2809                                    var last = data.property_det.getimage[i].image_path
2810                                        .split("/")
2811                                        .pop(); // no_image.png
2812                                    var no_image_last = last.split("."); // no_image
2813
2814                                    if (no_image_last[0] != "no_image") {
2815                                        $scope.property_image =
2816                                            theme_image_url +
2817                                            data.property_det.getsisdetails.getmlsdetails.name.toLowerCase() +
2818                                            "/" +
2819                                            data.property_det.getimage[i].image_path;
2820                                        $scope.property_image_url =
2821                                            base_url + $scope.property_image;
2822                                        break;
2823                                    }
2824                                }
2825                            }
2826                        }
2827
2828                        $scope.property_url = $location.absUrl();
2829
2830                        setTimeout(function () {
2831                            ProjectGallery();
2832                            projectDetailImgVideoSwiperSlider();
2833                            ImageFitCont();
2834
2835                            // FOR FACE BOOK INITILIZATION //
2836                            window.fbAsyncInit = function () {
2837                                FB.init({
2838                                    appId: fb_app_id,
2839                                    status: true,
2840                                    cookie: true,
2841                                    xfbml: true,
2842                                });
2843                            };
2844                            (function () {
2845                                var e = document.createElement("script");
2846                                e.async = true;
2847                                e.src =
2848                                    document.location.protocol +
2849                                    "//connect.facebook.net/en_US/all.js";
2850                                document.getElementById("fb-root").appendChild(e);
2851                            })();
2852                            // FOR FACE BOOK INITILIZATION //
2853
2854                            // Remove map loading call, it'll only be called when we click the "Load Map" button
2855                            // Wasim 29-01-2026
2856                            // initMap(); // init map call
2857
2858                            const homeProjectSliderSwiper = new Swiper(
2859                                ".home-project-slider",
2860                                {
2861                                    navigation: {
2862                                        nextEl: ".home-project-slider .swiper-button-next",
2863                                        prevEl: ".home-project-slider .swiper-button-prev",
2864                                    },
2865                                    slidesPerView: 1,
2866                                    spaceBetween: 30,
2867                                    breakpoints: {
2868                                        320: {
2869                                            slidesPerView: 1,
2870                                        },
2871                                        768: {
2872                                            slidesPerView: 2,
2873                                        },
2874                                        992: {
2875                                            slidesPerView: 3,
2876                                        },
2877                                        1200: {
2878                                            slidesPerView: 4,
2879                                        },
2880                                    },
2881                                }
2882                            );
2883
2884                            /* $('.home-project-slider').swiper({
2885                                          nextButton: '.project-slider .swiper-button-next',
2886                                          prevButton: '.project-slider .swiper-button-prev',
2887                                          slidesPerView: 4,
2888                                          spaceBetween: 30,
2889                                          breakpoints: {
2890                                  1024: {
2891                                      slidesPerView: 2
2892                                  },
2893                                  768: {
2894                                      slidesPerView: 1
2895                                  }
2896                              }
2897                          }); */
2898                        }, 1000);
2899                    }
2900                });
2901            };
2902
2903            // New Property details API
2904            $scope.fetchPropertyDetailsNew = function () {
2905                $rootScope.property_details_api_called = true;
2906                $scope.front_spinner = 1;
2907                $scope.propertyDetailsFetching = true;
2908                $scope.property_ml_id = $routeParams.property_ml_id;
2909                const ml = $scope.property_ml_id;
2910                var fb_app_id = $rootScope.fb_app_id;
2911
2912                // IF FACEBOOK APP ID  NOT  PUTED FACEBOOK SHARE NOT VISIBLE BUTTON START//
2913                if (fb_app_id != "") {
2914                    $scope.fb_button_visible = 1;
2915                }
2916
2917                var token = localStorage.getItem("access_token"); // If login
2918                if ($localStorage.my_listing_search_params) {
2919                    var search_params = JSON.parse($localStorage.my_listing_search_params);
2920                } else {
2921                    var search_params = "";
2922                }
2923
2924                var $httpRequest = $http({
2925                    method: "POST",
2926                    // url: base_url + '/firsthometheme/property-details-updated',
2927                    url: base_url + "/shared/property-details",
2928                    data: {
2929                        property_ml_id: $scope.property_ml_id,
2930                        member_id: $scope.userid,
2931                        search_params: search_params,
2932                    },
2933                    headers: {
2934                        "Content-Type": "application/json; charset=utf-8",
2935                        "Access-Token": token,
2936                    },
2937                }).success(function (data, status) {
2938                    $scope.front_spinner = 0;
2939                    if (data.property_det.length === 0) {
2940                        $scope.has_property = 0;
2941                    } else {
2942                        // if ($localStorage.mls_id) {
2943                        //     var storeMlsIds = JSON.parse($localStorage.mls_id);
2944                        //     var indexofMlsId = storeMlsIds.indexOf($scope.property_ml_id);
2945                        //     if (indexofMlsId > -1) {
2946                        //         $rootScope.all_property_search_list = storeMlsIds;
2947                        //         $rootScope.currentPropertyIndex = indexofMlsId;
2948                        //     }
2949                        // }
2950
2951                        // Set shareMail subject and message
2952                        let propertyUrl =
2953                            base_url + "/property-details/" + $scope.property_det.ml;
2954                        $scope.shareMail["msg"] = "Check out this property " + propertyUrl;
2955                        $scope.shareMail["subject"] =
2956                            $scope.property_det.address +
2957                            "-" +
2958                            $scope.property_det.city_name +
2959                            ", " +
2960                            $scope.property_det.state +
2961                            ", " +
2962                            $scope.property_det.zip_code;
2963
2964                        $scope.allRelatedProperty = [];
2965                        $scope.has_property = 1;
2966                        $scope.property_det = data.property_det;
2967                        $scope.property_ml_id = $scope.property_det.ml;
2968
2969                        $scope.latitude = parseFloat(data.property_det.lat);
2970                        $scope.longitude = parseFloat(data.property_det.lng);
2971
2972                        $scope.address = data.property_det.address;
2973                        fb_app_id = data.user_fb_app_id;
2974
2975                        if (data.logged_user_fav_property > 0) {
2976                            // For Checking user fav property
2977                            $scope.fav_status = 1;
2978                        } else {
2979                            $scope.fav_status = 0;
2980                        }
2981
2982                        $scope.property_image_url = ""; // image share url for FB
2983
2984                        if (data.property_det.getimage.length > 0) {
2985                            // check property images.. In which position get image set for the facebook share
2986                            for (var i = 0; i < data.property_det.getimage.length; i++) {
2987                                if (
2988                                    typeof data.property_det.getimage[i].image_path != "undefined"
2989                                ) {
2990                                    var last = data.property_det.getimage[i].image_path
2991                                        .split("/")
2992                                        .pop(); // no_image.png
2993                                    var no_image_last = last.split("."); // no_image
2994
2995                                    if (no_image_last[0] != "no_image") {
2996                                        $scope.property_image_url = data.property_det.getimage[i].image_path;
2997                                        // $scope.property_image =
2998                                        //   theme_image_url +
2999                                        //   data.property_det.getsisdetails.getmlsdetails.name.toLowerCase() +
3000                                        //   "/" +
3001                                        //   data.property_det.getimage[i].image_path;
3002                                        // $scope.property_image_url =
3003                                        //   base_url + $scope.property_image;
3004                                        break;
3005                                    }
3006                                }
3007                            }
3008                        }
3009                        $scope.property_url = $location.absUrl();
3010
3011                        setTimeout(function () {
3012                            ProjectGallery();
3013                            projectDetailImgVideoSwiperSlider();
3014                            ImageFitCont();
3015
3016                            // FOR FACE BOOK INITILIZATION //
3017                            window.fbAsyncInit = function () {
3018                                FB.init({
3019                                    appId: fb_app_id,
3020                                    status: true,
3021                                    cookie: true,
3022                                    xfbml: true,
3023                                });
3024                            };
3025                            (function () {
3026                                var e = document.createElement("script");
3027                                e.async = true;
3028                                e.src =
3029                                    document.location.protocol +
3030                                    "//connect.facebook.net/en_US/all.js";
3031                                document.getElementById("fb-root").appendChild(e);
3032                            })();
3033                            // FOR FACE BOOK INITILIZATION //
3034
3035                            // Remove map loading call, it'll only be called when we click the "Load Map" button
3036                            // Wasim 29-01-2026
3037                            // initMap(); // init map call
3038
3039                            const homeProjectSliderSwiper = new Swiper(
3040                                ".home-project-slider",
3041                                {
3042                                    navigation: {
3043                                        nextEl: ".home-project-slider .swiper-button-next",
3044                                        prevEl: ".home-project-slider .swiper-button-prev",
3045                                    },
3046                                    slidesPerView: 1,
3047                                    spaceBetween: 30,
3048                                    breakpoints: {
3049                                        320: {
3050                                            slidesPerView: 1,
3051                                        },
3052                                        768: {
3053                                            slidesPerView: 2,
3054                                        },
3055                                        992: {
3056                                            slidesPerView: 3,
3057                                        },
3058                                        1200: {
3059                                            slidesPerView: 4,
3060                                        },
3061                                    },
3062                                }
3063                            );
3064                        }, 1000);
3065
3066                        setTimeout(() => {
3067                            jQuery(
3068                                "#propertyProjectDetailModal .modal-body"
3069                            ).mCustomScrollbar("scrollTo", ["top", null]);
3070                        }, 500);
3071
3072                        $scope.propertyDetailsFetching = false;
3073                        // fetch related properties
3074                        $scope.fetchRelatedProperties(ml);
3075                    }
3076                });
3077            };
3078
3079
3080            // if ($scope.routeName == 'property_details' && ($rootScope.property_details_api_called == false || typeof $rootScope.property_details_api_called == 'undefined')) {
3081            //     // Call Property details
3082            //     $scope.property_ml_id = $routeParams.property_ml_id;
3083            //     $scope.fetchPropertyDetailsNew();
3084            // }
3085            // Project Details Page Function //
3086
3087            $scope.getRelatedImageSource = function (imagename, mlsname) {
3088                //var newbaseurl = 'https://dpirealtywebsites.com'
3089                if (imagename == "")
3090                    return (
3091                        base_url + "/public/themes/" + current_theme + "/images/no_menu.png"
3092                    );
3093                else
3094                    return (
3095                        base_url +
3096                        "/dpi_beta/uploads/" +
3097                        mlsname.toLowerCase() +
3098                        "/" +
3099                        imagename
3100                    );
3101            };
3102            // Project Details Page Function //
3103
3104            /******* SEARCH PROPERTY BUTTON AJAX END *******/
3105
3106            /******* Search Filter Checkbox Making Start *******/
3107
3108            $scope.checker = function (
3109                index,
3110                val // index= filter field name ; val= value[ex: Yes/No]
3111            ) {
3112                if (
3113                    typeof $scope.advanced_search[index] != "undefined" &&
3114                    $scope.advanced_search[index] == val
3115                ) {
3116                    delete $scope.advanced_search[index];
3117                } else {
3118                    $scope.advanced_search[index] = val; // Push advanced search filter in advanced_search array
3119                }
3120            };
3121
3122            /******* Search Filter Checkbox Making End *******/
3123
3124            /******* SEARCH PROPERTY BUTTON AJAX END *******/
3125
3126            $scope.changePage = function () // Pagination
3127            {
3128                $scope.pageChanged = true;
3129                if ($scope.search_by_polygon) {
3130                    // 
3131                    var cond =
3132                        $localStorage.my_listing_search_params != undefined &&
3133                            $localStorage.my_listing_search_params != ""
3134                            ? JSON.parse($localStorage.my_listing_search_params)
3135                            : {};
3136                    cond.page = $scope.currentPage;
3137                    $localStorage.my_listing_search_params = JSON.stringify(cond);
3138                    $scope.callingSearchProperty = true;
3139                    $scope.searchProperty($localStorage.my_listing_search_params, $scope.all_bound);
3140                } else {
3141                    // var cond = JSON.parse($localStorage.my_listing_search_params);
3142                    var cond =
3143                        $localStorage.my_listing_search_params != undefined &&
3144                            $localStorage.my_listing_search_params != ""
3145                            ? JSON.parse($localStorage.my_listing_search_params)
3146                            : {};
3147                    cond.page = $scope.currentPage;
3148                    $localStorage.my_listing_search_params = JSON.stringify(cond);
3149                    $scope.callingSearchProperty = true;
3150                    $scope.searchProperty($localStorage.my_listing_search_params, $scope.all_bound);
3151                }
3152            };
3153
3154            // For project details page //
3155            $scope.showNextProperty = function () {
3156                if ($rootScope.currentPropertyIndex < 20 && $localStorage.mls_id) {
3157                    $rootScope.currentPropertyIndex = $rootScope.currentPropertyIndex + 1;
3158                    var storeMlsIds = JSON.parse($localStorage.mls_id);
3159                    $routeParams.property_ml_id =
3160                        storeMlsIds[$rootScope.currentPropertyIndex];
3161                    $location.path("/property-details/" + $routeParam
3161s.property_ml_id);
3162                }
3163            };
3164
3165            $scope.showPreviousProperty = function () {
3166                if ($rootScope.currentPropertyIndex >= 0 && $localStorage.mls_id) {
3167                    $rootScope.currentPropertyIndex = $rootScope.currentPropertyIndex - 1;
3168                    var storeMlsIds = JSON.parse($localStorage.mls_id);
3169                    $routeParams.property_ml_id =
3170                        storeMlsIds[$rootScope.currentPropertyIndex];
3171                    $location.path("/property-details/" + $routeParams.property_ml_id);
3172                }
3173            };
3174            // For project details page //
3175
3176            /* DETAILS PAGE BACK BUTTON */
3177            $scope.backToSearchpage = function () {
3178                $localStorage.backwards = 1;
3179                if ($rootScope.history && $rootScope.polygon_lat_long) {
3180                    $rootScope.hitorybackbtn = 1;
3181                }
3182                var prevUrl = $rootScope.history ? $rootScope.history : "/";
3183                $location.path(prevUrl);
3184            };
3185            /* DETAILS PAGE BACK BUTTON */
3186
3187            /******* Search Details Page Start *******/
3188
3189            $scope.goToProjectDetails = function (prop_id, prop_ml_id) {
3190                $location.path("/property-details/" + prop_ml_id);
3191            };
3192
3193            //============ SHARE WITH FACEBOOK START ===========//
3194            $scope.share = function (post) {
3195                var fbpopup = window.open(
3196                    "https://www.facebook.com/sharer/sharer.php?u=" +
3197                    base_url +
3198                    "/property-details/" +
3199                    $scope.property_det.ml,
3200                    "pop",
3201                    "width=600, height=400, scrollbars=no"
3202                );
3203                $("#share").modal("hide");
3204            };
3205            //============ SHARE WITH FACEBOOK END ===========//
3206            //============ SHARE WITH LINKEDIN START ===========//
3207            $scope.linkedInShare = function (post) {
3208                window.open(
3209                    "https://www.linkedin.com/shareArticle?mini=true&url=" +
3210                    base_url +
3211                    "/property-details/" +
3212                    $scope.property_det.ml,
3213                    "pop",
3214                    "width=600, height=400, scrollbars=no"
3215                );
3216                $("#share").modal("hide");
3217            };
3218            //============ SHARE WITH LINKEDIN END ===========//
3219
3220            /******* Search Details Page End *******/
3221
3222            $scope.makeToFav =
3223                function () // From Property Details page make a property favourite list
3224                {
3225                    $scope.saveFavourite($scope.property_ml_id, "", "details");
3226                };
3227
3228            /****** Request/ And 2 get advice  Send Mail To Contact Agent Start ******/
3229
3230            $scope.submitFormMail = function (param) {
3231                const formData = angular.copy($scope.request);
3232                formData.captcha = {
3233                    id: $scope.request.captcha[param].id,
3234                    value: $scope.request.captcha[param].value,
3235                };
3236                var property_url = $location.absUrl();
3237
3238                var data = {
3239                    request: formData,
3240                    member_id: $scope.userid, //Agent id Website owner
3241                    param: param,
3242                    property_url: property_url,
3243                };
3244
3245                var httpRequest = $http({
3246                    method: "POST",
3247                    url: base_url + "/firsthometheme/send-request-mail",
3248                    data: data,
3249                })
3250                    .success(function (data, status) {
3251                        if (data.success == 1) {
3252                            // Reload all captchas
3253                            $scope.reloadAllCaptchas();
3254                            
3255                            if (param == "expert") {
3256                                $scope.showSuccMsg = 1;
3257                                $scope.change_class = "#FFF";
3258                            } else if (param == "advice") {
3259                                $scope.showSuccMsg1 = 1;
3260                                $scope.change_class = "#71b100";
3261                            } else {
3262                                $scope.showSuccMsg2 = 1;
3263                                $scope.change_class = "#71b100";
3264                            }
3265
3266                            $scope.show_message =
3267                                "Your query has been sent successfully.We will contact you soon.";
3268
3269                            $timeout(function () {
3270                                $scope.showSuccMsg1 = 0;
3271                                $scope.showSuccMsg2 = 0;
3272                                $scope.showSuccMsg = 0;
3273                                angular.element(".close").trigger("click");
3274                                $scope.$digest();
3275                            }, 3000);
3276                            $scope.requestForm.reset();
3277                            $scope.adviceForm.reset();
3278                            $scope.expertForm.reset();
3279                        } else {
3280                            if (param == "expert") {
3281                                $scope.showSuccMsg = 1;
3282                            } else if (param == "advice") {
3283                                $scope.showSuccMsg1 = 1;
3284                            } else {
3285                                $scope.showSuccMsg2 = 1;
3286                            }
3287                            if(data.message) {
3288                                $scope.show_message = data.message;
3289                            } else {
3290                                $scope.show_message = "Some error occured.";
3291                            }
3292                            $scope.change_class = "#F00";
3293
3294                            $timeout(function () {
3295                                $scope.showSuccMsg1 = 0;
3296                                $scope.showSuccMsg2 = 0;
3297                                $scope.showSuccMsg = 0;
3298                                $scope.$digest();
3299                            }, 3000);
3300                        }
3301                    })
3302                    .error(function (data, status, header, config) {
3303                        if (param == "expert") {
3304                            $scope.showSuccMsg = 1;
3305                        } else if (param == "advice") {
3306                            $scope.showSuccMsg1 = 1;
3307                        } else {
3308                            $scope.showSuccMsg2 = 1;
3309                        }
3310                        $scope.show_message = "Some error occured.";
3311                        $scope.change_class = "#F00";
3312                        $timeout(function () {
3313                            $scope.showSuccMsg1 = 0;
3314                            $scope.showSuccMsg2 = 0;
3315                            $scope.showSuccMsg = 0;
3316                            $scope.$digest();
3317                        }, 3000);
3318                    });
3319            };
3320
3321            /****** Request Send Mail To Contact Agent End******/
3322
3323            /**** Remove Search Filter ****/
3324            $scope.removeSearchFilter = function (index) {
3325                if (typeof $scope.advanced_search[index] != "undefined") {
3326                    if (index == "bedrooms") {
3327                        $scope.bedrating = 0;
3328
3329                        $scope.getSelectedBed($scope.bedrating);
3330                        $scope.bedrooms[0].current = 0;
3331                    } else if (index == "bathrooms") {
3332                        $scope.bathrating = 0;
3333                        $scope.getSelectedBath($scope.bathrating);
3334                        $scope.bathrooms[0].current = 0;
3335                    }
3336                    $scope.agent_zip_search = "";
3337                    delete $scope.advanced_search[index];
3338                    // $scope.searchProperty($localStorage.my_listing_search_params, $scope.all_bound);
3339                    // 
3340                }
3341                //
3342            };
3343
3344            // CHANGE PROPERTY TYPE //
3345
3346            $scope.changePropertyType = function () {
3347                $(".m200").toggleClass("open");
3348                // var cond = JSON.parse($localStorage.my_listing_search_params);
3349                var cond =
3350                    $localStorage.my_listing_search_params != undefined &&
3351                        $localStorage.my_listing_search_params != ""
3352                        ? JSON.parse($localStorage.my_listing_search_params)
3353                        : {};
3354                cond.property_type = $scope.search.property_type;
3355                $localStorage.my_listing_search_params = JSON.stringify(cond);
3356                $scope.callingSearchProperty = true;
3357                $scope.searchProperty($localStorage.my_listing_search_params, $scope.all_bound);
3358            };
3359
3360            $scope.closePropertyDropdown = function () {
3361                $(".m200").toggleClass("open");
3362            };
3363            $scope.setPropertyTypeDropdownText = function (propertyType) {
3364                if (propertyType == "all") {
3365                    $scope.setPropertyTypeDropdownText(propertyType);
3366                    $scope.propertyTypeDropdownText = "Property Type";
3367                    return;
3368                }
3369                $scope.propertyTypeDropdownText = "";
3370                const firstPropertyTypeStringLength = $scope.property_types_array[0].length;
3371                if (firstPropertyTypeStringLength > 13) {
3372                    $scope.propertyTypeDropdownText = $scope.property_types_array[0].substring(0, 13) + "...";
3373                } else {
3374                    $scope.propertyTypeDropdownText = $scope.property_types_array[0];
3375                }
3376                if ($scope.property_types_array.length > 1) {
3377                    $scope.propertyTypeDropdownText += " +";
3378                    $scope.propertyTypeDropdownText += $scope.property_types_array.length - 1;
3379                }
3380            }
3381
3382            $scope.setPropertyTypeDropdownTextFromAllPropertyTypes = function () {
3383                $scope.propertyTypeDropdownText = "";
3384                // Check if no property types is selected
3385
3386
3387
3388                if ($scope.property_types_array.length == 0) {
3389                    $scope.propertyTypeDropdownText = "Property Type";
3390                    return;
3391                }
3392                const firstPropertyTypeStringLength = $scope.property_types_array[0].length;
3393                if (firstPropertyTypeStringLength > 13) {
3394                    $scope.propertyTypeDropdownText = $scope.property_types_array[0].substring(0, 13) + "...";
3395                } else {
3396                    $scope.propertyTypeDropdownText = $scope.property_types_array[0];
3397                }
3398                if ($scope.property_types_array.length > 1) {
3399                    $scope.propertyTypeDropdownText += " +";
3400                    $scope.propertyTypeDropdownText += $scope.property_types_array.length - 1;
3401                }
3402            }
3403
3404            // Support for multiple property types
3405            $scope.togglePropertyTypes = function (propertyType) {
3406                if (propertyType === "all") {
3407                    $scope.setPropertyTypeDropdownText(propertyType);
3408                    $scope.property_types_array = [];
3409
3410
3411                    $('#user_all').prop("checked", true);
3412                    var cond =
3413                        $localStorage.my_listing_search_params != undefined &&
3414                            $localStorage.my_listing_search_params != ""
3415                            ? JSON.parse($localStorage.my_listing_search_params)
3416                            : {};
3417                    cond.property_types = $scope.property_types_array;
3418                    $localStorage.my_listing_search_params = JSON.stringify(cond);
3419                    $scope.callingSearchProperty = true;
3420                    $scope.searchProperty($localStorage.my_listing_search_params, $scope.all_bound);
3421
3422
3423                    return;
3424                }
3425                if ($scope.property_types_array.indexOf(propertyType) === -1) {
3426                    $scope.property_types_array.push(propertyType);
3427                } else {
3428                    $scope.property_types_array.splice($scope.property_types_array.indexOf(propertyType), 1);
3429                }
3430                $scope.setPropertyTypeDropdownText(propertyType);
3431                // $(".m200").toggleClass("open");
3432
3433
3434                // var cond = JSON.parse($localStorage.my_listing_search_params);
3435                var cond =
3436                    $localStorage.my_listing_search_params != undefined &&
3437                        $localStorage.my_listing_search_params != ""
3438                        ? JSON.parse($localStorage.my_listing_search_params)
3439                        : {};
3440                // var cond =
3441                //     $localStorage.my_listing_search_params != undefined &&
3442                //         $localStorage.my_listing_search_params != ""
3443                //         ? JSON.parse($localStorage.my_listing_search_params)
3444                //         : {};
3445                cond.property_types = $scope.property_types_array;
3446                $localStorage.my_listing_search_params = JSON.stringify(cond);
3447                // $localStorage.my_listing_search_params = JSON.stringify(cond);
3448                $scope.callingSearchProperty = true;
3449                // $scope.searchProperty($localStorage.my_listing_search_params, $scope.all_bound);
3450                $scope.searchProperty($localStorage.my_listing_search_params, $scope.all_bound);
3451
3452
3453            };
3454
3455            $scope.changeMinPrice = function () {
3456                // var cond = JSON.parse($localStorage.my_listing_search_params);
3457                var cond =
3458                    $localStorage.my_listing_search_params != undefined &&
3459                        $localStorage.my_listing_search_params != ""
3460                        ? JSON.parse($localStorage.my_listing_search_params)
3461                        : {};
3462                cond.min_price = $scope.search.min_price;
3463                $localStorage.my_listing_search_params = JSON.stringify(cond);
3464                $scope.callingSearchProperty = true;
3465                $scope.searchProperty($localStorage.my_listing_search_params, $scope.all_bound);
3466            };
3467            $scope.changeMaxPrice = function () {
3468                // var cond = JSON.parse($localStorage.my_listing_search_params);
3469                var cond =
3470                    $localStorage.my_listing_search_params != undefined &&
3471                        $localStorage.my_listing_search_params != ""
3472                        ? JSON.parse($localStorage.my_listing_search_params)
3473                        : {};
3474                cond.max_price = $scope.search.max_price;
3475                $localStorage.my_listing_search_params = JSON.stringify(cond);
3476                $scope.callingSearchProperty = true;
3477                $scope.searchProperty($localStorage.my_listing_search_params, $scope.all_bound);
3478
3479                if ($scope.search.max_price == null) {
3480                    $scope.priceMinLimitTotal = 10;
3481                    $scope.priceMaxLimitStart = $scope.minSelectedIndex + 1;
3482                }
3483            };
3484
3485            //////////////////////////////////
3486
3487            // For reset your search params //
3488            $scope.resetSearch = function () // Reset Search
3489            {
3490
3491                // $scope.clearPolygonStucture();
3492                listneradded_zoom = false;
3493                listneradded_drag = false;
3494
3495                $scope.search.put_location = "";
3496                $localStorage.my_listing_search_params = "";
3497                $scope.currentPage = 1; //after reset search paging start from 1st
3498                $scope.search.property_type = "";
3499                $scope.property_types_array = [];
3500                $scope.search.min_price = "";
3501                $scope.search.max_price = "";
3502                // $scope.search_listing_sort = "listprice_asc";
3503                $scope.search_listing_sort = $rootScope.my_listing_page_sort;
3504                $scope.image_category = $rootScope.image_category;
3505
3506                $scope.recordLimit = 20;
3507                $scope.currentPage = 1;
3508                $scope.advanced_search = {};
3509                $scope.advanced_search.zip_code = [$localStorage.agent_zip_search];
3510                if ($scope.menu_id == 14 && $scope.criteria_id == 99) {
3511                    delete $scope.advanced_search.zip_code;
3512                }
3513                $scope.halfbathrooms[0].current = 0;
3514                $scope.bedrating = 0;
3515                $scope.bedrooms[0].current = 0;
3516                $scope.bathrating = 0;
3517                $scope.bathrooms[0].current = 0;
3518                // $scope.agent_zip_search = '';
3519                $scope.agent_zip_search = $localStorage.agent_zip_search;
3520                if ($scope.menu_id == 14 && $scope.criteria_id == 99) {
3521                    delete $scope.advanced_search.agent_zip_search;
3522                }
3523
3524                $scope.all_bound = {};
3525
3526                if (!$scope.callingSearchProperty) {
3527                    $scope.searchProperty();
3528                }
3529            };
3530
3531            /*********** ADVANCED SEARCH SECTION SHOW HIDE START ************/
3532            $scope.animate = false;
3533            $scope.showHide = function () {
3534                $scope.animate = !$scope.animate;
3535                if ($scope.animate == true) {
3536                    $scope.show_advanced_text = "Hide Advanced Search";
3537                } else {
3538                    $scope.show_advanced_text = "Show Advanced Search";
3539                }
3540            };
3541
3542            /*********** ADVANCED SEARCH SECTION SHOW HIDE START ************/
3543
3544            /* make active with active class advanced filter */
3545            /* make active with active class advanced filter */
3546            $scope.$watch(
3547                "advanced_search",
3548                function (newVal, oldVal) {
3549
3550                    if (!$rootScope.advanceSearchWatcherEnabled) {
3551                        return;
3552                    }
3553                    // if ($rootScope.firstSearchLoading) {
3554                    //     return;
3555                    // }
3556                    if (oldVal === newVal) {
3557
3558
3559
3560
3561
3562                        if (
3563                            // $rootScope.firstSearchLoading &&
3564                            Object.keys($scope.advanced_search).length != 0
3565                        ) {
3566                            $scope.callingSearchProperty = true;
3567                            $scope.searchProperty();
3568                        }
3569                    } else {
3570
3571
3572
3573                        if ($rootScope.hitback) {
3574                            $rootScope.hitback = 0;
3575                            // var cond = JSON.parse($localStorage.my_listing_search_params);
3576                            var cond =
3577                                $localStorage.my_listing_search_params != undefined &&
3578                                    $localStorage.my_listing_search_params != ""
3579                                    ? JSON.parse($localStorage.my_listing_search_params)
3580                                    : {};
3581                            var agentid = $scope.userid; // Site owner
3582
3583                            $scope.search.property_type = cond.property_type;
3584                            $scope.property_types_array = cond.property_types;
3585                            $scope.bedrating = cond.bedroom;
3586                            $scope.bathrating = cond.bathroom;
3587                            $scope.search.min_price = cond.min_price;
3588                            $scope.search.max_price = cond.max_price;
3589                            $scope.search_listing_sort = cond.search_listing_sort;
3590                            $scope.image_category = cond.image_category;
3591                            $scope.recordLimit = cond.limit;
3592                            $scope.currentPage = cond.page;
3593                            $scope.advanced_search = JSON.parse(cond.advance_search);
3594                            $scope.all_bound = JSON.parse(cond.all_bound);
3595
3596                            $scope.bedrooms[0].current = cond.bedroom;
3597                            $scope.bathrooms[0].current = cond.bathroom;
3598
3599                            var cond = {
3600                                property_type: $scope.search.property_type,
3601                                property_types: $scope.property_types_array,
3602                                bedroom: $scope.bedrating,
3603                                bathroom: $scope.bathrating,
3604                                min_price: $scope.search.min_price,
3605                                max_price: $scope.search.max_price,
3606                                search_listing_sort: $scope.search_listing_sort,
3607                                image_category: $scope.image_category,
3608                                limit: $scope.recordLimit,
3609                                page: $scope.currentPage,
3610                                advanced_search: JSON.parse(cond.advance_search),
3611                                all_bound: typeof $scope.all_bound === 'string' ? $scope.all_bound : JSON.stringify(cond.all_bound),
3612                                agentid: agentid,
3613                            };
3614                            $localStorage.backwards = 1; // from property details page  back to search page
3615                            $scope.callingSearchProperty = true;
3616                            $scope.searchProperty(cond, $scope.all_bound);
3617
3618                        } else {
3619                            if ($localStorage.my_listing_search_params) {
3620                                // var cond = JSON.parse($localStorage.my_listing_search_params);
3621                                var cond =
3622                                    $localStorage.my_listing_search_params != undefined &&
3623                                        $localStorage.my_listing_search_params != ""
3624                                        ? JSON.parse($localStorage.my_listing_search_params)
3625                                        : {};
3626                                if (newVal.bedrooms) {
3627                                    cond.bedroom = newVal.bedrooms;
3628                                } else {
3629                                    cond.bedroom = 0;
3630                                }
3631                                if (newVal.bathrooms) {
3632                                    cond.bathroom = newVal.bathrooms;
3633                                } else {
3634                                    cond.bathroom = 0;
3635                                }
3636
3637                                var new_advance_serach = JSON.stringify(newVal);
3638                                cond.advance_search = new_advance_serach;
3639
3640                                cond = JSON.stringify(cond);
3641                                if ($rootScope.ignore_watcher == false) {
3642                                    $scope.callingSearchProperty = true;
3643                                    $scope.searchProperty(cond, $scope.all_bound);
3644                                } else {
3645                                    $scope.callingSearchProperty = true;
3646                                    $scope.searchProperty(cond, $scope.all_bound);
3647                                    $rootScope.ignore_watcher = false;
3648                                }
3649
3650                                //Call save search history
3651                                var usertoken = localStorage.getItem("access_token");
3652                                if (typeof usertoken != "undefined") {
3653                                    $scope.saveSearchHistory();
3654                                }
3655
3656                                // $localStorage.my_listing_search_params = cond;
3657                            } else {
3658                                var agentid = $scope.userid; // Site owner
3659
3660                                var cond = {
3661                                    property_type: $scope.search.property_type,
3662                                    property_types: $scope.property_types_array,
3663                                    bedroom: $scope.bedrating,
3664                                    bathroom: $scope.bathrating,
3665                                    min_price: $scope.search.min_price,
3666                                    max_price: $scope.search.max_price,
3667                                    search_listing_sort: $scope.search_listing_sort,
3668                                    image_category: $scope.image_category,
3669                                    limit: $scope.recordLimit,
3670                                    page: $scope.currentPage,
3671                                    advance_search: JSON.stringify([]),
3672                                    agentid: agentid,
3673                                };
3674                                $scope.callingSearchProperty = true;
3675                                $scope.searchProperty(cond, $scope.all_bound);
3676
3677                                // $localStorage.my_listing_search_params = cond;
3678                            }
3679                            // Involking search function any changes in search filter
3680                        }
3681
3682                        $("#searchModal").modal("hide"); // After Search modal close
3683
3684                        $scope.advance_search_make_green_active();
3685                    } //else end
3686                },
3687                true
3688            ); /**********************************************************/
3689
3690            $scope.sortListingSearchProperty = function () {
3691                // var cond = JSON.parse($localStorage.my_listing_search_params);
3692                var cond =
3693                    $localStorage.my_listing_search_params != undefined &&
3694                        $localStorage.my_listing_search_params != ""
3695                        ? JSON.parse($localStorage.my_listing_search_params)
3696                        : {};
3697
3698
3699                var cond = {
3700                    property_type: $scope.search.property_type,
3701                    property_types: $scope.property_types_array,
3702                    bedroom: $scope.bedrating,
3703                    bathroom: $scope.bathrating,
3704                    min_price: $scope.search.min_price,
3705                    max_price: $scope.search.max_price,
3706                    search_listing_sort: $scope.search_listing_sort,
3707                    image_category: $scope.image_category,
3708                    limit: $scope.recordLimit,
3709                    page: $scope.currentPage,
3710                    advanced_search:
3711                        typeof cond.advance_search === "undefined"
3712                            ? {}
3713                            : typeof cond.advance_search === 'string' ? JSON.parse(cond.advance_search) : cond.advance_search,
3714                    // advanced_search:
3715                    //     typeof cond.advance_search === "undefined"
3716                    //         ? []
3717                    //         : JSON.parse(cond.advance_search),
3718                    all_bound: typeof cond.all_bound === 'string' ? cond.all_bound : JSON.stringify(cond.all_bound),
3719                    agentid: $scope.userid,
3720                };
3721                $scope.callingSearchProperty = true;
3722                $scope.searchProperty(cond, $scope.all_bound);
3723            };
3724
3725            $scope.changeImageCategory = function (imgageCategoryOption = {}) {
3726                // Check if empty object
3727                if (Object.keys(imgageCategoryOption).length == 0) {
3728                    $scope.image_category = "";
3729                } else {
3730                    $scope.image_category = imgageCategoryOption.visible_name;
3731                }
3732                // var cond = JSON.parse($localStorage.search_params);
3733                var cond =
3734                    $localStorage.search_params != undefined &&
3735                        $localStorage.search_params != ""
3736                        ? $scope.getSearchParamsFromLocalStorage()
3737                        : {};
3738
3739
3740                var cond = {
3741                    property_type: $scope.search.property_type,
3742                    property_types: $scope.property_types_array,
3743                    bedroom: $scope.bedrating,
3744                    bathroom: $scope.bathrating,
3745                    min_price: $scope.search.min_price,
3746                    max_price: $scope.search.max_price,
3747                    search_listing_sort: $scope.search_listing_sort,
3748                    search_listing_date_sort: $scope.search_listing_date_sort,
3749                    image_category: $scope.image_category,
3750                    limit: $scope.recordLimit,
3751                    page: $scope.currentPage,
3752                    advanced_search:
3753                        typeof cond.advance_search === "undefined"
3754                            ? {}
3755                            : typeof cond.advance_search === 'string' ? JSON.parse(cond.advance_search) : cond.advance_search,
3756                    // advanced_search:
3757                    //     typeof cond.advance_search === "undefined"
3758                    //         ? []
3759                    //         : JSON.parse(cond.advance_search),
3760                    all_bound: typeof cond.all_bound === 'string' ? cond.all_bound : JSON.stringify(cond.all_bound),
3761                    agentid: $scope.userid,
3762                };
3763                $scope.callingSearchProperty = true;
3764                $scope.searchProperty(cond, $scope.all_bound);
3765            };
3766
3767            /**********************************************************/
3768
3769            // Responsive Toggle View //
3770            $scope.toggleFilter = function () {
3771                $(".middle_searchform").toggleClass("open");
3772            };
3773
3774            $scope.toggleView = function () {
3775                //$('.middle_searchform').toggleClass('open');
3776                $(".search_results").toggleClass("mapview");
3777                if ($(".search_results").hasClass("mapview")) {
3778                    $("#toggleView").html("List");
3779                } else $("#toggleView").html("Map");
3780            };
3781            $("#navbar").on("show.bs.collapse", function () {
3782                $("header").addClass("higherzindex");
3783            });
3784            $("#navbar").on("hidden.bs.collapse", function () {
3785                $("header").removeClass("higherzindex");
3786            });
3787            // Responsive Toggle End //
3788
3789            // SAVE SEARCH
3790            $scope.saveSearch = function (user_id, page) {
3791                // if ($localStorage.my_listing_search_params) {
3792                //     var parsed_data = $localStorage.my_listing_search_params;
3793                // }
3794                if ($scope.searchCondition != "") {
3795                    var searchCondition = JSON.parse($scope.searchCondition);
3796                    // remove pit and mls id from search condition
3797                    delete searchCondition.pit;
3798                    delete searchCondition.mls_ids;
3799                    var parsed_data = JSON.stringify(searchCondition);
3800                }
3801                const saveSearchEditing = localStorage.getItem("save_search_editing");
3802                const saveSearchId = localStorage.getItem("save_search_id");
3803
3804                if (saveSearchEditing == 1) {
3805                    var data = {
3806                        page: page,
3807                        parsed_data: parsed_data,
3808                        member_id: $scope.userid,
3809                        save_search_id: saveSearchId,
3810                    };
3811                } else {
3812                    var data = {
3813                        page: page,
3814                        parsed_data: parsed_data,
3815                        member_id: $scope.userid,
3816                    };
3817                }
3818
3819                var token = localStorage.getItem("access_token");
3820                var config = {
3821                    headers: {
3822                        "Content-Type": "application/json; charset=utf-8",
3823                        "Access-Token": token,
3824                    },
3825                };
3826
3827                $http
3828                    .post(base_url + "/firstclient/save-search", data, config)
3829                    .success(function (data, status, headers, config) {
3830                        if (data.success == 1) {
3831                            $scope.change_class = "success-save";
3832                            $scope.show_message = "Search saved successfully.";
3833                            $scope.showSuccMsg = 1;
3834                            setTimeout(function () {
3835                                $scope.$apply(function () {
3836                                    $scope.showSuccMsg = 0;
3837                                });
3838                                if (localStorage.getItem("save_search_editing") == 1) {
3839                                    localStorage.setItem("save_search_editing", 0);
3840                                    localStorage.setItem("save_search_id", 0);
3841                                    // close the tab
3842                                    window.close();
3843                                }
3844                            }, 2000);
3845                        } else if (data.success == 2) {
3846                            localStorage.setItem(
3847                                "prevroute",
3848                                "/11/" + $routeParams.page_name + $routeParams.menu_id
3849                            );
3850                            // Close the modal then redirect to login
3851                            $scope.goingToLogin = true;
3852                            // 
3853                            // jQuery('#propertyProjectDetailModal').modal('hide');
3854                            $scope.hidePropertyDetailModal();
3855                            $scope.showClientLoginPopup(); // Show login popup instead of redirecting to user-login
3856                            // $location.path("/user-login");
3857                        } else {
3858                            $scope.change_class = "error-save";
3859                            $scope.show_message = "Some error occured.";
3860                            $scope.showSuccMsg = 1;
3861                            setTimeout(function () {
3862                                $scope.$apply(function () {
3863                                    $scope.showSuccMsg = 0;
3864                                });
3865                            }, 2000);
3866                        }
3867                    });
3868            };
3869
3870            /******************** SAVE SEARCH BY LOGGED IN USER START *******************/
3871
3872            /**
3873             *
3874             * Hide the property detail modal start
3875             *
3876             */
3877            $scope.hidePropertyDetailModal = function () {
3878                jQuery("#propertyProjectDetailModal").modal("hide");
3879                // If backdrop still remains
3880                jQuery(".modal-backdrop").hide();
3881            };
3882            /**
3883             *
3884             * Hide the property detail modal end
3885             *
3886             */
3887
3888            /******************** FAVOURITE PROPERTY BY LOGGED IN USER START *******************/
3889            $scope.saveFavourite = function (property_ml_id, i, page) {
3890                var data = {
3891                    property_ml_id: property_ml_id,
3892                    member_id: $scope.userid,
3893                };
3894
3895                var token = localStorage.getItem("access_token");
3896                var config = {
3897                    headers: {
3898                        "Content-Type": "application/json; charset=utf-8",
3899                        "Access-Token": token,
3900                    },
3901                };
3902
3903                $http
3904                    .post(base_url + "/firstclient/favourite-property-new", data, config)
3905                    .success(function (data, status, headers, config) {
3906                        $scope.makeToFavClicked = false;
3907
3908                        if (page == "search") {
3909                            // For Search Pages if like from search page
3910                            if (data.success == 1) {
3911                                if (
3912                                    typeof $scope.all_property_list[i].fav_status !=
3913                                    "undefined" &&
3914                                    $scope.all_property_list[i].fav_status == 1
3915                                )
3916                                    $scope.all_property_list[i].fav_status = 0;
3917                                else $scope.all_property_list[i].fav_status = 1;
3918                            } else if (data.success == 2) {
3919                                if ($scope.routeName === "property_details") {
3920                                    // After login
3921                                    localStorage.setItem(
3922                                        "prevroute",
3923                                        "/property-details/" + property_ml_id
3924                                    );
3925                                } else {
3926                                    localStorage.setItem(
3927                                        "prevroute",
3928                                        "/11/" + $routeParams.page_name + "/" + $routeParams.menu_id
3929                                    );
3930                                }
3931                                // Close the modal then redirect to login
3932                                $scope.goingToLogin = true;
3933                                // 
3934                                // jQuery('#propertyProjectDetailModal').modal('hide');
3935                                $scope.hidePropertyDetailModal();
3936                                $scope.showClientLoginPopup(); // Show login popup instead of redirecting to user-login
3937                                // $location.path("/user-login");
3938                            }
3939                        } else if (page == "details") {
3940                            // For Search Pages if like from property details page
3941                            if (data.success == 1) {
3942                                if (
3943                                    typeof $scope.fav_status != "undefined" &&
3944                                    $scope.fav_status == 1
3945                                )
3946                                    $scope.fav_status = 0;
3947                                else $scope.fav_status = 1;
3948                            } else if (data.success == 2) {
3949                                if ($scope.routeName === "property_details") {
3950                                    // After login
3951                                    localStorage.setItem(
3952                                        "prevroute",
3953                                        "/property-details/" + property_ml_id
3954                                    );
3955                                }
3956                                // Hide property details modal
3957                                $scope.goingToLogin = true;
3958                                // 
3959                                // jQuery('#propertyProjectDetailModal').modal('hide');
3960                                $scope.hidePropertyDetailModal();
3961                                $scope.showClientLoginPopup();
3961 // Show login popup instead of redirecting to user-login
3962                                // $location.path("/user-login");
3963                            }
3964                        }
3965                    });
3966            };
3967
3968            // Capture the login and registration modal hide
3969            jQuery('#clientLoginModal').on('hidden.bs.modal', function (e) {
3970                let searchUrl = "/my_listings";
3971                $scope.goingToLogin = false;
3972                location.skipReload().path(searchUrl).replace();
3973            });
3974            jQuery('#clientRegistrationModal').on('hidden.bs.modal', function (e) {
3975                let searchUrl = "/my_listings";
3976                $scope.goingToLogin = false;
3977                location.skipReload().path(searchUrl).replace();
3978            });
3979
3980            /******************** FAVOURITE PROPERTY BY LOGGED IN USER END *******************/
3981
3982            /************** SAVE IDX SEARCH BY LOGGED IN USER START ***************/
3983
3984            /**********  QUICK SEARCH STRAT **********/
3985
3986            $scope.quickSearch = function () {
3987                $scope.quickSearchCalled = true;
3988                var agentid = $scope.userid; // Site owner
3989                $rootScope.fromhomesearch = 1;
3990
3991                var cond = {
3992                    property_type: $scope.search.property_type,
3993                    property_types: $scope.property_types_array,
3994                    bedroom: $scope.bedrating,
3995                    bathroom: $scope.bathrating,
3996                    min_price: $scope.search.min_price,
3997                    max_price: $scope.search.max_price,
3998                    search_listing_sort: $scope.search_listing_sort,
3999                    image_category: $scope.image_category,
4000                    limit: $scope.recordLimit,
4001                    page: $scope.currentPage,
4002                    advance_search: typeof $scope.advanced_search === 'string' ? $scope.advanced_search : JSON.stringify($scope.advanced_search),
4003                    agentid: agentid,
4004                };
4005
4006                if (typeof cond != "undefined") {
4007                    $localStorage.my_listing_search_params = JSON.stringify(cond); // Set search parameters in local storage
4008                }
4009
4010                // $location.path('/11/search/11');
4011                // Making dynamic /11/search/11 & /11/search-property/11
4012                const pageName =
4013                    $routeParams.page_name == undefined
4014                        ? "search"
4015                        : $routeParams.page_name;
4016                const menuId =
4017                    $routeParams.menu_id == undefined ? "11" : $routeParams.menu_id;
4018                var searchUrl = "/11/" + pageName + "/" + menuId;
4019                $location.path(searchUrl);
4020                //$location.path($scope.menu_id+'/'+$routeParams.page_name+'/'+$scope.menu_id);
4021            };
4022
4023            /**********  QUICK SEARCH END **********/
4024
4025            /* For Dynamic Meta data call Start */
4026
4027            $scope.allSetMeta =
4028                function () // Call all meta tag and social tag set for user/ default
4029                {
4030                    var httpRequest = $http({
4031                        method: "POST",
4032                        url: base_url + "/firsthometheme/all-social-meta",
4033                        data: {
4034                            menu_id: $scope.menu_id,
4035                            userid: $scope.userid,
4036                        },
4037                    }).success(function (data, status) {
4038                        $scope.allsocialmeta = data.social_meta_des;
4039                        $rootScope.my_listing_page_sort = data.listing_sorts.my_listing_page_sort;
4040                        $scope.search_listing_sort = $rootScope.my_listing_page_sort;
4041                        if ($scope.allsocialmeta.og_url == 1) {
4042                            $scope.allsocialmeta.og_url = $location.absUrl();
4043                        }
4044                    });
4045                };
4046
4047            /* For Dynamic Meta data call End */
4048            //====================================================================//
4049            if ($scope.routeName !== "property_details") {
4050                $scope.allSetMeta(); // self invoking
4051            }
4052            //====================================================================//
4053
4054            if (
4055                $scope.criteria_id > 0 &&
4056                $scope.menu_id > 0 &&
4057                $scope.callingSearchProperty === false
4058            ) {
4059                $scope.callingSearchProperty = true;
4060                $scope.advance_search = {};
4061                if (
4062                    $scope.currentRoute != "property_details" &&
4063                    $rootScope.previousRoute !== $scope.currentRoute &&
4064                    isEmpty
4065                ) {
4066
4067                    // Save the access token and usr_info before clearing
4068                    const accessToken = localStorage.getItem("access_token");
4069                    const userInfo = localStorage.getItem("usr_info");
4070                    const visited = localStorage.getItem("visited");
4071                    $localStorage.$reset();
4072                    localStorage.clear();
4073                    localStorage.setItem("usr_info", userInfo);
4074                    localStorage.setItem("access_token", accessToken);
4075                    if(visited) {
4076                        localStorage.setItem("visited", visited);
4077                    }
4078                }
4079                // $scope.firstSearchLoading = true;
4080                $scope.searchProperty();
4081            } else {
4082                $scope.advance_search = {};
4083                if (
4084                    $routeParams.page_name != "search-property" &&
4085                    $rootScope.fromhomesearch != 1 &&
4086                    $scope.currentRoute != "property_details" &&
4087                    $rootScope.previousRoute !== $scope.currentRoute &&
4088                    isEmpty &&
4089                    typeof $rootScope.previousRoute !== "undefined"
4090                ) {
4091
4092
4093                    // Save the access token and usr_info before clearing
4094                    const accessToken = localStorage.getItem("access_token");
4095                    const userInfo = localStorage.getItem("usr_info");
4096                    $localStorage.$reset();
4097                    localStorage.clear();
4098                    localStorage.setItem("usr_info", userInfo);
4099                    localStorage.setItem("access_token", accessToken);
4100                }
4101
4102                // $scope.firstSearchLoading = true;
4103                if ($rootScope.doNotCallZipCode !== true) {
4104                    $scope.getAgentDetails();
4105                }
4106            }
4107            $scope.getPublicRelatorMedias = function () {
4108                $http({
4109                    method: "POST",
4110                    url: "https://api.ibuyervideos.com/api/public-medias",
4111                    data: {
4112                        user_id: $scope.userid,
4113                        mls_id: $scope.property_ml_id,
4114                    },
4115                }).success(function (data, status) {
4116                    $scope.realtorMedias = data.medias;
4117
4118                    if ($scope.realtorMedias.children.length) {
4119                        $scope.realtorSlides = $scope.realtorMedias.children[0].files;
4120                        // $scope.slideDescription = $scope.realtorMedias.folder.folder_description;
4121                        $scope.activeFolderSlide = 0;
4122                        $scope.activeFileSlide = null;
4123                        $scope.setDescription();
4124                    } else if ($scope.realtorMedias.files.length) {
4125                        $scope.realtorSlides = $scope.realtorMedias.files;
4126                        // $scope.slideDescription = $scope.realtorMedias.folder.folder_description;
4127                        $scope.activeFileSlide = index;
4128                        $scope.activeFolderSlide = null;
4129                        $scope.setDescription();
4130                    }
4131                });
4132            };
4133
4134            $scope.changeFolderSlide = function (index) {
4135                $scope.realtorSlides = $scope.realtorMedias.children[index].files;
4136                $scope.activeFolderSlide = index;
4137                $scope.activeFileSlide = null;
4138                fileFolder_detail_sliderSwiper.update();
4139                window.setTimeout(function () {
4140                    window.dispatchEvent(new Event("resize"));
4141                    fileFolder_detail_sliderSwiper.slideTo(0);
4142                    $scope.setDescription(fileFolder_detail_sliderSwiper.realIndex);
4143                }, 1000);
4144            };
4145
4146            $scope.changeFileSlide = function (index) {
4147                $scope.realtorSlides = $scope.realtorMedias.files;
4148                $scope.activeFileSlide = index;
4149                $scope.activeFolderSlide = null;
4150                fileFolder_detail_sliderSwiper.update();
4151                window.setTimeout(function () {
4152                    window.dispatchEvent(new Event("resize"));
4153                    fileFolder_detail_sliderSwiper.slideTo(index);
4154                    $scope.setDescription(fileFolder_detail_sliderSwiper.realIndex);
4155                }, 1000);
4156            };
4157
4158            $scope.setDescription = function (index = null) {
4159                if ($scope.activeFolderSlide != null) {
4160                    $scope.slideDescription = index
4161                        ? $scope.realtorSlides[index].description
4162                        : $scope.realtorMedias.children[0].files[0].description;
4163                } else if ($scope.activeFileSlide != null) {
4164                    $scope.slideDescription = index
4165                        ? $scope.realtorSlides[index].description
4166                        : $scope.realtorMedias.files[0].description;
4167                }
4168                if (projectDetailFileFolderModal.classList.contains("in")) {
4169                    $scope.$apply();
4170                }
4171            };
4172
4173            if ($scope.routeName === "property_details") {
4174                $scope.getPublicRelatorMedias();
4175            }
4176
4177            $scope.setMinPrice = function (price) {
4178                let minIndex = $scope.priceRanges.indexOf(price);
4179                // $scope.priceMinLimitStart = Math.min(index + 1, 9);
4180                $scope.priceMaxLimitStart = minIndex + 1;
4181                $scope.search.min_price = $scope.priceRanges[minIndex];
4182                $scope.minSelectedIndex = minIndex;
4183                $scope.showMinPriceList = false;
4184                $scope.showMaxPriceList = true;
4185
4186                if ($scope.maxSelectedIndex == 0) {
4187                    $scope.maxSelectedIndex = $scope.minSelectedIndex;
4188                }
4189            };
4190
4191            $scope.setMaxPrice = function (price) {
4192                let maxIndex = $scope.priceRanges.indexOf(price);
4193                $scope.maxSelectedIndex = maxIndex;
4194                $scope.search.max_price = $scope.priceRanges[$scope.maxSelectedIndex];
4195                $scope.priceMaxLimitStart = $scope.maxSelectedIndex + 1;
4196                $scope.priceMinLimitTotal = Math.min($scope.maxSelectedIndex, 10);
4197                $scope.showMinPriceList = true;
4198                $scope.showMaxPriceList = false;
4199                $scope.closePriceList();
4200            };
4201
4202            $scope.setMaxPriceEmpty = function () {
4203                $scope.maxSelectedIndex = null;
4204                $scope.search.max_price = "";
4205                $scope.priceMaxLimitStart = $scope.minSelectedIndex + 1;
4206                $scope.priceMinLimitTotal = 10;
4207                // $scope.closePriceList();
4208            };
4209
4210            $scope.adjustMinDropdown = function () {
4211                $scope.showMinPriceList = true;
4212                $scope.showMaxPriceList = false;
4213            };
4214
4215            $scope.adjustMaxDropdown = function () {
4216                $scope.showMinPriceList = false;
4217                $scope.showMaxPriceList = true;
4218            };
4219
4220            $scope.closePriceList = function () {
4221                $(".mw165").toggleClass("open");
4222                $scope.changeMaxPrice();
4223            };
4224
4225            // price Range Value change watch function start //
4226            $scope.$watchGroup(
4227                ["search.min_price", "search.max_price"],
4228                function (newValues, oldValues, scope) {
4229                    // if ($rootScope.firstSearchLoading) {
4230                    //     return;
4231                    // }
4232                    if (
4233                        newValues[0] > 0 &&
4234                        (newValues[1] == "" || newValues[1] == null)
4235                    ) {
4236                        $scope.price_view_value =
4237                            "$" + $scope.kFormatter(newValues[0]) + "+";
4238                    } else if (
4239                        (newValues[0] == "" || newValues[0] == 0 || newValues[0] == null) &&
4240                        newValues[1] > 0
4241                    ) {
4242                        $scope.price_view_value =
4243                            "Up To $" + $scope.kFormatter(newValues[1]) + "+";
4244                    } else if (
4245                        newValues[0] != "" &&
4246                        newValues[1] != "" &&
4247                        newValues[0] > 0 &&
4248                        newValues[1] > 0
4249                    ) {
4250                        $scope.price_view_value =
4251                            "$" +
4252                            $scope.kFormatter(newValues[0]) +
4253                            " - $" +
4254                            $scope.kFormatter(newValues[1]);
4255                    } else if (
4256                        (newValues[0] == "" || newValues[0] == 0 || newValues[0] == null) &&
4257                        (newValues[1] == "" || newValues[1] == null)
4258                    ) {
4259                        $scope.price_view_value = "Enter Price";
4260                    }
4261                }
4262            );
4263
4264            // price Range Value change watch function end //
4265
4266            $scope.kFormatter = function (
4267                num //price formatter after 1000 its convert to K $2000 = $2k
4268            ) {
4269                return num > 999 ? parseFloat((num / 1000).toFixed(1)) + "k" : num;
4270            };
4271
4272            // Save Search History Of loggedin User Start//
4273            $scope.saveSearchHistory = function () {
4274                if ($localStorage.my_listing_search_params) {
4275                    var parsed_data = $localStorage.my_listing_search_params;
4276                }
4277                var data = {
4278                    parsed_data: parsed_data,
4279                    member_id: $scope.userid,
4280                };
4281                var token = localStorage.getItem("access_token");
4282                var config = {
4283                    headers: {
4284                        "Content-Type": "application/json; charset=utf-8",
4285                        "Access-Token": token,
4286                    },
4287                };
4288                $http
4289                    .post(base_url + "/firstclient/save-search-history", data, config)
4290                    .success(function (data, status, headers, config) {
4291                        if (data.success == 1) {
4292                            //
4293                        } else {
4294                            //
4295                        }
4296                    });
4297            };
4298            // Save Search History Of loggedin User End//
4299
4300            //////////////////////////////////////////////////////////////////////////////
4301
4302            // if ($scope.routeName == 'search_property' && $scope.callingSearchProperty == false) {
4303            //     if (typeof $scope.all_bound != 'undefined' && Object.keys($scope.all_bound).length > 0) {
4304            //         $scope.searchProperty({}, $scope.all_bound);
4305            //     } else {
4306            //         $scope.searchProperty();
4307            //     }
4308
4309            // }
4310
4311            // Add event listener for project-thumb
4312            jQuery(".project-thumb > a").hover(function () {
4313                var mlCode = jQuery(this).attr("id");
4314
4315
4316                jQuery(".marker_googlemap").removeClass("property_hovered");
4317                jQuery(".marker_" + mlCode).addClass("property_hovered");
4318            });
4319        }
4320    ); // Controller end

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.