Skip to content

Commit a08334c

Browse files
committed
Fix js error when no audio file present.
1 parent 642c17b commit a08334c

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

lute/templates/read/index.html

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -269,23 +269,19 @@ <h2>&#127881;</h2>
269269

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

276-
/**
277-
* If book_audio_file is not null, set up the player.
278-
*
279-
* Don't actually load the source -- for some reason,
280-
* the ajax page load was causing the audio src to
281-
* only load occasionally! Not sure why. Source loading
282-
* is handled in load_player_source().
283-
*/
284-
let show_player = function() {
285-
const have_file = ($('#book_audio_file').val() != '');
286-
if (have_file) {
287-
$('div.audio-player-container').show();
288-
}
282+
283+
let have_audio_file = function() {
284+
return ($('#book_audio_file').val() != '');
289285
}
290286

291287
/**
@@ -404,7 +400,7 @@ <h2>&#127881;</h2>
404400

405401
// Magic hack for player source to load consistently
406402
// in Firefox.
407-
if (load_source_file) {
403+
if (load_source_file && have_audio_file()) {
408404
load_player_source();
409405
}
410406
}

0 commit comments

Comments
 (0)