Преглед изворни кода

Fixed time display and seekerbar.

KrisVos130 пре 9 година
родитељ
комит
cfb9caf7ef
3 измењених фајлова са 10 додато и 4 уклоњено
  1. 3 0
      app/app.css
  2. 6 3
      app/app.js
  3. 1 1
      app/templates/room.html

+ 3 - 0
app/app.css

@@ -1110,4 +1110,7 @@ footer .fa {
 #room-icons {
     margin-top: 11px;
     float: left;
+}
+#time-display {
+    color: white;
 }

+ 6 - 3
app/app.js

@@ -869,7 +869,7 @@ if (Meteor.isClient) {
             if (currentSong !== undefined) {
                 var room = Rooms.findOne({type: type});
                 if (room !== undefined) {
-                    return Date.now() - currentSong.started + room.timePaused;
+                    return Date.now() - currentSong.started - room.timePaused;
                 }
             }
             return 0;
@@ -890,6 +890,7 @@ if (Meteor.isClient) {
         }
 
         function startSong() {
+            $("#time-elapsed").text("0:00");
             if (currentSong !== undefined) {
                 if (_sound !== undefined) _sound.stop();
                 if (yt_player !== undefined && yt_player.stopVideo !== undefined) yt_player.stopVideo();
@@ -993,9 +994,11 @@ if (Meteor.isClient) {
 
                     if (currentSong !== undefined) {
                         if (room !== undefined) {
-                            var duration = (Date.now() - currentSong.started + room.timePaused) / 1000;
+                            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));
+                            if (Session.get("state") === "playing") {
+                                $("#time-elapsed").text(d.minutes() + ":" + ("0" + d.seconds()).slice(-2));
+                            }
                         }
                     }
                 }, 1000);

+ 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}}} <small>(<span id="time-elapsed"></span> / <span>{{songDuration}}</span>)</small></h2>
+                          <h2 class="room-title">{{{title}}} <small id="time-display">(<span id="time-elapsed"></span> / <span>{{songDuration}}</span>)</small></h2>
                           <h2 class="room-artist">{{{artist}}}</h2>
                         </div>
                     </div>