Skip to content

Instantly share code, notes, and snippets.

@fcasco
Created August 12, 2015 23:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fcasco/447ceb734f74943e5d5c to your computer and use it in GitHub Desktop.
Save fcasco/447ceb734f74943e5d5c to your computer and use it in GitHub Desktop.
function add_hotel_result(hotel, i, hotels) {
// Crea un nuevo elemento para mostrar los datos del hotel
var $new_hotel_result = $hotels_results.find('.template.hotel_result')
.clone()
.removeClass('template');
$new_hotel_result.find('.hotel_name').html(hotel.hotel_name);
function add_rate_option(rate) {
// Agrega el tipo de habitacion para el hotel
var $rooms_list = $new_hotel_result.find('.room_info'),
$new_rate = $new_hotel_result.find('.room_info>.template').clone();
$new_rate.removeClass('template')
.find('.description')
.html(rate.description);
function add_exchange_option(exchange_option) {
// Agrega la opcion de canje para el tipo de habitacion
var $exchange_options = $new_rate.find('.exchange_options'),
$new_exchange_option;
if (exchange_option.pesos === '0') {
$new_exchange_option = $exchange_options.find('.template.points_only')
.clone()
.removeClass('template');
$new_exchange_option.find('p').prepend(exchange_option.points);
} else {
$new_exchange_option = $exchange_options.find('.template.points_and_money')
.clone()
.removeClass('template');
$new_exchange_option.find('.shares')
.prepend(exchange_option.shares)
.append(exchange_option.pesos);
}
$new_exchange_option.appendTo($exchange_options).show();
}
rate.exchange_options.map(add_exchange_option);
$new_rate.appendTo($rooms_list).show();
}
hotel.rates.map(add_rate_option);
$hotels_results.append($new_hotel_result);
$new_hotel_result.show();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment