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=san-diego%2Fcosas-para-hacer%2Fnatonal-comedy-theatre&controller=topics&country_code=¤t_user_id=&filters%5BClass%5D%5B%5D=Hotel&id=3000000210830&klass_name=Attraction&list_type=hotels&nearby=true&order=asc&path=san-diego%2Fcosas-para-hacer%2Fnatonal-comedy-theatre%2Fcerca-hoteles&place=3000000210830&place_type=Attraction&place_type=attraction®ion=2000000000073&sort=best_value", function(status){
if (status === 200) {
HotelRates.ajax();
}
});
var HotelRates = {
hotels: "hotel_ids%5B%5D=5000000371920&hotel_ids%5B%5D=5000000000458&hotel_ids%5B%5D=5000000095908&hotel_ids%5B%5D=5000000009728&hotel_ids%5B%5D=5000000250233&hotel_ids%5B%5D=5000000346775&hotel_ids%5B%5D=5000000331981&hotel_ids%5B%5D=5000000015740&hotel_ids%5B%5D=5000000409406&hotel_ids%5B%5D=5000000346826&hotel_ids%5B%5D=5000000249932&hotel_ids%5B%5D=5000000038661&hotel_ids%5B%5D=5000000250256&hotel_ids%5B%5D=5000000000164&hotel_ids%5B%5D=5000000249993&hotel_ids%5B%5D=5000000234958&hotel_ids%5B%5D=5000000406748&hotel_ids%5B%5D=5000000310202&hotel_ids%5B%5D=5000000085893&hotel_ids%5B%5D=5000000698778&hotel_ids%5B%5D=5000000095273&hotel_ids%5B%5D=5000000177248&hotel_ids%5B%5D=5000000114890&hotel_ids%5B%5D=5000002603912&hotel_ids%5B%5D=5000000969216&hotel_ids%5B%5D=5000000048144&hotel_ids%5B%5D=5000003596262&hotel_ids%5B%5D=5000000024714&hotel_ids%5B%5D=5000000380755&hotel_ids%5B%5D=5000000972529",
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=2000000000073" + "&" + 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);
}
};