<commit_before>/*****************************************************************************
 * 
 * Function:
 *   onFirebaseAuthStateChanged
 * 
 * Parameters:
 *   user - Currently authenticated user (or null).
 * 
 * Description:
 *   Dynamically adjusts the web page depending on the current user.
 * 
 *****************************************************************************/

 var onFirebaseAuthStateChanged_MembersPage = function( user ) {

  if( user ) {

    var userUsername = emailToUsername( user.email );
    var userAdminPath = "/markup/admin/" + userUsername;
    var userAdminRef = ref.child( userAdminPath );
    userAdminRef.once( "value", function( userAdminSnap ) {

      /* If user is admin */
      if( userAdminSnap.exists() ) {

        populateMemberList( user );

      } else { /* User is not an admin */
        alert( "You must be a markup admin to manage registered members." );
        window.location.replace( "/" );
      }

    } );

  } else {

  }

}
firebase.auth().onAuthStateChanged( onFirebaseAuthStateChanged_MembersPage );


/*****************************************************************************
 * 
 * Function:
 *   changeAdminContext
 * 
 * Parameters:
 *   memberContext - Relevant data pertaining to the member who is having 
 *                   their admin status changed.
 * 
 * Description:
 *   Completes action after user has indicated to change a member's admin 
 *   status.
 * 
 *****************************************************************************/

var changeAdminStatus = function( memberContext, checkContext ) {

  var userSelection 
    = confirm( "Are you sure you want to change " + memberContext.name + "'s member status from " + 
               memberContext.isAdmin + " to " + $( "#" + memberContext.checkID ).prop('checked') + "?" );

    if( userSelection ) {
      
      changes = {}

      changes['/members/' + memberContext.username + '/markup/admin' ] = ( !memberContext.isAdmin ? true : null );
      changes['/markup/admin/' + memberContext.username ] = ( !memberContext.isAdmin ? true : null );

      firebase.database().ref().update( changes );
    } else {
      // TODO: Just cancel 
      location.reload();
    }

}

/*****************************************************************************
 * 
 * Function:
 *   populateMemberList
 * 
 * Parameters:
 *   none
 * 
 * Description:<commit_msg>Fix typeo<commit_after>/*****************************************************************************
 * 
 * Function:
 *   onFirebaseAuthStateChanged
 * 
 * Parameters:
 *   user - Currently authenticated user (or null).
 * 
 * Description:
 *   Dynamically adjusts the web page depending on the current user.
 * 
 *****************************************************************************/

 var onFirebaseAuthStateChanged_MembersPage = function( user ) {

  if( user ) {

    var userUsername = emailToUsername( user.email );
    var userAdminPath = "/markup/admin/" + userUsername;
    var userAdminRef = ref.child( userAdminPath );
    userAdminRef.once( "value", function( userAdminSnap ) {

      /* If user is admin */
      if( userAdminSnap.exists() ) {

        populateMemberList( user );

      } else { /* User is not an admin */
        alert( "You must be a markup admin to manage registered members." );
        window.location.replace( "/" );
      }

    } );

  } else {

  }

}
firebase.auth().onAuthStateChanged( onFirebaseAuthStateChanged_MembersPage );


/*****************************************************************************
 * 
 * Function:
 *   changeAdminContext
 * 
 * Parameters:
 *   memberContext - Relevant data pertaining to the member who is having 
 *                   their admin status changed.
 * 
 * Description:
 *   Completes action after user has indicated to change a member's admin 
 *   status.
 * 
 *****************************************************************************/

var changeAdminStatus = function( memberContext, checkContext ) {

  var userSelection 
    = confirm( "Are you sure you want to change " + memberContext.name + "'s admin status from " + 
               memberContext.isAdmin + " to " + $( "#" + memberContext.checkID ).prop('checked') + "?" );

    if( userSelection ) {
      
      changes = {}

      changes['/members/' + memberContext.username + '/markup/admin' ] = ( !memberContext.isAdmin ? true : null );
      changes['/markup/admin/' + memberContext.username ] = ( !memberContext.isAdmin ? true : null );

      firebase.database().ref().update( changes );
    } else {
      // TODO: Just cancel 
      location.reload();
    }

}

/*****************************************************************************
 * 
 * Function:
 *   populateMemberList
 * 
 * Parameters:
 *   none
 * 
 * Description:
{'fraction_non_alphanumeric': 0.26108682073703937, 'fraction_numerical': 0.0, 'mean_word_length': 3.2288732394366195, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1042868', 'n_tokens_mistral': 1269, 'n_tokens_neox': 1158, 'n_words': 304}