Compara y ahorra en hoteles en queso Cheddar
Sue Hasker - Catching up! -flickr
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.espanol.skyscanner.com/trip/hotels/hotel_list_page?action=index&clean_path=queso-cheddar-reino-unido&controller=topics&country_code=¤t_user_id=&filters=&id=2000000021374&klass_name=Region&list_type=hotels&nearby=false&order=asc&path=queso-cheddar-reino-unido%2Fhoteles&place=2000000021374&place_type=City&place_type=region®ion=2000000021374&sort=best_value", function(status){
if (status === 200) {
HotelRates.ajax();
}
});
var HotelRates = {
hotels: "hotel_ids%5B%5D=5000000030803&hotel_ids%5B%5D=5000000284848&hotel_ids%5B%5D=5000000193375&hotel_ids%5B%5D=5000000017060&hotel_ids%5B%5D=5000000054702&hotel_ids%5B%5D=5000000378037&hotel_ids%5B%5D=5000000060769&hotel_ids%5B%5D=5000003729329&hotel_ids%5B%5D=5000003732135&hotel_ids%5B%5D=5000000335064&hotel_ids%5B%5D=5000003811927&hotel_ids%5B%5D=5000003961898&hotel_ids%5B%5D=5000004035372&hotel_ids%5B%5D=5000003689297&hotel_ids%5B%5D=5000003746915&hotel_ids%5B%5D=5000000033423&hotel_ids%5B%5D=5000003988883&hotel_ids%5B%5D=5000000166287&hotel_ids%5B%5D=5000000256621&hotel_ids%5B%5D=5000000413870",
ajaxCalls: function(tryIndex) {
if (this.hotels) {
ListPage.update("https://www.espanol.skyscanner.com/trip/hotels/hotel_rates_list?bookable_only=&country_code=¤t_user_id=&locale=es-LATAM®ion=2000000021374" + "&" + 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);
}
};