summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjak1 <jak1@themanaworld.org>2023-01-12 13:06:10 +0100
committerjak1 <jak1@themanaworld.org>2023-01-12 13:06:10 +0100
commit3808842dc1530c879acafe6597d7c5802bdf3d23 (patch)
tree8bae5c4f5d807d868c3730adc3381731b23d05ba
parentcf42b00752da9c0cbf3842194f073c83e53fde48 (diff)
downloadthepixelworld-3808842dc1530c879acafe6597d7c5802bdf3d23.tar.gz
thepixelworld-3808842dc1530c879acafe6597d7c5802bdf3d23.tar.bz2
thepixelworld-3808842dc1530c879acafe6597d7c5802bdf3d23.tar.xz
thepixelworld-3808842dc1530c879acafe6597d7c5802bdf3d23.zip
added basic chat emotes
-rw-r--r--app.js17
1 files changed, 15 insertions, 2 deletions
diff --git a/app.js b/app.js
index 3601207..efee026 100644
--- a/app.js
+++ b/app.js
@@ -96,7 +96,7 @@ io.sockets.on('connection', function(socket){
socket.on('sendMsgToServer', function(data){
if (data)
for (var i in SOCKET_LIST){
- SOCKET_LIST[i].emit('addToChat', {ctimestamp: getTimeStamp(0), content: socket.playerName + ': ' + escapeHTML(data), tab: "world"});
+ SOCKET_LIST[i].emit('addToChat', {ctimestamp: getTimeStamp(0), content: socket.playerName + ': ' + escapeHTML(chatEmote(data)), tab: "world"});
}
});
@@ -328,4 +328,17 @@ escapeHTML = function(unsafe) {
.replace(/>/g, "&gt;")
.replace(/"/g, "&quot;")
.replace(/'/g, "&#039;");
- } \ No newline at end of file
+ }
+
+chatEmote = function(msg) {
+ return msg.replace(":D", "😀")
+ .replace("O:)", "😇")
+ .replace("0:)", "😇")
+ .replace(":)", "🙂")
+ .replace(":(", "🙁")
+ .replace(":o", "😮")
+ .replace(":O", "😲")
+ .replace(":'(", "😢")
+ .replace(":')", "🥲")
+ .replace(":P", "😛");
+}