function updateUserToDB(){

  checkUserNames(userNameField.value);

  if (nameField.value === "" || userNameField.value === "" || pinField.value === "" || pinconfField.value === ""){
    alert("It looks like you left some fields blank. Make sure you have your full name, username, a pin, and " +
      "a confirmed pin below.");
  } else if (pinconfField.value !== pinField.value){
    alert("It looks like the pins you entered are not the same");
  } else if (!isNaN(pinField.value) == false) {
    alert("It looks like the pins you entered are not numeric, please make sure that they are numbers only");
  } else if (userNameBool == false && user == null){
    alert("It looks like the User Name you chose is already taken, please choose another.");
    userNameBool = true;
  } else {
    var newPin = parseInt(pinField.value);
    injectUserArr(userArr);
    var encodeKey = encode(pinField.value);
    firebase.database().ref("users/" + user.uid).update({
      name: nameField.value,
      pin: newPin,
      encodeStr: encodeKey,
      userName: userNameField.value,
      ban: user.ban,
      firstLogin: user.firstLogin,
      moderatorInt: user.moderatorInt,
      organize: user.organize,
      strike: user.strike,
      theme: user.theme,
      uid: user.uid,
      warn: user.warn,
    });
    if(user.giftList != undefined) {
      firebase.database().ref("users/" + user.uid).update({
        giftList: user.giftList
      });
    }
    if(user.support != undefined) {
      firebase.database().ref("users/" + user.uid).update({
        support: user.support
      });
    }
    if(user.invites != undefined) {
      firebase.database().ref("users/" + user.uid).update({
        invites: user.invites
      });
    }
    if(user.friends != undefined) {
      firebase.database().ref("users/" + user.uid).update({
        friends: user.friends
      });
    }
    if(user.shareCode != undefined) {
      firebase.database().ref("users/" + user.uid).update({
        shareCode: user.shareCode
      });
    }
    if(user.notifications != undefined) {
      firebase.database().ref("users/" + user.uid).update({
        notifications: user.notifications
      });
    }
    if (user.readNotifications != undefined) {
      firebase.database().ref("users/" + user.uid).update({
        readNotifications: user.readNotifications
      });
    }

    btnUpdate.innerHTML = "Please Wait...";
    btnUpdate.onclick = function(){};//forces the update button to do nothing
    btnDelete.onclick = function(){};//forces the delete button to do nothing
    sessionStorage.setItem("validUser", JSON.stringify(user));
    sessionStorage.setItem("userArr", JSON.stringify(userArr));
    window.location.href = "settings.html";
  }

}
//data is updated into the database and the user is redirected back to the settings page.
data is updated into the database and the user is redirected back to the settings page.
data is updated into the database and the user is redirected back to the settings page .
function updateUserToDB(){
  checkUserNames(userNameField.value);
  if (nameField.value === "" || userNameField.value === "" || pinField.value === "" || pinconfField.value === ""){
    alert("It looks like you left some fields blank. Make sure you have your full name, username, a pin, and " +
      "a confirmed pin below.");
  } else if (pinconfField.value !== pinField.value){
    alert("It looks like the pins you entered are not the same");
  } else if (!isNaN(pinField.value) == false) {
    alert("It looks like the pins you entered are not numeric, please make sure that they are numbers only");
  } else if (userNameBool == false && user == null){
    alert("It looks like the User Name you chose is already taken, please choose another.");
    userNameBool = true;
  } else {
    var newPin = parseInt(pinField.value);
    injectUserArr(userArr);
    var encodeKey = encode(pinField.value);
    firebase.database().ref("users/" + user.uid).update({
      name: nameField.value,
      pin: newPin,
      encodeStr: encodeKey,
      userName: userNameField.value,
      ban: user.ban,
      firstLogin: user.firstLogin,
      moderatorInt: user.moderatorInt,
      organize: user.organize,
      strike: user.strike,
      theme: user.theme,
      uid: user.uid,
      warn: user.warn,
    });
    if(user.giftList != undefined) {
      firebase.database().ref("users/" + user.uid).update({
        giftList: user.giftList
      });
    }
    if(user.support != undefined) {
      firebase.database().ref("users/" + user.uid).update({
        support: user.support
      });
    }
    if(user.invites != undefined) {
      firebase.database().ref("users/" + user.uid).update({
        invites: user.invites
      });
    }
    if(user.friends != undefined) {
      firebase.database().ref("users/" + user.uid).update({
        friends: user.friends
      });
    }
    if(user.shareCode != undefined) {
      firebase.database().ref("users/" + user.uid).update({
        shareCode: user.shareCode
      });
    }
    if(user.notifications != undefined) {
      firebase.database().ref("users/" + user.uid).update({
        notifications: user.notifications
      });
    }
    if (user.readNotifications != undefined) {
      firebase.database().ref("users/" + user.uid).update({
        readNotifications: user.readNotifications
      });
    }
    btnUpdate.innerHTML = "Please Wait...";
    btnUpdate.onclick = function(){};
    btnDelete.onclick = function(){};
    sessionStorage.setItem("validUser", JSON.stringify(user));
    sessionStorage.setItem("userArr", JSON.stringify(userArr));
    window.location.href = "settings.html";
  }
}
function updateUserToDB ( ) { checkUserNames ( userNameField . value ) ; if ( nameField . value === "" || userNameField . value === "" || pinField . value === "" || pinconfField . value === "" ) { alert ( "It looks like you left some fields blank. Make sure you have your full name, username, a pin, and " + "a confirmed pin below." ) ; } else if ( pinconfField . value !== pinField . value ) { alert ( "It looks like the pins you entered are not the same" ) ; } else if ( ! isNaN ( pinField . value ) == false ) { alert ( "It looks like the pins you entered are not numeric, please make sure that they are numbers only" ) ; } else if ( userNameBool == false && user == null ) { alert ( "It looks like the User Name you chose is already taken, please choose another." ) ; userNameBool = true ; } else { var newPin = parseInt ( pinField . value ) ; injectUserArr ( userArr ) ; var encodeKey = encode ( pinField . value ) ; firebase . database ( ) . ref ( "users/" + user . uid ) . update ( { name : nameField . value , pin : newPin , encodeStr : encodeKey , userName : userNameField . value , ban : user . ban , firstLogin : user . firstLogin , moderatorInt : user . moderatorInt , organize : user . organize , strike : user . strike , theme : user . theme , uid : user . uid , warn : user . warn , } ) ; if ( user . giftList != undefined ) { firebase . database ( ) . ref ( "users/" + user . uid ) . update ( { giftList : user . giftList } ) ; } if ( user . support != undefined ) { firebase . database ( ) . ref ( "users/" + user . uid ) . update ( { support : user . support } ) ; } if ( user . invites != undefined ) { firebase . database ( ) . ref ( "users/" + user . uid ) . update ( { invites : user . invites } ) ; } if ( user . friends != undefined ) { firebase . database ( ) . ref ( "users/" + user . uid ) . update ( { friends : user . friends } ) ; } if ( user . shareCode != undefined ) { firebase . database ( ) . ref ( "users/" + user . uid ) . update ( { shareCode : user . shareCode } ) ; } if ( user . notifications != undefined ) { firebase . database ( ) . ref ( "users/" + user . uid ) . update ( { notifications : user . notifications } ) ; } if ( user . readNotifications != undefined ) { firebase . database ( ) . ref ( "users/" + user . uid ) . update ( { readNotifications : user . readNotifications } ) ; } btnUpdate . innerHTML = "Please Wait..." ; btnUpdate . onclick = function ( ) { } ; btnDelete . onclick = function ( ) { } ; sessionStorage . setItem ( "validUser" , JSON . stringify ( user ) ) ; sessionStorage . setItem ( "userArr" , JSON . stringify ( userArr ) ) ; window . location . href = "settings.html" ; } }
data is updated into the database and the user is redirected back to the settings page.
data is updated into the database and the user is redirected back to the settings page .
//forces the update button to do nothing //forces the delete button to do nothing