aboutsummaryrefslogtreecommitdiffstats
path: root/src/client/Main.hx
diff options
context:
space:
mode:
authorRblSb <msrblsb@gmail.com>2020-03-29 21:12:08 +0300
committerRblSb <msrblsb@gmail.com>2020-03-29 21:12:08 +0300
commita9a5e20324998a15432e90581666e8f72aeca8af (patch)
tree2360e39525e65c80b2857057a9a37469f6bf8d8e /src/client/Main.hx
parent498b6ca644fcf666a49097fb197e72800769e03a (diff)
Improve emotes handling
Diffstat (limited to 'src/client/Main.hx')
-rw-r--r--src/client/Main.hx21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/client/Main.hx b/src/client/Main.hx
index e5c67a7..b0b295e 100644
--- a/src/client/Main.hx
+++ b/src/client/Main.hx
@@ -8,6 +8,7 @@ import js.html.KeyboardEvent;
import js.html.Event;
import js.html.Element;
import js.html.InputElement;
+import js.html.VideoElement;
import js.html.WebSocket;
import js.Browser;
import js.Browser.document;
@@ -474,9 +475,10 @@ class Main {
});
}
for (emote in config.emotes) {
+ final tag = emote.image.endsWith("mp4") ? 'video autoplay="" loop=""' : "img";
filters.push({
- regex: new EReg(escapeRegExp(emote.name), "g"),
- replace: '<img class="channel-emote" src="${emote.image}" title="${emote.name}"/>'
+ regex: new EReg("(^| )" + escapeRegExp(emote.name) + "($| )", "g"),
+ replace: '$1<$tag class="channel-emote" src="${emote.image}" title="${emote.name}"/>$2'
});
}
final smilesWrap = ge("#smileswrap");
@@ -488,11 +490,16 @@ class Main {
}
smilesWrap.textContent = "";
for (emote in config.emotes) {
- final img = document.createImageElement();
- img.className = "smile-preview";
- img.dataset.src = emote.image;
- img.title = emote.name;
- smilesWrap.appendChild(img);
+ final tag = emote.image.endsWith("mp4") ? "video" : "img";
+ final el = document.createElement(tag);
+ el.className = "smile-preview";
+ el.dataset.src = emote.image;
+ el.title = emote.name;
+ if (tag == "video") {
+ (cast el : VideoElement).autoplay = true;
+ (cast el : VideoElement).loop = true;
+ }
+ smilesWrap.appendChild(el);
}
}
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage