(username)
| 178 | |
| 179 | // Gets the color of a username through our hash function |
| 180 | function getUsernameColor (username) { |
| 181 | // Compute hash code |
| 182 | var hash = 7; |
| 183 | for (var i = 0; i < username.length; i++) { |
| 184 | hash = username.charCodeAt(i) + (hash << 5) - hash; |
| 185 | } |
| 186 | // Calculate color |
| 187 | var index = Math.abs(hash % COLORS.length); |
| 188 | return COLORS[index]; |
| 189 | } |
| 190 | |
| 191 | // Keyboard events |
| 192 |