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=santa-fe%2Frestaurantes%2Ftomasitas-santa-fe&controller=topics&country_code=¤t_user_id=&filters%5BClass%5D%5B%5D=Hotel&id=4000000177940&klass_name=Restaurant&list_type=hotels&nearby=true&order=asc&path=santa-fe%2Frestaurantes%2Ftomasitas-santa-fe%2Fcerca-hoteles&place=4000000177940&place_type=Restaurant&place_type=restaurant®ion=2000000000273&sort=best_value", function(status){
if (status === 200) {
HotelRates.ajax();
}
});
var HotelRates = {
hotels: "hotel_ids%5B%5D=5000000178083&hotel_ids%5B%5D=5000000200207&hotel_ids%5B%5D=5000000377455&hotel_ids%5B%5D=5000000048691&hotel_ids%5B%5D=5000000065299&hotel_ids%5B%5D=5000000155397&hotel_ids%5B%5D=5000000140373&hotel_ids%5B%5D=5000000095017&hotel_ids%5B%5D=5000000177642&hotel_ids%5B%5D=5000000706167&hotel_ids%5B%5D=5000000147870&hotel_ids%5B%5D=5000000147915&hotel_ids%5B%5D=5000000017177&hotel_ids%5B%5D=5000000105635&hotel_ids%5B%5D=5000000214659&hotel_ids%5B%5D=5000000895987&hotel_ids%5B%5D=5000000140499&hotel_ids%5B%5D=5000000189096&hotel_ids%5B%5D=5000000045328&hotel_ids%5B%5D=5000000186408&hotel_ids%5B%5D=5000003544192&hotel_ids%5B%5D=5000000393120&hotel_ids%5B%5D=5000000273028&hotel_ids%5B%5D=5000000312386&hotel_ids%5B%5D=5000000425981&hotel_ids%5B%5D=5000000148265&hotel_ids%5B%5D=5000000233157&hotel_ids%5B%5D=5000000162996&hotel_ids%5B%5D=5000000235518&hotel_ids%5B%5D=5000000895985",
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=2000000000273" + "&" + 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);
}
};