mirror of
https://github.com/Luzifer/twitch-bot.git
synced 2024-12-30 00:21:16 +00:00
[overlays] Add a simple overlay to display a template
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
5f5f96a35e
commit
d51dd27630
1 changed files with 38 additions and 0 deletions
38
internal/apimodules/overlays/default/template.html
Normal file
38
internal/apimodules/overlays/default/template.html
Normal file
|
@ -0,0 +1,38 @@
|
|||
<html>
|
||||
<style>
|
||||
[v-cloak] { display: none; }
|
||||
html {
|
||||
font-family: sans-serif;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div id="content" />
|
||||
|
||||
<script type="module">
|
||||
import EventClient from './eventclient.mjs'
|
||||
|
||||
function updateTemplate(botClient) {
|
||||
return botClient.renderTemplate(botClient.paramOptionFallback('template', ''))
|
||||
.then(content => { document.querySelector('#content').innerText = content })
|
||||
}
|
||||
|
||||
(() => {
|
||||
// Connect to Bot
|
||||
const botClient = new EventClient({
|
||||
handlers: {},
|
||||
replay: false,
|
||||
})
|
||||
|
||||
// Initially fetch template string
|
||||
updateTemplate(botClient)
|
||||
|
||||
// Add interval if requested
|
||||
const interval = Number(botClient.paramOptionFallback('interval', 0))
|
||||
if (interval && interval > 0) {
|
||||
window.setInterval(() => updateTemplate(botClient), interval * 1000)
|
||||
}
|
||||
})()
|
||||
</script>
|
||||
</html>
|
||||
|
||||
<!-- vim: set sw=2 : -->
|
Loading…
Reference in a new issue