<commit_before>var Signup = {
  CHECK_DELAY: 500, // milliseconds
  
  onKeyDown: function(event)
  {
    if (Signup.checking)
    {
      clearTimeout(Signup.checking);
    }
    Signup.checking = setTimeout(Signup.check,Signup.CHECK_DELAY);
  },
  
  check: function(event)
  {
    var current = $F(Signup.nameField);
    if (!Signup.lastChecked || Signup.lastChecked != current)
    {
      Signup.lastChecked = current;
      new Ajax.Request(Signup.availabilityURL, {
        method: 'get',
        parameters: {
          'name': current
        },
        onSuccess: Signup.doCheck
      });
    }
  },
  
  doCheck: function(xhr)
  {
    // Replace the image
    var newAvail = Signup.elementFromText(xhr,'availability');
    var avail = $('availability');
    var parent = avail.parentNode;
    
    parent.insertBefore(newAvail,avail);
    parent.removeChild(avail);
    
    // Replace or insert the message
    var newMessage = Signup.elementFromText(xhr,'unavailable_message');
    var message = $('unavailable_message');
    // The message goes above buttons
    var buttons = $('buttons');
    parent = buttons.parentNode;
    
    if (message) parent.removeChild(message);
    parent.insertBefore(newMessage,buttons);
  },

  // Given an XHR, creates a temp element from the response and  
  // extracts an element with a given id from within it.
  elementFromText: function(xhr,id)
  {
    var temp = new Element('div');
    temp.innerHTML = xhr.responseText;
    var r = temp.select("#" + id);
    if (r.length > 0) return r[0];
    return null;
  },
  
  load: function(event)
  {
    Signup.nameField = $('name');
    Signup.availabilityURL = $('availability').href;
    Event.observe(Signup.nameField,'keydown',Signup.onKeyDown);
  }
}

Event.observe(window, 'load', Signup.load);<commit_msg>Change signup code to use non-ID selectors. This will be resolved with Prototype 1.6.0.3, but couldn't use ID selectors on disconnected nodes with duplicate in-DOM IDs. Stupid.<commit_after>var Signup = {
  CHECK_DELAY: 500, // milliseconds
  
  onKeyDown: function(event)
  {
    if (Signup.checking)
    {
      clearTimeout(Signup.checking);
    }
    Signup.checking = setTimeout(Signup.check,Signup.CHECK_DELAY);
  },
  
  check: function(event)
  {
    var current = $F(Signup.nameField);
    if (!Signup.lastChecked || Signup.lastChecked != current)
    {
      Signup.lastChecked = current;
      new Ajax.Request(Signup.availabilityURL, {
        method: 'get',
        parameters: {
          'name': current
        },
        onSuccess: Signup.doCheck
      });
    }
  },
  
  doCheck: function(xhr)
  {
    // Replace the image
    var newAvail = Signup.elementFromText(xhr,'a');
    var avail = $('availability');
    var parent = avail.parentNode;

    parent.insertBefore(newAvail,avail);
    parent.removeChild(avail);
    
    // Replace or insert the message
    var newMessage = Signup.elementFromText(xhr,'p');
    var message = $('unavailable_message');
    // The message goes above buttons
    var buttons = $('buttons');
    parent = buttons.parentNode;
    
    if (message) parent.removeChild(message);
    parent.insertBefore(newMessage,buttons);
  },

  // Given an XHR, creates a temp element from the response and  
  // extracts an element with a given id from within it.
  elementFromText: function(xhr,selector)
  {
    var temp = new Element('div');
    temp.innerHTML = xhr.responseText;
    var r = temp.select(selector);
    if (r.length > 0) 
    {
      return r[0];
    }
    return null;
  },
  
  load: function(event)
  {
    Signup.nameField = $('name');
    Signup.availabilityURL = $('availability').href;
    Event.observe(Signup.nameField,'keydown',Signup.onKeyDown);
  }
}

Event.observe(window, 'load', Signup.load);
{'fraction_non_alphanumeric': 0.12695054218460725, 'fraction_numerical': 0.0037027241470510446, 'mean_word_length': 2.867075664621677, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, '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': '5276267', 'n_tokens_mistral': 1236, 'n_tokens_neox': 1186, 'n_words': 270}