瀏覽代碼

Merge branch 'february_release' of https://github.com/Musare/Musare into february_release

KrisVos130 9 年之前
父節點
當前提交
35c97b70d2
共有 3 個文件被更改,包括 52 次插入15 次删除
  1. 47 11
      app/client/scripts/events.js
  2. 3 3
      app/client/scripts/onCreated.js
  3. 2 1
      app/client/templates/room.html

+ 47 - 11
app/client/scripts/events.js

@@ -1418,19 +1418,29 @@ Template.room.events({
         $parent.append('<a id="lock"><i class="material-icons">lock_outline</i></a>')
     },
     "click #submit": function () {
-        sendMessageGlobal();
-        Meteor.setTimeout(function () {
-            $(".chat-ul").scrollTop(100000);
-        }, 1000)
+        if(Meteor.userId()){
+            sendMessageGlobal();
+            Meteor.setTimeout(function () {
+                $(".chat-ul").scrollTop(100000);
+            }, 1000)
+        } else {
+            var $toastContent = $('<span>Message not sent. You must log in</span>');
+            Materialize.toast($toastContent, 2000);
+        }
     },
     "keyup #chat-message": function (e) {
         if (e.type === "keyup" && e.which === 13) {
-            e.preventDefault();
-            if (!$('#chat-message').data('dropdownshown')) {
-                sendMessageGlobal();
-                Meteor.setTimeout(function () {
-                    $(".chat-ul").scrollTop(100000);
-                }, 1000)
+            if(Meteor.userId()){
+                e.preventDefault();
+                if (!$('#chat-message').data('dropdownshown')) {
+                    sendMessageGlobal();
+                    Meteor.setTimeout(function () {
+                        $(".chat-ul").scrollTop(100000);
+                    }, 1000)
+                }
+            } else {
+                var $toastContent = $('<span>Message not sent. You must log in</span>');
+                Materialize.toast($toastContent, 2000);
             }
         }
     },
@@ -1597,10 +1607,15 @@ Template.room.events({
             Session.set(camelCase, e.target.checked);
         }*/
     },
+    "click #report-modal-button": function(){
+        $("#report-pre-song-button").removeClass("disabled")
+        Session.set("reportingSong", Session.get("currentSong"));
+        $("#report-which").html(Session.get("currentSong").title + ' <span class="thin">by</span> ' + Session.get("currentSong").artist);
+    },
     "click #report-song-button": function () {
         var room = Session.get("type");
         var reportData = {};
-        reportData.song = Session.get("currentSong").mid;
+        reportData.song = Session.get("reportingSong").mid;
         reportData.type = [];
         reportData.reason = [];
 
@@ -1614,6 +1629,7 @@ Template.room.events({
 
         console.log(reportData);
         Meteor.call("submitReport", room, reportData, function () {
+            $("#report-pre-song-button").removeClass("disabled")
             $("report_modal").closeModal();
         });
     },
@@ -1630,6 +1646,26 @@ Template.room.events({
         Meteor.setTimeout(function(){
             $(".dropdown-button").click();
         }, 10);
+    },
+    "click #report-pre-song-button": function(){
+        $("#report-pre-song-button").addClass("disabled")
+        var previousSong = {}
+        var songs = Songs.find({"genres": Session.get("type")}).fetch();
+        for(var i = 0; i < songs.length; i++){
+            if(songs[i].mid === Session.get("currentSong").mid){
+                if(i === 0){
+                    previousSong.title = songs[i].title;
+                    previousSong.artist = songs[i].artist;
+                } else {
+                    previousSong.title = songs[i-1].title;
+                    previousSong.artist = songs[i-1].artist;
+                    previousSong.mid = songs[i-1].mid;
+                    Session.set("reportingSong", previousSong);
+                }
+            }
+        }
+        console.log(previousSong.title + ' <span class="thin">by</span> ' + previousSong.artist);
+        $("#report-which").html(previousSong.title + ' <span class="thin">by</span> ' + previousSong.artist);
     }
 });
 // Settings Template

+ 3 - 3
app/client/scripts/onCreated.js

@@ -337,7 +337,7 @@ Template.room.onCreated(function () {
             if($("#chat-slide-out").css("right") === "0px"){
                 $("#chat-slideout").sideNav("hide");
             }
-            if($("#users-slide-out").css("right") === "0px"){
+            else if($("#users-slide-out").css("right") === "0px"){
                 $("#users-slideout").sideNav("hide");
             }
             var marginRightWidth = ($(document).width() - $(".container").width()) / 2 + "px";
@@ -350,7 +350,7 @@ Template.room.onCreated(function () {
             if($("#playlist-slide-out").css("right") === "0px"){
                 $("#playlist-slideout").sideNav("hide");
             }
-            if($("#users-slide-out").css("right") === "0px"){
+            else if($("#users-slide-out").css("right") === "0px"){
                 $("#users-slideout").sideNav("hide");
             }
             var marginRightWidth = ($(document).width() - $(".container").width()) / 2 + "px";
@@ -364,7 +364,7 @@ Template.room.onCreated(function () {
             if($("#playlist-slide-out").css("right") === "0px"){
                 $("#playlist-slideout").sideNav("hide");
             }
-            if($("#chat-slide-out").css("right") === "0px"){
+            else if($("#chat-slide-out").css("right") === "0px"){
                 $("#chat-slideout").sideNav("hide");
             }
             var marginRightWidth = ($(document).width() - $(".container").width()) / 2 + "px";

+ 2 - 1
app/client/templates/room.html

@@ -281,7 +281,7 @@
     <div id="report_modal" class="modal">
         <div class="modal-content container">
             <h4>Reporting:</h4>
-            <h5>{{currentSong.title}} <span class="thin">by</span> {{currentSong.artist}}</h5>
+            <h5 id="report-which">{{currentSong.title}} <span class="thin">by</span> {{currentSong.artist}}</h5>
             <div class="report-layer-1">
                 <div>
                     <input type="checkbox" id="report-song">
@@ -478,6 +478,7 @@
                 </div>
             </div>
             <a id="report-song-button" class="waves-effect waves-light btn">Report Song</a>
+            <a id="report-pre-song-button" class="waves-effect waves-light btn">Report Previous Song</a>
         </div>
         <div class="divider"></div>
         <div class="modal-footer">