this.refresh_content = function() {
if (this.search_result.TotalCount == 0) {
$('#search_res_items').html('');
return false;
}
var items_content = [];
usort(this.search_result.Air,function(a,b){
//console.log(a);
if (this.filter.data.sort == 'price') {
if (a.Prices.Price.convert_value > b.Prices.Price.convert_value) {
return 1;
}
} else {
var dep_date = moment(a.Flight[0].Segment[0].Departure.attributes.Date+' '+a.Flight[0].Segment[0].Departure.attributes.Time);
var arr_date = moment(a.Flight[0].Segment[0].Arrival.attributes.Date+' '+a.Flight[0].Segment[0].Arrival.attributes.Time);
if (dep_date.diff(arr_date) < 0) {
return 1;
}
}
return 0;
});
for (var i=0;i<this.search_result.Air.length;i++) {
if (this.search_result.Air.hasOwnProperty(i) && this.check_item_by_filter(this.search_result.Air[i])) {
items_content.push(this.create_blocks.list_item_item(this.search_result.Air[i]));
}
}
//$('#search_res_items').html(items_content.join(''));
document.getElementById("search_res_items").innerHTML = items_content.join('');
};
for (var i=0;i<this.search_result.Air.length;i++) { if (!this.search_result.Air.hasOwnProperty(i)) continue;
this.update_all = function() {
if (flights.search_result.TotalCount == 0)
return false;
for (var i=0;i<flights.search_result.Air.length;i++) {
if (flights.search_result.Air.hasOwnProperty(i)) {
var item = flights.search_result.Air[i];
this.transplants.process.call(flights.filter.transplants,item);
flights.hot.process.call(flights.hot,item,i);
for (var j=0;j<item.Flight.length;j++) {
if (item.Flight.hasOwnProperty(j)) {
this.airlines.process(item.Flight[j]);
}
}
}
}
this.airlines.insert_html.call(flights.filter.airlines);
this.transplants.insert_html.call(flights.filter.transplants);
};