2
0
Эх сурвалжийг харах

Added duration display to station pages.

KrisVos130 9 жил өмнө
parent
commit
c5878e51b4
2 өөрчлөгдсөн 16 нэмэгдсэн , 1 устгасан
  1. 15 0
      app/app.js
  2. 1 1
      app/templates/room.html

+ 15 - 0
app/app.js

@@ -210,6 +210,7 @@ if (Meteor.isClient) {
             Meteor.clearInterval(resizeSeekerbarInterval);
             resizeSeekerbarInterval = undefined;
         }
+        Session.set("type", undefined);
     });
 
     Template.room.events({
@@ -524,6 +525,11 @@ if (Meteor.isClient) {
     });
 
     Template.room.helpers({
+        songDuration: function() {
+            var duration = Session.get("duration");
+            var d = moment.duration(duration, 'seconds');
+            return d.minutes() + ":" + ("0" + d.seconds()).slice(-2);
+        },
         type: function() {
             var parts = location.href.split('/');
             var id = parts.pop().toLowerCase();
@@ -949,6 +955,7 @@ if (Meteor.isClient) {
             var parts = location.href.split('/');
             var id = parts.pop();
             var type = id.toLowerCase();
+            Session.set("type", type);
             if (Rooms.find({type: type}).count() !== 1) {
                 window.location = "/";
             } else {
@@ -983,6 +990,14 @@ if (Meteor.isClient) {
 
                         startSong();
                     }
+
+                    if (currentSong !== undefined) {
+                        if (room !== undefined) {
+                            var duration = (Date.now() - currentSong.started + room.timePaused) / 1000;
+                            var d = moment.duration(duration, 'seconds');
+                            $("#time-elapsed").text(d.minutes() + ":" + ("0" + d.seconds()).slice(-2));
+                        }
+                    }
                 }, 1000);
                 resizeSeekerbarInterval = Meteor.setInterval(function () {
                     resizeSeekerbar();

+ 1 - 1
app/templates/room.html

@@ -36,7 +36,7 @@
                         </div>
                         <div id="song-info" class="col-md-4" style="margin-top:15px">
                           <img class="song-img" onError="this.src='http://static.boredpanda.com/blog/wp-content/uploads/2014/04/amazing-fox-photos-182.jpg'" id="song-img"/>
-                          <h2 class="room-title">{{{title}}}</h2>
+                          <h2 class="room-title">{{{title}}} (<span id="time-elapsed"></span> / <span>{{songDuration}}</span>)</h2>
                           <h2 class="room-artist">{{{artist}}}</h2>
                         </div>
                     </div>