From 08d20a1096b76fe6f1b346ad3ae99aec83a3dd18 Mon Sep 17 00:00:00 2001 From: Gabe Kangas Date: Mon, 15 Jun 2020 13:41:37 -0700 Subject: [PATCH] Add color hash for user avatar backgrounds --- webroot/js/message.js | 2 +- webroot/js/usercolors.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/webroot/js/message.js b/webroot/js/message.js index 13f177514..8cecfb804 100644 --- a/webroot/js/message.js +++ b/webroot/js/message.js @@ -20,7 +20,7 @@ class Message { return this.addNewlines(linked); } userColor() { - return colorForString(this.author); + return messageBubbleColorForString(this.author); } toModel() { diff --git a/webroot/js/usercolors.js b/webroot/js/usercolors.js index 238e947fc..4e12e9858 100644 --- a/webroot/js/usercolors.js +++ b/webroot/js/usercolors.js @@ -71,14 +71,14 @@ function messageBubbleColorForString(str) { // eslint-disable-next-line hash = str.charCodeAt(i) + ((hash << 5) - hash); } - let colour = '#'; + let color = '#'; for (let i = 0; i < 3; i++) { // eslint-disable-next-line let value = (hash >> (i * 8)) & 0xff; - colour += ('00' + value.toString(16)).substr(-2); + color += ('00' + value.toString(16)).substr(-2); } // Convert to RGBA - let result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(colour); + let result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(color); let rgb = result ? { r: parseInt(result[1], 16), g: parseInt(result[2], 16),