Skip to content

Commit

Permalink
Fix js error when no audio file present.
Browse files Browse the repository at this point in the history
  • Loading branch information
jzohrab committed Dec 21, 2023
1 parent 642c17b commit a08334c
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions lute/templates/read/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -269,23 +269,19 @@ <h2>&#127881;</h2>

<script>
$(document).ready(function () {
show_player();
if (have_audio_file()) {
// Don't actually load the source -- for some reason,
// the ajax page load was causing the audio src to
// only load occasionally! Not sure why. Source loading
// is handled in load_player_source().
$('div.audio-player-container').show();
}
goto_relative_page(0, true);
});

/**
* If book_audio_file is not null, set up the player.
*
* Don't actually load the source -- for some reason,
* the ajax page load was causing the audio src to
* only load occasionally! Not sure why. Source loading
* is handled in load_player_source().
*/
let show_player = function() {
const have_file = ($('#book_audio_file').val() != '');
if (have_file) {
$('div.audio-player-container').show();
}

let have_audio_file = function() {
return ($('#book_audio_file').val() != '');
}

/**
Expand Down Expand Up @@ -404,7 +400,7 @@ <h2>&#127881;</h2>

// Magic hack for player source to load consistently
// in Firefox.
if (load_source_file) {
if (load_source_file && have_audio_file()) {
load_player_source();
}
}
Expand Down

0 comments on commit a08334c

Please sign in to comment.