After the introduction of the tab complete feature, the tab
key can no longer be used to navigate away from the chatbox.
This commit adds a shift+tab function to navigate away from
the chatbox, rather than tab completing a name.
This commit implements a feature commonly found in IRC clients
and often referred to as "tab complete". This allows a user to
type part of a user's name in the chat box and then press tab, which
causes the program to complete the user's name in the chat box. The
user can then press tab additional times in order to cycle through
the list of possible matches.
Tab complete has been implemented for the main chat, for battles,
and for private messages.
The algorithm implemented is that when you press tab, the program
looks backward to the last space (or start of the line) and
considers the substring between the last space and the position of
the cursor to be the prefix of a name. It then builds a list of
all names that it could be, which is then sorted. The sort is
done first based on activity (i.e. users who have spoken more
recently are sorted higher), and if users are tied as to activity,
then by alphabetical order.
After a name has been tab-completed, you can then press tab
subsequent times in order to cycle through the remainder of the list.
The idea behind this algorithm is that a user will usually want
to refer to somebody who has spoken recently in the chat. This
is especially helpful for Pokemon Showdown because with 1500+
users, it would be difficult to complete the correct name if it
were based purely on alphabetical order.
Matching of names is based on userids, which are strictly
alphanumeric. Therefore, when intending to use tab complete,
a user should type only the letters and numbers from a user's
name, not any spaces or symbols. After pressing tab, the spaces
and symbols will appear in the chatbox, however.
In order to avoid having a dirty working directory on the
live web server, this commit moves index.php to index.php.template.txt
and generates index.php in update-version-query-strings. The index.php
file is not under version control.
The live web server runs PHP 5.2, which apparently does not
support anonymous functions, so the anonymous funciton has
been removed from update-version-query-strings.
The index.php file specifies a version query string for each
resource which is likely to change. For example:
<script src="/js/sim.js?v0.8.2c"></script>
Each time the file is changed, we have incremented the version
number so that browsers and/or the CDN know to download the
file from the web site, rather than using a cached version.
This works because changing the version query string changes
the file name of the resource.
This commit introduces a new program (update-version-query-strings)
which parses index.php and sets each version query string to be
the MD5 hash of the corresponding resource. On the live web
server, this program is set to run for the following git hooks:
post-commit, post-checkout, post-merge, post-rewrite
This new system removes the need to manually update version query
strings. Instead, the version query strings will be automatically
updated when we update the live web site from now on.