Skip to content
Snippets Groups Projects
Commit 62db8d8f authored by ale's avatar ale
Browse files

fix some silly typos

parent d77b8fbf
No related branches found
No related tags found
No related merge requests found
......@@ -15,7 +15,7 @@ djr.Backend = function(userid) {
};
// Read a playlist, calls callback(Playlist).
djr.Backend.prototype.getPlaylist(uuid, callback, ctx) {
djr.Backend.prototype.getPlaylist = function(uuid, callback, ctx) {
$.ajax({url: '/json/playlist/get/' + uuid,
dataType: 'json',
context: ctx,
......@@ -26,7 +26,7 @@ djr.Backend.prototype.getPlaylist(uuid, callback, ctx) {
};
// Save a playlist (song array).
djr.Backend.prototype.savePlaylist(uuid, songs) {
djr.Backend.prototype.savePlaylist = function(uuid, songs) {
$.ajax({url: '/json/playlist/save',
data: {uuid: uuid,
h: songs.join(',')},
......@@ -35,7 +35,7 @@ djr.Backend.prototype.savePlaylist(uuid, songs) {
};
// Return the HTML fragment for an array of songs.
djr.Backend.prototype.getHtmlForSongs(songs, callback, ctx) {
djr.Backend.prototype.getHtmlForSongs = function(songs, callback, ctx) {
$.ajax({url: '/fragment/songs',
data: {'h': songs.join(',')},
dataType: 'html',
......@@ -57,11 +57,11 @@ djr.PlaylistChunk = function(songs) {
this.songs = songs || [];
};
djr.PlaylistChunk.prototype.hasSong(sha1) {
djr.PlaylistChunk.prototype.hasSong = function(sha1) {
return (this.songs.indexOf(sha1) >= 0);
};
djr.PlaylistChunk.prototype.removeSong(sha1) {
djr.PlaylistChunk.prototype.removeSong = function(sha1) {
this.songs = $.grep(this.songs, function(a) { return a != sha1; });
};
......@@ -69,8 +69,8 @@ djr.PlaylistChunk.prototype.removeSong(sha1) {
// Playlist.
djr.Playlist = function() {
this.uuid = null;
djr.Playlist = function(uuid) {
this.uuid = uuid || djr.generateRandomId();
this.chunks = [];
this.song_map = {};
this.chunk_map = {};
......@@ -90,6 +90,7 @@ djr.Playlist.prototype.allSongs = function() {
// Add a new chunk (only adds unique songs).
// Returns the chunk ID.
djr.Playlist.prototype.addChunk = function(playlist_chunk) {
djr.debug('adding chunk to playlist ' + this.uuid);
chunk_id = this.next_chunk_id++;
var songs = [];
$.each(playlist_chunk.songs, function(idx, song) {
......@@ -106,6 +107,7 @@ djr.Playlist.prototype.addChunk = function(playlist_chunk) {
// Remove a chunk (by ID).
djr.Playlist.prototype.removeChunk = function(chunk_id) {
djr.debug('removing chunk ' + chunk_id);
$.each(this.chunks[chunk_id].songs, function(idx, song){
delete this.song_map[song];
});
......@@ -181,8 +183,13 @@ djr.Player.prototype.search = function(query) {
$.each(results, function(idx, item) {
songs.push(item.sha1);
});
if (songs.length == 0) {
djr.debug('No results found.');
return;
}
var chunk_id = this.playlist.addChunk(new PlaylistChunk(songs));
djr.debug('search: new chunk ' + chunk_id);
var player = this;
this.backend.getHtmlForSongs(songs, function(songs_html) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment