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