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://gr.skyscanner.com/trip/hotels/hotel_list_page?action=nearby&clean_path=ubud%2F%CE%BE%CE%B5%CE%BD%CE%BF%CE%B4%CE%BF%CF%87%CE%B5%CE%AF%CE%B1%2Fmandapa-a-ritz-carlton-reserve&controller=topics&country_code=¤t_user_id=&filters%5BClass%5D%5B%5D=Hotel&id=5000003646505&klass_name=Hotel&list_type=hotels&nearby=true&order=asc&path=ubud%2F%CE%BE%CE%B5%CE%BD%CE%BF%CE%B4%CE%BF%CF%87%CE%B5%CE%AF%CE%B1%2Fmandapa-a-ritz-carlton-reserve%2F%CE%BA%CE%BF%CE%BD%CF%84%CE%B9%CE%BD%CF%8C-%CE%BE%CE%B5%CE%BD%CE%BF%CE%B4%CE%BF%CF%87%CE%B5%CE%AF%CE%B1&place=5000003646505&place_type=Hotel&place_type=hotel®ion=2000000000617&sort=best_value", function(status){
if (status === 200) {
HotelRates.ajax();
}
});
var HotelRates = {
hotels: "hotel_ids%5B%5D=5000003646505&hotel_ids%5B%5D=5000000250244&hotel_ids%5B%5D=5000000342097&hotel_ids%5B%5D=5000004426477&hotel_ids%5B%5D=5000000095286&hotel_ids%5B%5D=5000000264901&hotel_ids%5B%5D=5000003939967&hotel_ids%5B%5D=5000005911078&hotel_ids%5B%5D=5000000398924&hotel_ids%5B%5D=5000000414451&hotel_ids%5B%5D=5000003523458&hotel_ids%5B%5D=5000000407462&hotel_ids%5B%5D=5000000000503&hotel_ids%5B%5D=5000000095240&hotel_ids%5B%5D=5000000406206&hotel_ids%5B%5D=5000004043557&hotel_ids%5B%5D=5000000076539&hotel_ids%5B%5D=5000000205920&hotel_ids%5B%5D=5000000293385&hotel_ids%5B%5D=5000000177348&hotel_ids%5B%5D=5000003611277&hotel_ids%5B%5D=5000000091654&hotel_ids%5B%5D=5000000000422&hotel_ids%5B%5D=5000001373718&hotel_ids%5B%5D=5000000076450&hotel_ids%5B%5D=5000000016312&hotel_ids%5B%5D=5000000249583&hotel_ids%5B%5D=5000000053290&hotel_ids%5B%5D=5000000703008&hotel_ids%5B%5D=5000000187760",
ajaxCalls: function(tryIndex) {
if (this.hotels) {
ListPage.update("https://gr.skyscanner.com/trip/hotels/hotel_rates_list?bookable_only=&country_code=¤t_user_id=&locale=el®ion=2000000000617" + "&" + 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);
}
};