..
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32 | $(document).ready(function(){
function showAlert(message) {
// Get the snackbar DIV
var x = document.getElementById("snackbar");
$('#snackbar').text(message)
// Add the "show" class to DIV
x.className = "show";
// After 3 seconds, remove the show class from DIV
setTimeout(function(){ x.className = x.className.replace("show", ""); }, 3000);
}
$('#signup').click(function(){
var email = $("#email").val()
var password = $("#password").val()
if(email === '' || password === '') {
showAlert('Please fill in all the fields')
} else {
firebase.auth().createUserWithEmailAndPassword(email, password).catch(function(error) {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
showAlert(errorMessage)
// ...
});
}
})
firebase.auth().onAuthStateChanged(function(user) {
if (user) {
window.location.replace('dashboard')
}
});
})
|
|