Provide usernames without further data as more human-readable numbers
This commit is contained in:
@@ -14,6 +14,18 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// We use long keys in many places. Provide a method to trim those down for
|
||||
// human readability.
|
||||
String.prototype.hashCode = function() {
|
||||
var hash = 0;
|
||||
for (i = 0; i < this.length; i++) {
|
||||
var char = this.charCodeAt(i);
|
||||
hash = ((hash << 5) - hash) + char;
|
||||
hash = hash & hash;
|
||||
}
|
||||
return hash;
|
||||
};
|
||||
|
||||
var cosmopolite = {};
|
||||
|
||||
cosmopolite.Client = function(opt_callbacks, opt_urlPrefix, opt_namespace) {
|
||||
|
||||
@@ -73,7 +73,7 @@ var addMessage = function(message) {
|
||||
var messageDiv = document.createElement('div');
|
||||
messageDiv.innerHTML = (
|
||||
(new Date(message['created'] * 1000)).toString() +
|
||||
' <' + message['sender'] + '> ' +
|
||||
' <????-' + (Math.abs(message['sender'].hashCode()) % 10000) + '> ' +
|
||||
message['message']
|
||||
);
|
||||
messages.appendChild(messageDiv);
|
||||
|
||||
Reference in New Issue
Block a user