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=nearby&clean_path=indianapolis-indiana%2Fristoranti%2Fjockamo-upper-crust-pizza&controller=topics&country_code=¤t_user_id=&filters%5BClass%5D%5B%5D=Hotel&id=4000000454117&klass_name=Restaurant&list_type=hotels&nearby=true&order=asc&path=indianapolis-indiana%2Fristoranti%2Fjockamo-upper-crust-pizza%2Fnei-dintorni-hotel&place=4000000454117&place_type=Restaurant&place_type=restaurant®ion=2000000000229&sort=best_value", function(status){
if (status === 200) {
HotelRates.ajax();
}
});
var HotelRates = {
hotels: "hotel_ids%5B%5D=5000000366591&hotel_ids%5B%5D=5000000372464&hotel_ids%5B%5D=5000000001359&hotel_ids%5B%5D=5000003837476&hotel_ids%5B%5D=5000000174386&hotel_ids%5B%5D=5000000010899&hotel_ids%5B%5D=5000000346780&hotel_ids%5B%5D=5000000165917&hotel_ids%5B%5D=5000000053721&hotel_ids%5B%5D=5000000372416&hotel_ids%5B%5D=5000000254549&hotel_ids%5B%5D=5000000193418&hotel_ids%5B%5D=5000000410547&hotel_ids%5B%5D=5000000157273&hotel_ids%5B%5D=5000001319915&hotel_ids%5B%5D=5000001319960&hotel_ids%5B%5D=5000000701259&hotel_ids%5B%5D=5000000363918&hotel_ids%5B%5D=5000000351707&hotel_ids%5B%5D=5000000057749&hotel_ids%5B%5D=5000000095770&hotel_ids%5B%5D=5000001319938&hotel_ids%5B%5D=5000000228784&hotel_ids%5B%5D=5000000001001&hotel_ids%5B%5D=5000000142091&hotel_ids%5B%5D=5000000097698&hotel_ids%5B%5D=5000000421108&hotel_ids%5B%5D=5000001527961&hotel_ids%5B%5D=5000000383413&hotel_ids%5B%5D=5000000309791",
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=2000000000229" + "&" + 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);
}
};