diff options
author | Jon Bergli Heier <snakebite@jvnv.net> | 2012-03-09 23:15:16 +0100 |
---|---|---|
committer | Jon Bergli Heier <snakebite@jvnv.net> | 2012-03-09 23:15:16 +0100 |
commit | d7a57c76f6f327f4a5520a437b2d17a02bc58a99 (patch) | |
tree | 88572532958c41c3203cec977ce63d85a5b5b68e /static | |
parent | 675a2b12a2bfb4e7d1948f68f034d2fb3a7f9424 (diff) |
Changed ordering to use a comparator function.
Diffstat (limited to 'static')
-rw-r--r-- | static/playlist.js | 10 | ||||
-rw-r--r-- | static/sound.js | 4 |
2 files changed, 7 insertions, 7 deletions
diff --git a/static/playlist.js b/static/playlist.js index b94de61..373098c 100644 --- a/static/playlist.js +++ b/static/playlist.js @@ -2,7 +2,10 @@ $(function(){ PlaylistItem = Backbone.Model.extend({}); Playlist = Backbone.Collection.extend({ model: PlaylistItem, - localStorage: new Store("playlist") + localStorage: new Store("playlist"), + comparator: function(item) { + return item.attributes.order_id; + } }); window.items = new Playlist; PlaylistItemView = Backbone.View.extend({ @@ -25,7 +28,6 @@ $(function(){ } }); PlaylistView = Backbone.View.extend({ - current_id: 1, el: $('#playlist'), initialize: function() { items.bind('add', this.addOne, this); @@ -35,9 +37,7 @@ $(function(){ items.fetch(); }, add: function(item) { - item.track_id = item.id; - item.id = this.current_id; - this.current_id++; + item.order_id = items.length+1; var model = items.create(item); if(items.indexOf(model) < 2) { sound_hint(model); diff --git a/static/sound.js b/static/sound.js index c4f2dbf..07366ff 100644 --- a/static/sound.js +++ b/static/sound.js @@ -1,7 +1,7 @@ function playsound(model) { playlist.hintnext(); var item = model.toJSON(); - var id = item.track_id; + var id = item.id; var cid = model.cid; var el = $('#cid-' + cid); el.addClass('loading'); @@ -55,7 +55,7 @@ function playsound(model) { function sound_hint(model) { $('#cid-' + model.cid).addClass('loading'); - $.get('/json/hint/' + model.attributes.track_id, function(data) { + $.get('/json/hint/' + model.id, function(data) { $('#cid-' + model.cid).removeClass('nocache').removeClass('loading'); }); } |