summaryrefslogtreecommitdiff
path: root/static
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2012-03-03 22:56:36 +0100
committerJon Bergli Heier <snakebite@jvnv.net>2012-03-03 22:56:36 +0100
commit0f4155c33283522fe278b3f47e3405446f2165ff (patch)
tree4faff747d05f406cd6e7c32ccf02d60d864d7711 /static
parent85ab54b57f254c0b1c38edf9910882eb94cbc85a (diff)
Format artist and title in directory item template.
Diffstat (limited to 'static')
-rw-r--r--static/init.js21
1 files changed, 20 insertions, 1 deletions
diff --git a/static/init.js b/static/init.js
index 26ef404..0dd0af6 100644
--- a/static/init.js
+++ b/static/init.js
@@ -13,8 +13,27 @@ function pause() {
sound.togglePause();
}
+Handlebars.registerHelper('trackname', function() {
+ var item = this;
+ if(!item.metadata)
+ return item.name;
+
+ var s = '';
+ if(item.metadata.title)
+ s = item.metadata.title;
+ if(item.metadata.artist) {
+ if(s.length) {
+ s = ' - ' + s;
+ s = item.metadata.artist + s;
+ }
+ }
+ if(!s.length)
+ s = item.name;
+ return s;
+});
+
var templates = new (function Templates() {
- this.directory_item = Handlebars.compile('<li class="{{type}}"><a href="#">{{name}}</a>');
+ this.directory_item = Handlebars.compile('<li class="{{type}}"><a href="#">{{trackname}}</a>');
})();
function load_directory(dir_id, dir_item) {