includes/clientside/static/autofill.js
author Dan
Wed, 22 Oct 2008 10:49:15 -0400
changeset 717 236360cf79a0
parent 704 077887be639d
child 747 cffe13960330
permissions -rw-r--r--
Made template inclusion wikisyntax fully MediaWiki-compatible
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
/**
699
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
     2
 * Javascript auto-completion for form fields. jQuery based in 1.1.5.
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
     3
 * Different types of auto-completion fields can be defined (e.g. with different data sets). For each one, a schema
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
     4
 * can be created describing how to draw each row.
184
d74ff822acc9 Replaced autocompleting username with a much more efficient algorithm and caching system
Dan
parents:
diff changeset
     5
 */
581
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
     6
701
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
     7
var autofill_schemas = window.autofill_schemas || {};
581
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
     8
699
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
     9
/**
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
    10
 * SCHEMA - GENERIC
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
    11
 */
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
    12
581
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    13
autofill_schemas.generic = {
699
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
    14
  init: function(element, fillclass, params)
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
    15
  {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
    16
    $(element).autocomplete(makeUrlNS('Special', 'Autofill', 'type=' + fillclass) + '&userinput=', {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
    17
        minChars: 3
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
    18
    });
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
    19
  }
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
    20
}
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
    21
701
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
    22
/**
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
    23
 * SCHEMA - USERNAME
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
    24
 */
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
    25
699
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
    26
autofill_schemas.username = {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
    27
  init: function(element, fillclass, params)
184
d74ff822acc9 Replaced autocompleting username with a much more efficient algorithm and caching system
Dan
parents:
diff changeset
    28
  {
701
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
    29
    params = params || {};
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
    30
    var allow_anon = params.allow_anon ? '1' : '0';
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
    31
    $(element).autocomplete(makeUrlNS('Special', 'Autofill', 'type=' + fillclass + '&allow_anon=' + allow_anon) + '&userinput=', {
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
    32
        minChars: 3,
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
    33
        formatItem: function(row, _, __)
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
    34
        {
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
    35
          var html = row.name_highlight + ' – ';
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
    36
          html += '<span style="' + row.rank_style + '">' + row.rank_title + '</span>';
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
    37
          return html;
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
    38
        },
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
    39
        tableHeader: '<tr><th>' + $lang.get('user_autofill_heading_suggestions') + '</th></tr>',
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
    40
        showWhenNoResults: true,
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
    41
        noResultsHTML: '<tr><td class="row1" style="font-size: smaller;">' + $lang.get('user_autofill_msg_no_suggestions') + '</td></tr>',
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
    42
    });
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
    43
  }
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
    44
}
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
    45
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
    46
autofill_schemas.page = {
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
    47
  init: function(element, fillclass, params)
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
    48
  {
699
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
    49
    $(element).autocomplete(makeUrlNS('Special', 'Autofill', 'type=' + fillclass) + '&userinput=', {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
    50
        minChars: 3,
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
    51
        formatItem: function(row, _, __)
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
    52
        {
701
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
    53
          var html = '<u>' + row.name_highlight + '</u>';
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
    54
          html += ' &ndash; ' + row.pid_highlight;
699
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
    55
          return html;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
    56
        },
701
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
    57
        showWhenNoResults: true,
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
    58
        noResultsHTML: '<tr><td class="row1" style="font-size: smaller;">' + $lang.get('user_autofill_msg_no_suggestions') + '</td></tr>',
699
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
    59
    });
581
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    60
  }
699
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
    61
}
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
    62
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
    63
window.autofill_onload = function()
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
    64
{
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
    65
  if ( this.loaded )
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
    66
  {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
    67
    return true;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
    68
  }
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
    69
  
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
    70
  var inputs = document.getElementsByClassName('input', 'autofill');
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
    71
  
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
    72
  if ( inputs.length > 0 )
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
    73
  {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
    74
    // we have at least one input that needs to be made an autofill element.
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
    75
    // is spry data loaded?
701
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
    76
    load_component('l10n');
699
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
    77
  }
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
    78
  
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
    79
  this.loaded = true;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
    80
  
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
    81
  for ( var i = 0; i < inputs.length; i++ )
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
    82
  {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
    83
    autofill_init_element(inputs[i]);
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
    84
  }
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
    85
}
581
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    86
701
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
    87
