Created
July 27, 2016 19:49
-
-
Save reidab/53da78665fa17ea7a696d6c75a54a2d0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const api_key = JSON.parse($('#_bootstrap-layout-init').attr('content')).api_config.key, | |
base_path = '/api/v2/pricing_quotes?_format=for_detailed_booking_info_on_web_p3¤cy=USD&locale=en&'; | |
var guests = $('.guest-select').attr('value'), | |
check_in = moment($('#map-search-checkin').attr('value')).format('YYYY-MM-DD'), | |
check_out = moment($('#map-search-checkout').attr('value')).format('YYYY-MM-DD'); | |
function refresh_total_prices() { | |
$('.listings-container .listing').each(function() { | |
var listing = $(this), | |
id = listing.find('a.media-cover').attr('target').split('_')[1], | |
query = [ | |
'listing_id=' + id, | |
'guests=' + guests, | |
'check_in=' + check_in, | |
'check_out=' + check_out, | |
'key=' + api_key | |
].join('&'); | |
$.getJSON(base_path + query, function(data) { | |
console.log(data); | |
var per_night = listing.find('.price-amount').text(); | |
listing.find('.price-amount').text( per_night + ' / ' + data.pricing_quotes[0].price.total.amount ); | |
}); | |
}); | |
} | |
refresh_total_prices(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment