Skip to content

Commit

Permalink
Shifted all emoji data in a json file (#147)
Browse files Browse the repository at this point in the history
Changes done
 - Dumped emoji ids and names into JSON file
 - Shifted emoji adding code from emojify.js to elient.js
 - deleted emojify.js

Co-authored-by: Lalit Narayan Mudgal <[email protected]>
  • Loading branch information
Ezio-Sarthak and LalitNM authored Oct 21, 2020
1 parent ff5145c commit 85b10d3
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 28 deletions.
16 changes: 14 additions & 2 deletions public/client.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
// Adding emojis in emoji-box
emobox = document.getElementById('emobox');
for (var i = 0; i < emojiCodes.length; i++) {
var listElement = document.createElement('li');
var imgElement = document.createElement('img');
imgElement.src = '/images/emoji/' + emojiCodes[i] + '.png';
imgElement.id = emojiNames[i];
imgElement.title = emojiNames[i].replace(/_/g, ' ');
imgElement.setAttribute('onclick', 'writeEmoji(this)');
listElement.appendChild(imgElement);
emobox.appendChild(listElement);
}
const socket = io();
let username, scrollDiff;

Expand Down Expand Up @@ -170,9 +182,9 @@ socket.on('Display Message', (data) => {
let colon2 = p.indexOf(":", colon1 + 1);
if (colon2 != -1) {
emoji_name = p.slice(colon1 + 1, colon2);
position = emoji_names.indexOf(emoji_name)
position = emojiNames.indexOf(emoji_name)
if (position != -1) {
p = p.slice(0, colon1) + "<img class=\"emoji\" src=\"images/emoji/" + emojis[position] + ".png\">" + p.slice(colon2 + 1);
p = p.slice(0, colon1) + "<img class=\"emoji\" src=\"images/emoji/" + emojiCodes[position] + ".png\">" + p.slice(colon2 + 1);
}
colon1 = p.indexOf(":", colon2 + 1);
} else {
Expand Down
1 change: 1 addition & 0 deletions public/emoji.json

Large diffs are not rendered by default.

Loading

0 comments on commit 85b10d3

Please sign in to comment.