1
0
mirror of https://github.com/wbbaddons/Tims-Chat.git synced 2025-01-09 00:20:08 +00:00

Ignore case when autocompleting usernames

This commit is contained in:
Tim Düsterhus 2013-05-24 01:47:15 +02:00
parent 1b61f4bc63
commit 41765c53be

View File

@ -172,8 +172,9 @@ The the word the caret is in will be passed to `autocomplete` and replaced if a
return if toComplete.length is 0 return if toComplete.length is 0
console.log "Autocompleting '#{toComplete}'" console.log "Autocompleting '#{toComplete}'"
users = (username for user in $('.timsChatUser') when (username = $(user).data('username')).indexOf(toComplete) is 0) regex = new RegExp "^#{WCF.String.escapeRegExp(toComplete)}", "i"
users = (username for user in $('.timsChatUser') when regex.test(username = $(user).data('username')))
toComplete = users[autocomplete.offset++ % users.length] + ', ' if users.length isnt 0 toComplete = users[autocomplete.offset++ % users.length] + ', ' if users.length isnt 0