From f8b61281be84a6e4e7a44be5109e688a7c56c671 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Fri, 7 Jul 2017 21:18:33 +0200 Subject: refactor files so list updates while processing --- client/components/UI/AudioPlayer.jsx | 36 -------------------------------- client/components/UI/AudioPlayerView.jsx | 36 ++++++++++++++++++++++++++++++++ client/components/UI/Header.jsx | 5 ++--- 3 files changed, 38 insertions(+), 39 deletions(-) delete mode 100644 client/components/UI/AudioPlayer.jsx create mode 100644 client/components/UI/AudioPlayerView.jsx (limited to 'client/components/UI') diff --git a/client/components/UI/AudioPlayer.jsx b/client/components/UI/AudioPlayer.jsx deleted file mode 100644 index 1a68518..0000000 --- a/client/components/UI/AudioPlayer.jsx +++ /dev/null @@ -1,36 +0,0 @@ -import { h, Component } from 'preact' - -const audio = document.createElement('audio') - -export default function AudioPlayer (props) { - if (props.file) { - document.body.style.backgroundImage = 'url(' + pngpath(file) + ')' - audio.src = mp3path(props.file) - audio.play() - return ( -
- Playing {props.file.name} -
- ) - } - else { - return ( -
- Not Playing -
- ) - } -} - -function filepath (file) { - return '/data/' + file.folder_id + '/' + encodeURIComponent(file.name) -} -function mp3path (file) { - if (file.mime !== 'audio/mp3') { - return filepath(file) + '.mp3' - } - return filepath(file) -} -function pngpath (file) { - return filepath(file) + '.png' -} diff --git a/client/components/UI/AudioPlayerView.jsx b/client/components/UI/AudioPlayerView.jsx new file mode 100644 index 0000000..62745ed --- /dev/null +++ b/client/components/UI/AudioPlayerView.jsx @@ -0,0 +1,36 @@ +import { h, Component } from 'preact' + +const audio = document.createElement('audio') + +export default function AudioPlayerView (props) { + if (props.file) { + document.body.style.backgroundImage = 'url(' + pngpath(props.file) + ')' + audio.src = mp3path(props.file) + audio.play() + return ( +
+ Playing {props.file.name} +
+ ) + } + else { + return ( +
+ Not Playing +
+ ) + } +} + +function filepath (file) { + return '/data/' + file.folder_id + '/' + encodeURIComponent(file.name) +} +function mp3path (file) { + if (file.mime !== 'audio/mp3') { + return filepath(file) + '.mp3' + } + return filepath(file) +} +function pngpath (file) { + return filepath(file) + '.png' +} diff --git a/client/components/UI/Header.jsx b/client/components/UI/Header.jsx index 55dd25f..3f643ba 100644 --- a/client/components/UI/Header.jsx +++ b/client/components/UI/Header.jsx @@ -1,6 +1,5 @@ import { h, Component } from 'preact' -// import { Link } from 'react-router-dom' -import AudioPlayerContainer from '../../containers/audioPlayerContainer.js' +import AudioPlayer from '../../containers/audioPlayer.js' export default class Header extends Component { constructor(props) { @@ -12,7 +11,7 @@ export default class Header extends Component { return (
spawn cortex - +
) } -- cgit v1.2.3-70-g09d2