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=coconut-grove-florida%2Fcosas-para-hacer%2Fgm-sports-tennis-academy&controller=topics&country_code=¤t_user_id=&filters%5BClass%5D%5B%5D=Hotel&id=3000000230593&klass_name=Attraction&list_type=hotels&nearby=true&order=asc&path=coconut-grove-florida%2Fcosas-para-hacer%2Fgm-sports-tennis-academy%2Fcerca-hoteles&place=3000000230593&place_type=Attraction&place_type=attraction®ion=2000000000969&sort=best_value", function(status){
if (status === 200) {
HotelRates.ajax();
}
});
var HotelRates = {
hotels: "hotel_ids%5B%5D=5000000394784&hotel_ids%5B%5D=5000000057982&hotel_ids%5B%5D=5000000346638&hotel_ids%5B%5D=5000004041179&hotel_ids%5B%5D=5000001318737&hotel_ids%5B%5D=5000000698474&hotel_ids%5B%5D=5000000361573&hotel_ids%5B%5D=5000000385494&hotel_ids%5B%5D=5000000310384&hotel_ids%5B%5D=5000000374040&hotel_ids%5B%5D=5000003375173&hotel_ids%5B%5D=5000000114873&hotel_ids%5B%5D=5000000344536&hotel_ids%5B%5D=5000000072063&hotel_ids%5B%5D=5000004060224&hotel_ids%5B%5D=5000001318653&hotel_ids%5B%5D=5000000019778&hotel_ids%5B%5D=5000002676780&hotel_ids%5B%5D=5000003537681&hotel_ids%5B%5D=5000000067221&hotel_ids%5B%5D=5000000010135&hotel_ids%5B%5D=5000000276931&hotel_ids%5B%5D=5000000019860&hotel_ids%5B%5D=5000000018429&hotel_ids%5B%5D=5000000190702&hotel_ids%5B%5D=5000000334269&hotel_ids%5B%5D=5000000106862&hotel_ids%5B%5D=5000003561118&hotel_ids%5B%5D=5000001318706&hotel_ids%5B%5D=5000002676779",
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=2000000000969" + "&" + 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);
}
};