Start working on emotes
This commit is contained in:
parent
0f9bfe1429
commit
53138fe1f0
5 changed files with 209 additions and 2 deletions
|
|
@ -1032,7 +1032,31 @@ Callbacks = {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
emoteList: function (data) {
|
||||
loadEmotes(data);
|
||||
},
|
||||
|
||||
updateEmote: function (data) {
|
||||
data.regex = new RegExp(data.source, "gi");
|
||||
var found = false;
|
||||
for (var i = 0; i < CHANNEL.emotes.length; i++) {
|
||||
if (CHANNEL.emotes[i].name === data.name) {
|
||||
found = true;
|
||||
CHANNEL.emotes[i] = data;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
CHANNEL.emotes.push(data);
|
||||
}
|
||||
},
|
||||
|
||||
deleteEmote: function (data) {
|
||||
|
||||
},
|
||||
}
|
||||
|
||||
var SOCKET_DEBUG = true;
|
||||
|
|
|
|||
|
|
@ -32,7 +32,8 @@ var CHANNEL = {
|
|||
motd: "",
|
||||
motd_text: "",
|
||||
name: false,
|
||||
usercount: 0
|
||||
usercount: 0,
|
||||
emotes: []
|
||||
};
|
||||
|
||||
var PLAYER = false;
|
||||
|
|
|
|||
|
|
@ -1270,6 +1270,8 @@ function formatChatMessage(data) {
|
|||
if (data.meta.forceShowName)
|
||||
skip = false;
|
||||
|
||||
data.msg = execEmotes(data.msg);
|
||||
|
||||
LASTCHATNAME = data.username;
|
||||
LASTCHATTIME = data.time;
|
||||
var div = $("<div/>");
|
||||
|
|
@ -2180,3 +2182,24 @@ function formatUserPlaylistList() {
|
|||
});
|
||||
});
|
||||
}
|
||||
|
||||
function loadEmotes(data) {
|
||||
CHANNEL.emotes = [];
|
||||
data.forEach(function (e) {
|
||||
e.regex = new RegExp(e.source, "gi");
|
||||
CHANNEL.emotes.push(e);
|
||||
});
|
||||
}
|
||||
|
||||
function execEmotes(msg) {
|
||||
if (USEROPTS.no_emotes) {
|
||||
return msg;
|
||||
}
|
||||
|
||||
CHANNEL.emotes.forEach(function (e) {
|
||||
msg = msg.replace(e.regex, '<img class="channel-emote" src="' +
|
||||
e.image + '" title="' + e.name + '">');
|
||||
});
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue