This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
logoutButon.addEventListener('click', function() { | |
const isLeaved = confirm('Do you want to log out?'); | |
if (isLeaved) { | |
// logout from cometchat and then clear storage. | |
CometChatWidget.logout().then(response => { | |
// User successfully logged out. | |
// Perform any clean up if required. | |
// redirect to login page. | |
window.location.href = '/login.html'; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CometChatWidget.launch({ | |
"widgetID": `${config.CometChatWidgetId}`, | |
"target": "#cometchat", | |
"roundedCorners": "false", | |
"height": "100%", | |
"width": "100%", | |
"defaultID": `${user.uid}`, //default UID (user) or GUID (group) to show, | |
"defaultType": 'user' //user or group | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.addEventListener('DOMContentLoaded', function() { | |
// hide loading indicator. | |
hideLoading(); | |
// get authenticated user | |
CometChatWidget.init({ | |
"appID": `${config.CometChatAppId}`, | |
"appRegion": `${config.CometChatRegion}`, | |
"authKey": `${config.CometChatAuthKey}` | |
}).then(response => { | |
CometChatWidget.CometChat.getLoggedinUser().then( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8" /> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
<title>Video Chat App with Vanilla JS</title> | |
<link rel="stylesheet" href="/css/styles.css" /> | |
<script | |
defer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const config = { | |
... | |
CometChatAppId: xxx - xxx - xxx - xxx - xxx - xxx - xxx - xxx, | |
CometChatRegion: xxx - xxx - xxx - xxx - xxx - xxx - xxx - xxx, | |
CometChatAuthKey: xxx - xxx - xxx - xxx - xxx - xxx - xxx - xxx, | |
CometChatAPIKey: xxx - xxx - xxx - xxx - xxx - xxx - xxx - xxx, | |
CometChatWidgetId: xxx - xxx - xxx - xxx - xxx - xxx - xxx - xxx, | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
loginBtn.addEventListener("click", function () { | |
// show loading indicator. | |
showLoading(); | |
// get input user's credentials. | |
const email = emailLoginInputElement ? emailLoginInputElement.value : null; | |
const password = passwordLoginInputElement | |
? passwordLoginInputElement.value | |
: null; | |
if (isUserCredentialsValid({ email, password })) { | |
// if the user's credentials are valid, call Firebase authentication service. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// hide loading indicator. | |
hideLoading(); | |
// get sign up container. | |
const signUpContainer = document.getElementById("signup"); | |
// set up event for sign up close btn | |
const signUpCloseBtn = document.getElementById("signup__close-btn"); | |
// set up event for create new account button. | |
const createNewAccountBtn = document.getElementById( | |
"login__create-account-btn" | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const loading = document.getElementById('loading'); | |
function hideLoading() { | |
loading.classList.add('loading--hide'); | |
} | |
function showLoading() { | |
loading.classList.remove('loading--hide'); | |
loading.classList.add('loading--active'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.addEventListener('DOMContentLoaded', function() { | |
function shouldRedirectToHomePage(user, isLoginPage) { | |
return user && isLoginPage; | |
} | |
function shouldRedirectToLoginPage(user, isLoginPage) { | |
return !user && !isLoginPage; | |
} | |
CometChatWidget.init({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Login</title> | |
<link rel="stylesheet" href="/css/styles.css"> | |
<script | |
defer |
NewerOlder