From 9a05a988571e586eab001bea36d7cd6363381cbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juuso=20K=C3=A4enm=C3=A4ki?= Date: Thu, 19 Jan 2017 20:26:21 +0200 Subject: [PATCH] Created css and added functionality to mark busses leaving soon. --- infoscreen/static/css/hsl.css | 41 +++++++++++++++++++ infoscreen/static/html/hsl.html | 7 ++-- .../static/js/infoscreen_controllers.js | 20 ++++----- 3 files changed, 54 insertions(+), 14 deletions(-) create mode 100644 infoscreen/static/css/hsl.css diff --git a/infoscreen/static/css/hsl.css b/infoscreen/static/css/hsl.css new file mode 100644 index 0000000..5595cdd --- /dev/null +++ b/infoscreen/static/css/hsl.css @@ -0,0 +1,41 @@ +table { + font-size: 3vw; + font-family: monospace; +} +.red { + color: red; + -webkit-animation-name: blinker; + -webkit-animation-duration: 2s; + -webkit-animation-timing-function: linear; + -webkit-animation-iteration-count: infinite; + + -moz-animation-name: blinker; + -moz-animation-duration: 2s; + -moz-animation-timing-function: linear; + -moz-animation-iteration-count: infinite; + + animation-name: blinker; + animation-duration: 2s; + animation-timing-function: linear; + animation-iteration-count: infinite; +} +.black { + color: black; +} +@-moz-keyframes blinker { + 0% { opacity: 1.0; } + 50% { opacity: 0.1; } + 100% { opacity: 1.0; } +} + +@-webkit-keyframes blinker { + 0% { opacity: 1.0; } + 50% { opacity: 0.1; } + 100% { opacity: 1.0; } +} + +@keyframes blinker { + 0% { opacity: 1.0; } + 50% { opacity: 0.1; } + 100% { opacity: 1.0; } +} diff --git a/infoscreen/static/html/hsl.html b/infoscreen/static/html/hsl.html index 69aa920..23db165 100644 --- a/infoscreen/static/html/hsl.html +++ b/infoscreen/static/html/hsl.html @@ -1,5 +1,6 @@ +
- +
- - +
@@ -17,8 +18,8 @@
+
{{x.time}} diff --git a/infoscreen/static/js/infoscreen_controllers.js b/infoscreen/static/js/infoscreen_controllers.js index 1f7fc6d..e3ff3d4 100644 --- a/infoscreen/static/js/infoscreen_controllers.js +++ b/infoscreen/static/js/infoscreen_controllers.js @@ -95,10 +95,6 @@ app.controller('timetableCtrl', var line = stop['departures'][lineIndex]; var time=line['time']; date=line['date']; - if(time<1000) - var unit = 1; - else - var unit = 2; var hours= Math.floor(line['time']/100); if(hours>=24){ hours-=24; @@ -113,7 +109,8 @@ app.controller('timetableCtrl', "bus":code, "date":date, "time":pad(hours,2)+":"+pad(minutes,2), - "laststop":dict[line['code']].split(",")[0].split(" l.")[0] + "laststop":dict[line['code']].split(",")[0].split(" l.")[0], + "hurry":false }; var trigger=true; for(var objectIndex= $scope.arr.length-1;objectIndex>=0;objectIndex--) @@ -141,21 +138,22 @@ app.controller('timetableCtrl', delOld(); } function delOld(){ + var toSoon=5; + var hurry=10; f= new Date(); for(var a=$scope.arr.length-1; a>=0; a--){ - if( $scope.arr[a]['time']<1000) - var unit = 1; - else - var unit = 2; var time=$scope.arr[a]['time'].split(":"); date=$scope.arr[a]['date'].toString(); d= new Date(f); d.setFullYear(date.substring(0,4),date.substring(4,6)-1,date.substring(6,8)); d.setHours(time[0]); d.setMinutes(time[1]); - if(d < f){ + var diff=(d.getTime()-f.getTime()); + if(diff < toSoon*60000) $scope.arr.splice(a,1); - } + else if(diff < hurry*60000) + $scope.arr[a]['hurry']=true; + } } load();