<commit_before>var mainText = document.getElementById("mainText");
var returnField = document.getElementById("returnField");
var fieldRef = firebase.database().ref('messageLog');
var timeStamp = firebase.database.ServerValue.TIMESTAMP;
var count = 0;
var totalMsg = 0;

function sendClick() {

  firebaseRef = firebase.database().ref('messageLog');

  var messageText = mainText.value;
    firebaseRef.push({messageText,
	timeStamp,
	count
	});
  firebaseRef.orderByChild('timeStamp');l
}

fieldRef.on('child_added', function(textSnap, id) {

   id = textSnap.key;
   var div = document.createElement('p'); // creates new p tag in chatbox
   chatArea.appendChild(div);
   div.textContent = textSnap.val().messageText;
   count++;
   totalMsg++;
});

fieldRef.on('child_removed', function(textSnap, id) {

  id = chatArea.firstChild.key;
  chatArea.removeChild(chatArea.firstChild);
  count--;
});

  fieldRef.on('value', function(parentSnap) {
    parentSnap.forEach(function(childSnap) {
    var childBirth = childSnap.val().timeStamp;
    var childKey = childSnap.key;
    alert("before if");
    if (true) {
      alert("after if");
      childSnap.ref().set(null);
      alert("done");
    }
  });
});<commit_msg>added auto remove after # messages<commit_after>var mainText = document.getElementById("mainText");
var returnField = document.getElementById("returnField");
var fieldRef = firebase.database().ref('messageLog');
var timeStamp = firebase.database.ServerValue.TIMESTAMP;
var count = 0;
var totalMsg = 0;

function sendClick() {

  firebaseRef = firebase.database().ref('messageLog');

  var messageText = mainText.value;
    firebaseRef.child(totalMsg).set({messageText,
	timeStamp,
	count
	});
  if (totalMsg >= 3) {
    fieldRef.child(totalMsg - count).remove();
  }
}

fieldRef.on('child_added', function(textSnap, id) {

   id = textSnap.key;
   var div = document.createElement('p'); // creates new p tag in chatbox
   chatArea.appendChild(div);
   div.textContent = textSnap.val().messageText;
   count++;
   totalMsg++;

});

fieldRef.on('child_removed', function(textSnap, id) {

  id = chatArea.firstChild.key;
  chatArea.removeChild(chatArea.firstChild);
  count--;
});
{'fraction_non_alphanumeric': 0.1504102096627165, 'fraction_numerical': 0.0022789425706472195, 'mean_word_length': 4.556962025316456, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '1228782', 'n_tokens_mistral': 721, 'n_tokens_neox': 708, 'n_words': 135}