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=los-angeles%2Frestaurantes%2Fanimal&controller=topics&country_code=¤t_user_id=&filters%5BClass%5D%5B%5D=Hotel&id=4000000567180&klass_name=Restaurant&list_type=hotels&nearby=true&order=asc&path=los-angeles%2Frestaurantes%2Fanimal%2Fcerca-hoteles&place=4000000567180&place_type=Restaurant&place_type=restaurant®ion=2000000000130&sort=best_value", function(status){
if (status === 200) {
HotelRates.ajax();
}
});
var HotelRates = {
hotels: "hotel_ids%5B%5D=5000000077560&hotel_ids%5B%5D=5000000249975&hotel_ids%5B%5D=5000001087916&hotel_ids%5B%5D=5000000114731&hotel_ids%5B%5D=5000003424646&hotel_ids%5B%5D=5000000699982&hotel_ids%5B%5D=5000000054545&hotel_ids%5B%5D=5000000705196&hotel_ids%5B%5D=5000000000118&hotel_ids%5B%5D=5000003565854&hotel_ids%5B%5D=5000003561614&hotel_ids%5B%5D=5000003424645&hotel_ids%5B%5D=5000000113515&hotel_ids%5B%5D=5000000243508&hotel_ids%5B%5D=5000000341082&hotel_ids%5B%5D=5000000698388&hotel_ids%5B%5D=5000000051947&hotel_ids%5B%5D=5000000167287&hotel_ids%5B%5D=5000000001182&hotel_ids%5B%5D=5000000210450&hotel_ids%5B%5D=5000000230283&hotel_ids%5B%5D=5000000001112&hotel_ids%5B%5D=5000000409330&hotel_ids%5B%5D=5000000372123&hotel_ids%5B%5D=5000000092026&hotel_ids%5B%5D=5000000373902&hotel_ids%5B%5D=5000000704016&hotel_ids%5B%5D=5000001059268&hotel_ids%5B%5D=5000000308505&hotel_ids%5B%5D=5000000000095",
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=2000000000130" + "&" + 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);
}
};