| 17 | |
| 18 | // Watch for state change from sign in |
| 19 | function initApp() { |
| 20 | firebase.auth().onAuthStateChanged(user => { |
| 21 | if (user) { |
| 22 | // User is signed in. |
| 23 | document.getElementById('signInButton').innerText = 'Sign Out'; |
| 24 | document.getElementById('form').style.display = ''; |
| 25 | } else { |
| 26 | // No user is signed in. |
| 27 | document.getElementById('signInButton').innerText = 'Sign In with Google'; |
| 28 | document.getElementById('form').style.display = 'none'; |
| 29 | } |
| 30 | }); |
| 31 | } |
| 32 | window.onload = function () { |
| 33 | initApp(); |
| 34 | }; |