Platform
Resources
Pricing
Sign in
Get started
Chris Zubak-Skees
Developer, journalist
Workspace
Fork
Published
By
Chris Zubak-Skees
Edited
Dec 30, 2019
Importers
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
{
const
el
=
DOM
.
element
(
'div'
)
;
el
.
classList
.
add
(
'captions'
)
;
yield
el
;
for
await
(
const
word
of
new
OpenedCaptions
(
)
)
{
el
.
innerHTML
+=
word
+
' '
;
}
}
Insert cell
class
OpenedCaptions
{
constructor
(
url
=
"https://openedcaptions.com"
)
{
this
.
_socket
=
socketIO
(
url
)
;
return
new
EventIterator
(
push
=>
this
.
_socket
.
on
(
'word'
,
(
{
data
}
)
=>
push
(
data
.
body
)
)
)
;
}
}
Insert cell
socketIO
=
require
(
"socket.io-client/dist/socket.io.js"
)
Insert cell
EventIterator
=
(
await
require
(
'https://bundle.run/event-iterator@1.2.0/lib/event-iterator.js'
)
)
.
EventIterator
Insert cell
html
`<style>
.captions {
min-height: 50px;
padding: 20px;
font-size: 17px;
font-family: Consolas,"Lucida Grande",Arial,Verdana;
background-color: black;
color: white;
}
</style>`
Insert cell
Purpose-built for displays of data
Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Try it for free
Learn more
Fork
View
Export
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
OpenedCaptions
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
socketIO
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
EventIterator
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML