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=nearby&clean_path=key-west%2Fhoteles%2Fthe-reach-a-waldorf-astoria-resort&controller=topics&country_code=¤t_user_id=&filters%5BClass%5D%5B%5D=Hotel&id=5000000704408&klass_name=Hotel&list_type=hotels&nearby=true&order=asc&path=key-west%2Fhoteles%2Fthe-reach-a-waldorf-astoria-resort%2Fcerca-hoteles&place=5000000704408&place_type=Hotel&place_type=hotel®ion=2000000000038&sort=best_value", function(status){
if (status === 200) {
HotelRates.ajax();
}
});
var HotelRates = {
hotels: "hotel_ids%5B%5D=5000000177441&hotel_ids%5B%5D=5000000000433&hotel_ids%5B%5D=5000000039145&hotel_ids%5B%5D=5000000704408&hotel_ids%5B%5D=5000000095186&hotel_ids%5B%5D=5000000000112&hotel_ids%5B%5D=5000000062902&hotel_ids%5B%5D=5000000281605&hotel_ids%5B%5D=5000000284316&hotel_ids%5B%5D=5000005910761&hotel_ids%5B%5D=5000000294242&hotel_ids%5B%5D=5000004381932&hotel_ids%5B%5D=5000000249890&hotel_ids%5B%5D=5000000121970&hotel_ids%5B%5D=5000000285821&hotel_ids%5B%5D=5000000326204&hotel_ids%5B%5D=5000000310081&hotel_ids%5B%5D=5000000067264&hotel_ids%5B%5D=5000000000083&hotel_ids%5B%5D=5000003657861&hotel_ids%5B%5D=5000000086029&hotel_ids%5B%5D=5000000346581&hotel_ids%5B%5D=5000000896213&hotel_ids%5B%5D=5000000095293&hotel_ids%5B%5D=5000000096070&hotel_ids%5B%5D=5000000250022&hotel_ids%5B%5D=5000000066994&hotel_ids%5B%5D=5000000048693&hotel_ids%5B%5D=5000000427870&hotel_ids%5B%5D=5000000280443",
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=2000000000038" + "&" + 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);
}
};