浏览代码

added 'report previous song' function

Akira Laine 9 年之前
父节点
当前提交
2282f3b6a9
共有 3 个文件被更改,包括 32 次插入5 次删除
  1. 27 1
      app/client/scripts/events.js
  2. 3 3
      app/client/scripts/onCreated.js
  3. 2 1
      app/client/templates/room.html

+ 27 - 1
app/client/scripts/events.js

@@ -1597,10 +1597,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 +1619,7 @@ Template.room.events({
 
         console.log(reportData);
         Meteor.call("submitReport", room, reportData, function () {
+            $("#report-pre-song-button").removeClass("disabled")
             $("report_modal").closeModal();
         });
     },
@@ -1630,6 +1636,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">