Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function propertyData(res, property){
- var results_page = [];
- var permalink = verifyData(property.find('.flexmls_connect__sr_address a').attr('href'));
- var title = verifyData(property.find('.flexmls_connect__sr_address a').html());
- var description = $(res).find('.flexmls_connect__sr_detail:not(b)').contents().filter(function() {
- return this.nodeType == 3;
- }).text();
- var img = verifyData(property.find('.flexmls_connect__sr_main_photo').attr('src'));
- var lat = verifyData($(res).find('#flexmls_connect__map_canvas').attr('latitude'));
- var lng = verifyData($(res).find('#flexmls_connect__map_canvas').attr('longitude'));
- var type = verifyData(property.find('.flexmls_connect__sr_listing_facts .flexmls_connect__zebra').first().find('.flexmls_connect__field_value').html().toLowerCase().replace(/ /g, "-"));
- var location = '';
- $(property.find('.flexmls_connect__sr_listing_facts .flexmls_connect__zebra .flexmls_connect__field_label:contains("Area:")')).each(function () {
- location = $(this).siblings().html().toLowerCase().replace(/ /g, "-");
- });
- var price = verifyData($(res).find('.flexmls_connect__ld_price').html());
- var bathsAndBeds = verifyData($(res).find('.flexmls_connect__sr_address').contents().filter(function() {
- return this.nodeType == 3 && $(this).text().indexOf('beds')>-1;
- }).text().split('|').reduce(function(a,c){
- if(c.indexOf('beds')>-1){
- a.beds = /d+/.exec(c)[0]
- }else if(c.indexOf('baths')>-1){
- a.baths = /d+/.exec(c)[0]
- }
- return a
- },{}));
- var features = [];
- var str_features = '';
- $(res).find('.flexmls_connect__ld_detail_table .flexmls_connect__detail_header:contains("Property Features")').each(function () {
- $(this).siblings().find('.flexmls_connect__ld_property_detail_row').each(function () {
- $(this).find("b").remove();
- str_features = $(this).find('.flexmls_connect__ld_property_detail').html();
- str_features = $.trim(str_features).toLowerCase();//.replace(/ /g, "-");
- features.push(str_features);
- });
- });
- var formatPrice = '';
- if (price) {
- formatPrice = Number(price.replace(/[^0-9.-]+/g,""));
- }else{
- formatPrice = '';
- }
- if (description) {
- description = description;
- }else{
- description = '';
- }
- results_page.push({
- permalink: permalink,
- title: title,
- description: description,
- img: img,
- position: {lat: lat, lng: lng},
- type: type,
- location: location,
- price: formatPrice,
- baths: bathsAndBeds.baths,
- beds: bathsAndBeds.beds,
- features: features
- });
- return results_page;
- }
Add Comment
Please, Sign In to add comment