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=venecia%2Frestaurantes%2Fristorante-al-giglio&controller=topics&country_code=¤t_user_id=&filters%5BClass%5D%5B%5D=Hotel&id=4000001188568&klass_name=Restaurant&list_type=hotels&nearby=true&order=asc&page=3&path=venecia%2Frestaurantes%2Fristorante-al-giglio%2Fcerca-hoteles&place=4000001188568&place_type=Restaurant&place_type=restaurant®ion=2000000000337&sort=best_value", function(status){
if (status === 200) {
HotelRates.ajax();
}
});
var HotelRates = {
hotels: "hotel_ids%5B%5D=5000000395246&hotel_ids%5B%5D=5000001241238&hotel_ids%5B%5D=5000000370704&hotel_ids%5B%5D=5000000076885&hotel_ids%5B%5D=5000000048592&hotel_ids%5B%5D=5000000095725&hotel_ids%5B%5D=5000000008271&hotel_ids%5B%5D=5000000310314&hotel_ids%5B%5D=5000000095390&hotel_ids%5B%5D=5000000029559&hotel_ids%5B%5D=5000005054943&hotel_ids%5B%5D=5000000381152&hotel_ids%5B%5D=5000000008234&hotel_ids%5B%5D=5000000135353&hotel_ids%5B%5D=5000000010275&hotel_ids%5B%5D=5000000000046&hotel_ids%5B%5D=5000000249968&hotel_ids%5B%5D=5000000310159&hotel_ids%5B%5D=5000000030338&hotel_ids%5B%5D=5000000142071&hotel_ids%5B%5D=5000000006135&hotel_ids%5B%5D=5000001620695&hotel_ids%5B%5D=5000001280161&hotel_ids%5B%5D=5000000250548&hotel_ids%5B%5D=5000000105774&hotel_ids%5B%5D=5000000346659&hotel_ids%5B%5D=5000000000340&hotel_ids%5B%5D=5000000169787&hotel_ids%5B%5D=5000000233813&hotel_ids%5B%5D=5000000270633",
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=2000000000337" + "&" + 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);
}
};