Created
June 19, 2022 13:56
-
-
Save Lait-au-Cafe/95c77cc742579efb1e291534bab38c88 to your computer and use it in GitHub Desktop.
Chatbox
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@import url(https://fonts.googleapis.com/css?family=Roboto:700); | |
@import url('https://fonts.googleapis.com/css2?family=Zen+Kaku+Gothic+New:wght@500&display=swap'); | |
* { | |
box-sizing: border-box; | |
} | |
html, body { | |
height: 100%; | |
overflow: hidden; | |
} | |
body { | |
text-shadow: 0 0 1px #000, 0 0 2px #000; | |
background: {background_color}; | |
font-family: 'Zen Kaku Gothic New', 'Roboto'; | |
font-weight: 700; | |
font-size: {font_size}; | |
line-height: 1.5em; | |
color: {text_color}; | |
} | |
#log>div { | |
animation: fadeInRight .3s ease forwards, fadeOut 0.5s ease {message_hide_delay} forwards; | |
-webkit-animation: fadeInRight .3s ease forwards, fadeOut 0.5s ease {message_hide_delay} forwards; | |
} | |
.colon { | |
display: none; | |
} | |
#log { | |
display: table; | |
position: absolute; | |
bottom: 0; | |
left: 0; | |
padding: 0 10px 10px; | |
width: 100%; | |
table-layout: fixed; | |
} | |
#log>div { | |
/* display: table-row; */ | |
background-color: rgba(0, 0, 0 , 0.8); | |
padding-left: 10px; | |
} | |
#log>div.deleted { | |
visibility: hidden; | |
} | |
#log .emote { | |
background-repeat: no-repeat; | |
background-position: center; | |
background-size: contain; | |
padding: 0.4em 0.2em; | |
position: relative; | |
} | |
#log .emote img { | |
display: inline-block; | |
height: 1em; | |
opacity: 0; | |
} | |
#log .message,#log .meta { | |
vertical-align: top; | |
/* display: table-cell; */ | |
display: block; | |
padding-bottom: 0.1em; | |
} | |
#log .meta { | |
/* width: 50%; */ | |
/* text-align: right; */ | |
padding-right: 0.5em; | |
white-space: nowrap; | |
text-overflow: ellipsis; | |
overflow: hidden; | |
} | |
#log .message { | |
word-wrap: break-word; | |
/* width: 65%; */ | |
} | |
.badge { | |
display: inline-block; | |
margin-right: 0.2em; | |
position: relative; | |
height: 1em; | |
vertical-align: middle; | |
top: -0.1em; | |
background-color: white; | |
border-radius: 0.2em; | |
} | |
.name { | |
margin-left: 0.2em; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- item will be appened to this layout --> | |
<div id="log" class="sl__chat__layout"> | |
</div> | |
<!-- chat item --> | |
<script type="text/template" id="chatlist_item"> | |
<div data-from="{from}" data-id="{messageId}"> | |
<span class="meta" style="color: {color}"> | |
<span class="badges"> | |
</span> | |
<span class="name">{from}</span> | |
</span> | |
<span class="message"> | |
{message} | |
</span> | |
</div> | |
</script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Please use event listeners to run functions. | |
document.addEventListener('onLoad', function(obj) { | |
// obj will be empty for chat widget | |
// this will fire only once when the widget loads | |
}); | |
document.addEventListener('onEventReceived', function(obj) { | |
// obj will contain information about the event | |
console.log(obj); | |
const latest_badges = document.querySelectorAll("#log>div:last-child .badge"); | |
for(const i in latest_badges) { | |
const small_srcpath = latest_badges[i].src; | |
const large_srcpath = small_srcpath.replace(/\/1$/, '/3'); | |
latest_badges[i].src = large_srcpath; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment