add download button to song view

This commit is contained in:
2022-05-27 20:44:48 +02:00
parent c30323b217
commit 758de5b110
3 changed files with 17 additions and 6 deletions

View File

@@ -4,8 +4,8 @@ with pkgs.yarn;
stdenv.mkDerivation { stdenv.mkDerivation {
name = "yarn"; name = "yarn";
buildInputs = [ buildInputs = [
nodejs-10_x nodejs
(yarn.override { nodejs = nodejs-10_x; }) (yarn.override { nodejs = nodejs; })
mozjpeg mozjpeg
optipng optipng
autoconf autoconf

View File

@@ -7,7 +7,6 @@ let table = null;
let columns = [ let columns = [
{ data: 'name' } { data: 'name' }
]; ];
let currentSong = null;
let songDir = []; let songDir = [];
let player = null; let player = null;
let aLoopTime = null; let aLoopTime = null;
@@ -87,7 +86,7 @@ $(function () {
return return
resetLoop(); resetLoop();
}); });
//dropdown //dropdown
$( '#dir-dropdown' ).change(function () { $( '#dir-dropdown' ).change(function () {
@@ -168,6 +167,7 @@ function updateDisplay(){
let aLoopBtn = $( '#aLoopBtn' ); let aLoopBtn = $( '#aLoopBtn' );
let bLoopBtn = $( '#bLoopBtn' ); let bLoopBtn = $( '#bLoopBtn' );
let resetLoopBtn= $( '#resetLoopBtn' ); let resetLoopBtn= $( '#resetLoopBtn' );
let downloadBtn = $( '#downloadBtn' );
let volumeSl = $( '#volume-slider' ); let volumeSl = $( '#volume-slider' );
let speedSl = $( '#speed-slider' ); let speedSl = $( '#speed-slider' );
@@ -182,6 +182,7 @@ function updateDisplay(){
aLoopBtn.prop("disabled", true); aLoopBtn.prop("disabled", true);
bLoopBtn.prop("disabled", true); bLoopBtn.prop("disabled", true);
resetLoopBtn.prop("disabled", true); resetLoopBtn.prop("disabled", true);
downloadBtn.prop("disabled", true);
positionSl.prop("disabled", true); positionSl.prop("disabled", true);
}else{ }else{
stopBtn.prop("disabled", false); stopBtn.prop("disabled", false);
@@ -204,6 +205,11 @@ function updateTable(){
}); });
} }
function updateDownloadLink(){
$( '#downloadLink' ).attr("href", player.url);
$( '#downloadLink' ).attr("download", player.song);
}
function tableClickListener(){ function tableClickListener(){
$( "tbody tr").unbind(); $( "tbody tr").unbind();
$( "tbody tr").hover(function(){ $( "tbody tr").hover(function(){
@@ -274,6 +280,8 @@ Player.prototype = {
onload: function() { onload: function() {
$( '#txt-duration' ).text(self.formatTime(Math.round(sound.duration()))); $( '#txt-duration' ).text(self.formatTime(Math.round(sound.duration())));
$( '#playBtn' ).prop("disabled", false); $( '#playBtn' ).prop("disabled", false);
$( '#downloadBtn' ).prop("disabled", false);
updateDownloadLink();
self.step(); self.step();
}, },
onend: function() { onend: function() {

View File

@@ -42,7 +42,7 @@
<i class='fa fa-redo'></i> <i class='fa fa-redo'></i>
<label class="info-txt-small" id="txt-bLoop">0:00</label> <label class="info-txt-small" id="txt-bLoop">0:00</label>
<button id='bLoopBtn' class='btn btn-danger'><b>B</b></button> <button id='bLoopBtn' class='btn btn-danger'><b>B</b></button>
<button id='resetLoopBtn' class='btn btn-danger'><i class='fa fa-times'></i></button> <button id='resetLoopBtn' class='btn btn-danger'><i class='fa fa-times'></i></button>
</div> </div>
<div class="col-lg-6"> <div class="col-lg-6">
<label class="info-txt-small">Geschwindigkeit:</label> <label class="info-txt-small">Geschwindigkeit:</label>
@@ -56,10 +56,13 @@
<label class="info-txt-small align-right not-on-iOS" id="txt-volume">70%</label> <label class="info-txt-small align-right not-on-iOS" id="txt-volume">70%</label>
<input type="range" min="0" max="1000" value="700" class="slider not-on-iOS" id="volume-slider"> <input type="range" min="0" max="1000" value="700" class="slider not-on-iOS" id="volume-slider">
</div> </div>
<div class="col-12"> <div class="col-8">
<p>Wenn du eine Datei von deinem PC auswählen willst, drücke auf diesen Button:</p> <p>Wenn du eine Datei von deinem PC auswählen willst, drücke auf diesen Button:</p>
<input id="extFile" type="file" accept=".mp3,audio/*" > <input id="extFile" type="file" accept=".mp3,audio/*" >
</div> </div>
<div class="col-4">
<a id="downloadLink" download href="" target="about:blank"><button id='downloadBtn' class='btn btn-success align-right'><i class='fa fa-download'></i></button></a>
</div>
</div> </div>
</div> </div>
</div> </div>