includes/clientside/static/autofill.js
author Dan
Sun, 22 Jun 2008 18:13:59 -0400
changeset 581 5e8fd89c02ea
parent 550 685e839d934e
child 582 a38876c0793c
permissions -rw-r--r--
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
184
d74ff822acc9 Replaced autocompleting username with a much more efficient algorithm and caching system
Dan
parents:
diff changeset
     1
/**
263
d57af0b0302e Major improvements in the security of the CAPTCHA system (no SQL injection or anything like that); fixed denied form submission due to _af_acting on form object wrongly switched to true
Dan
parents: 184
diff changeset
     2
 * Javascript auto-completion for form fields. This supercedes the code in autocomplete.js for MOZILLA ONLY. It doesn't seem to work real
d57af0b0302e Major improvements in the security of the CAPTCHA system (no SQL injection or anything like that); fixed denied form submission due to _af_acting on form object wrongly switched to true
Dan
parents: 184
diff changeset
     3
 * well with other browsers yet.
184
d74ff822acc9 Replaced autocompleting username with a much more efficient algorithm and caching system
Dan
parents:
diff changeset
     4
 */
581
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
     5
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
     6
// fill schemas
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
     7
var autofill_schemas = {};
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
     8
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
     9
// default, generic schema
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    10
autofill_schemas.generic = {
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    11
  template: '<div id="--ID--_region" spry:region="autofill_region_--ID--" class="tblholder">' + "\n" +
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    12
            '  <table border="0" cellspacing="1" cellpadding="3" style="font-size: smaller;">' + "\n" +
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    13
            '    <tr spry:repeat="autofill_region_--ID--">' + "\n" +
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    14
            '      <td class="row1" spry:suggest="{name}">{name}</td>' + "\n" +
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    15
            '    </tr>' + "\n" +
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    16
            '  </table>' + "\n" +
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    17
            '</div>',
184
d74ff822acc9 Replaced autocompleting username with a much more efficient algorithm and caching system
Dan
parents:
diff changeset
    18
  
581
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    19
  init: function(element, fillclass)
184
d74ff822acc9 Replaced autocompleting username with a much more efficient algorithm and caching system
Dan
parents:
diff changeset
    20
  {
581
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    21
    // setup the dataset
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    22
    window["autofill_region_" + element.id] = new Spry.Data.JSONDataSet(makeUrlNS('Special', 'Autofill', 'type=' + fillclass));
184
d74ff822acc9 Replaced autocompleting username with a much more efficient algorithm and caching system
Dan
parents:
diff changeset
    23
    
581
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    24
    // inject our HTML wrapper
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    25
    var template = this.template.replace(new RegExp('--ID--', 'g'), element.id);
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    26
    var wrapper = element.parentNode; // document.createElement('div');
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    27
    wrapper.id = 'autofill_wrap_' + element.id;
184
d74ff822acc9 Replaced autocompleting username with a much more efficient algorithm and caching system
Dan
parents:
diff changeset
    28
    
581
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    29
    // a bunch of hacks to add a spry wrapper
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    30
    // var el2 = element.cloneNode(false);
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    31
    // wrapper.appendChild(el2);
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    32
    wrapper.innerHTML += template;
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    33
    // insertAfter(element.parentNode, wrapper, element);
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    34
    // element.parentNode.removeChild(element);
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    35
    // element = el2;
184
d74ff822acc9 Replaced autocompleting username with a much more efficient algorithm and caching system
Dan
parents:
diff changeset
    36
    
581
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    37
    var autosuggest = new Spry.Widget.AutoSuggest("autofill_wrap_" + element.id, element.id + '_region', window["autofill_region_" + element.id], 'name', {loadFromServer: true, urlParam: 'userinput', hoverSuggestClass: 'row2', minCharsType: 3});
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    38
  }
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    39
};
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    40
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    41
function autofill_init_element(element, params)
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    42
{
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    43
  if ( element.parentNode.id.match(/^autofill_wrap_/) )
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    44
    return false;
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    45
  
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    46
  params = params || {};
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    47
  // assign an ID if it doesn't have one yet
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    48
  if ( !element.id )
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    49
  {
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    50
    element.id = 'autofill_' + Math.floor(Math.random() * 100000);
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    51
  }
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    52
  var id = element.id;
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    53
  
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    54
  // get the fill type
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    55
  var fillclass = element.className;
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    56
  fillclass = fillclass.split(' ');
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    57
  fillclass = fillclass[1];
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    58
  
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    59
  var schema = ( autofill_schemas[fillclass] ) ? autofill_schemas[fillclass] : autofill_schemas['generic'];
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    60
  if ( typeof(schema.init) != 'function' )
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    61
  {
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    62
    schema.init = autofill_schemas.generic.init;
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    63
  }
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    64
  schema.init(element, fillclass, params);
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    65
  
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    66
  element.af_initted = true;
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    67
}
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    68
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    69
var autofill_onload = function()
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    70
{
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    71
  autofill_schemas.username = {
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    72
    template: '<div id="--ID--_region" spry:region="autofill_region_--ID--" class="tblholder">' + "\n" +
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    73
              '  <table border="0" cellspacing="1" cellpadding="3" style="font-size: smaller;">' + "\n" +
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    74
              '    <tr>' + "\n" +
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    75
              '      <th>' + $lang.get('user_autofill_heading_suggestions') + '</th>' + "\n" +
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    76
              '    </tr>' + "\n" +
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    77
              '    <tr spry:repeat="autofill_region_--ID--">' + "\n" +
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    78
              '      <td class="row1" spry:suggest="{name}">{name_highlight}<br /><small style="{rank_style}">{rank_title}</small></td>' + "\n" +
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    79
              '    </tr>' + "\n" +
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    80
              '  </table>' + "\n" +
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    81
              '</div>',
184
d74ff822acc9 Replaced autocompleting username with a much more efficient algorithm and caching system
Dan
parents:
diff changeset
    82
    
581
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    83
    init: function(element, fillclass, params)
184
d74ff822acc9 Replaced autocompleting username with a much more efficient algorithm and caching system
Dan
parents:
diff changeset
    84
    {
581
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    85
      // calculate positions before spry f***s everything up
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    86
      var top = $dynano(element).Top() + $dynano(element).Height() - 10; // tblholder has 10px top margin
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    87
      var left = $dynano(element).Left();
184
d74ff822acc9 Replaced autocompleting username with a much more efficient algorithm and caching system
Dan
parents:
diff changeset
    88
      
581
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    89
      var allow_anon = ( params.allow_anon ) ? '1' : '0';
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    90
      // setup the dataset
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    91
      window["autofill_region_" + element.id] = new Spry.Data.JSONDataSet(makeUrlNS('Special', 'Autofill', 'type=' + fillclass + '&allow_anon' + allow_anon));
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    92
      Spry.Data.initRegions(document.body);
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    93
      (window["autofill_region_" + element.id]).loadData();
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    94
      
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    95
      // inject our HTML wrapper
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    96
      var template = this.template.replace(new RegExp('--ID--', 'g'), element.id);
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    97
      var wrapper = element.parentNode; // document.createElement('div');
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    98
      wrapper.id = 'autofill_wrap_' + element.id;
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    99
      
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
   100
      // a bunch of hacks to add a spry wrapper
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
   101
      wrapper.innerHTML = template + wrapper.innerHTML;
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
   102
      
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
   103
      var autosuggest = new Spry.Widget.AutoSuggest("autofill_wrap_" + element.id, element.id + '_region', window["autofill_region_" + element.id], 'name', {loadFromServer: true, urlParam: 'userinput', hoverSuggestClass: 'row2', minCharsType: 3});
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
   104
      var regiondiv = document.getElementById(element.id + '_region');
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
   105
      regiondiv.style.position = 'absolute';
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
   106
      regiondiv.style.top = top + 'px';
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
   107
      regiondiv.style.left = left + 'px';
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
   108
    }
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
   109
  };
184
d74ff822acc9 Replaced autocompleting username with a much more efficient algorithm and caching system
Dan
parents:
diff changeset
   110
  
581
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
   111
  autofill_schemas.page = {
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
   112
    template: '<div id="--ID--_region" spry:region="autofill_region_--ID--" class="tblholder">' + "\n" +
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
   113
              '  <table border="0" cellspacing="1" cellpadding="3" style="font-size: smaller;">' + "\n" +
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
   114
              '    <tr>' + "\n" +
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
   115
              '      <th colspan="2">' + $lang.get('page_autosuggest_heading') + '</th>' + "\n" +
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
   116
              '    </tr>' + "\n" +
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
   117
              '    <tr spry:repeat="autofill_region_--ID--">' + "\n" +
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
   118
              '      <td class="row1" spry:suggest="{page_id}">{pid_highlight}<br /><small>{name_highlight}</small></td>' + "\n" +
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
   119
              '    </tr>' + "\n" +
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
   120
              '  </table>' + "\n" +
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
   121
              '</div>'
184
d74ff822acc9 Replaced autocompleting username with a much more efficient algorithm and caching system
Dan
parents:
diff changeset
   122
  }
d74ff822acc9 Replaced autocompleting username with a much more efficient algorithm and caching system
Dan
parents:
diff changeset
   123
  
581
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
   124
  var inputs = document.getElementsByClassName('input', 'autofill');
184
d74ff822acc9 Replaced autocompleting username with a much more efficient algorithm and caching system
Dan
parents:
diff changeset
   125
  
581
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
   126
  for ( var i = 0; i < inputs.length; i++ )
184
d74ff822acc9 Replaced autocompleting username with a much more efficient algorithm and caching system
Dan
parents:
diff changeset
   127
  {
581
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
   128
    autofill_init_element(inputs[i]);
184
d74ff822acc9 Replaced autocompleting username with a much more efficient algorithm and caching system
Dan
parents:
diff changeset
   129
  }
581
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
   130
}
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
   131
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
   132
