Guest User

Untitled

a guest
Jan 18th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.73 KB | None | 0 0
  1. function propertyData(res, property){
  2. var results_page = [];
  3. var permalink = verifyData(property.find('.flexmls_connect__sr_address a').attr('href'));
  4. var title = verifyData(property.find('.flexmls_connect__sr_address a').html());
  5. var description = $(res).find('.flexmls_connect__sr_detail:not(b)').contents().filter(function() {
  6. return this.nodeType == 3;
  7. }).text();
  8. var img = verifyData(property.find('.flexmls_connect__sr_main_photo').attr('src'));
  9. var lat = verifyData($(res).find('#flexmls_connect__map_canvas').attr('latitude'));
  10. var lng = verifyData($(res).find('#flexmls_connect__map_canvas').attr('longitude'));
  11. var type = verifyData(property.find('.flexmls_connect__sr_listing_facts .flexmls_connect__zebra').first().find('.flexmls_connect__field_value').html().toLowerCase().replace(/ /g, "-"));
  12. var location = '';
  13. $(property.find('.flexmls_connect__sr_listing_facts .flexmls_connect__zebra .flexmls_connect__field_label:contains("Area:")')).each(function () {
  14. location = $(this).siblings().html().toLowerCase().replace(/ /g, "-");
  15. });
  16. var price = verifyData($(res).find('.flexmls_connect__ld_price').html());
  17. var bathsAndBeds = verifyData($(res).find('.flexmls_connect__sr_address').contents().filter(function() {
  18. return this.nodeType == 3 && $(this).text().indexOf('beds')>-1;
  19. }).text().split('|').reduce(function(a,c){
  20. if(c.indexOf('beds')>-1){
  21. a.beds = /d+/.exec(c)[0]
  22. }else if(c.indexOf('baths')>-1){
  23. a.baths = /d+/.exec(c)[0]
  24. }
  25. return a
  26. },{}));
  27. var features = [];
  28. var str_features = '';
  29. $(res).find('.flexmls_connect__ld_detail_table .flexmls_connect__detail_header:contains("Property Features")').each(function () {
  30. $(this).siblings().find('.flexmls_connect__ld_property_detail_row').each(function () {
  31. $(this).find("b").remove();
  32. str_features = $(this).find('.flexmls_connect__ld_property_detail').html();
  33. str_features = $.trim(str_features).toLowerCase();//.replace(/ /g, "-");
  34. features.push(str_features);
  35. });
  36. });
  37.  
  38. var formatPrice = '';
  39.  
  40. if (price) {
  41. formatPrice = Number(price.replace(/[^0-9.-]+/g,""));
  42. }else{
  43. formatPrice = '';
  44. }
  45.  
  46. if (description) {
  47. description = description;
  48. }else{
  49. description = '';
  50. }
  51.  
  52. results_page.push({
  53. permalink: permalink,
  54. title: title,
  55. description: description,
  56. img: img,
  57. position: {lat: lat, lng: lng},
  58. type: type,
  59. location: location,
  60. price: formatPrice,
  61. baths: bathsAndBeds.baths,
  62. beds: bathsAndBeds.beds,
  63. features: features
  64. });
  65.  
  66. return results_page;
  67. }
Add Comment
Please, Sign In to add comment