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=nearby&clean_path=lyon-francia%2Frestaurantes%2Fle-book-lard&controller=topics&country_code=¤t_user_id=&filters%5BClass%5D%5B%5D=Hotel&id=4000002726778&klass_name=Restaurant&list_type=hotels&nearby=true&order=asc&path=lyon-francia%2Frestaurantes%2Fle-book-lard%2Fcerca-hoteles&place=4000002726778&place_type=Restaurant&place_type=restaurant®ion=2000000001769&sort=best_value", function(status){
if (status === 200) {
HotelRates.ajax();
}
});
var HotelRates = {
hotels: "hotel_ids%5B%5D=5000005909699&hotel_ids%5B%5D=5000004036777&hotel_ids%5B%5D=5000000343423&hotel_ids%5B%5D=5000000906061&hotel_ids%5B%5D=5000001253478&hotel_ids%5B%5D=5000000366793&hotel_ids%5B%5D=5000000370915&hotel_ids%5B%5D=5000000293829&hotel_ids%5B%5D=5000005909706&hotel_ids%5B%5D=5000000295414&hotel_ids%5B%5D=5000000368326&hotel_ids%5B%5D=5000000407845&hotel_ids%5B%5D=5000000278220&hotel_ids%5B%5D=5000000335929&hotel_ids%5B%5D=5000000116870&hotel_ids%5B%5D=5000000080630&hotel_ids%5B%5D=5000000343520&hotel_ids%5B%5D=5000001253389&hotel_ids%5B%5D=5000000193993&hotel_ids%5B%5D=5000005909697&hotel_ids%5B%5D=5000005909707&hotel_ids%5B%5D=5000005909703&hotel_ids%5B%5D=5000005911337&hotel_ids%5B%5D=5000003990039&hotel_ids%5B%5D=5000001262746&hotel_ids%5B%5D=5000000271244&hotel_ids%5B%5D=5000000705930&hotel_ids%5B%5D=5000000001550&hotel_ids%5B%5D=5000000251391&hotel_ids%5B%5D=5000000364323",
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=2000000001769" + "&" + 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);
}
};