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.skyscanner.com.br/trip/hotels/hotel_list_page?action=nearby&clean_path=praia-de-miami%2Frestaurantes%2Fplaya-cafe&controller=topics&country_code=¤t_user_id=&filters%5BClass%5D%5B%5D=Hotel&id=4000000415325&klass_name=Restaurant&list_type=hotels&nearby=true&order=asc&path=praia-de-miami%2Frestaurantes%2Fplaya-cafe%2Fpor-perto-hoteis&place=4000000415325&place_type=Restaurant&place_type=restaurant®ion=2000000000324&sort=best_value", function(status){
if (status === 200) {
HotelRates.ajax();
}
});
var HotelRates = {
hotels: "hotel_ids%5B%5D=5000000213693&hotel_ids%5B%5D=5000000033307&hotel_ids%5B%5D=5000000334675&hotel_ids%5B%5D=5000001264115&hotel_ids%5B%5D=5000000326856&hotel_ids%5B%5D=5000000077793&hotel_ids%5B%5D=5000000423949&hotel_ids%5B%5D=5000001240290&hotel_ids%5B%5D=5000000010952&hotel_ids%5B%5D=5000000140378&hotel_ids%5B%5D=5000000350400&hotel_ids%5B%5D=5000000378539&hotel_ids%5B%5D=5000004045125&hotel_ids%5B%5D=5000000254644&hotel_ids%5B%5D=5000000300468&hotel_ids%5B%5D=5000000099447&hotel_ids%5B%5D=5000005364540&hotel_ids%5B%5D=5000000021746&hotel_ids%5B%5D=5000001318725&hotel_ids%5B%5D=5000000243866&hotel_ids%5B%5D=5000000360713&hotel_ids%5B%5D=5000000280259&hotel_ids%5B%5D=5000000365630&hotel_ids%5B%5D=5000000698618&hotel_ids%5B%5D=5000001318739&hotel_ids%5B%5D=5000000092081&hotel_ids%5B%5D=5000001021696&hotel_ids%5B%5D=5000000105735&hotel_ids%5B%5D=5000000266835&hotel_ids%5B%5D=5000000140167",
ajaxCalls: function(tryIndex) {
if (this.hotels) {
ListPage.update("https://www.skyscanner.com.br/trip/hotels/hotel_rates_list?bookable_only=&country_code=¤t_user_id=&locale=pt-BR®ion=2000000000324" + "&" + 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);
}
};