<commit_before>
var timestamp = document.createElement('div');
timestamp.setAttribute('class', 'timestamp_bg');

document.addEventListener('mouseup', function (e) {

  document.body.appendChild(timestamp);

  var selection = window.getSelection().toString();
  var myDate;
  if (selection.length === 10) {
    myDate = new Date(JSON.parse(window.getSelection().toString() * 1000));
  } else {
    myDate = new Date(JSON.parse(window.getSelection().toString()));
  }

  if (selection.length > 0) {
    showTimestamp(e.clientX, e.clientY, myDate);
  }
}, false);


document.addEventListener('mousedown', function (e) {
  timestamp.style.visibility = 'hidden';
}, false);

function showTimestamp(xPos, yPos, selection) {
  timestamp.innerHTML = selection;
  timestamp.style.top = yPos + 'px';
  timestamp.style.left = xPos + 'px';<commit_msg>added a bit of validation<commit_after>var timestamp = document.createElement('div');
timestamp.setAttribute('class', 'timestamp_bg');

document.addEventListener('mouseup', function(e) {

  document.body.appendChild(timestamp);

  var selection = window.getSelection().toString();
  var myDate;
  if (isNaN(selection) || (!selection)) {
    return;
  } else {
    if (selection.length === 10) {
      myDate = new Date(JSON.parse(window.getSelection().toString() * 1000));
    } else {
      myDate = new Date(JSON.parse(window.getSelection().toString()));
    }
  }


  if (selection.length > 0) {
    showTimestamp(e.clientX, e.clientY, myDate);
  }
}, false);


document.addEventListener('mousedown', function(e) {
  timestamp.style.visibility = 'hidden';
}, false);

function showTimestamp(xPos, yPos, selection) {
  timestamp.innerHTML = selection;
  timestamp.style.top = yPos + 'px';
  timestamp.style.left = xPos + 'px';
{'fraction_non_alphanumeric': 0.16072439162422184, 'fraction_numerical': 0.00792303338992643, 'mean_word_length': 4.577287066246057, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '3767241', 'n_tokens_mistral': 555, 'n_tokens_neox': 529, 'n_words': 107}