summaryrefslogtreecommitdiffstats
path: root/webapp
diff options
context:
space:
mode:
authorHarrison Healey <harrisonmhealey@gmail.com>2016-03-23 18:10:25 -0400
committerHarrison Healey <harrisonmhealey@gmail.com>2016-03-24 09:22:58 -0400
commit5cfae469a5a53c7b8a58858f3704eadd1f66e332 (patch)
tree8216729804859c0ae35da4c8fd5804623d242fb6 /webapp
parent5689bb73981dc2becae580effa812d39cc3e3db3 (diff)
downloadchat-5cfae469a5a53c7b8a58858f3704eadd1f66e332.tar.gz
chat-5cfae469a5a53c7b8a58858f3704eadd1f66e332.tar.bz2
chat-5cfae469a5a53c7b8a58858f3704eadd1f66e332.zip
Fixed ESLint errors
Diffstat (limited to 'webapp')
-rw-r--r--webapp/utils/emoticons.jsx39
1 files changed, 20 insertions, 19 deletions
diff --git a/webapp/utils/emoticons.jsx b/webapp/utils/emoticons.jsx
index d7ba66388..d3afe372a 100644
--- a/webapp/utils/emoticons.jsx
+++ b/webapp/utils/emoticons.jsx
@@ -32,27 +32,28 @@ const emoticonPatterns = {
export const emoticons = initializeEmoticons();
function initializeEmoticons() {
- const emoticons = new Map();
+ const emoticonMap = new Map();
for (const emoji of emojis) {
const unicode = emoji.emoji;
let filename = '';
- if (emoji.emoji) {
+ if (unicode) {
// this is a unicode emoji so the character code determines the file name
- const code = fixedCharCodeAt(emoji.emoji, 0).toString(16);
- filename = pad(code.toString(16));
-
- if (emoji.emoji.length > 2) {
- // some emojis like the country flags span multiple utf-16 characters
- for (let i = 2; i < emoji.emoji.length; i += 2) {
- const code = fixedCharCodeAt(emoji.emoji, i);
-
- // ignore variation selectors
- if (code < 0xfe00 || code > 0xfe0f) {
- filename += '-' + pad(code.toString(16));
- }
+ for (let i = 0; i < unicode.length; i += 2) {
+ const code = fixedCharCodeAt(unicode, i);
+
+ // ignore variation selector characters
+ if (code >= 0xfe00 && code <= 0xfe0f) {
+ continue;
+ }
+
+ // some emoji (such as country flags) span multiple unicode characters
+ if (i !== 0) {
+ filename += '-';
}
+
+ filename += pad(code.toString(16));
}
} else {
// this isn't a unicode emoji so the first alias determines the file name
@@ -60,14 +61,14 @@ function initializeEmoticons() {
}
for (const alias of emoji.aliases) {
- emoticons.set(alias, {
+ emoticonMap.set(alias, {
alias,
path: getImagePathForEmoticon(filename)
});
}
}
- return emoticons;
+ return emoticonMap;
}
// Pads a hexadecimal number with zeroes to be at least 4 digits long
@@ -89,18 +90,18 @@ function fixedCharCodeAt(str, idx = 0) {
// High surrogate (could change last hex to 0xDB7F to treat high
// private surrogates as single characters)
- if (0xD800 <= code && code <= 0xDBFF) {
+ if (code >= 0xD800 && code <= 0xDBFF) {
const hi = code;
const low = str.charCodeAt(idx + 1);
if (isNaN(low)) {
- console.log('High surrogate not followed by low surrogate in fixedCharCodeAt()'); // eslint-ignore-line
+ console.log('High surrogate not followed by low surrogate in fixedCharCodeAt()'); // eslint-disable-line
}
return ((hi - 0xD800) * 0x400) + (low - 0xDC00) + 0x10000;
}
- if (0xDC00 <= code && code <= 0xDFFF) { // Low surrogate
+ if (code >= 0xDC00 && code <= 0xDFFF) { // Low surrogate
// We return false to allow loops to skip this iteration since should have
// already handled high surrogate above in the previous iteration
return false;