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=bibury-reino-unido%2Fhoteles%2Fthe-tallet&controller=topics&country_code=¤t_user_id=&filters%5BClass%5D%5B%5D=Hotel&id=5000003650399&klass_name=Hotel&list_type=hotels&nearby=true&order=asc&path=bibury-reino-unido%2Fhoteles%2Fthe-tallet%2Fcerca-hoteles&place=5000003650399&place_type=Hotel&place_type=hotel®ion=2000000052924&sort=best_value", function(status){
if (status === 200) {
HotelRates.ajax();
}
});
var HotelRates = {
hotels: "hotel_ids%5B%5D=5000003650399&hotel_ids%5B%5D=5000000249839&hotel_ids%5B%5D=5000000343265&hotel_ids%5B%5D=5000000341316&hotel_ids%5B%5D=5000000368167&hotel_ids%5B%5D=5000000176623&hotel_ids%5B%5D=5000000026622&hotel_ids%5B%5D=5000000387956&hotel_ids%5B%5D=5000000206498&hotel_ids%5B%5D=5000000125636&hotel_ids%5B%5D=5000000426953&hotel_ids%5B%5D=5000000034815&hotel_ids%5B%5D=5000000318095&hotel_ids%5B%5D=5000000195232&hotel_ids%5B%5D=5000000291617&hotel_ids%5B%5D=5000000237944&hotel_ids%5B%5D=5000000921531&hotel_ids%5B%5D=5000000031406&hotel_ids%5B%5D=5000000107750&hotel_ids%5B%5D=5000000075281&hotel_ids%5B%5D=5000000002781&hotel_ids%5B%5D=5000000324834&hotel_ids%5B%5D=5000000304976&hotel_ids%5B%5D=5000000121852&hotel_ids%5B%5D=5000000402791&hotel_ids%5B%5D=5000000088404&hotel_ids%5B%5D=5000000310586&hotel_ids%5B%5D=5000000182661&hotel_ids%5B%5D=5000003657490&hotel_ids%5B%5D=5000000016865",
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=2000000052924" + "&" + 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);
}
};