Răsfoiți Sursa

Fixed issue with volume slider, songs, added border around private rooms.

KrisVos130 9 ani în urmă
părinte
comite
69ebfc9071

+ 5 - 4
app/client/scripts/helpers.js

@@ -137,9 +137,9 @@ Template.playlist.helpers({
     },
     nextSong: function(){
         var song;
-        var data = Playlists.find({"type": Session.get("type")}).fetch()[0].songs
+        var data = Playlists.find({"type": Session.get("type")}).fetch()[0].songs;
         for(var i = 0; i < data.length; i++){
-            if(data[i] === Session.get("currentSong").mid){
+            if(Session.get("currentSong") !== undefined && data[i] === Session.get("currentSong").mid){
                 if(i === data.length - 1){
                     song = Songs.findOne({"mid": data[0]});
                     Session.set("nextSong", [song])
@@ -148,7 +148,7 @@ Template.playlist.helpers({
                     Session.set("nextSong", [song]);
                 }
             }
-        };
+        }
         return Session.get("nextSong");
     }
 });
@@ -404,7 +404,8 @@ Template.room.helpers({
         return Session.get("state") === "paused";
     },
     private: function () {
-        return Rooms.findOne({type: Session.get("type")}).private === true;
+        return 1;
+        //return Rooms.findOne({type: Session.get("type")}).private === true;
     },
     currentSong: function(){
         return Session.get("currentSong");

+ 1 - 0
app/client/scripts/onCreated.js

@@ -209,6 +209,7 @@ Template.room.onCreated(function () {
             if (YTPlayer !== undefined && YTPlayer.stopVideo !== undefined) YTPlayer.stopVideo();
 
             var volume = localStorage.getItem("volume") || 20;
+            $("#volume_slider").val(volume);
 
             $("#player").show();
             function loadVideo() {

+ 4 - 4
app/client/scripts/onRendered.js

@@ -12,7 +12,7 @@ Template.queues.onRendered(function() {
         }
     });
     $(document).ready(function() {
-        var volume = localStorage.getItem("volume") || 20;
+        var volume = (localStorage.getItem("volume") !== undefined) ? localStorage.getItem("volume") : 20;
         $("#volume_slider").val(volume).on("input", function() {
             volume = Number($("#volume_slider").val());
             localStorage.setItem("volume", volume);
@@ -37,7 +37,7 @@ Template.manageStation.onRendered(function() {
         }
     });
     $(document).ready(function() {
-        var volume = localStorage.getItem("volume") || 20;
+        var volume = (localStorage.getItem("volume") !== undefined) ? localStorage.getItem("volume") : 20;
         $("#volume_slider").val(volume).on("input", function() {
             volume = Number($("#volume_slider").val());
             localStorage.setItem("volume", volume);
@@ -62,7 +62,7 @@ Template.manageSongs.onRendered(function() {
         }
     });
     $(document).ready(function() {
-        var volume = localStorage.getItem("volume") || 20;
+        var volume = (localStorage.getItem("volume") !== undefined) ? localStorage.getItem("volume") : 20;
         $("#volume_slider").val(volume).on("input", function() {
             volume = Number($("#volume_slider").val());
             localStorage.setItem("volume", volume);
@@ -90,7 +90,7 @@ Template.room.onRendered(function() {
         Session.set("time", new Date().getTime());
     }, 10000));
     window.setTimeout(function(){
-        var volume = Number(localStorage.getItem("volume")) || 20;
+        var volume = (localStorage.getItem("volume") !== undefined) ? localStorage.getItem("volume") : 20;
         $("#volume_slider").val(volume);
     }, 1000)
 });

+ 1 - 0
app/client/scripts/routes.js

@@ -194,6 +194,7 @@ Router.route("/:type", {
         var room = Rooms.findOne({type: this.params.type});
         if (room !== undefined) {
             if ((room.private === true && user !== undefined && user.profile !== undefined && (user.profile.rank === "admin" || user.profile.rank === "moderator")) || room.private === false) {
+                Session.set("type", this.params.type);
                 this.render("room");
             } else {
                 this.redirect("/");

+ 1 - 1
app/client/templates/home.html

@@ -6,7 +6,7 @@
                 {{#each rooms}}
                     {{#if private}}
                         {{#if isModerator}}
-                            <div class="col s6 m4 l2">
+                            <div class="col s6 m4 l2 red">
                                 <div class="card hoverable">
                                     <div class="card-image waves-effect waves-block waves-light">
                                         <a href=/{{type}}>

+ 7 - 0
app/server/server.js

@@ -244,6 +244,7 @@ function Station(type) {
     Rooms.update({type: type}, {$set: {timePaused: 0}});
 
     var timer;
+    var timerInitialised = false;
 
     this.songTimer = function () {
         if (state !== "paused") {
@@ -252,6 +253,7 @@ function Station(type) {
             if (timer !== undefined) {
                 timer.pause();
             }
+            timerInitialised = true;
             timer = new Timer(function () {
                 self.skipSong();
             }, Songs.findOne({mid: songs[currentSong]}).duration * 1000);
@@ -269,6 +271,11 @@ function Station(type) {
     };
     this.resumeRoom = function () {
         if (state !== "playing") {
+            if (!timerInitialised) {
+                timer = new Timer(function () {
+                    self.skipSong();
+                }, Songs.findOne({mid: songs[currentSong]}).duration * 1000);
+            }
             timer.resume();
             Rooms.update({type: type}, {$set: {state: "playing", timePaused: timer.timeWhenPaused()}});
             state = "playing";