Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var lastCompletion = '';
- $('#m').keydown(function(e)
- {
- console.log('Action');
- names = [];
- for(x in chat.currentChannel.users)
- {
- if(x > 0)
- {
- names.push(chat.currentChannel.users[x].name);
- }
- }
- var keyCode = e.keyCode || e.which;
- if(keyCode == 9)
- {
- e.preventDefault();
- if(this.value == '')
- {
- if(lastCompletion != '')
- {
- this.value = lastCompletion + ', ';
- }
- return;
- }
- var matches = [];
- for(i=0;i<names.length;i++)
- {
- if(this.value.toLowerCase() == names[i].substring(0,this.value.length).toLowerCase())
- {
- matches.push(names[i]);
- }
- }
- console.log(matches);
- if(matches.length == 1)
- {
- lastCompletion = matches[0];
- this.value = matches[0] + ', ';
- }
- else if(matches.length > 1)
- {
- var common = matches[0];
- for(i=1;i<matches.length;i++)
- {
- common = inCommon(common,matches[i]);
- }
- this.value = common;
- }
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement