Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
This commit is contained in:
parent
93e3a48004
commit
b38dea0597
25901 changed files with 9982925 additions and 369 deletions
65
gaia/apps/music/views/playlist-detail/view.js
Executable file
65
gaia/apps/music/views/playlist-detail/view.js
Executable file
|
|
@ -0,0 +1,65 @@
|
|||
/* global View, IntlHelper */
|
||||
'use strict';
|
||||
|
||||
var PlaylistDetailView = View.extend(function PlaylistDetailView() {
|
||||
View.call(this); // super();
|
||||
|
||||
this.list = document.getElementById('list');
|
||||
|
||||
this.list.addEventListener('click', (evt) => {
|
||||
var link = evt.target.closest('a[data-file-path]');
|
||||
if (link) {
|
||||
this.queuePlaylist(link.dataset.filePath);
|
||||
}
|
||||
});
|
||||
|
||||
this.client.on('databaseChange', () => this.update());
|
||||
|
||||
this.update();
|
||||
});
|
||||
|
||||
PlaylistDetailView.prototype.update = function() {
|
||||
return this.getPlaylist().then((songs) => {
|
||||
this.songs = songs;
|
||||
return this.render();
|
||||
});
|
||||
};
|
||||
|
||||
PlaylistDetailView.prototype.destroy = function() {
|
||||
this.client.destroy();
|
||||
View.prototype.destroy.call(this); // super(); // Always call *last*
|
||||
};
|
||||
|
||||
PlaylistDetailView.prototype.render = function() {
|
||||
return this.list.setModel(this.songs)
|
||||
.then(this.onRenderDone);
|
||||
};
|
||||
|
||||
PlaylistDetailView.prototype.getPlaylist = function() {
|
||||
var unpaddedIndex = IntlHelper.get('unpaddedIndex');
|
||||
|
||||
return this.fetch('/api/playlists/info/' + this.params.id)
|
||||
.then(response => response.json())
|
||||
.then(songs => {
|
||||
return songs.map((song, index) => {
|
||||
return {
|
||||
index: unpaddedIndex.format(index + 1),
|
||||
name: song.name,
|
||||
title: song.metadata.title,
|
||||
artist: song.metadata.artist
|
||||
};
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
PlaylistDetailView.prototype.queuePlaylist = function(filePath) {
|
||||
this.fetch('/api/queue/playlist/' + this.params.id + '/song/' + filePath);
|
||||
};
|
||||
|
||||
IntlHelper.define('unpaddedIndex', 'number', {
|
||||
style: 'decimal',
|
||||
useGrouping: false,
|
||||
minimumIntegerDigits: 1
|
||||
});
|
||||
|
||||
window.view = new PlaylistDetailView();
|
||||
Loading…
Reference in a new issue