sort by date

master
Rob 3 years ago
parent 1d1d3e6761
commit 2120ab8de5
  1. 47
      js/Schedule.js

@ -84,26 +84,33 @@ class Schedule {
getEvents()
{
let allEvents = [];
if (this.events.length == 0 ){
//this.schedule.find('event').toArray();
var now = this.now
this.schedule.find('event').each( function(){
var eventStart = new Date($(this).children('date').text());
var tenHours = 36000000;
if ((eventStart - now) >= 0 && (eventStart - now) < tenHours){
allEvents.push({
title: $(this).children('title').text(),
room: $(this).children('room').text(),
date: $(this).children('date').text(),
start: $(this).children('start').text(),
duration: $(this).children('duration').text(),
abstract: $(this).children('abstract').text().slice(0, 256),
persons: $(this).children('persons').text(),
});
}
});
}
//this.schedule.find('event').toArray();
var now = this.now
this.schedule.find('event').each( function(){
var eventStart = new Date($(this).children('date').text());
var tenHours = 36000000;
if ((eventStart - now) >= 0 && (eventStart - now) < tenHours){
allEvents.push({
title: $(this).children('title').text(),
room: $(this).children('room').text(),
date: $(this).children('date').text(),
start: $(this).children('start').text(),
duration: $(this).children('duration').text(),
abstract: $(this).children('abstract').text().slice(0, 256),
persons: $(this).children('persons').text(),
});
}
});
allEvents.sort((a,b) => {
var a_start = new Date(a.date).getTime();
var b_start = new Date(b.date).getTime();
console.log(a_start, b_start, a_start - b_start);
return a_start - b_start;
});
this.events = allEvents;
}

Loading…
Cancel
Save