This repository has been archived on 2026-05-07. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
instructions-clear/public/menu/index.html
T

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>