From 9e5cafbde816d6c3535fa7d3cc97a3f9c0fe265a Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Tue, 6 Mar 2012 21:58:47 +0100 Subject: Use sequential ids to store playlist tracks in the correct order. --- static/playlist.js | 4 ++++ static/sound.js | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'static') diff --git a/static/playlist.js b/static/playlist.js index 99ec6c5..6f57075 100644 --- a/static/playlist.js +++ b/static/playlist.js @@ -25,6 +25,7 @@ $(function(){ } }); PlaylistView = Backbone.View.extend({ + current_id: 1, el: $('#playlist'), initialize: function() { items.bind('add', this.addOne, this); @@ -34,6 +35,9 @@ $(function(){ items.fetch(); }, add: function(item) { + item.track_id = item.id; + item.id = this.current_id; + this.current_id++; var model = items.create(item); }, addOne: function(item) { diff --git a/static/sound.js b/static/sound.js index 252741c..874c213 100644 --- a/static/sound.js +++ b/static/sound.js @@ -1,6 +1,6 @@ function playsound(model) { var item = model.toJSON(); - var id = item.id; + var id = item.track_id; var cid = model.cid; var el = $('#cid-' + cid); el.addClass('loading'); @@ -10,7 +10,7 @@ function playsound(model) { } sound = soundManager.createSound({ id: 'audio', - url: '/track/' + item.id, + url: '/track/' + id, whileloading: function() { $('#status').text('Loading... ' + this.bytesLoaded); el.addClass('loading'); -- cgit v1.2.3