Compare and save on Ketchikan 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=ketchikan-ak&controller=topics&country_code=¤t_user_id=&filters=&id=2000000001341&klass_name=Region&list_type=hotels&nearby=false&order=asc&path=ketchikan-ak%2Fhotels&place=2000000001341&place_type=City&place_type=region®ion=2000000001341&sort=best_value", function(status){
if (status === 200) {
HotelRates.ajax();
}
});
var HotelRates = {
hotels: "hotel_ids%5B%5D=5000004114433&hotel_ids%5B%5D=5000000245473&hotel_ids%5B%5D=5000000345398&hotel_ids%5B%5D=5000000176362&hotel_ids%5B%5D=5000000123526&hotel_ids%5B%5D=5000000061232&hotel_ids%5B%5D=5000000048125&hotel_ids%5B%5D=5000000053299&hotel_ids%5B%5D=5000000173602&hotel_ids%5B%5D=5000000703488&hotel_ids%5B%5D=5000000180729&hotel_ids%5B%5D=5000000192368&hotel_ids%5B%5D=5000000201849&hotel_ids%5B%5D=5000000221047&hotel_ids%5B%5D=5000000153884&hotel_ids%5B%5D=5000000126594&hotel_ids%5B%5D=5000000249192&hotel_ids%5B%5D=5000000298185&hotel_ids%5B%5D=5000000302844&hotel_ids%5B%5D=5000000371178&hotel_ids%5B%5D=5000000266197&hotel_ids%5B%5D=5000000268710&hotel_ids%5B%5D=5000000326172&hotel_ids%5B%5D=5000000345502&hotel_ids%5B%5D=5000000005836&hotel_ids%5B%5D=5000000009068&hotel_ids%5B%5D=5000000412370&hotel_ids%5B%5D=5000000410571&hotel_ids%5B%5D=5000003718995&hotel_ids%5B%5D=5000003677407",
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=2000000001341" + "&" + 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);
}
};