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

Buggy version of move/copy

Kirs and muffin made me play CS:GO :/ so yeh :cactus:
Johand 9 жил өмнө
parent
commit
877eef3d7c

+ 19 - 0
app/client/client.js

@@ -1148,6 +1148,25 @@ Template.stations.events({
         var genre = $(e.target).data("genre") || $(e.target).parent().data("genre");
         Meteor.call("removeSongFromPlaylist", genre, this.mid);
     },
+    "click #moveSong": function(e){
+      var genre = $(e.target).data("genre") || $(e.target).parent().data("genre");
+      if (genre !== Session.get(genre)) {
+        Meteor.call("addSongToPlaylist", genre, {type: Session.get("song").type, mid: Session.get("song").mid, id: Session.get("song").id, title: Session.get("song").title, artist: Session.get("song").artist, duration: Session.get("song").duration, skipDuration: Session.get("song").skipDuration, img: Session.get("song").img, likes: Session.get("song").likes, dislikes: Session.get("song").dislikes});
+        Meteor.call("removeSongFromPlaylist", Session.get("genre"), Session.get("song").mid);
+      }else {
+        console.log("Something Went Wrong?!");
+        return false;
+      }
+
+    },
+    "click #copySong": function(e){
+      var genre = $(e.target).data("genre") || $(e.target).parent().data("genre");
+      Meteor.call("addSongToPlaylist", genre, {type: Session.get("song").type, mid: Session.get("song").mid, id: Session.get("song").id, title: Session.get("song").title, artist: Session.get("song").artist, duration: Session.get("song").duration, skipDuration: Session.get("song").skipDuration, img: Session.get("song").img, likes: Session.get("song").likes, dislikes: Session.get("song").dislikes});
+    },
+    "click .copyMove-button": function(e){
+        Session.set("song", this);
+        Session.set("genre", $(e.target).data("genre"));
+    },
     "click #play": function() {
         $("#play").attr("disabled", true);
         $("#stop").attr("disabled", false);

+ 3 - 3
app/client/templates/stations.html

@@ -37,7 +37,7 @@
                               <td>{{id}}</td>
                               <td>{{likes}}</td>
                               <td>{{dislikes}}</td>
-                              <td class="column-small"><button class="btn btn-primary preview-button" id="copyMoveButton" data-toggle="modal" data-target="#copyMoveModal">Copy/Move</button></td>
+                              <td class="column-small"><button class="btn btn-primary copyMove-button" data-genre="{{../type}}" id="copyMoveButton" data-toggle="modal" data-target="#copyMoveModal">Copy/Move</button></td>
                               <td class="column-small"><button class="btn btn-primary preview-button" id="previewImageButton" data-toggle="modal" data-target="#previewImageModal">Preview Image</button></td>
                               <td class="column-small"><button class="btn btn-primary preview-button" data-toggle="modal" data-target="#previewModal">Preview</button></td>
                               <td class="column-small"><button class="btn btn-primary edit-playlist-button" data-genre="{{../type}}" data-toggle="modal" data-target="#editModal">Edit</button></td>
@@ -96,12 +96,12 @@
                     <div class="modal-body">
                         <h4><i class="fa fa-arrows"></i> Move This Song To:</h4>
                         {{#each playlists}}
-                        <button id="move" type="button" class="btn btn-warning"> <span>{{display}}</span> playlist</button>
+                        <button id="moveSong" data-genre="{{type}}" type="button" class="btn btn-warning"> <span>{{display}}</span> playlist</button>
                         {{/each}}
                       <hr />
                         <h4><i class="fa fa-files-o"></i> Copy This Song To:</h4>
                         {{#each playlists}}
-                        <button id="copy" type="button" class="btn btn-warning"> <span>{{display}}</span> playlist</button>
+                        <button id="copySong" data-genre="{{type}}" type="button" class="btn btn-warning"> <span>{{display}}</span> playlist</button>
                         {{/each}}
                     </div>
                     <div class="modal-footer">