1'use strict'; 2 3 4angular.module('dpiApp') 5 .controller('RecentlyClosedSearchPropertyController', function ($scope, $timeout, $http, configService, $rootScope, $location, $route, $routeParams, $localStorage, $window) { 6 7 $scope.search_by_polygon = 0; 8 $scope.show_advanced_text = "Show Advanced Search"; 9 $scope.page_heading = ''; 10 $scope.userid = isNaN(current_theme) ? user_id : current_theme; 11 $scope.show_default = 1; // For default website show default list 12 $scope.property_list = {}; 13 $scope.recordLimit = 20; 14 $scope.currentPage = 1; 15 $scope.newCurrentPage = 1; 16 $scope.property_found = 0; 17 $scope.visible_property_found = 0; 18 $scope.totalItemsProp = 0; 19 $scope.search_but_show_hide = 1; 20 $scope.fb_button_visible = 0; // Facebook Share button 21 $scope.visited = {}; 22 $scope.search = {}; 23 $scope.bedrating = 0; 24 $scope.bathrating = 0; 25 $scope.search.property_type = ''; 26 //$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 27 //$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 28 $scope.search.min_price = 0; 29 $scope.search.max_price = 0; 30 $scope.search_listing_sort = 'listprice_desc'; 31 $scope.sethbaths = {}; 32 $scope.all_bound = {}; // lat lng boundary 33 $scope.front_spinner = 0; 34 $scope.search_loader = 0; 35 $scope.advance_open = 0; 36 $scope.fivehundred_msg_status = 0; 37 $scope.property_ml_id = $routeParams.property_ml_id; 38 $scope.latitude = 27.6648; 39 $scope.longitude = -81.5158; 40 $scope.address = ''; 41 $scope.filter_data = {}; 42 $scope.furnished_active = $scope.water_front_active = $scope.water_access_active = $scope.view_active = $scope.pool_active = $scope.pet_active = $scope.hbaths_active = $scope.complex_name_active = $scope.subdivision_name_active = $scope.development_name_active = $scope.county_active = $scope.zip_code_active = $scope.foreclosure_active = $scope.short_sale_active = $scope.mebership_fee_active = ''; 43 $scope.advanced_search = {}; 44 $scope.optionsFromQuery = []; // Filter Value array 45 $scope.show_loader = 1; // Search property loader 46 $scope.modal_loader = 1; // Modal Pop up loader 47 $scope.price_view_value = 'Any Price'; 48 $scope.hitsavedsearch = 0; 49 $scope.copyright = Date.now(); 50 $scope.search_by_polygon = 0; 51 $rootScope.using_saved_zip=true; //use it skip saved search zip if user enter in location 52 $rootScope.ignore_watcher=false; 53 $scope.is_coming_from_home=0; 54 55 $scope.menu_id = (typeof $routeParams.menu_id == 'undefined') ? 2 : $routeParams.menu_id; 56 57 // page heading Setting 58 if (typeof $scope.meta_heading[$routeParams.page_name] != 'undefined') { 59 $scope.page_heading = $scope.meta_heading[$routeParams.page_name]; 60 } else { 61 $scope.$on('menudatareceived', function (event, args) { 62 $scope.page_heading = $scope.meta_heading[$routeParams.page_name]; 63 }); 64 } 65 66 // image fit call on page load 67 setTimeout(function () { 68 ImageFitCont(); 69 jQuery(document).on('click', '.dropdown-menu', function (evt) { 70 evt.stopPropagation(); 71 }); 72 jQuery(document).on('click', function (event) { 73 var clickover = jQuery(event.target); 74 75 clickover = clickover.hasClass('feature_listpanel'); 76 var _opened = jQuery("#advance_collapse").hasClass("in"); 77 if (_opened == true && clickover != true) { 78 jQuery('.collapse').collapse('hide'); 79 } 80 }); 81 }, 500); 82 83 /**********************/ 84 85 86 /****** Get Current Route Name ******/ 87 $scope.location = $location.path(); 88 $scope.routeName = $route.current.$$route.name; 89
90 $scope.newobject.active_class = $routeParams.page_name; // Active Class Settings 91 92 /****** Get Current Route Name ******/ 93 $scope.$on('$viewContentLoaded', function(){ 94 console.log('viewContentLoaded') 95 var pathArr = $location.path().split('/'); 96 console.log(pathArr); 97 if(pathArr.indexOf('recently_sold')==2) 98 { 99 100 setTimeout(()=>{ 101 102 //console.log($scope.agent_zip_search) 103 104 if (typeof $scope.agent_zip_search != 'undefined' && $scope.agent_zip_search != '' && $scope.is_coming_from_home == 0) { 105 console.log("Search hit"); 106 //$rootScope.using_saved_zip=true; 107 108 if (!$scope.advanced_search.zip_code) { 109 $scope.advanced_search.zip_code = []; 110 $scope.advanced_search.zip_code[0] = $scope.agent_zip_search; 111 112 console.log($scope.agent_zip_search) 113 } 114 else { 115 if ($scope.advanced_search.zip_code.indexOf($scope.agent_zip_search) === '-1') 116 $scope.advanced_search.zip_code.push($scope.agent_zip_search); 117 } 118 } 119 },1000); 120 } 121 //Here your view content is fully loaded !! 122 }); 123 124 125 ///// AGENT WEBSITE DETAILS START ///// 126 $scope.getAgentDetails = function () // get agent details for home page of his website 127 { 128 var agent_id = $scope.userid; 129 var httpRequest = $http({ 130 method: 'POST', 131 url: base_url + '/hometheme/get-agent-details', 132 data: { 133 agent_id: agent_id 134 } 135 136 }).success(function (data, status) { 137 console.log("AG DETAILS"); 138 $scope.agentDetails = data.agent_details; 139 $scope.agent_zip_search = data.agent_details.zip_search; 140 $scope.agent_set_zip_code = data.agent_details.zip_search; // For only reset search 141 $scope.property_details_view_count = data.agent_details.property_details_view_count; //property_details_view_count 142 143 if ($scope.routeName == 'search_property') { 144 $scope.getSelectedBed(0, 1); 145 $scope.getSelectedBath(0, 1); 146 $scope.bedrooms[0].current = 0; 147 $scope.bathrooms[0].current = 0; 148 $scope.advanced_search.bedrooms = 0; 149 $scope.advanced_search.bathrooms = 0; 150 } 151 152 }); 153 } 154 ///// AGENT WEBSITE DETAILS START ///// 155 156 157 // For Google Map 158 var markers = []; 159 160 $scope.getAllProperty = function () { 161 var httpRequest = $http({ 162 method: 'POST', 163 url: base_url + '/hometheme/all-property', 164 data: {} 165 166 }).success(function (data, status) { 167 168 $scope.property_type = data.all_property_type; 169 }); 170 } 171 172 $scope.getAllProperty(); 173 174 // START NEW FEATURES ADDED FOR POLYGON DRAW // 175 $scope.drawOrRemovePolygone = function () { 176 177 $scope.search_by_polygon = 1; 178 $rootScope.polygon_lat_long = $scope.polygon_lat_long; 179 var cond = JSON.parse($localStorage.search_params); 180 cond.polygon_lat_long = $rootScope.polygon_lat_long; 181 $scope.currentPage = 1; 182 cond.currentPage = $scope.currentPage; 183 $localStorage.search_params = JSON.stringify(cond); 184 185 var latlngarray = JSON.parse($rootScope.polygon_lat_long); 186 187 var newArray = Array(); 188 if (latlngarray.length > 0) { 189 190 for (var i = 0; i < latlngarray.length; i++) { 191 var latlng = [latlngarray[i].lat, latlngarray[i].lng]; 192 newArray.push(latlng); 193 } 194 } 195 196 var geoJsonData = { "type": "Feature", "properties": {}, "geometry": { "type": "Polygon", "coordinates": [newArray] } }; 197 198 var geoJsonLayer = L.geoJson(geoJsonData); 199 var bound = geoJsonLayer.getBounds(); 200 var northeastbound = bound.getNorthEast();
201 var southwastbound = bound.getSouthWest(); 202 203 var max_lat = northeastbound.lng; 204 var max_lng = northeastbound.lat; 205 var min_lat = southwastbound.lng; 206 var min_lng = southwastbound.lat; 207 var latlng_arr = {}; 208 209 latlng_arr['max_lat'] = max_lat; 210 latlng_arr['max_lng'] = max_lng; 211 latlng_arr['min_lat'] = min_lat; 212 latlng_arr['min_lng'] = min_lng; 213 214 $scope.all_bound = latlng_arr; 215 $scope.searchProperty($localStorage.search_params, $scope.all_bound); 216 } 217 218 $scope.clearPolygonStucture = function () { 219 $rootScope.polygon_lat_long = ''; 220 $rootScope.hitorybackbtn = 0; 221 var cond = JSON.parse($localStorage.search_params); 222 if (cond.polygon_lat_long) { 223 delete cond['polygon_lat_long']; 224 } 225 $scope.currentPage = 1; 226 cond.currentPage = $scope.currentPage; 227 $localStorage.search_params = JSON.stringify(cond); 228 $scope.all_bound = {}; 229 $scope.searchProperty($localStorage.search_params, $scope.all_bound); 230 } 231 232 /****** Check All property inside polygon or not ****/ 233 function isPointInPoly(poly, y, x) { 234 var c = false, j = poly.length - 1, i; 235 236 for (i = 0; i < poly.length; i++) { 237 238 if ((poly[i][0] < y && poly[j][0] >= y || poly[j][0] < y && poly[i][0] >= y) 239 && (poly[i][1] <= x || poly[j][1] <= x)) { 240 if (poly[i][1] + (y - poly[i][0]) / (poly[j][0] - poly[i][0]) * (poly[j][1] - poly[i][1]) < x) { 241 c = !c; 242 } 243 } 244 j = i; 245 246 } 247 return c; 248 } 249 /****** Check All property inside polygon or not ****/ 250 251 // END NEW FEATURES ADDED FOR POLYGON DRAW // 252 253 $scope.getDistinct = function (params) // Filter For Advanced Search 254 { 255 $scope.modal_loader = 1; 256 $scope.filter_data = ''; 257 var httpRequest = $http({ 258 method: 'POST', 259 url: base_url + '/hometheme/search-filter', 260 data: { 261 filter: params, 262 advanced_search: JSON.stringify($scope.advanced_search), 263 member_id: $scope.userid 264 } 265 }).success(function (data, status) { 266 $scope.modal_loader = 0; 267 $scope.filter_data = data; 268 $scope.optionsFromQuery = data.get_val; 269 270 if ($rootScope.polygon_lat_long && $scope.uniquezipcode_array && data.filter_param == 'zip_code') { 271 $scope.optionsFromQuery = $scope.uniquezipcode_array; 272 } 273 if ($rootScope.polygon_lat_long && $scope.uniquecounty_array && data.filter_param == 'county') { 274 $scope.optionsFromQuery = $scope.uniquecounty_array; 275 } 276 if ($rootScope.polygon_lat_long && $scope.development_Name_array && data.filter_param == 'development_name') { 277 $scope.optionsFromQuery = $scope.development_Name_array; 278 } 279 if ($rootScope.polygon_lat_long && $scope.complex_Name_array && data.filter_param == 'complex_name') { 280 $scope.optionsFromQuery = $scope.complex_Name_array; 281 } 282 if ($rootScope.polygon_lat_long && $scope.views_Name_array && data.filter_param == 'view') { 283 $scope.optionsFromQuery = $scope.views_Name_array; 284 } 285 if ($rootScope.polygon_lat_long && $scope.water_access_array && data.filter_param == 'water_access') { 286 $scope.optionsFromQuery = $scope.water_access_array; 287 } 288 if ($rootScope.polygon_lat_long && $scope.subdivision_Name_array && data.filter_param == 'subdivision_name') { 289 $scope.optionsFromQuery = $scope.subdivision_Name_array; 290 } 291 }); 292 } 293 294 /**** Generate Polygon Boundary ******/ 295 $scope.generateBoundary = function () { 296 297 $scope.search_by_polygon = 1; 298 var latlngarray = JSON.parse($rootScope.polygon_lat_long); 299 300 var newArray = Array(); 301 if (latlngarray.length > 0) { 302 303 for (var i = 0; i < latlngarray.length; i++) { 304 var latlng = [latlngarray[i].lat, latlngarray[i].lng]; 305 newArray.push(latlng); 306 } 307 } 308 309 var geoJsonData = { "type": "Feature", "properties": {}, "geometry": { "type": "Polygon", "coordinates": [newArray] } }; 310 311 var geoJsonLayer = L.geoJson(geoJsonData); 312 var bound = geoJsonLayer.getBounds(); 313 var northeastbound = bound.getNorthEast();
314 var southwastbound = bound.getSouthWest(); 315 316 var max_lat = northeastbound.lng; 317 var max_lng = northeastbound.lat; 318 var min_lat = southwastbound.lng; 319 var min_lng = southwastbound.lat; 320 var latlng_arr = {}; 321 322 latlng_arr['max_lat'] = max_lat; 323 latlng_arr['max_lng'] = max_lng; 324 latlng_arr['min_lat'] = min_lat; 325 latlng_arr['min_lng'] = min_lng; 326 327 $scope.all_bound = latlng_arr; 328 } 329 /**** Generate Polygon Boundary ******/ 330 331 332 /* Bedroom Bathroom icon setup start */ 333 334 $scope.bedrooms = [{ 335 current: 0, 336 max: 4 337 }]; 338 $scope.bathrooms = [{ 339 current: 0, 340 max: 4 341 }]; 342 $scope.halfbathrooms = [{ 343 current: 0, 344 max: 4 345 }]; 346 347 $scope.getSelectedBed = function (bedrating, sp) { 348 $scope.bedrating = bedrating; 349 $scope.advanced_search.bedrooms = $scope.bedrating; 350 351 if (!sp) { 352 $scope.searchProperty($localStorage.search_params, $scope.all_bound); 353 } 354 } 355 $scope.getSelectedBath = function (bathrating, sp) { 356 $scope.bathrating = bathrating; 357 $scope.advanced_search.bathrooms = $scope.bathrating; 358 359 if (!sp) { 360 $scope.searchProperty($localStorage.search_params, $scope.all_bound); 361 } 362 } 363 $scope.getSelectedHalfBath = function (halfbath) { 364 $scope.halfbath = halfbath; 365 $scope.advanced_search.hbaths = $scope.halfbath; 366 if ($scope.advanced_search['hbaths'] == 'undefined') { 367 $scope.hbaths_active = ''; 368 } else { 369 $scope.hbaths_active = 'active'; 370 } 371 } 372 373 /* Bedroom Bathroom icon setup end */ 374 375 376 /******* ADVANCED SEARCH ACTIVE FUNCTION SEARCH *******/ 377 378 $scope.advance_search_make_green_active = function () { 379 380 if (typeof $scope.advanced_search['membership_fee_required'] != 'undefined') { 381 $scope.mebership_fee_active = 'active'; 382 } else { 383 $scope.mebership_fee_active = ''; 384 } 385 386 if (typeof $scope.advanced_search['short_sale'] != 'undefined') { 387 $scope.short_sale_active = 'active'; 388 389 } else { 390 $scope.short_sale_active = ''; 391 } 392 if (typeof $scope.advanced_search['foreclosure'] != 'undefined') { 393 $scope.foreclosure_active = 'active'; 394 } else { 395 $scope.foreclosure_active = ''; 396 } 397 //console.log($scope.advanced_search['zip_code'].length); 398 if (typeof $scope.advanced_search['zip_code'] != 'undefined' && $scope.advanced_search['zip_code'].length > 0) { 399 $scope.zip_code_active = 'active'; 400 } else { 401 $scope.zip_code_active = ''; 402 } 403 if (typeof $scope.advanced_search['county'] != 'undefined') { 404 $scope.county_active = 'active'; 405 } else { 406 $scope.county_active = ''; 407 } 408 if (typeof $scope.advanced_search['development_name'] != 'undefined') { 409 $scope.development_name_active = 'active'; 410 } else { 411 $scope.development_name_active = ''; 412 } 413 if (typeof $scope.advanced_search['subdivision_name'] != 'undefined') { 414 $scope.subdivision_name_active = 'active'; 415 } else { 416 $scope.subdivision_name_active = ''; 417 } 418 if (typeof $scope.advanced_search['complex_name'] != 'undefined') { 419 $scope.complex_name_active = 'active'; 420 } else { 421 $scope.complex_name_active = ''; 422 } 423 if (typeof $scope.advanced_search['hbaths'] != 'undefined') { 424 $scope.hbaths_active = 'active'; 425 } else { 426 $scope.hbaths_active = ''; 427 } 428 if (typeof $scope.advanced_search['pet'] != 'undefined') { 429 $scope.pet_active = 'active'; 430 } else { 431 $scope.pet_active = ''; 432 } 433 if (typeof $scope.advanced_search['pool'] != 'undefined') { 434 $scope.pool_active = 'active'; 435 } else { 436 $scope.pool_active = ''; 437 } 438 if (typeof $scope.advanced_search['view'] != 'undefined') { 439 $scope.view_active = 'active'; 440 } else { 441 $scope.view_active = ''; 442 } 443 if (typeof $scope.advanced_search['water_access'] != 'undefined') { 444 $scope.water_access_active = 'active'; 445 } else { 446 $scope.water_access_active = ''; 447 } 448 if (typeof $scope.advanced_search['water_front'] != 'undefined') { 449 $scope.water_front_active = 'active'; 450 } else { 451 $scope.water_front_active = ''; 452 } 453 if (typeof $scope.advanced_search['furnished'] != 'undefined') { 454 $scope.furnished_active = 'active'; 455 } else { 456 $scope.furnished_active = ''; 457 } 458 459 460 } 461 462 /******* ADVANCED SEARCH ACTIVE FUNCTION END *******/ 463 464 /******* SEARCH PROPERTY BUTTON AJAX START *******/ 465 $scope.searchProperty = function (cond, allbound) //cond 466 { 467 console.log("SEARCH SERVICE"); 468 469 if (typeof localStorage.getItem('hit_saved_search') !== 'undefined') { 470 $scope.hitsavedsearch = localStorage.getItem('hit_saved_search'); 471 localStorage.removeItem('hit_saved_search'); 472 } 473 474 $scope.all_bound = allbound; 475 var agentid = $scope.userid; // Site owner 476 $scope.front_spinner = 1; 477 var backwards = localStorage.getItem('backwards'); // from property details page back to search page 478 479 // For V2 release client didn't want default zip code search, So commented the below code // 480 481 console.log($rootScope.fromhomesearch); 482 /* if (typeof $scope.agent_zip_search != 'undefined' && $scope.agent_zip_search != '' && backwards != 1 ) 483 { 484 console.log("Search hit"); 485 //$rootScope.using_saved_zip=true; 486 487 if(!$scope.advanced_search.zip_code) 488 { 489 $scope.advanced_search.zip_code = []; 490 $scope.advanced_search.zip_code[0] = $scope.agent_zip_search; 491 } 492 else 493 { 494 if($scope.advanced_search.zip_code.indexOf($scope.agent_zip_search)==='-1') 495 $scope.advanced_search.zip_code.push($scope.agent_zip_search); 496 } 497 } */ 498 499 500 if ($rootScope.fromhomesearch == 1 || $scope.hitsavedsearch == 1) { 501 $rootScope.fromhomesearch = 0; 502 $scope.hitsavedsearch = 0; 503 $scope.is_coming_from_home = 1; 504 505 var cond = JSON.parse($localStorage.search_params); 506 507 $scope.search.property_type = cond.property_type; 508 $scope.bedrating = cond.bedroom; 509 $scope.bathrating = cond.bathroom;
510 $scope.search.min_price = cond.min_price; 511 $scope.search.max_price = cond.max_price; 512 $scope.search_listing_sort = cond.search_listing_sort; 513 $scope.recordLimit = cond.limit; 514 $scope.currentPage = cond.page; 515 $scope.advanced_search = JSON.parse(cond.advance_search); 516 $scope.all_bound = JSON.parse(cond.all_bound); 517 $scope.polygon_lat_long = JSON.parse(cond.polygon_lat_long); 518 } 519 520 if ($rootScope.hitorybackbtn == 1 && $rootScope.polygon_lat_long) { 521 $scope.generateBoundary(); 522 } 523 524 525 /** 526 * loading from copied search param 527 * If there is query params of search include it in localstorage 528 */ 529 // console.log('SDD',$rootScope.polygon_lat_long); 530 531 if ($routeParams.search) { 532 try { 533 console.log('$routeParams', $routeParams.search) 534 var setParams = JSON.parse(atob($routeParams.search)); 535 $scope.search.property_type = setParams.property_type; 536 $scope.bedrating = setParams.bedroom; 537 $scope.bathrating = setParams.bathroom; 538 $scope.search.min_price = setParams.min_price; 539 $scope.search.max_price = setParams.max_price; 540 $scope.search_listing_sort = setParams.search_listing_sort; 541 $scope.recordLimit = setParams.limit; 542 $scope.currentPage = setParams.page; 543 $scope.advanced_search = JSON.parse(setParams.advance_search); 544 $scope.all_bound = JSON.parse(setParams.all_bound); 545 $scope.polygon_lat_long = JSON.parse(setParams.polygon_lat_long); 546 547 //For map pointer 548 $rootScope.polygon_lat_long = setParams.polygon_lat_long; 549 $rootScope.hitorybackbtn=1; 550 551 // //var redirectUrl = ''; 552 // var redirectUrl = $location.host(); 553 // $routeParams.params = undefined; 554 // console.log('$setParams', redirectUrl); 555 556 // var stateObj = { foo: "bar" }; 557 // history.pushState(stateObj, "page 2", "11/search/11"); 558 // alert(redirectUrl) 559 $routeParams.search = null; 560 } 561 catch (e) { 562 console.warn('parse error of search params'); 563 } 564 } 565 566 567 568 var cond = { 569 property_type: $scope.search.property_type, 570 bedroom: $scope.bedrating, 571 bathroom: $scope.bathrating, 572 min_price: $scope.search.min_price, 573 max_price: $scope.search.max_price, 574 search_listing_sort: $scope.search_listing_sort, 575 limit: $scope.recordLimit, 576 page: $scope.currentPage, 577 advance_search: JSON.stringify($scope.advanced_search), 578 agentid: agentid, 579 all_bound: JSON.stringify($scope.all_bound), 580 polygon_lat_long: JSON.stringify($scope.polygon_lat_long), 581 //page_type: "search", 582 }; 583 584 var apiurl = ''; 585 //console.log($rootScope.polygon_lat_long); 586 if ($rootScope.polygon_lat_long) { 587 cond.polygon_lat_long = $rootScope.polygon_lat_long; 588 apiurl = base_url + '/hometheme/recent-sale-search-property-result-with-polygon'; 589 } else { 590 apiurl = base_url + '/hometheme/recent-sale-search-property-result'; 591 } 592 593 var token = localStorage.getItem("access_token"); // If login 594 595 $scope.show_loader = 1; 596 var httpRequest = $http({ 597 method: 'POST', 598 url: apiurl, 599 data: cond, 600 headers: { 601 'Content-Type': 'application/json; charset=utf-8', 602 'Access-Token': token, 603 } 604 605 }).success(function (data, status) { 606 607 $scope.front_spinner = 0; 608 $scope.show_loader = 0; 609 $scope.fivehundred_msg_status = 0; 610 $scope.all_property_list = data.all_property; 611 $scope.property_found = data.total_matched_property; // to show all matched property count 612 $scope.marker_map_prioperties = data.all_map_property; 613 $scope.last_update_corn_time = data.last_update_corn_time; // Last Update Mid Florida Property 614 615 $scope.bedrooms[0].current = cond.bedroom; 616 $scope.bathrooms[0].current = cond.bathroom;
617 618 //$rootScope.all_property_search_list = $scope.all_property_list.map(a => a.ml); 619 var resultArray = $scope.marker_map_prioperties.map(a => a.ml); 620 $localStorage.mls_id = JSON.stringify(resultArray); 621 622 /* Map and Pagination propety start */ 623 if (data.total_matched_property > 500) { 624 $scope.visible_property_found = 500; 625 $scope.fivehundred_msg_status = 1; 626 } else { 627 $scope.visible_property_found = data.total_matched_property; 628 $scope.fivehundred_msg_status = 0; 629 } 630 /* Map and Pagination propety end */ 631 632 $localStorage.search_params = JSON.stringify(cond); // Set search parameters in local storage 633 setTimeout(function () { 634 ImageFitCont(); 635 }, 500); 636 637 //***** Google map integration code here start *****// 638 var ip = 0; 639 var tmp = {}; 640 var tmp_arr = []; 641 $scope.propertylatlngs = []; 642 643 var latlngArray = Array(); 644 if ($rootScope.polygon_lat_long) { 645 646 var latngtdata = JSON.parse($rootScope.polygon_lat_long); 647 for (var i = 0; i < latngtdata.length; i++) { 648 latlngArray[i] = [latngtdata[i].lat, latngtdata[i].lng]; 649 } 650 } 651 652 for (ip = 0; ip < $scope.marker_map_prioperties.length; ip++) { 653 tmp = $scope.marker_map_prioperties[ip]; 654 655 if (latlngArray.length > 0) { 656 var checkPropertyBelongs = isPointInPoly(latlngArray, tmp.lat, tmp.lng); 657 } 658 659 var prop_image = ''; 660 661 if ((typeof tmp.getimage != 'undefined') && tmp.getimage != null && (typeof tmp.getsisdetails != 'undefined') && tmp.getsisdetails != null) { 662 prop_image = tmp.getsisdetails.getmlsdetails.name.toLowerCase() + '/' + tmp.getimage.image_path; 663 } 664 665 tmp_arr = [tmp.address + ", " + tmp.city_name + ", " + tmp.state + " - " + tmp.zip_code, tmp.lat, tmp.lng, tmp.address + ", " + tmp.city_name + ", " + tmp.state + " - " + tmp.zip_code, tmp.list_price, tmp.id, prop_image, tmp.beds, tmp.fbaths, tmp.hbaths, tmp.sqft_liv_area, tmp.ml]; 666 $scope.propertylatlngs.push(tmp_arr); 667 } 668 669 setTimeout(function () { 670 //console.log($scope.agentDetails.zip_search ); 671 // initMap2($scope.propertylatlngs, $scope.all_bound, $scope.agentDetails.zip_search); 672 initMap2($scope.propertylatlngs, $scope.all_bound); 673 }, 1000); 674 675 $rootScope.history = $location.$$path; 676 677 if ($rootScope.polygon_lat_long) { 678 var specify_by_polygon = $rootScope.polygon_lat_long; 679 if (specify_by_polygon != '' && $rootScope.hitorybackbtn == 1) { 680 isBeingDragged=false; 681 draw_polygon_change = true; 682 var specify_by_polygon_arr = JSON.parse(specify_by_polygon); 683 var polygonset = new google.maps.Polygon({ 684 map: map, 685 paths: specify_by_polygon_arr, 686 strokeWeight: 2, 687 fillColor: '#1aff1a', 688 fillOpacity: 0.5, 689 draggable: true, 690 editable: true, 691 geodesic: true 692 }); 693 polygonset.setMap(map2); 694 drawingManager.setDrawingMode(null); 695 696 google.maps.event.addListener(polygonset, 'dragend', function () { 697 // Polygon was dragged 698 isBeingDragged = false; 699 draw_polygon_change = true; 700 var myJson = JSON.stringify(polygonset.getPath().getArray()); 701 setPolygonLatLngChnage(myJson); 702 }); 703 704 google.maps.event.addListener(polygonset, 'dragstart', function () { 705 isBeingDragged = true; 706 }); 707
708 polygonset.getPaths().forEach(function (path, index) { 709 710 google.maps.event.addListener(path, 'insert_at', function (markerCoords) { 711 // New point 712 var myJson = JSON.stringify(polygonset.getPath().getArray()); 713 //call polygn value initialize and service call // 714 setPolygonLatLngChnage(myJson); 715 draw_polygon_change = true; 716 }); 717 718 google.maps.event.addListener(path, 'remove_at', function () { 719 // Point was removed 720 var myJson = JSON.stringify(polygonset.getPath().getArray()); 721 //call polygn value initialize and service call // 722 setPolygonLatLngChnage(myJson); 723 draw_polygon_change = true; 724 }); 725 726 google.maps.event.addListener(path, 'set_at', function () { 727 // Point was moved 728 if (!isBeingDragged) { 729 var myJson = JSON.stringify(polygonset.getPath().getArray()); 730 //call polygn value initialize and service call // 731 setPolygonLatLngChnage(myJson); 732 draw_polygon_change = true; 733 } 734 }); 735 }); 736 737 setTimeout(function () { 738 $(document).find('.result-blocks .col-sm-6:nth-child(2) a').trigger('mouseover'); 739 }, 2000) 740 } 741 742 $rootScope.hitorybackbtn = 0; 743 744 if ($rootScope.polygon_lat_long && draw_polygon_change) { 745 746 draw_polygon_change = false; 747 // Generate All ZIP code Array From result set // 748 $scope.zipcode_array = $scope.all_property_list.map(a => a.zip_code); 749 $scope.uniquezipcode_array = $scope.zipcode_array.filter(function (item, pos) { 750 return $scope.zipcode_array.indexOf(item) == pos; 751 }); 752 753 // Generate All County Name Array From result set // 754 $scope.county_array = $scope.all_property_list.map(a => a.county); 755 $scope.uniquecounty_array = $scope.county_array.filter(function (item, pos) { 756 return $scope.county_array.indexOf(item) == pos; 757 }); 758 759 // Generate All Development Name Array From result set // 760 $scope.development_Name = $scope.all_property_list.map(a => a.development_name); 761 $scope.development_Name_array = $scope.development_Name.filter(function (item, pos) { 762 return $scope.development_Name.indexOf(item) == pos; 763 }); 764 765 // Generate All Complex Name Array From result set // 766 $scope.complex_Name = $scope.all_property_list.map(a => a.complex_name); 767 $scope.complex_Name_array = $scope.complex_Name.filter(function (item, pos) { 768 return $scope.complex_Name.indexOf(item) == pos; 769 }); 770 771 // Generate All View Array From result set // 772 $scope.views_Name = $scope.all_property_list.map(a => a.view); 773 $scope.views_Name_array = $scope.views_Name.filter(function (item, pos) { 774 return $scope.views_Name.indexOf(item) == pos; 775 }); 776 777 // Generate Water Access Array From result set // 778 $scope.water_access = $scope.all_property_list.map(a => a.water_access); 779 $scope.water_access_array = $scope.water_access.filter(function (item, pos) { 780 return $scope.water_access.indexOf(item) == pos; 781 }); 782 783 // Generate All Subdivition Name Array From result set // 784 $scope.subdivision_Name = $scope.all_property_list.map(a => a.subdivision_name); 785 $scope.subdivision_Name_array = $scope.subdivision_Name.filter(function (item, pos) { 786 return $scope.subdivision_Name.indexOf(item) == pos; 787 }); 788 } 789 } 790 }); 791 } 792 793 // Project Details Page Function // 794 795 // Project Details Page Function // 796 $scope.propertyDetails = function () { 797 798 $scope.front_spinner = 1;
799 $scope.property_ml_id = $routeParams.property_ml_id; 800 var fb_app_id = $rootScope.fb_app_id; 801 // IF FACEBOOK APP ID NOT PUTED FACEBOOK SHARE NOT VISIBLE BUTTON START// 802 if (fb_app_id != '') { 803 $scope.fb_button_visible = 1; 804 } 805 // IF FACEBOOK APP ID NOT PUTED FACEBOOK SHARE NOT VISIBLE BUTTON END// 806 807 var token = localStorage.getItem("access_token"); // If login 808 809 let lastPage = $localStorage.last_page; 810 811 var search_params = ''; 812 if (lastPage == "recent-sale-search") { 813 if ($localStorage.search_params) { 814 var search_params = JSON.parse($localStorage.search_params); 815 } 816 } 817 818 819 var httpRequest = $http({ 820 method: 'POST', 821 url: base_url + '/hometheme/closed-property-details', 822 data: { 823 property_ml_id: $scope.property_ml_id, 824 member_id: $scope.userid, 825 search_params: search_params, 826 last_page: $localStorage.last_page 827 }, 828 headers: { 829 'Content-Type': 'application/json; charset=utf-8', 830 'Access-Token': token, 831 } 832 833 }).success(function (data, status) { 834 $scope.front_spinner = 0; 835 836 if (data.property_det.length === 0) //if property is in database 837 { 838 $scope.has_property = 0; 839 } else { 840 if ($localStorage.mls_id) { 841 var storeMlsIds = JSON.parse($localStorage.mls_id); 842 var indexofMlsId = storeMlsIds.indexOf($scope.property_ml_id); 843 if (indexofMlsId > -1) { 844 $rootScope.all_property_search_list = storeMlsIds; 845 $rootScope.currentPropertyIndex = indexofMlsId; 846 } 847 } 848 849 $scope.allRelatedProperty = data.realted_property; 850 $scope.has_property = 1; 851 $scope.property_det = data.property_det; 852 $scope.last_update_corn_time = data.last_update_corn_time; 853 $scope.latitude = my_lat = parseFloat(data.property_det.lat); 854 $scope.longitude = my_lng = parseFloat(data.property_det.lng); 855 $scope.address = address = data.property_det.address; 856 fb_app_id = data.user_fb_app_id; 857 858 // Set property details page in the local storage // 859 localStorage.setItem('prevroute', '/property-details/' + $scope.property_det.ml); 860 861 if (data.logged_user_fav_proerty > 0) // For Checking user fav property 862 { 863 $scope.fav_status = 1; 864 } else { 865 $scope.fav_status = 0; 866 } 867 868 // For Meta setting We use below section [Share image and Url] // 869 870 $scope.property_image_url = ''; // image share url for FB 871 872 if (data.property_det.getimage.length > 0) // check property images.. In which position get image set for the facebook share 873 { 874 for (var i = 0; i < data.property_det.getimage.length; i++) { 875 if (typeof data.property_det.getimage[i].image_path != 'undefined') { 876 var last = data.property_det.getimage[i].image_path.split("/").pop(); // no_image.png 877 var no_image_last = last.split("."); // no_image 878 879 if (no_image_last[0] != 'no_image') { 880 $scope.property_image = theme_image_url + data.property_det.getsisdetails.getmlsdetails.name.toLowerCase() + '/' + data.property_det.getimage[i].image_path; 881 $scope.property_image_url = base_url + $scope.property_image; 882 break; 883 } 884 } 885 } 886 } 887 888 $scope.property_url = $location.absUrl(); 889 890 setTimeout(function () { 891 ProjectGallery(); 892 ImageFitCont(); 893 894 // FOR FACE BOOK INITILIZATION // 895 window.fbAsyncInit = function () { 896 FB.init({ 897 appId: fb_app_id, 898 status: true, 899 cookie: true, 900 xfbml: true 901 }); 902 }; 903 (function () { 904 var e = document.createElement('script'); 905 e.async = true; 906 e.src = document.location.protocol + 907 '//connect.facebook.net/en_US/all.js'; 908 document.getElementById('fb-root').appendChild(e); 909 }()); 910 // FOR FACE BOOK INITILIZATION // 911 912 initMap(); // init map call 913 914 $('.home-project-slider').swiper({ 915 nextButton: '.project-slider .swiper-button-next', 916 prevButton: '.project-slider .swiper-button-prev', 917 slidesPerView: 4, 918 spaceBetween: 30, 919 breakpoints: { 920 1024: { 921 slidesPerView: 2 922 }, 923 768: { 924 slidesPerView: 1 925 } 926 } 927 }); 928 929 }, 1000); 930 } 931 932 }); 933 } 934 // Project Details Page Function // 935 936 $scope.getRelatedImageSource = function (imagename, mlsname) { 937 //var newbaseurl = 'https://dpirealtywebsites.com' 938 if (imagename == '') 939 return base_url + '/public/themes/' + current_theme + '/images/no_menu.png'; 940 else 941 return base_url + '/dpi_beta/uploads/' + mlsname.toLowerCase() + '/' + imagename; 942 }; 943 // Project Details Page Function // 944 945 /******* SEARCH PROPERTY BUTTON AJAX END *******/ 946 947 /****** Check All property inside polygon or not ****/ 948 949 function isPointInPoly(poly, y, x) { 950 var c = false, j = poly.length - 1, i; 951 952 for (i = 0; i < poly.length; i++) { 953
954 if ((poly[i][0] < y && poly[j][0] >= y || poly[j][0] < y && poly[i][0] >= y) 955 && (poly[i][1] <= x || poly[j][1] <= x)) { 956 if (poly[i][1] + (y - poly[i][0]) / (poly[j][0] - poly[i][0]) * (poly[j][1] - poly[i][1]) < x) { 957 c = !c; 958 } 959 } 960 j = i; 961 962 } 963 return c; 964 } 965 /****** Check All property inside polygon or not ****/ 966 967 968 /******* Search Filter Checkbox Making Start *******/ 969 970 $scope.checker = function (index, val) // index= filter field name ; val= value[ex: Yes/No] 971 { 972 if ((typeof $scope.advanced_search[index] != 'undefined') && ($scope.advanced_search[index] == val)) { 973 delete $scope.advanced_search[index]; 974 } else { 975 $scope.advanced_search[index] = val; // Push advanced search filter in advanced_search array 976 } 977 } 978 979 /******* Search Filter Checkbox Making End *******/ 980 981 /******* SEARCH PROPERTY BUTTON AJAX END *******/ 982 983 984 985 $scope.changePage = function () // Pagination 986 { 987 if ($scope.search_by_polygon) { 988 989 } else { 990 var cond = JSON.parse($localStorage.search_params); 991 cond.page = $scope.currentPage; 992 $localStorage.search_params = JSON.stringify(cond); 993 $scope.searchProperty($localStorage.search_params, $scope.all_bound); 994 } 995 } 996 997 // For project details page // 998 $scope.showNextProperty = function () { 999 if ($rootScope.currentPropertyIndex < 20 && $localStorage.mls_id) { 1000 1001 $rootScope.currentPropertyIndex = $rootScope.currentPropertyIndex + 1; 1002 var storeMlsIds = JSON.parse($localStorage.mls_id); 1003 $routeParams.property_ml_id = storeMlsIds[$rootScope.currentPropertyIndex]; 1004 $location.path('/property-details/' + $routeParams.property_ml_id); 1005 } 1006 1007 } 1008 1009 $scope.showPreviousProperty = function () { 1010 if ($rootScope.currentPropertyIndex >= 0 && $localStorage.mls_id) { 1011 1012 $rootScope.currentPropertyIndex = $rootScope.currentPropertyIndex - 1; 1013 var storeMlsIds = JSON.parse($localStorage.mls_id); 1014 $routeParams.property_ml_id = storeMlsIds[$rootScope.currentPropertyIndex]; 1015 $location.path('/property-details/' + $routeParams.property_ml_id); 1016 } 1017 } 1018 // For project details page // 1019 1020 /* DETAILS PAGE BACK BUTTON */ 1021 $scope.backToSearchpage = function () { 1022 if ($rootScope.history && $rootScope.polygon_lat_long) { 1023 $rootScope.hitorybackbtn = 1; 1024 } 1025 var prevUrl = $rootScope.history ? $rootScope.history : "/"; 1026 console.log(prevUrl); 1027 $location.path(prevUrl); 1028 } 1029 /* DETAILS PAGE BACK BUTTON */ 1030 1031 1032 1033 1034 /******* Search Details Page Start *******/ 1035 1036 1037 $scope.goToClosePropertyDetails = function (prop_id, prop_ml_id) { 1038 $location.path('/closed-property-details/' + prop_ml_id); 1039 } 1040 1041 //============ SHARE WITH FACEBOOK START ===========// 1042 $scope.share = function (post) { 1043 FB.ui({ 1044 method: 'feed', 1045 name: ($scope.property_det.sys_details.mls_id == 4 && ($scope.property_det.show_address_on_internet == null || $scope.property_det.show_address_on_internet == 0)) ? 'Address Withheld' : $scope.property_det.address, 1046 link: $scope.property_url, 1047 picture: $scope.property_image_url, 1048 caption: ($scope.property_det.sys_details.mls_id == 4 && ($scope.property_det.show_address_on_internet == null || $scope.property_det.show_address_on_internet == 0)) ? 'Address Withheld' : $scope.property_det.address, 1049 description: $scope.property_det.remarks 1050 }); 1051 1052 $('#share').modal('hide'); 1053 } 1054 //============ SHARE WITH FACEBOOK START ===========// 1055 1056 /******* Search Details Page End *******/ 1057 1058 $scope.makeToFav = function () // From Property Details page make a property favourite list 1059 {
1060 $scope.saveFavourite($scope.property_ml_id, '', 'details'); 1061 } 1062 1063 1064 /****** Request/ And 2 get advice Send Mail To Contact Agent Start ******/ 1065 1066 $scope.submitFormMail = function (param) { 1067 var property_url = $location.absUrl(); 1068 1069 var data = { 1070 request: $scope.request, 1071 member_id: $scope.userid, //Agent id Website owner 1072 param: param, 1073 property_url: property_url, 1074 }; 1075 1076 var httpRequest = $http({ 1077 method: 'POST', 1078 url: base_url + '/hometheme/send-request-mail', 1079 data: data 1080 }).success(function (data, status) { 1081 1082 if (data.success == 1) { 1083 if (param == 'expert') { 1084 $scope.showSuccMsg = 1; 1085 $scope.change_class = "#FFF"; 1086 } else if (param == 'advice') { 1087 $scope.showSuccMsg1 = 1; 1088 $scope.change_class = "#71b100"; 1089 } else { 1090 $scope.showSuccMsg2 = 1; 1091 $scope.change_class = "#71b100"; 1092 } 1093 1094 $scope.show_message = "Your query has been sent successfully.We will contact you soon."; 1095 1096 $timeout(function () { 1097 $scope.showSuccMsg1 = 0; 1098 $scope.showSuccMsg2 = 0; 1099 $scope.showSuccMsg = 0; 1100 angular.element('.close').trigger('click'); 1101 $scope.$digest(); 1102 }, 3000); 1103 $scope.requestForm.reset(); 1104 $scope.adviceForm.reset(); 1105 $scope.expertForm.reset(); 1106 } else { 1107 if (param == 'expert') { 1108 $scope.showSuccMsg = 1; 1109 } else if (param == 'advice') { 1110 $scope.showSuccMsg1 = 1; 1111 } else { 1112 $scope.showSuccMsg2 = 1; 1113 } 1114 $scope.show_message = "Some error occured."; 1115 $scope.change_class = "#F00"; 1116 1117 $timeout(function () { 1118 $scope.showSuccMsg1 = 0; 1119 $scope.showSuccMsg2 = 0; 1120 $scope.showSuccMsg = 0; 1121 $scope.$digest(); 1122 }, 3000); 1123 } 1124 }) 1125 .error(function (data, status, header, config) { 1126 if (param == 'expert') { 1127 $scope.showSuccMsg = 1; 1128 } else if (param == 'advice') { 1129 $scope.showSuccMsg1 = 1; 1130 } else { 1131 $scope.showSuccMsg2 = 1; 1132 } 1133 $scope.show_message = "Some error occured."; 1134 $scope.change_class = "#F00"; 1135 $timeout(function () { 1136 $scope.showSuccMsg1 = 0; 1137 $scope.showSuccMsg2 = 0; 1138 $scope.showSuccMsg = 0; 1139 $scope.$digest(); 1140 }, 3000); 1141 }); 1142 } 1143 1144 /****** Request Send Mail To Contact Agent End******/ 1145 1146 1147 /**** Remove Search Filter ****/ 1148 $scope.removeSearchFilter = function (index) { 1149 if (typeof $scope.advanced_search[index] != 'undefined') { 1150 1151 if (index == 'bedrooms') { 1152 $scope.bedrating = 0; 1153 1154 $scope.getSelectedBed($scope.bedrating); 1155 $scope.bedrooms[0].current = 0; 1156 } else if (index == 'bathrooms') { 1157 $scope.bathrating = 0; 1158 $scope.getSelectedBath($scope.bathrating); 1159 $scope.bathrooms[0].current = 0; 1160 } 1161 $scope.agent_zip_search = ''; 1162 delete $scope.advanced_search[index]; 1163 $scope.searchProperty($localStorage.search_params, $scope.all_bound); 1164 } 1165 //console.log($scope.advanced_search); 1166 } 1167 1168 // CHANGE PROPERTY TYPE [DIASBLED FOR]// 1169 1170 // $scope.drawOrRemovePolygone = function () { 1171 1172 // $scope.search_by_polygon = 1; 1173 1174 // var cond = JSON.parse($localStorage.search_params); 1175 // cond.polygon_lat_long = $scope.polygon_lat_long; 1176 // $scope.currentPage = 1; 1177 // cond.currentPage = $scope.currentPage; 1178 // $localStorage.search_params = JSON.stringify(cond); 1179 1180 // var latlngarray = JSON.parse($scope.polygon_lat_long); 1181 1182 // var newArray = Array(); 1183 // if (latlngarray.length > 0) { 1184 1185 // for (var i = 0; i < latlngarray.length; i++) { 1186 // var latlng = [latlngarray[i].lat, latlngarray[i].lng]; 1187 // newArray.push(latlng); 1188 // } 1189 // } 1190 1191 1192 1193 // var geoJsonData = { "type": "Feature", "properties": {}, "geometry": { "type": "Polygon", "coordinates": [newArray] } }; 1194 1195 // var geoJsonLayer = L.geoJson(geoJsonData); 1196 // var bound = geoJsonLayer.getBounds(); 1197 // var northeastbound = bound.getNorthEast();
1198 // var southwastbound = bound.getSouthWest(); 1199 1200 // var max_lat = northeastbound.lng; 1201 // var max_lng = northeastbound.lat; 1202 // var min_lat = southwastbound.lng; 1203 // var min_lng = southwastbound.lat; 1204 // var latlng_arr = {}; 1205 1206 // latlng_arr['max_lat'] = max_lat; 1207 // latlng_arr['max_lng'] = max_lng; 1208 // latlng_arr['min_lat'] = min_lat; 1209 // latlng_arr['min_lng'] = min_lng; 1210 1211 // $scope.all_bound = latlng_arr; 1212 // $scope.searchProperty($localStorage.search_params, $scope.all_bound); 1213 1214 // /*cond.polygon_lat_long = latlng_arr; 1215 // $scope.polygon_lat_long = [latlng_arr]; 1216 // $localStorage.search_params = JSON.stringify(cond);*/ 1217 1218 // /*var rectangle; 1219 // var map; 1220 // var latlng = new google.maps.LatLng(northeastbound.lng,northeastbound.lat); 1221 1222 // // Initializing a map 1223 1224 // var myOptions = { 1225 // zoom: 9, 1226 // center: latlng, 1227 // mapTypeId: google.maps.MapTypeId.ROADMAP 1228 // }; 1229 // // Draw a map on DIV "map_canvas" 1230 // map = new google.maps.Map(document.getElementById("map_canvas2"), myOptions); 1231 1232 // var bounds = { 1233 // north: northeastbound.lng, 1234 // south: southwastbound.lng, 1235 // east: northeastbound.lat, 1236 // west: southwastbound.lat 1237 // }; 1238 1239 // // Define the rectangle and set its editable property to true. 1240 // rectangle = new google.maps.Rectangle({ 1241 // bounds: bounds,fillColor: '#1aff1a', 1242 // fillOpacity: 0.5, 1243 // strokeWeight: 2, 1244 // clickable: false, 1245 // editable: false, 1246 // draggable:false, 1247 // zIndex: 1 1248 // }); 1249
1250 // rectangle.setMap(map);*/ 1251 1252 // } 1253 1254 $scope.clearPolygonStucture = function () { 1255 1256 var cond = JSON.parse($localStorage.search_params); 1257 if (cond.polygon_lat_long) { 1258 delete cond['polygon_lat_long']; 1259 } 1260 $scope.currentPage = 1; 1261 cond.currentPage = $scope.currentPage; 1262 $localStorage.search_params = JSON.stringify(cond); 1263 $scope.all_bound = {}; 1264 $scope.searchProperty($localStorage.search_params, $scope.all_bound); 1265 } 1266 1267 $scope.changePropertyType = function () { 1268 var cond = JSON.parse($localStorage.search_params); 1269 cond.property_type = $scope.search.property_type; 1270 $localStorage.search_params = JSON.stringify(cond); 1271 $scope.searchProperty($localStorage.search_params, $scope.all_bound); 1272 } 1273 $scope.changeMinPrice = function () { 1274 var cond = JSON.parse($localStorage.search_params); 1275 cond.min_price = $scope.search.min_price; 1276 $localStorage.search_params = JSON.stringify(cond); 1277 $scope.searchProperty($localStorage.search_params, $scope.all_bound); 1278 } 1279 $scope.changeMaxPrice = function () { 1280 var cond = JSON.parse($localStorage.search_params); 1281 cond.max_price = $scope.search.max_price; 1282 $localStorage.search_params = JSON.stringify(cond); 1283 $scope.searchProperty($localStorage.search_params, $scope.all_bound); 1284 } 1285 1286 1287
1288 ////////////////////////////////// 1289 1290 // For reset your search params // 1291 $scope.resetSearch = function () // Reset Search 1292 { 1293 $scope.currentPage = 1; //after reset search paging start from 1st 1294 $scope.search.property_type = ''; 1295 $scope.search.min_price = 0; 1296 $scope.search.max_price = 0; 1297 $scope.search_listing_sort = 'listprice_desc'; 1298 $scope.recordLimit = 20; 1299 $scope.currentPage = 1; 1300 $scope.advanced_search = {}; 1301 $scope.halfbathrooms[0].current = 0; 1302 $scope.bedrating = 0; 1303 $scope.bedrooms[0].current = 0; 1304 $scope.bathrating = 0; 1305 $scope.bathrooms[0].current = 0; 1306 $scope.agent_zip_search = ''; 1307 1308 $scope.all_bound = {}; 1309 } 1310 1311 1312 /*********** ADVANCED SEARCH SECTION SHOW HIDE START ************/ 1313 $scope.animate = false; 1314 $scope.showHide = function () { 1315 $scope.animate = !$scope.animate; 1316 if ($scope.animate == true) { 1317 $scope.show_advanced_text = "Hide Advanced Search"; 1318 } else { 1319 $scope.show_advanced_text = "Show Advanced Search"; 1320 } 1321 } 1322 1323 1324 /*********** ADVANCED SEARCH SECTION SHOW HIDE START ************/ 1325 1326 /* make active with active class advanced filter */ 1327 $scope.$watch('advanced_search', function (newVal, oldVal) { 1328 console.log('cursed watcher'); 1329 // if( $rootScope.ignore_watcher==false) 1330 // { 1331 if (oldVal === newVal) { 1332 // Nothing to do 1333 1334 //console.log('same'); 1335 } else { 1336 if ($rootScope.hitback) { 1337 $rootScope.hitback = 0; 1338 var cond = JSON.parse($localStorage.search_params); 1339 var agentid = $scope.userid; // Site owner 1340 1341 $scope.search.property_type = cond.property_type; 1342 $scope.bedrating = cond.bedroom; 1343 $scope.bathrating = cond.bathroom; 1344 $scope.search.min_price = cond.min_price; 1345 $scope.search.max_price = cond.max_price; 1346 $scope.search_listing_sort = cond.search_listing_sort; 1347 $scope.recordLimit = cond.limit; 1348 $scope.currentPage = cond.page; 1349 $scope.advanced_search = JSON.parse(cond.advance_search); 1350 $scope.all_bound = JSON.parse(cond.all_bound); 1351 1352 $scope.bedrooms[0].current = cond.bedroom; 1353 $scope.bathrooms[0].current = cond.bathroom; 1354 1355 var cond = { 1356 property_type: $scope.search.property_type, 1357 bedroom: $scope.bedrating, 1358 bathroom: $scope.bathrating, 1359 min_price: $scope.search.min_price, 1360 max_price: $scope.search.max_price, 1361 search_listing_sort: $scope.search_listing_sort, 1362 limit: $scope.recordLimit, 1363 page: $scope.currentPage, 1364 advanced_search: JSON.parse(cond.advance_search), 1365 all_bound: JSON.stringify(cond.all_bound), 1366 agentid: agentid 1367 }; 1368 localStorage.setItem('backwards', 1); // from property details page back to search page 1369 $scope.searchProperty(cond, $scope.all_bound); 1370 console.log('A'); 1371 1372 } else { 1373 if ($localStorage.search_params) { 1374 var cond = JSON.parse($localStorage.search_params); 1375 if (newVal.bedrooms) { 1376 cond.bedroom = newVal.bedrooms; 1377 } else { 1378 cond.bedroom = 0; 1379 } 1380 if (newVal.bathrooms) { 1381 cond.bathroom = newVal.bathrooms; 1382 } else { 1383 cond.bathroom = 0; 1384 } 1385 1386 var new_advance_serach = JSON.stringify(newVal); 1387 cond.advance_search = new_advance_serach; 1388 1389 cond = JSON.stringify(cond); 1390 if($rootScope.ignore_watcher == false) 1391 { 1392 1393 //console.log(cond); 1394 $scope.searchProperty(cond, $scope.all_bound); 1395 } 1396 else{ 1397 $rootScope.ignore_watcher=false; 1398 } 1399 1400 //Call save search history 1401 var usertoken = localStorage.getItem("access_token"); 1402 if (typeof usertoken != 'undefined') {
1403 $scope.saveSearchHistory(); 1404 } 1405 console.log('B'); 1406 } else { 1407 var agentid = $scope.userid; // Site owner 1408 1409 var cond = { 1410 property_type: $scope.search.property_type, 1411 bedroom: $scope.bedrating, 1412 bathroom: $scope.bathrating, 1413 min_price: $scope.search.min_price, 1414 max_price: $scope.search.max_price, 1415 search_listing_sort: $scope.search_listing_sort, 1416 limit: $scope.recordLimit, 1417 page: $scope.currentPage, 1418 advance_search: JSON.stringify([]), 1419 agentid: agentid 1420 }; 1421 $scope.searchProperty(cond, $scope.all_bound); 1422 console.log('C'); 1423 } 1424 // Involking search function any changes in search filter 1425 } 1426 1427 1428 $("#searchModal").modal('hide'); // After Search modal close 1429 1430 $scope.advance_search_make_green_active(); 1431 } //else end 1432 // } else { 1433 // $rootScope.ignore_watcher= false; 1434 // } 1435 }, true); 1436 1437 /**********************************************************/ 1438 1439 $scope.sortListingSearchProperty = function () { 1440 var cond = JSON.parse($localStorage.search_params); 1441 1442 var cond = { 1443 property_type: $scope.search.property_type, 1444 bedroom: $scope.bedrating, 1445 bathroom: $scope.bathrating, 1446 min_price: $scope.search.min_price, 1447 max_price: $scope.search.max_price, 1448 search_listing_sort: $scope.search_listing_sort, 1449 limit: $scope.recordLimit, 1450 page: $scope.currentPage, 1451 advanced_search: JSON.parse(cond.advance_search), 1452 all_bound: JSON.stringify(cond.all_bound), 1453 agentid: $scope.userid 1454 }; 1455 1456 $scope.searchProperty(cond, $scope.all_bound); 1457 1458 } 1459 1460 /**********************************************************/ 1461 1462 // Responsive Toggle View // 1463 $scope.toggleFilter = function () { 1464 $('.middle_searchform').toggleClass('open'); 1465 }; 1466 1467 $scope.toggleView = function () { 1468 //$('.middle_searchform').toggleClass('open'); 1469 $('.search_results').toggleClass('mapview'); 1470 if ($('.search_results').hasClass('mapview')) { 1471 $('#toggleView').html('List'); 1472 } else 1473 $('#toggleView').html('Map'); 1474 }; 1475 $("#navbar").on('show.bs.collapse', function () { 1476 $('header').addClass('higherzindex'); 1477 }); 1478 $("#navbar").on('hidden.bs.collapse', function () { 1479 $('header').removeClass('higherzindex'); 1480 }); 1481 // Responsive Toggle End // 1482 1483 // SAVE SEARCH 1484 $scope.saveSearch = function (user_id, page) { 1485 if ($localStorage.search_params) { 1486 var parsed_data = $localStorage.search_params; 1487 } 1488 1489 var data = { 1490 page: page, 1491 parsed_data: parsed_data, 1492 member_id: $scope.userid 1493 }; 1494 1495 var token = localStorage.getItem("access_token"); 1496 var config = { 1497 headers: { 1498 'Content-Type': 'application/json; charset=utf-8', 1499 'Access-Token': token, 1500 } 1501 }; 1502 1503 $http.post(base_url + "/firstclient/save-search", data, config) 1504 .success(function (data, status, headers, config) { 1505 if (data.success == 1) { 1506 $scope.change_class = "success-save"; 1507 $scope.show_message = 'Search saved successfully.'; 1508 $scope.showSuccMsg = 1; 1509 setTimeout(function () { 1510 $scope.$apply(function () { 1511 $scope.showSuccMsg = 0; 1512 }); 1513 }, 2000); 1514 } else if (data.success == 2) { 1515 localStorage.setItem('prevroute', '/11/' + $routeParam
1515s.page_name + $routeParams.menu_id); 1516 $location.path('/user-login'); 1517 } else { 1518 $scope.change_class = "error-save"; 1519 $scope.show_message = 'Some error occured.'; 1520 $scope.showSuccMsg = 1; 1521 setTimeout(function () { 1522 $scope.$apply(function () { 1523 $scope.showSuccMsg = 0; 1524 }); 1525 }, 2000); 1526 } 1527 1528 }); 1529 } 1530 1531 /******************** SAVE SEARCH BY LOGGED IN USER START *******************/ 1532 1533 1534 /******************** FAVOURITE PROPERTY BY LOGGED IN USER START *******************/ 1535 $scope.saveFavourite = function (property_ml_id, i, page) { 1536 var data = { 1537 property_ml_id: property_ml_id, 1538 member_id: $scope.userid 1539 }; 1540 1541 var token = localStorage.getItem("access_token"); 1542 var config = { 1543 headers: { 1544 'Content-Type': 'application/json; charset=utf-8', 1545 'Access-Token': token, 1546 } 1547 }; 1548 1549 $http.post(base_url + "/firstclient/favourite-property-new", data, config) 1550 .success(function (data, status, headers, config) { 1551 1552 if (page == 'search') // For Search Pages if like from search page 1553 { 1554 if (data.success == 1) { 1555 if (typeof $scope.all_property_list[i].fav_status != 'undefined' && $scope.all_property_list[i].fav_status == 1) 1556 $scope.all_property_list[i].fav_status = 0; 1557 else 1558 $scope.all_property_list[i].fav_status = 1; 1559 } else if (data.success == 2) { 1560 if ($scope.routeName === 'property_details') // After login 1561 { 1562 localStorage.setItem('prevroute', '/property-details/' + property_ml_id); 1563 } else { 1564 localStorage.setItem('prevroute', '/11/' + $routeParams.page_name + '/' + $routeParams.menu_id); 1565 } 1566 1567 $location.path('/user-login'); 1568 } 1569 } else if (page == 'details') // For Search Pages if like from property details page 1570 { 1571 if (data.success == 1) { 1572 if (typeof $scope.fav_status != 'undefined' && $scope.fav_status == 1) 1573 $scope.fav_status = 0; 1574 else 1575 $scope.fav_status = 1; 1576 } else if (data.success == 2) { 1577 if ($scope.routeName === 'property_details') // After login 1578 { 1579 localStorage.setItem('prevroute', '/property-details/' + property_ml_id); 1580 } 1581 $location.path('/user-login'); 1582 } 1583 } 1584 1585 }); 1586 } 1587 1588 /******************** FAVOURITE PROPERTY BY LOGGED IN USER END *******************/ 1589 1590 1591 1592 /************** SAVE IDX SEARCH BY LOGGED IN USER START ***************/ 1593 1594 /********** QUICK SEARCH STRAT **********/ 1595 1596 $scope.quickSearch = function () { 1597 console.log("QC"); 1598 var agentid = $scope.userid; // Site owner 1599 //$scope.is_coming_from_home=1; 1600 //$rootScope.fromhomesearch = 1; 1601 1602 1603 var cond = { 1604 property_type: $scope.search.property_type, 1605 bedroom: $scope.bedrating, 1606 bathroom: $scope.bathrating, 1607 min_price: $scope.search.min_price, 1608 max_price: $scope.search.max_price, 1609 search_listing_sort: $scope.search_listing_sort, 1610 limit: $scope.recordLimit, 1611 page: $scope.currentPage, 1612 advance_search: JSON.stringify($scope.advanced_search), 1613 agentid: agentid 1614 }; 1615 1616 if (typeof cond != 'undefined') { 1617 $localStorage.search_params = JSON.stringify(cond); // Set search parameters in local storage 1618 } 1619 1620 $rootScope.fromhomesearch = 1; 1621 $location.path('/11/search/11');
1622 //$location.path($scope.menu_id+'/'+$routeParams.page_name+'/'+$scope.menu_id); 1623 1624 } 1625 1626 /********** QUICK SEARCH END **********/ 1627 1628 /* For Dynamic Meta data call Start */ 1629 1630 $scope.allSetMeta = function () // Call all meta tag and social tag set for user/ default 1631 { 1632 var httpRequest = $http({ 1633 method: 'POST', 1634 url: base_url + '/hometheme/all-social-meta', 1635 data: { 1636 menu_id: $scope.menu_id, 1637 userid: $scope.userid 1638 } 1639 1640 }).success(function (data, status) { 1641 $scope.allsocialmeta = data.social_meta_des; 1642 if ($scope.allsocialmeta.og_url == 1) { 1643 $scope.allsocialmeta.og_url = $location.absUrl(); 1644 } 1645 }); 1646 } 1647 1648 /* For Dynamic Meta data call End */ 1649 //====================================================================// 1650 if ($scope.routeName !== 'property_details') { 1651 $scope.allSetMeta(); // self invoking 1652 } 1653 1654 //console.log($scope.routeName); 1655 //If page is search set it in localstorage 1656 if ($scope.routeName == 'search_property') { 1657 $localStorage.last_page = "search"; 1658 } 1659 1660 if ($scope.routeName == 'recent_sale_search') { 1661 $localStorage.last_page = "recent-sale-search"; 1662 } 1663 //====================================================================// 1664 1665 $scope.getAgentDetails(); 1666 1667 // price Range Value change watch function start // 1668 $scope.$watchGroup(['search.min_price', 'search.max_price'], function (newValues, oldValues, scope) { 1669 1670 if (newValues[0] > 0 && newValues[1] == '') { 1671 $scope.price_view_value = "$" + $scope.kFormatter(newValues[0]) + "+"; 1672 } else if ((newValues[0] == '' || newValues[0] == 0) && newValues[1] > 0) { 1673 $scope.price_view_value = "Up To $" + $scope.kFormatter(newValues[1]) + "+"; 1674 } else if ((newValues[0] != '' && newValues[1] != '') && (newValues[0] > 0 && newValues[1] > 0)) { 1675 $scope.price_view_value = "$" + $scope.kFormatter(newValues[0]) + " - $" + $scope.kFormatter(newValues[1]); 1676 } else if ((newValues[0] == '' || newValues[0] == 0) && newValues[1] == '') { 1677 $scope.price_view_value = "Any Price"; 1678 } 1679 }); 1680 1681 // price Range Value change watch function end // 1682 1683 $scope.kFormatter = function (num) //price formatter after 1000 its convert to K $2000 = $2k 1684 { 1685 return num > 999 ? parseFloat((num / 1000).toFixed(1)) + 'k' : num 1686 } 1687 1688 1689 // Save Search History Of loggedin User Start// 1690 $scope.saveSearchHistory = function () { 1691 1692 if ($localStorage.search_params) { 1693 var parsed_data = $localStorage.search_params; 1694 var pdata= JSON.parse(parsed_data); 1695 pdata.search_page_type='recent_sales'; 1696 parsed_data= JSON.stringify(pdata); 1697 } 1698 var data = { 1699 parsed_data: parsed_data, 1700 member_id: $scope.userid 1701 }; 1702 var token = localStorage.getItem("access_token"); 1703 var config = { 1704 headers: { 1705 'Content-Type': 'application/json; charset=utf-8', 1706 'Access-Token': token, 1707 } 1708 }; 1709 console.log(parsed_data); 1710 $http.post(base_url + "/firstclient/save-search-history", data, config) 1711 .success(function (data, status, headers, config) { 1712 if (data.success == 1) { 1713 //console.log(data); 1714 } 1715 else { 1716 //console.log('error'); 1717 } 1718 }); 1719 } 1720 // Save Search History Of loggedin User End// 1721 1722
1723 ////////////////////////////////////////////////////////////////////////////// 1724 1725 $scope.showNextProperty = function () { 1726 if ($rootScope.currentPropertyIndex < 20 && $localStorage.mls_id) { 1727 1728 $rootScope.currentPropertyIndex = $rootScope.currentPropertyIndex + 1; 1729 var storeMlsIds = JSON.parse($localStorage.mls_id); 1730 $routeParams.property_ml_id = storeMlsIds[$rootScope.currentPropertyIndex]; 1731 $location.path('/property-details/' + $routeParams.property_ml_id); 1732 } 1733 1734 } 1735 1736 $scope.showPreviousProperty = function () { 1737 if ($rootScope.currentPropertyIndex >= 0 && $localStorage.mls_id) { 1738 1739 $rootScope.currentPropertyIndex = $rootScope.currentPropertyIndex - 1; 1740 var storeMlsIds = JSON.parse($localStorage.mls_id); 1741 $routeParams.property_ml_id = storeMlsIds[$rootScope.currentPropertyIndex]; 1742 $location.path('/property-details/' + $routeParams.property_ml_id); 1743 } 1744 } 1745 1746 1747 /** 1748 * Copy search Url 1749 */ 1750 1751 $scope.searchUrlCopy = function () { 1752 $scope.searchStorage = $localStorage.search_params; 1753 1754 //$scope.curreUrl = document.URL; 1755 $scope.curreUrl = window.location.href.split('?')[0] 1756 var generateSearchUrl = encodeURI($scope.curreUrl + '?search=' + btoa($scope.searchStorage)); 1757 //var generateSearchUrl = "mailto:?subject=Search Property Link&body="+$scope.curreUrl+'?params='+$scope.searchStorage; 1758 1759 //tiny url api 1760 let query ={ 1761 url: generateSearchUrl 1762 }; 1763 var tinyurl; 1764 $.get( "/hometheme/generate-tiny-url", query) 1765 .done(function( data ) { 1766 console.log(data); 1767 tinyurl=data.data; 1768 1769 1770 console.log(tinyurl); 1771 $('#urlInput').val(tinyurl); 1772 $scope.myFunction(); 1773 }); 1774 ; 1775 //window.location = generateSearchUrl; 1776 //window.open(generateSearchUrl, '_blank'); 1777 } 1778 1779 1780 $scope.myFunction = function () { 1781 / Get the text field / 1782 var copyText = document.getElementById("urlInput"); 1783 / Select the text field / 1784 copyText.select(); 1785 / Copy the text inside the text field / 1786 document.execCommand("copy"); 1787 / Alert the copied text / 1788 //alert("Copied the URL " + copyText.value); 1789 swal({ 1790 title: "success", 1791 text: "Copy the URL below and paste it into an email or text", 1792 content: { 1793 element: "input", 1794 attributes: { 1795 value: copyText.value, 1796 readonly: "true", 1797 }, 1798 }, 1799 }); 1800 } 1801 1802 1803 1804 1805 }); // Controller end 1806 1807 1808/* ANGULAR DIRECTIVES START */ //<span class="bath-label"></span> 1809 1810// angular.module('dpiApp') 1811// .directive('starRating', function () { 1812// return { 1813// restrict: 'A', 1814// template: '<ul class="rating">' + 1815// '<li ng-class="star" ng-click="toggle1(0)">' + 1816// '<span class="zero-label">0</span>' + 1817// '</li>' + 1818// '<li ng-repeat="star in stars" ng-class="star" ng-click="toggle($index)">' + 1819// '<span class="bed-label"><cite class="blockedelm">{{$index+1}}+</cite></span>' + 1820// '</li>' + 1821// '</ul>', 1822// scope: { 1823// ratingValue: '=', 1824// max: '=', 1825// onRatingSelected: '&' 1826// }, 1827// link: function (scope, elem, attrs) { 1828 1829// var updateStars = function () { 1830// scope.stars = []; 1831 1832// for (var i = 0; i < scope.max; i++) { 1833 1834// scope.stars.push({ 1835// filled: i < scope.ratingValue 1836// }); 1837// } 1838// //console.log(scope.stars); 1839// }; 1840 1841// scope.toggle = function (index) { 1842 1843// scope.ratingValue = index + 1; 1844// scope.onRatingSelected({ 1845// bedrating: index + 1 1846// }); 1847// }; 1848 1849// scope.toggle1 = function () // For 0 bath selected 1850// { 1851// scope.ratingValue = 0; 1852// scope.onRatingSelected({ 1853// bedrating: 0 1854// }); 1855// } 1856
1857// scope.$watch('ratingValue', function (newVal, oldVal) { 1858 1859// if (typeof newVal != 'undefined') { 1860// updateStars(); 1861// } 1862// }); 1863// } 1864// } 1865// }); 1866 1867/**************************************************************************************/ 1868 1869/****** ANGULAR DIRECTIVE FOR BATHROOM ******/ 1870 1871// angular.module('dpiApp') 1872// .directive('starRatingBath', function () { 1873// return { 1874// restrict: 'A', 1875// template: '<ul class="rating">' + 1876// '<li ng-class="star" ng-click="toggle1(0)">' + 1877// '<span class="zero-label">0</span>' + 1878// '</li>' + 1879// '<li ng-repeat="star in stars" ng-class="star" ng-click="toggle($index)">' + 1880// '<span class="bath-label"><cite class="blockedelm">{{$index+1}}+</cite></span>' + 1881// '</li>' + 1882// '</ul>', 1883// scope: { 1884// ratingValue: '=', 1885// max: '=', 1886// onRatingSelected: '&' 1887// }, 1888// link: function (scope, elem, attrs) { 1889 1890// var updateStars = function () { 1891// scope.stars = []; 1892 1893// for (var i = 0; i < scope.max; i++) { 1894 1895// scope.stars.push({ 1896// filled: i < scope.ratingValue 1897// }); 1898// } 1899// //console.log(scope.stars); 1900// }; 1901 1902// scope.toggle = function (index) { 1903 1904// scope.ratingValue = index + 1; 1905// scope.onRatingSelected({ 1906// bathrating: index + 1 1907// }); 1908// }; 1909 1910// scope.toggle1 = function () // For 0 bath selected 1911// { 1912// scope.ratingValue = 0; 1913// scope.onRatingSelected({ 1914// bathrating: 0 1915// }); 1916// } 1917 1918// scope.$watch('ratingValue', function (newVal, oldVal) { 1919 1920// if (typeof newVal != 'undefined') { 1921// updateStars(); 1922// } 1923// }); 1924// } 1925// } 1926// }); 1927 1928/***************************************************************************************/ 1929 1930/****** ANGULAR DIRECTIVE FOR HALF BATH ROOMS ******/ 1931 1932// angular.module('dpiApp') 1933// .directive('starRatingHalfBath', function () { 1934// return { 1935// restrict: 'A', 1936// template: '<ul class="rating">' + 1937// '<li ng-class="star" ng-click="toggle1(0)">' + 1938// '<span class="zero-label">0</span>' + 1939// '</li>' + 1940// '<li ng-repeat="star in stars" ng-class="star" ng-click="toggle($index)">' + 1941// '<span class="bath-label"><cite class="blockedelm">{{$index+1}}+</cite></span>' + 1942// '</li>' + 1943// '</ul>', 1944// scope: { 1945// ratingValue: '=', 1946// max: '=', 1947// onRatingSelected: '&' 1948// }, 1949// link: function (scope, elem, attrs) { 1950 1951// var updateStars = function () { 1952// scope.stars = []; 1953 1954// for (var i = 0; i < scope.max; i++) { 1955 1956// scope.stars.push({ 1957// filled: i < scope.ratingValue 1958// }); 1959// } 1960// //console.log(scope.stars); 1961// }; 1962 1963// scope.toggle = function (index) { 1964 1965// scope.ratingValue = index + 1; 1966// scope.onRatingSelected({ 1967// halfbath: index + 1 1968// }); 1969// }; 1970 1971// scope.toggle1 = function () // For 0 bath selected 1972// { 1973// scope.ratingValue = 0; 1974// scope.onRatingSelected({ 1975// halfbath: 0 1976// }); 1977// } 1978
1979// scope.$watch('ratingValue', function (newVal, oldVal) { 1980 1981// if (typeof newVal != 'undefined') { 1982// updateStars(); 1983// } 1984// }); 1985// } 1986// } 1987// }); 1988 1989/***************************************************************************************/
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.