window.autofill_init_element = function(element, params)
581
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    88
{
701
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
    89
  if ( element.af_initted )
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
    90
    return false;
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
    91
  
581
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    92
  params = params || {};
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    93
  // 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
    94
  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
    95
  {
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    96
    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
    97
  }
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
    98
  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
    99
  
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
   100
  // 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
   101
  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
   102
  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
   103
  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
   104
  
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
   105
  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
   106
  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
   107
  {
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
   108
    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
   109
  }
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
   110
  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
   111
  
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
   112
  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
   113
}
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
   114
701
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
   115
window.AutofillUsername = function(el, allow_anon)
581
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
   116
{
699
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   117
  el.onkeyup = null;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   118
  el.className = 'autofill username';
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   119
  autofill_init_element(el, { allow_anon: allow_anon });
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   120
}
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   121
701
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
   122
window.AutofillPage = function(el)
699
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   123
{
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   124
  el.onkeyup = null;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   125
  el.className = 'autofill page';
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   126
  autofill_init_element(el, {});
581
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
   127
}
5e8fd89c02ea Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents: 550
diff changeset
   128
699
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   129
addOnloadHook(function()
184
d74ff822acc9 Replaced autocompleting username with a much more efficient algorithm and caching system
Dan
parents:
diff changeset
   130
  {
701
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
   131
    load_component('l10n');
699
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   132
    load_component('jquery');
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   133
    load_component('jquery-ui');
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   134
    
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   135
    if ( !window.jQuery )
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   136
    {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   137
      throw('jQuery didn\'t load properly. Aborting auto-complete init.');
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   138
    }
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   139
    
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   140
    jQuery.autocomplete = function(input, options) {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   141
      // Create a link to self
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   142
      var me = this;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   143
    
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   144
      // Create jQuery object for input element
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   145
      var $input = $(input).attr("autocomplete", "off");
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   146
    
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   147
      // Apply inputClass if necessary
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   148
      if (options.inputClass) {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   149
        $input.addClass(options.inputClass);
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   150
      }
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   151
    
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   152
      // Create results
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   153
      var results = document.createElement("div");
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   154
      $(results).addClass('tblholder').css('z-index', getHighestZ() + 1).css('margin-top', 0);
704
077887be639d More work on auto-completion - it auto-scrolls now and limits result divs to 300px height
Dan
parents: 701
diff changeset
   155
      $(results).css('clip', 'rect(0px,auto,auto,0px)').css('overflow', 'auto').css('max-height', '300px');
699
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   156
    
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   157
      // Create jQuery object for results
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   158
      // var $results = $(results);
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   159
      var $results = $(results).hide().addClass(options.resultsClass).css("position", "absolute");
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   160
      if( options.width > 0 ) {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   161
        $results.css("width", options.width);
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   162
      }
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   163
    
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   164
      // Add to body element
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   165
      $("body").append(results);
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   166
    
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   167
      input.autocompleter = me;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   168
    
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   169
      var timeout = null;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   170
      var prev = "";
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   171
      var active = -1;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   172
      var cache = {};
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   173
      var keyb = false;
701
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
   174
      // hasFocus was false by default, see if making it true helps
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
   175
      var hasFocus = true;
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
   176
      var hasNoResults = false;
699
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   177
      var lastKeyPressCode = null;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   178
      var mouseDownOnSelect = false;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   179
      var hidingResults = false;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   180
    
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   181
      // flush cache
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   182
      function flushCache(){
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   183
        cache = {};
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   184
        cache.data = {};
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   185
        cache.length = 0;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   186
      };
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   187
    
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   188
      // flush cache
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   189
      flushCache();
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   190
    
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   191
      // if there is a data array supplied
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   192
      if( options.data != null ){
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   193
        var sFirstChar = "", stMatchSets = {}, row = [];
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   194
    
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   195
        // no url was specified, we need to adjust the cache length to make sure it fits the local data store
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   196
        if( typeof options.url != "string" ) {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   197
          options.cacheLength = 1;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   198
        }
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   199
    
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   200
        // loop through the array and create a lookup structure
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   201
        for( var i=0; i < options.data.length; i++ ){
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   202
          // if row is a string, make an array otherwise just reference the array
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   203
          row = ((typeof options.data[i] == "string") ? [options.data[i]] : options.data[i]);
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   204
    
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   205
          // if the length is zero, don't add to list
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   206
          if( row[0].length > 0 ){
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   207
            // get the first character
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   208
            sFirstChar = row[0].substring(0, 1).toLowerCase();
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   209
            // if no lookup array for this character exists, look it up now
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   210
            if( !stMatchSets[sFirstChar] ) stMatchSets[sFirstChar] = [];
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   211
            // if the match is a string
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   212
            stMatchSets[sFirstChar].push(row);
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   213
          }
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   214
        }
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   215
    
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   216
        // add the data items to the cache
701
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
   217
        if ( options.cacheLength )
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
   218
        {
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
   219
          for( var k in stMatchSets ) {
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
   220
            // increase the cache size
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
   221
            options.cacheLength++;
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
   222
            // add to the cache
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
   223
            addToCache(k, stMatchSets[k]);
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
   224
          }
699
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   225
        }
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   226
      }
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   227
    
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   228
      $input
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   229
      .keydown(function(e) {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   230
        // track last key pressed
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   231
        lastKeyPressCode = e.keyCode;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   232
        switch(e.keyCode) {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   233
          case 38: // up
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   234
            e.preventDefault();
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   235
            moveSelect(-1);
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   236
            break;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   237
          case 40: // down
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   238
            e.preventDefault();
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   239
            moveSelect(1);
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   240
            break;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   241
          case 9:  // tab
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   242
          case 13: // return
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   243
            if( selectCurrent() ){
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   244
              // make sure to blur off the current field
704
077887be639d More work on auto-completion - it auto-scrolls now and limits result divs to 300px height
Dan
parents: 701
diff changeset
   245
              // (Enano edit - why do we want this, again?)
077887be639d More work on auto-completion - it auto-scrolls now and limits result divs to 300px height
Dan
parents: 701
diff changeset
   246
              // $input.get(0).blur();
699
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   247
              e.preventDefault();
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   248
            }
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   249
            break;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   250
          default:
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   251
            active = -1;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   252
            if (timeout) clearTimeout(timeout);
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   253
            timeout = setTimeout(function(){onChange();}, options.delay);
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   254
            break;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   255
        }
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   256
      })
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   257
      .focus(function(){
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   258
        // track whether the field has focus, we shouldn't process any results if the field no longer has focus
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   259
        hasFocus = true;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   260
      })
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   261
      .blur(function() {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   262
        // track whether the field has focus
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   263
        hasFocus = false;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   264
        if (!mouseDownOnSelect) {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   265
          hideResults();
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   266
        }
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   267
      });
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   268
    
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   269
      hideResultsNow();
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   270
    
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   271
      function onChange() {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   272
        // ignore if the following keys are pressed: [del] [shift] [capslock]
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   273
        if( lastKeyPressCode == 46 || (lastKeyPressCode > 8 && lastKeyPressCode < 32) ) return $results.hide();
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   274
        var v = $input.val();
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   275
        if (v == prev) return;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   276
        prev = v;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   277
        if (v.length >= options.minChars) {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   278
          $input.addClass(options.loadingClass);
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   279
          requestData(v);
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   280
        } else {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   281
          $input.removeClass(options.loadingClass);
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   282
          $results.hide();
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   283
        }
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   284
      };
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   285
    
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   286
      function moveSelect(step) {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   287
    
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   288
        var lis = $("td", results);
701
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
   289
        if (!lis || hasNoResults) return;
699
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   290
    
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   291
        active += step;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   292
    
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   293
        if (active < 0) {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   294
          active = 0;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   295
        } else if (active >= lis.size()) {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   296
          active = lis.size() - 1;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   297
        }
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   298
    
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   299
        lis.removeClass("row2");
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   300
    
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   301
        $(lis[active]).addClass("row2");
704
077887be639d More work on auto-completion - it auto-scrolls now and limits result divs to 300px height
Dan
parents: 701
diff changeset
   302
        
077887be639d More work on auto-completion - it auto-scrolls now and limits result divs to 300px height
Dan
parents: 701
diff changeset
   303
        // scroll the results div
077887be639d More work on auto-completion - it auto-scrolls now and limits result divs to 300px height
Dan
parents: 701
diff changeset
   304
        // are we going up or down?
077887be639d More work on auto-completion - it auto-scrolls now and limits result divs to 300px height
Dan
parents: 701
diff changeset
   305
        var td_top = $dynano(lis[active]).Top() - $dynano(results).Top();
077887be639d More work on auto-completion - it auto-scrolls now and limits result divs to 300px height
Dan
parents: 701
diff changeset
   306
        var td_height = $dynano(lis[active]).Height();
077887be639d More work on auto-completion - it auto-scrolls now and limits result divs to 300px height
Dan
parents: 701
diff changeset
   307
        var td_bottom = td_top + td_height;
077887be639d More work on auto-completion - it auto-scrolls now and limits result divs to 300px height
Dan
parents: 701
diff changeset
   308
        var visibleTopBoundary = getScrollOffset(results);
077887be639d More work on auto-completion - it auto-scrolls now and limits result divs to 300px height
Dan
parents: 701
diff changeset
   309
        var results_height = $dynano(results).Height();
077887be639d More work on auto-completion - it auto-scrolls now and limits result divs to 300px height
Dan
parents: 701
diff changeset
   310
        var visibleBottomBoundary = visibleTopBoundary + results_height;
077887be639d More work on auto-completion - it auto-scrolls now and limits result divs to 300px height
Dan
parents: 701
diff changeset
   311
        var scrollTo = false;
077887be639d More work on auto-completion - it auto-scrolls now and limits result divs to 300px height
Dan
parents: 701
diff changeset
   312
        console.debug('td top = %d, td height = %d, td bottom = %d, visibleTopBoundary = %d, results_height = %d, visibleBottomBoundary = %d, step = %d',
077887be639d More work on auto-completion - it auto-scrolls now and limits result divs to 300px height
Dan
parents: 701
diff changeset
   313
                       td_top, td_height, td_bottom, visibleTopBoundary, results_height, visibleBottomBoundary, step);
077887be639d More work on auto-completion - it auto-scrolls now and limits result divs to 300px height
Dan
parents: 701
diff changeset
   314
        if ( td_top < visibleTopBoundary && step < 0 )
077887be639d More work on auto-completion - it auto-scrolls now and limits result divs to 300px height
Dan
parents: 701
diff changeset
   315
        {
077887be639d More work on auto-completion - it auto-scrolls now and limits result divs to 300px height
Dan
parents: 701
diff changeset
   316
          // going up: scroll the results div to just higher than the result we're trying to see
077887be639d More work on auto-completion - it auto-scrolls now and limits result divs to 300px height
Dan
parents: 701
diff changeset
   317
          scrollTo = td_top - 7;
077887be639d More work on auto-completion - it auto-scrolls now and limits result divs to 300px height
Dan
parents: 701
diff changeset
   318
        }
077887be639d More work on auto-completion - it auto-scrolls now and limits result divs to 300px height
Dan
parents: 701
diff changeset
   319
        else if ( td_bottom > visibleBottomBoundary && step > 0 )
077887be639d More work on auto-completion - it auto-scrolls now and limits result divs to 300px height
Dan
parents: 701
diff changeset
   320
        {
077887be639d More work on auto-completion - it auto-scrolls now and limits result divs to 300px height
Dan
parents: 701
diff changeset
   321
          // going down is a little harder, we want the result to be at the bottom
077887be639d More work on auto-completion - it auto-scrolls now and limits result divs to 300px height
Dan
parents: 701
diff changeset
   322
          scrollTo = td_top - results_height + td_height + 7;
077887be639d More work on auto-completion - it auto-scrolls now and limits result divs to 300px height
Dan
parents: 701
diff changeset
   323
        }
077887be639d More work on auto-completion - it auto-scrolls now and limits result divs to 300px height
Dan
parents: 701
diff changeset
   324
        if ( scrollTo )
077887be639d More work on auto-completion - it auto-scrolls now and limits result divs to 300px height
Dan
parents: 701
diff changeset
   325
        {
077887be639d More work on auto-completion - it auto-scrolls now and limits result divs to 300px height
Dan
parents: 701
diff changeset
   326
          console.debug('scrolling the results div to %d', scrollTo);
077887be639d More work on auto-completion - it auto-scrolls now and limits result divs to 300px height
Dan
parents: 701
diff changeset
   327
          results.scrollTop = scrollTo;
077887be639d More work on auto-completion - it auto-scrolls now and limits result divs to 300px height
Dan
parents: 701
diff changeset
   328
        }
699
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   329
    
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   330
        // Weird behaviour in IE
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   331
        // if (lis[active] && lis[active].scrollIntoView) {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   332
        // 	lis[active].scrollIntoView(false);
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   333
        // }
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   334
    
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   335
      };
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   336
    
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   337
      function selectCurrent() {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   338
        var li = $("td.row2", results)[0];
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   339
        if (!li) {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   340
          var $li = $("td", results);
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   341
          if (options.selectOnly) {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   342
            if ($li.length == 1) li = $li[0];
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   343
          } else if (options.selectFirst) {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   344
            li = $li[0];
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   345
          }
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   346
        }
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   347
        if (li) {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   348
          selectItem(li);
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   349
          return true;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   350
        } else {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   351
          return false;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   352
        }
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   353
      };
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   354
    
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   355
      function selectItem(li) {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   356
        if (!li) {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   357
          li = document.createElement("li");
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   358
          li.extra = [];
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   359
          li.selectValue = "";
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   360
        }
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   361
        var v = $.trim(li.selectValue ? li.selectValue : li.innerHTML);
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   362
        input.lastSelected = v;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   363
        prev = v;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   364
        $results.html("");
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   365
        $input.val(v);
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   366
        hideResultsNow();
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   367
        if (options.onItemSelect) {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   368
          setTimeout(function() { options.onItemSelect(li) }, 1);
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   369
        }
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   370
      };
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   371
    
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   372
      // selects a portion of the input string
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   373
      function createSelection(start, end){
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   374
        // get a reference to the input element
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   375
        var field = $input.get(0);
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   376
        if( field.createTextRange ){
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   377
          var selRange = field.createTextRange();
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   378
          selRange.collapse(true);
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   379
          selRange.moveStart("character", start);
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   380
          selRange.moveEnd("character", end);
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   381
          selRange.select();
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   382
        } else if( field.setSelectionRange ){
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   383
          field.setSelectionRange(start, end);
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   384
        } else {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   385
          if( field.selectionStart ){
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   386
            field.selectionStart = start;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   387
            field.selectionEnd = end;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   388
          }
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   389
        }
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   390
        field.focus();
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   391
      };
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   392
    
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   393
      // fills in the input box w/the first match (assumed to be the best match)
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   394
      function autoFill(sValue){
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   395
        // if the last user key pressed was backspace, don't autofill
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   396
        if( lastKeyPressCode != 8 ){
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   397
          // fill in the value (keep the case the user has typed)
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   398
          $input.val($input.val() + sValue.substring(prev.length));
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   399
          // select the portion of the value not typed by the user (so the next character will erase)
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   400
          createSelection(prev.length, sValue.length);
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   401
        }
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   402
      };
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   403
    
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   404
      function showResults() {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   405
        // get the position of the input field right now (in case the DOM is shifted)
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   406
        var pos = findPos(input);
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   407
        // either use the specified width, or autocalculate based on form element
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   408
        var iWidth = (options.width > 0) ? options.width : $input.width();
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   409
        // reposition
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   410
        $results.css({
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   411
          width: parseInt(iWidth) + "px",
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   412
          top: (pos.y + input.offsetHeight) + "px",
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   413
          left: pos.x + "px"
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   414
        });
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   415
        if ( !$results.is(":visible") )
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   416
        {
701
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
   417
          $results.show("blind", {}, 200);
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
   418
        }
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
   419
        else
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
   420
        {
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
   421
          $results.show();
699
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   422
        }
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   423
      };
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   424
    
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   425
      function hideResults() {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   426
        if (timeout) clearTimeout(timeout);
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   427
        timeout = setTimeout(hideResultsNow, 200);
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   428
      };
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   429
    
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   430
      function hideResultsNow() {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   431
        if (hidingResults) {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   432
          return;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   433
        }
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   434
        hidingResults = true;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   435
      
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   436
        if (timeout) {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   437
          clearTimeout(timeout);
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   438
        }
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   439
        
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   440
        var v = $input.removeClass(options.loadingClass).val();
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   441
        
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   442
        if ($results.is(":visible")) {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   443
          $results.hide();
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   444
        }
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   445
        
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   446
        if (options.mustMatch) {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   447
          if (!input.lastSelected || input.lastSelected != v) {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   448
            selectItem(null);
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   449
          }
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   450
        }
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   451
    
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   452
        hidingResults = false;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   453
      };
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   454
    
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   455
      function receiveData(q, data) {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   456
        if (data) {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   457
          $input.removeClass(options.loadingClass);
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   458
          results.innerHTML = "";
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   459
    
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   460
          // if the field no longer has focus or if there are no matches, do not display the drop down
701
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
   461
          if( !hasFocus )
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
   462
          {
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
   463
            return hideResultsNow();
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
   464
          }
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
   465
          if ( data.length == 0 && !options.showWhenNoResults )
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
   466
          {
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
   467
            return hideResultsNow();
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
   468
          }
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
   469
          hasNoResults = false;
699
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   470
    
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   471
          if ($.browser.msie) {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   472
            // we put a styled iframe behind the calendar so HTML SELECT elements don't show through
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   473
            $results.append(document.createElement('iframe'));
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   474
          }
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   475
          results.appendChild(dataToDom(data));
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   476
          // autofill in the complete box w/the first match as long as the user hasn't entered in more data
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   477
          if( options.autoFill && ($input.val().toLowerCase() == q.toLowerCase()) ) autoFill(data[0][0]);
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   478
          showResults();
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   479
        } else {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   480
          hideResultsNow();
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   481
        }
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   482
      };
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   483
    
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   484
      function parseData(data) {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   485
        if (!data) return null;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   486
        var parsed = parseJSON(data);
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   487
        return parsed;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   488
      };
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   489
    
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   490
      function dataToDom(data) {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   491
        var ul = document.createElement("table");
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   492
        $(ul).attr("border", "0").attr("cellspacing", "1").attr("cellpadding", "3");
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   493
        var num = data.length;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   494
        
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   495
        if ( options.tableHeader )
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   496
        {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   497
          ul.innerHTML = options.tableHeader;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   498
        }
701
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
   499
        
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
   500
        if ( num == 0 )
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
   501
        {
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
   502
          // not showing any results
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
   503
          if ( options.noResultsHTML )
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
   504
            ul.innerHTML += options.noResultsHTML;
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
   505
          
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
   506
          hasNoResults = true;
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
   507
          return ul;
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
   508
        }
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
   509
        
699
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   510
        // limited results to a max number
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   511
        if( (options.maxItemsToShow > 0) && (options.maxItemsToShow < num) ) num = options.maxItemsToShow;
701
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
   512
        
699
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   513
        for (var i=0; i < num; i++) {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   514
          var row = data[i];
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   515
          if (!row) continue;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   516
          
701
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
   517
          if ( typeof(row[0]) != 'string' )
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
   518
          {
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
   519
            // last ditch resort if it's a 1.1.4 autocomplete plugin that doesn't provide an automatic result.
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
   520
            // hopefully this doesn't slow it down a lot.
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
   521
            for ( var i in row )
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
   522
            {
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
   523
              if ( i == "0" || i == 0 )
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
   524
                break;
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
   525
              row[0] = row[i];
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
   526
              break;
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
   527
            }
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
   528
          }
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
   529
          
699
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   530
          var li = document.createElement("tr");
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   531
          var td = document.createElement("td");
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   532
          td.selectValue = row[0];
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   533
          $(td).addClass('row1');
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   534
          $(td).css("font-size", "smaller");
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   535
          
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   536
          if ( options.formatItem )
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   537
          {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   538
            td.innerHTML = options.formatItem(row, i, num);
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   539
          }
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   540
          else
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   541
          {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   542
            td.innerHTML = row[0];
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   543
          }
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   544
          li.appendChild(td);
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   545
          ul.appendChild(li);
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   546
          
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   547
          $(td).hover(
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   548
            function() { $("tr", ul).removeClass("row2"); $(this).addClass("row2"); active = $("tr", ul).indexOf($(this).get(0)); },
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   549
            function() { $(this).removeClass("row2"); }
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   550
          ).click(function(e) { 
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   551
            e.preventDefault();
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   552
            e.stopPropagation();
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   553
            selectItem(this)
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   554
          });
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   555
        }
701
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
   556
        
699
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   557
        $(ul).mousedown(function() {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   558
          mouseDownOnSelect = true;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   559
        }).mouseup(function() {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   560
          mouseDownOnSelect = false;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   561
        });
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   562
        return ul;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   563
      };
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   564
    
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   565
      function requestData(q) {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   566
        if (!options.matchCase) q = q.toLowerCase();
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   567
        var data = options.cacheLength ? loadFromCache(q) : null;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   568
        // recieve the cached data
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   569
        if (data) {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   570
          receiveData(q, data);
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   571
        // if an AJAX url has been supplied, try loading the data now
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   572
        } else if( (typeof options.url == "string") && (options.url.length > 0) ){
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   573
          $.get(makeUrl(q), function(data) {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   574
            data = parseData(data);
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   575
            addToCache(q, data);
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   576
            receiveData(q, data);
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   577
          });
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   578
        // if there's been no data found, remove the loading class
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   579
        } else {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   580
          $input.removeClass(options.loadingClass);
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   581
        }
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   582
      };
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   583
    
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   584
      function makeUrl(q) {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   585
        var sep = options.url.indexOf('?') == -1 ? '?' : '&'; 
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   586
        var url = options.url + encodeURI(q);
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   587
        for (var i in options.extraParams) {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   588
          url += "&" + i + "=" + encodeURI(options.extraParams[i]);
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   589
        }
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   590
        return url;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   591
      };
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   592
    
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   593
      function loadFromCache(q) {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   594
        if (!q) return null;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   595
        if (cache.data[q]) return cache.data[q];
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   596
        if (options.matchSubset) {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   597
          for (var i = q.length - 1; i >= options.minChars; i--) {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   598
            var qs = q.substr(0, i);
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   599
            var c = cache.data[qs];
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   600
            if (c) {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   601
              var csub = [];
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   602
              for (var j = 0; j < c.length; j++) {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   603
                var x = c[j];
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   604
                var x0 = x[0];
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   605
                if (matchSubset(x0, q)) {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   606
                  csub[csub.length] = x;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   607
                }
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   608
              }
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   609
              return csub;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   610
            }
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   611
          }
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   612
        }
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   613
        return null;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   614
      };
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   615
    
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   616
      function matchSubset(s, sub) {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   617
        if (!options.matchCase) s = s.toLowerCase();
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   618
        var i = s.indexOf(sub);
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   619
        if (i == -1) return false;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   620
        return i == 0 || options.matchContains;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   621
      };
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   622
    
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   623
      this.flushCache = function() {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   624
        flushCache();
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   625
      };
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   626
    
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   627
      this.setExtraParams = function(p) {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   628
        options.extraParams = p;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   629
      };
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   630
    
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   631
      this.findValue = function(){
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   632
        var q = $input.val();
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   633
    
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   634
        if (!options.matchCase) q = q.toLowerCase();
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   635
        var data = options.cacheLength ? loadFromCache(q) : null;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   636
        if (data) {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   637
          findValueCallback(q, data);
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   638
        } else if( (typeof options.url == "string") && (options.url.length > 0) ){
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   639
          $.get(makeUrl(q), function(data) {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   640
            data = parseData(data)
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   641
            addToCache(q, data);
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   642
            findValueCallback(q, data);
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   643
          });
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   644
        } else {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   645
          // no matches
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   646
          findValueCallback(q, null);
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   647
        }
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   648
      }
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   649
    
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   650
      function findValueCallback(q, data){
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   651
        if (data) $input.removeClass(options.loadingClass);
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   652
    
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   653
        var num = (data) ? data.length : 0;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   654
        var li = null;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   655
    
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   656
        for (var i=0; i < num; i++) {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   657
          var row = data[i];
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   658
    
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   659
          if( row[0].toLowerCase() == q.toLowerCase() ){
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   660
            li = document.createElement("li");
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   661
            if (options.formatItem) {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   662
              li.innerHTML = options.formatItem(row, i, num);
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   663
              li.selectValue = row[0];
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   664
            } else {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   665
              li.innerHTML = row[0];
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   666
              li.selectValue = row[0];
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   667
            }
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   668
            var extra = null;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   669
            if( row.length > 1 ){
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   670
              extra = [];
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   671
              for (var j=1; j < row.length; j++) {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   672
                extra[extra.length] = row[j];
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   673
              }
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   674
            }
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   675
            li.extra = extra;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   676
          }
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   677
        }
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   678
    
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   679
        if( options.onFindValue ) setTimeout(function() { options.onFindValue(li) }, 1);
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   680
      }
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   681
    
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   682
      function addToCache(q, data) {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   683
        if (!data || !q || !options.cacheLength) return;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   684
        if (!cache.length || cache.length > options.cacheLength) {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   685
          flushCache();
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   686
          cache.length++;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   687
        } else if (!cache[q]) {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   688
          cache.length++;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   689
        }
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   690
        cache.data[q] = data;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   691
      };
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   692
    
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   693
      function findPos(obj) {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   694
        var curleft = obj.offsetLeft || 0;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   695
        var curtop = obj.offsetTop || 0;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   696
        while (obj = obj.offsetParent) {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   697
          curleft += obj.offsetLeft
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   698
          curtop += obj.offsetTop
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   699
        }
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   700
        return {x:curleft,y:curtop};
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   701
      }
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   702
    }
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   703
    
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   704
    jQuery.fn.autocomplete = function(url, options, data) {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   705
      // Make sure options exists
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   706
      options = options || {};
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   707
      // Set url as option
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   708
      options.url = url;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   709
      // set some bulk local data
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   710
      options.data = ((typeof data == "object") && (data.constructor == Array)) ? data : null;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   711
    
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   712
      // Set default values for required options
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   713
      options = $.extend({
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   714
        inputClass: "ac_input",
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   715
        resultsClass: "ac_results",
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   716
        lineSeparator: "\n",
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   717
        cellSeparator: "|",
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   718
        minChars: 1,
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   719
        delay: 400,
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   720
        matchCase: 0,
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   721
        matchSubset: 1,
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   722
        matchContains: 0,
701
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
   723
        cacheLength: false,
699
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   724
        mustMatch: 0,
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   725
        extraParams: {},
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   726
        loadingClass: "ac_loading",
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   727
        selectFirst: false,
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   728
        selectOnly: false,
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   729
        maxItemsToShow: -1,
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   730
        autoFill: false,
701
dd80cde96a6c Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
Dan
parents: 699
diff changeset
   731
        showWhenNoResults: false,
699
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   732
        width: 0
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   733
      }, options);
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   734
      options.width = parseInt(options.width, 10);
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   735
    
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   736
      this.each(function() {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   737
        var input = this;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   738
        new jQuery.autocomplete(input, options);
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   739
      });
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   740
    
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   741
      // Don't break the chain
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   742
      return this;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   743
    }
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   744
    
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   745
    jQuery.fn.autocompleteArray = function(data, options) {
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   746
      return this.autocomplete(null, options, data);
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   747
    }
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   748
    
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   749
    jQuery.fn.indexOf = function(e){
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   750
      for( var i=0; i<this.length; i++ ){
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   751
        if( this[i] == e ) return i;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   752
      }
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   753
      return -1;
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   754
    };
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   755
    
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   756
    autofill_onload();
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 687
diff changeset
   757
  });