Merge pull request #158 from DavidRodriguezRay/master

Disabled join button after click
This commit is contained in:
Carlos Santos 2021-06-09 08:45:17 +02:00 committed by GitHub
commit 3cd15f9f5d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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>