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=monterrey-mexico%2Fhoteis%2Fhotel-el-regio&controller=topics&country_code=¤t_user_id=&filters%5BClass%5D%5B%5D=Hotel&id=5000003827427&klass_name=Hotel&list_type=hotels&nearby=true&order=asc&path=monterrey-mexico%2Fhoteis%2Fhotel-el-regio%2Fpor-perto-hoteis&place=5000003827427&place_type=Hotel&place_type=hotel®ion=2000000000637&sort=best_value", function(status){
if (status === 200) {
HotelRates.ajax();
}
});
var HotelRates = {
hotels: "hotel_ids%5B%5D=5000000304792&hotel_ids%5B%5D=5000001258221&hotel_ids%5B%5D=5000000277298&hotel_ids%5B%5D=5000000027672&hotel_ids%5B%5D=5000000125216&hotel_ids%5B%5D=5000000085948&hotel_ids%5B%5D=5000000119804&hotel_ids%5B%5D=5000000381623&hotel_ids%5B%5D=5000000211755&hotel_ids%5B%5D=5000000397515&hotel_ids%5B%5D=5000000057916&hotel_ids%5B%5D=5000000020524&hotel_ids%5B%5D=5000001260232&hotel_ids%5B%5D=5000000020310&hotel_ids%5B%5D=5000000345059&hotel_ids%5B%5D=5000000298940&hotel_ids%5B%5D=5000000052004&hotel_ids%5B%5D=5000000233906&hotel_ids%5B%5D=5000001058388&hotel_ids%5B%5D=5000000055091&hotel_ids%5B%5D=5000000359120&hotel_ids%5B%5D=5000000012176&hotel_ids%5B%5D=5000000001120&hotel_ids%5B%5D=5000000290773&hotel_ids%5B%5D=5000003932168&hotel_ids%5B%5D=5000000288741",
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=2000000000637" + "&" + 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);
}
};