Skip to content

Commit

Permalink
Added a play button to View Call
Browse files Browse the repository at this point in the history
- Re: #87
  • Loading branch information
emxsys committed Aug 29, 2020
1 parent 4d5b181 commit 466e3a2
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion callattendant/userinterface/templates/calls_view.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ <h5 class="mb-0">Voice Message</b></h5>
Your browser does not support the audio element.
</audio>
</p>
<button id="play-button" type="button" class="btn btn-primary">Play</button>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#modal-delete-message">Delete</button>
</div>
</div>
Expand Down Expand Up @@ -94,7 +95,17 @@ <h6>Delete voice message from {{ caller.phone_no }}?</h6>
history.back()
});

// Open the Messages page

// Play the message
$('#play-button').on('click', function (event) {
// It doesn't work with $("#audio").play() like you would expect. The official reason is that
// incorporating it into jQuery would add a play() to every element. So instead you have to refer
// to it by its position in the array of DOM elements
// https://stackoverflow.com/a/38547039/4797523
$("#audio")[0].play()
});

// Delete the messages
$('#delete-message').on('click', function (event) {
window.location.href = "/messages/delete/{{ caller.msg_no }}"
});
Expand Down

0 comments on commit 466e3a2

Please sign in to comment.