diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2017-07-02 22:49:26 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2017-07-02 22:49:26 +0200 |
| commit | db3a5fcd8edaa45ef05a6250e7f9452f0ed87250 (patch) | |
| tree | 871703028cef31309102d452197d737bc5cc76e8 /public/bundle.js | |
| parent | ef0d6a05a1717b9cb9b52fca9285c9ba8c191b0c (diff) | |
resample to 16bit 44100hz aiff
Diffstat (limited to 'public/bundle.js')
| -rw-r--r-- | public/bundle.js | 61 |
1 files changed, 55 insertions, 6 deletions
diff --git a/public/bundle.js b/public/bundle.js index 948ac8a..336fbee 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -1646,13 +1646,22 @@ module.exports = invariant; Object.defineProperty(exports, "__esModule", { value: true }); -function _get(data) { +function _get_url(_url, data) { + var url = new URL(document.origin + _url); + console.log(_url, data, document.origin); + if (data) { + Object.keys(data).forEach(function (key) { + return url.searchParams.append(key, data[key]); + }); + } + return url; +} +function _get_headers() { return { method: 'GET', headers: { 'Accept': 'application/json' - }, - query: data + } }; } function post(data) { @@ -1701,7 +1710,7 @@ function crud(type_s) { var type = '/' + type_s + 's/'; return { index: function index(data) { - return fetch(type, _get(data)).then(function (req) { + return fetch(_get_url(type, data), _get_headers()).then(function (req) { return req.json(); }).catch(error); }, @@ -6135,6 +6144,7 @@ var Folder = function (_Component) { return _this.setState({ files: files }); }); } + _this.audio = document.createElement('audio'); return _this; } @@ -6149,17 +6159,32 @@ var Folder = function (_Component) { this.setState({ files: files }); } }, { + key: 'handleClick', + value: function handleClick(file) { + console.log(file); + if (file.type === 'audio') { + this.audio.setAttribute('src', mp3path(file)); + this.audio.play(); + console.log(pngpath(file)); + document.body.style.backgroundImage = 'url(' + pngpath(file) + ')'; + } + } + }, { key: 'render', value: function render() { + var _this2 = this; + console.log(this.props); - var files = this.state.files.map(function (file, i) { + var files = this.state.files.map(toFilenamePair).sort(sortByFilename).map(fromPair).map(function (file, i) { if (!file) return; return (0, _preact.h)( 'div', { key: i }, (0, _preact.h)( 'span', - { 'class': 'name' }, + { 'class': 'name', onClick: function onClick() { + return _this2.handleClick(file); + } }, file.name ), (0, _preact.h)( @@ -6205,6 +6230,30 @@ var Folder = function (_Component) { exports.default = Folder; + +function toFilenamePair(file) { + return [file.name.toLowerCase(), file]; +} +function sortByFilename(a, b) { + return a[0] < b[0] ? -1 : a[0] == b[0] ? 0 : 1; +} +function fromPair(pair) { + return pair[1]; +} + +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'; +} + /***/ }), /* 58 */ /***/ (function(module, exports, __webpack_require__) { |
