Compare and save on Chicago hotels for Viaggi d'Affari
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.it/trip/hotels/hotel_list_page?action=index&clean_path=chicago&controller=topics&country_code=¤t_user_id=&filters=&id=2000000000012&klass_name=Region&list_type=hotels&nearby=false&order=asc&page=3&path=chicago%2Fhotels&place=2000000000012&place_type=City&place_type=region®ion=2000000000012&sort=best_value&sort_tribe_ids%5B%5D=1000000000004&sort_tribe_names=business-travelers", function(status){
if (status === 200) {
HotelRates.ajax();
}
});
var HotelRates = {
hotels: "hotel_ids%5B%5D=5000000019703&hotel_ids%5B%5D=5000000250227&hotel_ids%5B%5D=5000001027206&hotel_ids%5B%5D=5000003419695&hotel_ids%5B%5D=5000001267079&hotel_ids%5B%5D=5000000076609&hotel_ids%5B%5D=5000000076801&hotel_ids%5B%5D=5000001019557&hotel_ids%5B%5D=5000002747706&hotel_ids%5B%5D=5000000000237&hotel_ids%5B%5D=5000000095133&hotel_ids%5B%5D=5000000095196&hotel_ids%5B%5D=5000000000293&hotel_ids%5B%5D=5000000095165&hotel_ids%5B%5D=5000000105126&hotel_ids%5B%5D=5000001270403&hotel_ids%5B%5D=5000000096176&hotel_ids%5B%5D=5000003657627&hotel_ids%5B%5D=5000000346332&hotel_ids%5B%5D=5000000119417&hotel_ids%5B%5D=5000000095156&hotel_ids%5B%5D=5000000360450&hotel_ids%5B%5D=5000000085773&hotel_ids%5B%5D=5000000076561&hotel_ids%5B%5D=5000000010568&hotel_ids%5B%5D=5000000249942&hotel_ids%5B%5D=5000000388654&hotel_ids%5B%5D=5000000177086&hotel_ids%5B%5D=5000000177104&hotel_ids%5B%5D=5000000095318",
ajaxCalls: function(tryIndex) {
if (this.hotels) {
ListPage.update("https://www.skyscanner.it/trip/hotels/hotel_rates_list?bookable_only=&country_code=¤t_user_id=&locale=it®ion=2000000000012" + "&" + 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);
}
};