From 555fb6c8d95caa4349922c23818fc9e115226057 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Sat, 10 Mar 2018 13:20:28 +0100 Subject: new router, handle opus, eslintrc --- public/assets/js/lib/sdk/auth.js | 4 ++-- public/assets/js/lib/views/details/audio.js | 2 +- public/assets/js/lib/views/details/files.js | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'public/assets/js/lib') diff --git a/public/assets/js/lib/sdk/auth.js b/public/assets/js/lib/sdk/auth.js index 0b49449..63a903c 100644 --- a/public/assets/js/lib/sdk/auth.js +++ b/public/assets/js/lib/sdk/auth.js @@ -64,7 +64,7 @@ var auth = (function(){ auth.clear_user() } auth.logged_in = function(){ - return (auth.user.id && auth.user.id !== -1 && auth.user.id !== "undefined") + return (auth.user && auth.user.id && auth.user.id !== -1 && auth.user.id !== "undefined") } auth.checkin = function(opt){ $.ajax({ @@ -72,7 +72,7 @@ var auth = (function(){ url: '/api/checkin', headers: { "csrf-token": $("[name=_csrf]").attr("value") }, success: function(data){ - if (data && data.user && data.user.id !== -1) { + if (data && data.user && data.user.id && data.user.id !== -1) { auth.set_user(data.user) opt.success(data.user) return diff --git a/public/assets/js/lib/views/details/audio.js b/public/assets/js/lib/views/details/audio.js index 0f16dc7..c876520 100644 --- a/public/assets/js/lib/views/details/audio.js +++ b/public/assets/js/lib/views/details/audio.js @@ -17,7 +17,7 @@ var audio = (function(){ music = [] var links = document.querySelectorAll("a") Array.prototype.slice.apply(links).forEach(function(link){ - if (! link.href.match(/\.(mp3|wav|ogg)$/)) return + if (! link.href.match(/\.(mp3|wav|ogg|opus)$/)) return link.dataset.index = music.length music.push(link) if (playing && link.href === el.src) { diff --git a/public/assets/js/lib/views/details/files.js b/public/assets/js/lib/views/details/files.js index b6f1794..3c7f84f 100644 --- a/public/assets/js/lib/views/details/files.js +++ b/public/assets/js/lib/views/details/files.js @@ -25,7 +25,7 @@ var FilesView = FormView.extend({ // return } total += file.size - has_music = has_music || file.filename.match(/(mp3|wav|ogg)/i) + has_music = has_music || file.filename.match(/(mp3|wav|ogg|opus)$/i) }.bind(this)) this.total = total @@ -137,7 +137,7 @@ var FilesView = FormView.extend({ pick: function(e){ if (e.ctrlKey || e.altKey || e.metaKey || e.shiftKey) return - if (! e.target.href || ! e.target.href.match(/(mp3|wav|ogg)/i)) return + if (! e.target.href || ! e.target.href.match(/(mp3|wav|ogg|opus)$/i)) return e.preventDefault() audio.play( e.target.dataset.index ) // index set in audio.js }, -- cgit v1.2.3-70-g09d2