From 41765c53be975cb42de174760ac7a21786c3c98a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Fri, 24 May 2013 01:47:15 +0200 Subject: [PATCH] Ignore case when autocompleting usernames --- file/js/be.bastelstu.Chat.litcoffee | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/file/js/be.bastelstu.Chat.litcoffee b/file/js/be.bastelstu.Chat.litcoffee index ac370e0..284f509 100644 --- a/file/js/be.bastelstu.Chat.litcoffee +++ b/file/js/be.bastelstu.Chat.litcoffee @@ -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 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