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=miami-beach%2F%CE%B5%CF%83%CF%84%CE%B9%CE%B1%CF%84%CF%8C%CF%81%CE%B9%CE%B1%2Fplaya-cafe&controller=topics&country_code=¤t_user_id=&filters%5BClass%5D%5B%5D=Hotel&id=4000000415325&klass_name=Restaurant&list_type=hotels&nearby=true&order=asc&page=3&path=miami-beach%2F%CE%B5%CF%83%CF%84%CE%B9%CE%B1%CF%84%CF%8C%CF%81%CE%B9%CE%B1%2Fplaya-cafe%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=4000000415325&place_type=Restaurant&place_type=restaurant®ion=2000000000324&sort=best_value", function(status){
if (status === 200) {
HotelRates.ajax();
}
});
var HotelRates = {
hotels: "hotel_ids%5B%5D=5000003671873&hotel_ids%5B%5D=5000001199447&hotel_ids%5B%5D=5000000029311&hotel_ids%5B%5D=5000000266279&hotel_ids%5B%5D=5000000200108&hotel_ids%5B%5D=5000000416510&hotel_ids%5B%5D=5000000032660&hotel_ids%5B%5D=5000000303840&hotel_ids%5B%5D=5000000029750&hotel_ids%5B%5D=5000000059362&hotel_ids%5B%5D=5000000212390&hotel_ids%5B%5D=5000000329221&hotel_ids%5B%5D=5000001318731&hotel_ids%5B%5D=5000000385927&hotel_ids%5B%5D=5000005610792&hotel_ids%5B%5D=5000003949763&hotel_ids%5B%5D=5000000088342&hotel_ids%5B%5D=5000000305743&hotel_ids%5B%5D=5000004073633&hotel_ids%5B%5D=5000000418380&hotel_ids%5B%5D=5000000409196&hotel_ids%5B%5D=5000000386895&hotel_ids%5B%5D=5000004180073&hotel_ids%5B%5D=5000003207919&hotel_ids%5B%5D=5000000886215&hotel_ids%5B%5D=5000000274125&hotel_ids%5B%5D=5000000375049&hotel_ids%5B%5D=5000001240218&hotel_ids%5B%5D=5000003561123&hotel_ids%5B%5D=5000002748009",
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=2000000000324" + "&" + 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);
}
};