From 45f6a926bca6d8581cf5ceb0e6d7a66dc11afe4c Mon Sep 17 00:00:00 2001 From: Rob Date: Sat, 21 Sep 2019 13:56:06 +0200 Subject: [PATCH] bugfix: time now --- index.php | 2 +- js/Schedule.js | 27 ++++++++++++++++----------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/index.php b/index.php index f38d90c..90c8699 100644 --- a/index.php +++ b/index.php @@ -128,6 +128,7 @@ if (faketime != null) { s.setTimeTo(new Date(faketime)); } + s.getEvents(); // output part of the schedule $('.conf_version').html(s.getScheduleVersion()); @@ -141,7 +142,6 @@ $('.talks_plan').append(event_view(event)); }); var eventObj = s.getEventsAllTracks(10); - console.log(eventObj); eventObj.events.forEach(event => { $('.talks_overview').append(event_view(event, true)); }); diff --git a/js/Schedule.js b/js/Schedule.js index 1d1c3dd..66f9b9d 100644 --- a/js/Schedule.js +++ b/js/Schedule.js @@ -44,7 +44,6 @@ class Schedule { this.conf.title = this.schedule.children("conference").children("title").text(); this.conf.start = this.schedule.children("conference").children("start").text(); this.conf.end = this.schedule.children("conference").children("end").text(); - this.events = this.getEvents(); } /** @@ -87,19 +86,25 @@ class Schedule { let allEvents = []; if (this.events.length == 0 ){ //this.schedule.find('event').toArray(); + var now = this.now this.schedule.find('event').each( function(){ - 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(), - }); + + var eventStart = new Date($(this).children('date').text()); + if ((eventStart - now) >= 0){ + 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(), + }); + } }); } - return allEvents; + this.events = allEvents; + console.log('DDDD', allEvents.length); } getEventsAllTracks(count)