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=marrakech%2Fhoteles%2Friad-anya&controller=topics&country_code=¤t_user_id=&filters%5BClass%5D%5B%5D=Hotel&id=5000000245155&klass_name=Hotel&list_type=hotels&nearby=true&order=asc&path=marrakech%2Fhoteles%2Friad-anya%2Fcerca-hoteles&place=5000000245155&place_type=Hotel&place_type=hotel®ion=2000000000540&sort=best_value", function(status){
if (status === 200) {
HotelRates.ajax();
}
});
var HotelRates = {
hotels: "hotel_ids%5B%5D=5000000331174&hotel_ids%5B%5D=5000000139736&hotel_ids%5B%5D=5000000276994&hotel_ids%5B%5D=5000000245155&hotel_ids%5B%5D=5000000152043&hotel_ids%5B%5D=5000000260788&hotel_ids%5B%5D=5000000092987&hotel_ids%5B%5D=5000000127523&hotel_ids%5B%5D=5000001558839&hotel_ids%5B%5D=5000000284453&hotel_ids%5B%5D=5000000015904&hotel_ids%5B%5D=5000000365688&hotel_ids%5B%5D=5000000033125&hotel_ids%5B%5D=5000000174710&hotel_ids%5B%5D=5000003875698&hotel_ids%5B%5D=5000000400647&hotel_ids%5B%5D=5000000346644&hotel_ids%5B%5D=5000000203036&hotel_ids%5B%5D=5000000079336&hotel_ids%5B%5D=5000000087141&hotel_ids%5B%5D=5000000088054&hotel_ids%5B%5D=5000000705023&hotel_ids%5B%5D=5000003754977&hotel_ids%5B%5D=5000000380529&hotel_ids%5B%5D=5000000077977&hotel_ids%5B%5D=5000000192262&hotel_ids%5B%5D=5000000009738&hotel_ids%5B%5D=5000001254036&hotel_ids%5B%5D=5000000290627&hotel_ids%5B%5D=5000000264344",
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=2000000000540" + "&" + 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);
}
};