summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2012-03-13 23:40:16 +0100
committerJon Bergli Heier <snakebite@jvnv.net>2012-03-13 23:40:16 +0100
commite4792c42b4180d3779bf7d75c7e5ee6f41001d85 (patch)
tree5dbff9a3630a93ed5c84e5aeb2ca7ad7b6da78f7
parentb3f50be6ff9c72ed877f42e896c532b994cc49d1 (diff)
Make playlist sortable.
-rw-r--r--static/init.js13
1 files changed, 13 insertions, 0 deletions
diff --git a/static/init.js b/static/init.js
index 6102e29..6a37be5 100644
--- a/static/init.js
+++ b/static/init.js
@@ -90,4 +90,17 @@ $(document).ready(function() {
preload_images();
load_directory(0);
$('#progress').slider();
+ $('#playlist tbody').sortable({
+ items: 'tr:not(.playing)',
+ cancel: '.playing',
+ update: function() {
+ $('#playlist tbody tr').each(function(i, tr) {
+ var cid = $(tr).attr('id').match(/^cid-(c\d+)$/)[1];
+ var model = items.getByCid(cid);
+ model.attributes.order_id = i+1;
+ model.save();
+ });
+ items.sort({silent: true});
+ }
+ });
});