API - limit output with variable

0 votes
180 views
added Jun 19, 2018 in API by LC Marshal Captain (25,790 points)
edited Jul 13, 2018 by LC Marshal
//comma plugin
$.fn.digits = function(){ 
    return this.each(function(){ 
        $(this).text( $(this).text().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,") ); 
    })
}

var getProjname = $('.project-detail ul li:first-child .i-list-data').text(), 
    outlookPLislnk = 'https://alice.edgeprop.my/property/v1/nsearch?&keyword=', //API
    intypeSale = '&listing_type=sale',
    recOutput = '&size=4&order_by=posted_desc', //limit with size
    recTotalOutput = outlookPLislnk + getProjname + recOutput;

//recommendation listings
$.getJSON(recTotalOutput, function(recommendedList) {
var property_data = '';
$.each(recommendedList.property, function(index, row) {
  var listPrice = row.field_prop_asking_price.und["0"].value;
  property_data += '<div class="col-md-3 opacity-hover">';
  property_data += '<a target="_blank" href="'+'/listing/'+row.url+'"><span><img src="'+row.field_prop_images+'"></span></a>';
  property_data += '<span class="single-card"><span class="title"><a target="_blank" href="'+'/listing/'+row.url+'">'+row.title+'</a></span>';   
  property_data += '<span class="meta">'+row.district+', '+row.state+'</span>';
  property_data += '<span class="price-listing">RM '+listPrice+'</span></span>';
  property_data += '</div>';
});

var outlookListing    = $('#outlook-property-listing .row').append(property_data),
    outlooklistingWrp = $('#outlook-listing-wrapper');

$('.content-bottom.p-t-50.p-b-50').before('<div class="container showlisting"></div>');
$('.container.showlisting').append(outlooklistingWrp);
$('#outlook-property-listing').fadeIn(300);
$('.price-listing').digits(); //comma plugin
});
lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...