summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--www/js/calendar.js4
-rw-r--r--www/js/clock.js4
-rw-r--r--www/js/nextshows.js31
3 files changed, 28 insertions, 11 deletions
diff --git a/www/js/calendar.js b/www/js/calendar.js
index 815c5d9..740a4dd 100644
--- a/www/js/calendar.js
+++ b/www/js/calendar.js
@@ -24,7 +24,7 @@
var current_week_offset = 0;
function getLastMonday() {
- var d = new Date(clock.getRDTimeMS());
+ var d = clock.now()
d.setUTCHours(12, 0, 0, 0);
var dow = d.getUTCDay()
if(dow == 0) {
@@ -39,7 +39,7 @@ function addDeltaDays(d, days) {
}
function isToday(d) {
- var today = new Date(clock.getRDTimeMS());
+ var today = clock.now()
today.setUTCHours(12, 0, 0, 0);
return ((d - today) == 0)
}
diff --git a/www/js/clock.js b/www/js/clock.js
index 3fa5c24..722a979 100644
--- a/www/js/clock.js
+++ b/www/js/clock.js
@@ -29,6 +29,10 @@ function Clock() {
this.clock_rtt = 0;
this.state = 'NEW';
+ this.now = function() {
+ return new Date(this.getRDTimeMS());
+ }
+
this.getRDTimeMS = function() {
return (+new Date()) + (this.last_message.tz_offset * 1000) + this.clock_offset;
}
diff --git a/www/js/nextshows.js b/www/js/nextshows.js
index 0ab6c83..6d85f55 100644
--- a/www/js/nextshows.js
+++ b/www/js/nextshows.js
@@ -41,8 +41,14 @@ rh.ShowList.prototype.fetch = function() {
$.getJSON( "/rh-bin/schedules.json?DAYS=3&START=" + ydstr, function(data) {
if(data.status == "OK") {
self.shows = [];
- $(data.shows).each(function(index, show) {
- self.shows.push(new rh.Show(show));
+ $(data.shows).each(function(index, showdata) {
+ var show = new rh.Show(showdata);
+ if(self.shows.length > 0) {
+ if(self.shows[self.shows.length-1].end > show.start) {
+ self.shows[self.shows.length-1].end = show.start;
+ }
+ }
+ self.shows.push(show);
});
self.$this.trigger('update');
}
@@ -54,6 +60,7 @@ rh.Show = function(show) {
this.title = show.title;
this.start = new Date(show.start);
this.len = show.len;
+ this.end = new Date(this.start.valueOf() + show.len);
};
@@ -80,13 +87,17 @@ rh.ShowListView.prototype.render = function() {
$('div.show', list).remove();
this.showViews = [];
- var self = this;
- $(this.model.shows).each(function(index, show) {
- var showView = new rh.ShowView(show, self);
- self.showViews.push(showView);
+ var now = clock.now();
+ for (var i = 0; i < this.model.shows.length; i++) {
+ if((now.valueOf() + (this.model.shows[i].end.getTimezoneOffset() * 60000)) > this.model.shows[i].end) {
+ continue;
+ }
+
+ var showView = new rh.ShowView(this.model.shows[i], this);
+ this.showViews.push(showView);
showView.render();
list.append(showView.$el);
- });
+ }
};
@@ -103,8 +114,7 @@ rh.ShowView.prototype.render = function() {
var endstr = "Live";
if(this.model.len > 0) {
- var end = new Date(this.model.start.valueOf() + this.model.len);
- endstr = "Ende: " + format_time(end);
+ endstr = "Ende: " + format_time(this.model.end);
}
var end = $('<span>').addClass('show-end').text(endstr);
@@ -122,4 +132,7 @@ function nextshows_init() {
showListView = new rh.ShowListView(shows, 10);
setInterval("shows.fetch()", 5000);
+ clock.addCallback(function() {
+ showListView.render();
+ });
}