Confronta e risparmia sugli hotel di Sacramento
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=sacramento-california&controller=topics&country_code=¤t_user_id=&filters=&id=2000000000495&klass_name=Region&list_type=hotels&nearby=false&order=asc&path=sacramento-california%2Fhotels&place=2000000000495&place_type=City&place_type=region®ion=2000000000495&sort=best_value", function(status){
if (status === 200) {
HotelRates.ajax();
}
});
var HotelRates = {
hotels: "hotel_ids%5B%5D=5000000156880&hotel_ids%5B%5D=5000003868375&hotel_ids%5B%5D=5000000172297&hotel_ids%5B%5D=5000000303499&hotel_ids%5B%5D=5000000085697&hotel_ids%5B%5D=5000000351288&hotel_ids%5B%5D=5000000340785&hotel_ids%5B%5D=5000000150496&hotel_ids%5B%5D=5000000350981&hotel_ids%5B%5D=5000000089192&hotel_ids%5B%5D=5000000125627&hotel_ids%5B%5D=5000000403597&hotel_ids%5B%5D=5000000012003&hotel_ids%5B%5D=5000000338566&hotel_ids%5B%5D=5000000181044&hotel_ids%5B%5D=5000000363804&hotel_ids%5B%5D=5000000405912&hotel_ids%5B%5D=5000000177835&hotel_ids%5B%5D=5000000397658&hotel_ids%5B%5D=5000000177952&hotel_ids%5B%5D=5000000227799&hotel_ids%5B%5D=5000000039072&hotel_ids%5B%5D=5000000326893&hotel_ids%5B%5D=5000005909917&hotel_ids%5B%5D=5000005909920&hotel_ids%5B%5D=5000000266282&hotel_ids%5B%5D=5000000257137&hotel_ids%5B%5D=5000000310083&hotel_ids%5B%5D=5000000054236&hotel_ids%5B%5D=5000000124665",
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=2000000000495" + "&" + 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);
}
};