From 00990cfc88abc194d9eb56c3d7fd2c34beceb962 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sun, 26 Jun 2016 14:26:18 +0200 Subject: marking soon and imminent shows works now diff --git a/www/js/nextshows.js b/www/js/nextshows.js index f0f732b..b831e86 100644 --- a/www/js/nextshows.js +++ b/www/js/nextshows.js @@ -87,15 +87,16 @@ rh.ShowListView.prototype.render = function() { $('div.show', list).remove(); this.showViews = []; - var now = clock.now(); + var nowutc = 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) { + var now = (nowutc.valueOf() + (this.model.shows[i].end.getTimezoneOffset() * 60000)); + if(now > this.model.shows[i].end) { continue; } var showView = new rh.ShowView(this.model.shows[i], this); this.showViews.push(showView); - showView.render(); + showView.render(now); list.append(showView.$el); if(this.showViews.length >= this.maxlen) { break; @@ -111,7 +112,7 @@ rh.ShowView = function(model, listView) { this.$el = $('
'); }; -rh.ShowView.prototype.render = function() { +rh.ShowView.prototype.render = function(now) { var startstr = "Beginn: " + format_time(this.model.start); var start = $('').addClass('show-start').text(startstr); @@ -124,6 +125,33 @@ rh.ShowView.prototype.render = function() { var title = $('').addClass('show-title').text(this.model.title); this.$el.empty().addClass('show').append(start).append(end).append(title); + var until = this.model.start - now; + if(until > 138000) { + return + } + if(until > 123000) { + if(until%2000 >= 1000) { + this.$el.addClass('soon'); + } + return + } + if(until > 30000) { + this.$el.addClass('soon'); + return + } + if(until > 10000) { + if(until%2000 >= 1000) { + this.$el.addClass('imminent'); + } + return + } + if(until > 0) { + if(until%1000 >= 500) { + this.$el.addClass('imminent'); + } + return + } + this.$el.addClass('imminent'); } diff --git a/www/styles/nextshows.css b/www/styles/nextshows.css index 73efce8..67ae14c 100644 --- a/www/styles/nextshows.css +++ b/www/styles/nextshows.css @@ -103,3 +103,10 @@ span.show-title { #shows div:first-child span.show-title { font-size: 1.2em; } + +.soon { + background-color: #f0ad4e !important; +} +.imminent { + background-color: #d9534f !important; +} -- cgit v0.10.2