27 lines
770 B
HTML
27 lines
770 B
HTML
<style>
|
|
html {
|
|
background-color: black;
|
|
color: white;
|
|
font-family: sans-serif;
|
|
}
|
|
a:link, a:hover, a:active, a:visited {
|
|
color: white;
|
|
}
|
|
</style>
|
|
<h1>Take control of a unit:</h1>
|
|
<ul id="links"></ul>
|
|
<script>
|
|
websocket = new WebSocket(`ws://${window.location.hostname}:1280/ws`)
|
|
websocket.onopen = () => { websocket.send(JSON.stringify({ action: 'entities' })) }
|
|
websocket.onmessage = (event) => {
|
|
const message = JSON.parse(event.data)
|
|
const entityIds = message?.entities
|
|
if (entityIds == null) { return }
|
|
|
|
websocket.close()
|
|
let links = ''
|
|
entityIds.forEach((entityId) => links += `<li><a href="/?id=${encodeURI(entityId)}">${entityId}</a></li>`)
|
|
document.getElementById('links').innerHTML = links
|
|
}
|
|
</script>
|