addOnloadHook(autofill_onload);
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
   133
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
   134
function AutofillUsername(element, event, allowanon)
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
   135
{
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
   136
  element.onkeyup = element.onkeydown = element.onkeypress = function(e) {};
184
d74ff822acc9 Replaced autocompleting username with a much more efficient algorithm and caching system
Dan
parents:
diff changeset
   137
  
581
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
   138
  element.className = 'autofill username';
184
d74ff822acc9 Replaced autocompleting username with a much more efficient algorithm and caching system
Dan
parents:
diff changeset
   139
  
581
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
   140
  allowanon = allowanon ? true : false;
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
   141
  autofill_init_element(element, {
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
   142
      allow_anon: allowanon
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
   143
    });
184
d74ff822acc9 Replaced autocompleting username with a much more efficient algorithm and caching system
Dan
parents:
diff changeset
   144
}
d74ff822acc9 Replaced autocompleting username with a much more efficient algorithm and caching system
Dan
parents:
diff changeset
   145
d74ff822acc9 Replaced autocompleting username with a much more efficient algorithm and caching system
Dan
parents:
diff changeset
   146
function findParentForm(o)
d74ff822acc9 Replaced autocompleting username with a much more efficient algorithm and caching system
Dan
parents:
diff changeset
   147
{
d74ff822acc9 Replaced autocompleting username with a much more efficient algorithm and caching system
Dan
parents:
diff changeset
   148
  if ( o.tagName == 'FORM' )
d74ff822acc9 Replaced autocompleting username with a much more efficient algorithm and caching system
Dan
parents:
diff changeset
   149
    return o;
d74ff822acc9 Replaced autocompleting username with a much more efficient algorithm and caching system
Dan
parents:
diff changeset
   150
  while(true)
d74ff822acc9 Replaced autocompleting username with a much more efficient algorithm and caching system
Dan
parents:
diff changeset
   151
  {
d74ff822acc9 Replaced autocompleting username with a much more efficient algorithm and caching system
Dan
parents:
diff changeset
   152
    o = o.parentNode;
d74ff822acc9 Replaced autocompleting username with a much more efficient algorithm and caching system
Dan
parents:
diff changeset
   153
    if ( !o )
d74ff822acc9 Replaced autocompleting username with a much more efficient algorithm and caching system
Dan
parents:
diff changeset
   154
      return false;
d74ff822acc9 Replaced autocompleting username with a much more efficient algorithm and caching system
Dan
parents:
diff changeset
   155
    if ( o.tagName == 'FORM' )
d74ff822acc9 Replaced autocompleting username with a much more efficient algorithm and caching system
Dan
parents:
diff changeset
   156
      return o;
d74ff822acc9 Replaced autocompleting username with a much more efficient algorithm and caching system
Dan
parents:
diff changeset
   157
  }
d74ff822acc9 Replaced autocompleting username with a much more efficient algorithm and caching system
Dan
parents:
diff changeset
   158
  return false;
d74ff822acc9 Replaced autocompleting username with a much more efficient algorithm and caching system
Dan
parents:
diff changeset
   159
}
d74ff822acc9 Replaced autocompleting username with a much more efficient algorithm and caching system
Dan
parents:
diff changeset
   160