Copyleft Games

Webchat occupant tab completion

When directing messages in a chat room to a specific person in that room, its common to start with their name followed by a colon. Commonly, typing the TAB key auto-completes an occupants nickname. This is not currently implemented in our webchat client.

Implement this feature with these basic rules:

If TAB was the last key entered, cycle to the next possible option based on the entry so far. To do so, erase from the entry the last word in the entry and replace it with the new one.

Search the entry backward from the cursor to find the first whitespace or beginning of message, this is used for autocomplete purposes so that multiple names can be entered separated by a space.

If there are 0 characters before the cursor, auto-complete to the first user in the occupant list. Thus, if a user starts a word by typing TAB they'll begin cycling through the occupant list.

If there are 1 or more characters before the cursor, check if this matches any occupants and complete to the first match if found. Thus, typing the letter B followed by TAB will select the first occupant who's name starts with B, and hitting TAB again will cycle through all the B's until one is found. This case insensitive.

To enter a autocomplete match, first erase whatever is matched against and replace it with the occupant's full nickname followed by a colon and a space. So if "Bingo" is in the room, typing "b[TAB]" will replace the "b" with "Bingo: "

If possible, add this code to commands.js and attach it here.

Task tags

  • xmpp
  • javascript

Students who completed this task

Václav Šraier

Task type

  • code Code
  • assessment Outreach / Research
close

2015