function initApp(){

    // [END authstatelistener]

    document.getElementById('quickstart-sign-in').addEventListener('click', toggleSignIn, false);
    document.getElementById('quickstart-sign-up').addEventListener('click', handleSignUp, false);
    //document.getElementById('quickstart-verify-email').addEventListener('click', sendEmailVerification, false);
    //document.getElementById('quickstart-password-reset').addEventListener('click', sendPasswordReset, false);

    // Listening for auth state changes.
    // [START authstatelistener]
    firebase.auth().onAuthStateChanged(function(user) {
      // [START_EXCLUDE silent]
      //document.getElementById('quickstart-verify-email').disabled = true;
      //$('#profile').show()
      //$('#profile').append("<p>Hello Tarfah!</p>");
      // [END_EXCLUDE]
      if (user) {
        // User is signed in.
        //var displayName = user.displayName;
        var email = user.email;
        var emailVerified = user.emailVerified;
        // var photoURL = user.photoURL;
        // var isAnonymous = user.isAnonymous;
        // var uid = user.uid;
        // var providerData = user.providerData;
        // [START_EXCLUDE]

       // writeUserData(user.uid, document.getElementById('displayName').value, user.email);

        //document.getElementById('quickstart-sign-in-status').textContent = 'Signed in';
        document.getElementById('quickstart-sign-in').textContent = 'Sign out';
        //console.log(JSON.stringify(user, null, '  '));
        //document.getElementById('quickstart-account-details').textContent = JSON.stringify(user, null, '  ');
        if (!emailVerified) {
          //document.getElementById('quickstart-verify-email').disabled = false;
        }

        firebase.database().ref('/users/' + user.uid).once('value').then(function(snapshot) {
          var displayName = snapshot.val().name;
          // console.log("NAME: ", displayName);
          $("#SignupLogin").html(displayName);
        });

        $('#acc').show();
        $('#signout').show();

        $('#butDDInt').click();
        // [END_EXCLUDE]
      } else {

        // User is signed out.
        // [START_EXCLUDE]
        //document.getElementById('quickstart-sign-in-status').textContent = 'Signed out';
        document.getElementById('quickstart-sign-in').textContent = 'Sign in';
        //document.getElementById('quickstart-account-details').textContent = 'null';
        // [END_EXCLUDE]
        $('#loginModal').modal('show');
        $("#SignupLogin").html('Sign in');

      }


      // [START_EXCLUDE silent]
      document.getElementById('quickstart-sign-in').disabled = false;
      // [END_EXCLUDE]
    });

  }
/**
   * initApp handles setting up UI event listeners and registering Firebase auth listeners:
   *  - firebase.auth().onAuthStateChanged: This listener is called when the user is signed in or
   *    out, and that is where we update the UI.
   */
initApp handles setting up UI event listeners and registering Firebase auth listeners:
- firebase.auth().onAuthStateChanged: This listener is called when the user is signed in or
out, and that is where we update the UI.
initApp handles setting up UI event listeners and registering Firebase auth listeners : - firebase . auth () . onAuthStateChanged : This listener is called when the user is signed in or out and that is where we update the UI .
function initApp(){
    document.getElementById('quickstart-sign-in').addEventListener('click', toggleSignIn, false);
    document.getElementById('quickstart-sign-up').addEventListener('click', handleSignUp, false);
    firebase.auth().onAuthStateChanged(function(user) {
      if (user) {
        var email = user.email;
        var emailVerified = user.emailVerified;
        document.getElementById('quickstart-sign-in').textContent = 'Sign out';
        if (!emailVerified) {
        }
        firebase.database().ref('/users/' + user.uid).once('value').then(function(snapshot) {
          var displayName = snapshot.val().name;
          $("#SignupLogin").html(displayName);
        });
        $('#acc').show();
        $('#signout').show();
        $('#butDDInt').click();
      } else {
        document.getElementById('quickstart-sign-in').textContent = 'Sign in';
        $('#loginModal').modal('show');
        $("#SignupLogin").html('Sign in');
      }
      document.getElementById('quickstart-sign-in').disabled = false;
    });
  }
function initApp ( ) { document . getElementById ( 'quickstart-sign-in' ) . addEventListener ( 'click' , toggleSignIn , false ) ; document . getElementById ( 'quickstart-sign-up' ) . addEventListener ( 'click' , handleSignUp , false ) ; firebase . auth ( ) . onAuthStateChanged ( function ( user ) { if ( user ) { var email = user . email ; var emailVerified = user . emailVerified ; document . getElementById ( 'quickstart-sign-in' ) . textContent = 'Sign out' ; if ( ! emailVerified ) { } firebase . database ( ) . ref ( '/users/' + user . uid ) . once ( 'value' ) . then ( function ( snapshot ) { var displayName = snapshot . val ( ) . name ; $ ( "#SignupLogin" ) . html ( displayName ) ; } ) ; $ ( '#acc' ) . show ( ) ; $ ( '#signout' ) . show ( ) ; $ ( '#butDDInt' ) . click ( ) ; } else { document . getElementById ( 'quickstart-sign-in' ) . textContent = 'Sign in' ; $ ( '#loginModal' ) . modal ( 'show' ) ; $ ( "#SignupLogin" ) . html ( 'Sign in' ) ; } document . getElementById ( 'quickstart-sign-in' ) . disabled = false ; } ) ; }
initApp handles setting up UI event listeners and registering Firebase auth listeners:
  - firebase.auth().onAuthStateChanged: This listener is called when the user is signed in or
    out, and that is where we update the UI.
initApp handles setting up UI event listeners and registering Firebase auth listeners : - firebase . auth () . onAuthStateChanged : This listener is called when the user is signed in or out and that is where we update the UI .
// [END authstatelistener] //document.getElementById('quickstart-verify-email').addEventListener('click', sendEmailVerification, false); //document.getElementById('quickstart-password-reset').addEventListener('click', sendPasswordReset, false); // Listening for auth state changes. // [START authstatelistener] // [START_EXCLUDE silent] //document.getElementById('quickstart-verify-email').disabled = true; //$('#profile').show() //$('#profile').append("<p>Hello Tarfah!</p>"); // [END_EXCLUDE] // User is signed in. //var displayName = user.displayName; // var photoURL = user.photoURL; // var isAnonymous = user.isAnonymous; // var uid = user.uid; // var providerData = user.providerData; // [START_EXCLUDE] // writeUserData(user.uid, document.getElementById('displayName').value, user.email); //document.getElementById('quickstart-sign-in-status').textContent = 'Signed in'; //console.log(JSON.stringify(user, null, '  ')); //document.getElementById('quickstart-account-details').textContent = JSON.stringify(user, null, '  '); //document.getElementById('quickstart-verify-email').disabled = false; // console.log("NAME: ", displayName); // [END_EXCLUDE] // User is signed out. // [START_EXCLUDE] //document.getElementById('quickstart-sign-in-status').textContent = 'Signed out'; //document.getElementById('quickstart-account-details').textContent = 'null'; // [END_EXCLUDE] // [START_EXCLUDE silent] // [END_EXCLUDE]