diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2023-05-21 13:45:15 +0200 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2023-05-21 13:46:58 +0200 |
| commit | cef46aa5f5b9cac5c43bd842ed64580357718e86 (patch) | |
| tree | 233d183648c331ef7676dae1565e55962f29af6b /web/client.html | |
| parent | 6bd47783325a2c1833f8017abc6aa459c4d82538 (diff) | |
| download | WRMS-cef46aa5f5b9cac5c43bd842ed64580357718e86.tar.gz WRMS-cef46aa5f5b9cac5c43bd842ed64580357718e86.zip | |
implement the upload backend
Diffstat (limited to 'web/client.html')
| -rw-r--r-- | web/client.html | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/web/client.html b/web/client.html index 87ca51a..a330c00 100644 --- a/web/client.html +++ b/web/client.html @@ -237,6 +237,18 @@ return false; } + {{if .HasUpload}} + function submitUpload() { + const form = new FormData(document.getElementById("uploadForm")); + const file = form.get("song"); + const params = new URLSearchParams(); + params.append("song", file.name); + const song = params.toString(); + new HttpClient().post("/upload?" + song, file, console.log); + return false; + } + {{end}} + function addSong(song) { new HttpClient().post("/add", JSON.stringify(song), console.log); } @@ -282,6 +294,13 @@ <input id="searchInput" name="pattern" type="text" value="Title/Artist/Album/..."> <button id="searchButton">Search</button> </form> + + {{if .HasUpload}} + <form id="uploadForm" onsubmit="return submitUpload()"> + <input id="uploadInput" name="song" type="file"> + <button id="uploadButton", type="submit">Upload</button> + </form> + {{end}} </div> <div id="searchResultsOverlay" style="display: none;"> |
