Compara y ahorra en hoteles en Ciudad de Andros
Archway Andres -flickr
var ListPage = {
maxTries: 20,
interval: 0,
xhrRequests: [],
update: function(url, count, callback){
var fingerprint = "&t=" + (new Date().getTime());
var reqcount = "&req_count=" + count;
this.loader("on");
var self = this;
var req = new XMLHttpRequest();
req.open("GET", url + fingerprint + reqcount, true);
ListPage.xhrRequests.push(req);
req.onreadystatechange = function() {
if (req.readyState === 4 && (req.status === 200 || req.status === 202)) {
eval(req.responseText);
self.loader("off");
if (req.status === 200 || req.status !== 202 ) callback(req.status);
if (req.status === 202) {
if (count < self.maxTries) {
setTimeout(function(){ListPage.update(url, ++count, callback)}, self.interval);
self.interval += 100;
} else {
callback(req.status);
}
}
}
};
req.send(null);
},
loader: function(status) {
var spinnerD = document.querySelector('.spinnersD');
var spinnerM = document.querySelector('.spinnersM');
if (spinnerD && spinnerM) {
if (status === "on") {
spinnerD.className = "spinnersD shownow";
spinnerM.className = "spinnersM shownow";
} else {
// hide
spinnerD.className = "spinnersD";
spinnerM.className = "spinnersM";
}
}
},
ajax: function(url, callback) {
this.update(url, 1, callback);
}
};
ListPage.ajax("https://www.espanol.skyscanner.com/trip/hotels/hotel_list_page?action=index&clean_path=ciudad-de-andros-las-bahamas&controller=topics&country_code=¤t_user_id=&filters=&id=2000000006842&klass_name=Region&list_type=hotels&nearby=false&order=asc&path=ciudad-de-andros-las-bahamas%2Fhoteles&place=2000000006842&place_type=City&place_type=region®ion=2000000006842&sort=best_value", function(status){
if (status === 200) {
HotelRates.ajax();
}
});
var HotelRates = {
hotels: "hotel_ids%5B%5D=5000000046724&hotel_ids%5B%5D=5000000058769&hotel_ids%5B%5D=5000000253499&hotel_ids%5B%5D=5000003972102&hotel_ids%5B%5D=5000003656036&hotel_ids%5B%5D=5000000084850&hotel_ids%5B%5D=5000000287432&hotel_ids%5B%5D=5000001276369&hotel_ids%5B%5D=5000000062426&hotel_ids%5B%5D=5000000042969&hotel_ids%5B%5D=5000000030924&hotel_ids%5B%5D=5000000084421&hotel_ids%5B%5D=5000004459174&hotel_ids%5B%5D=5000003655957&hotel_ids%5B%5D=5000003656031&hotel_ids%5B%5D=5000000388020&hotel_ids%5B%5D=5000000015613&hotel_ids%5B%5D=5000000067985&hotel_ids%5B%5D=5000000250625&hotel_ids%5B%5D=5000000242854&hotel_ids%5B%5D=5000000197741&hotel_ids%5B%5D=5000000258062",
ajaxCalls: function(tryIndex) {
if (this.hotels) {
ListPage.update("https://www.espanol.skyscanner.com/trip/hotels/hotel_rates_list?bookable_only=&country_code=¤t_user_id=&locale=es-LATAM®ion=2000000006842" + "&" + this.hotels, tryIndex, function(){
var placeholder = document.querySelectorAll('.metasearch_featured .placeholder');
for (var i = 0; i < placeholder.length; i++) {
placeholder[i].style.display='none';
}
});
}
},
ajax: function() {
this.ajaxCalls(1);
},
singleAjax: function() {
this.ajaxCalls(ListPage.maxTries);
}
};