diff options
Diffstat (limited to 'public/assets/js/lib/views/details/files.js')
| -rw-r--r-- | public/assets/js/lib/views/details/files.js | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/public/assets/js/lib/views/details/files.js b/public/assets/js/lib/views/details/files.js index b19cf3c..399d8a7 100644 --- a/public/assets/js/lib/views/details/files.js +++ b/public/assets/js/lib/views/details/files.js @@ -3,6 +3,7 @@ var FilesView = FormView.extend({ el: "#files", events: { + "click .file": "pick", }, initialize: function(){ @@ -15,25 +16,35 @@ var FilesView = FormView.extend({ if (! files.length) { this.$el.hide() } - var total = 0 + var total = 0, has_music = false files.forEach(function(file){ this.appendFile(file) total += file.size + has_music = has_music || file.filename.match(/(mp3|wav|ogg)/i) }.bind(this)) var size = hush_size(total) var t = this.templateTotal.replace(/{{size_class}}/g, size[0]) .replace(/{{size}}/g, size[1]) this.$el.append(t) + + if (has_music) { + audio.init() + } }, parse: function(file){ var size = hush_size(file.size) var datetime = verbose_date(file.date, true) var date_class = carbon_date(file.date) + + var link = file.filename + if (link.indexOf("http") !== 0) { + link = "//carbonpictures.com/bucky/data/" + file.thread + "/" + file.filename + } var t = this.template.replace(/{{username}}/g, file.username) - .replace(/{{link}}/g, file.filename) + .replace(/{{link}}/g, link) .replace(/{{filename}}/g, file.filename) .replace(/{{date_class}}/g, date_class) .replace(/{{date}}/g, datetime[0]) @@ -53,7 +64,11 @@ var FilesView = FormView.extend({ this.$el.append($el) }, - success: function(){ - this.prependFile(file) - } + pick: function(e){ + if (e.ctrlKey || e.altKey || e.metaKey || e.shiftKey) return + if (! e.target.href.match(/(mp3|wav|ogg)/i)) return + e.preventDefault() + audio.play( e.target.dataset.index ) + }, + })
\ No newline at end of file |
