Compare and save on Noumea hotels
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.skyscanner.com/trip/hotels/hotel_list_page?action=index&clean_path=noumea-new-caledonia&controller=topics&country_code=¤t_user_id=&filters=&id=2000000017858&klass_name=Region&list_type=hotels&nearby=false&order=asc&path=noumea-new-caledonia%2Fhotels&place=2000000017858&place_type=City&place_type=region®ion=2000000017858&sort=best_value", function(status){
if (status === 200) {
HotelRates.ajax();
}
});
var HotelRates = {
hotels: "hotel_ids%5B%5D=5000000006027&hotel_ids%5B%5D=5000000136497&hotel_ids%5B%5D=5000000265368&hotel_ids%5B%5D=5000000101235&hotel_ids%5B%5D=5000003700063&hotel_ids%5B%5D=5000000146261&hotel_ids%5B%5D=5000000382948&hotel_ids%5B%5D=5000000066549&hotel_ids%5B%5D=5000000141626&hotel_ids%5B%5D=5000000095721&hotel_ids%5B%5D=5000000379985&hotel_ids%5B%5D=5000000049570&hotel_ids%5B%5D=5000000701620&hotel_ids%5B%5D=5000003345634&hotel_ids%5B%5D=5000000051511&hotel_ids%5B%5D=5000000348726&hotel_ids%5B%5D=5000000978815&hotel_ids%5B%5D=5000003711094&hotel_ids%5B%5D=5000004438788&hotel_ids%5B%5D=5000004448706&hotel_ids%5B%5D=5000003851206&hotel_ids%5B%5D=5000003742013&hotel_ids%5B%5D=5000000182848&hotel_ids%5B%5D=5000000158259&hotel_ids%5B%5D=5000000317937&hotel_ids%5B%5D=5000000095627&hotel_ids%5B%5D=5000000271620&hotel_ids%5B%5D=5000000011458&hotel_ids%5B%5D=5000000435560&hotel_ids%5B%5D=5000003681963",
ajaxCalls: function(tryIndex) {
if (this.hotels) {
ListPage.update("https://www.skyscanner.com/trip/hotels/hotel_rates_list?bookable_only=&country_code=¤t_user_id=&locale=en®ion=2000000017858" + "&" + 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);
}
};