modification to disable join button after click to avoid duplicate media

This commit is contained in:
david 2021-06-08 18:19:04 +02:00
parent a3ee7df193
commit 4d28335a01
2 changed files with 15 additions and 2 deletions

View File

@ -8,6 +8,10 @@ var token; // Token retrieved from OpenVidu Server
/* OPENVIDU METHODS */
function joinSession() {
document.getElementById("join-btn").disabled = true;
document.getElementById("join-btn").innerHTML = "Joining...";
getToken((token) => {
// --- 1) Get an OpenVidu object ---
@ -106,6 +110,7 @@ function joinSession() {
})
.catch(error => {
console.warn('There was an error connecting to the session:', error.code, error.message);
enableBtn();
});
});
@ -124,11 +129,17 @@ function leaveSession() {
$('#join').show();
$('#session').hide();
// eneble button
enableBtn();
}
/* OPENVIDU METHODS */
function enableBtn (){
document.getElementById("join-btn").disabled = false;
document.getElementById("join-btn").innerHTML = "Join!";
}
/* APPLICATION REST METHODS */
@ -161,6 +172,8 @@ function logOut() {
$("#logged").hide();
}
);
enableBtn();
}
function getToken(callback) {

View File

@ -92,7 +92,7 @@
<input class="form-control" type="text" id="sessionName" required>
</p>
<p class="text-center">
<button class="btn btn-lg btn-success" onclick="joinSession()">Join!</button>
<button class="btn btn-lg btn-success" id="join-btn" onclick="joinSession()">Join!</button>
</p>
</form>
<hr>