1 const commandInput = document.querySelector('#short-input')
2 const firstInsertInput = document.querySelector('#full-input')
3 const history = document.querySelector('#history')
4 const backend = new WebSocket('wss://ed-api.apps.penalosa.dev')
5 commandInput.value = ''
7 backend.onclose = () => {
8 document.body.innerHTML = `
14 ${document.body.innerHTML}`
16 backend.onmessage = (m) => {
21 let div = document.createElement('div')
23 div.className = 'response-data'
26 commandInput.scrollIntoView({ behavior: 'smooth' })
28 commandInput.addEventListener('keypress', (e) => {
30 backend.send(commandInput.value + '\n')
31 let div = document.createElement('div')
32 div.textContent = commandInput.value
33 div.className = 'command-data'
36 commandInput.value.endsWith('i') ||
37 commandInput.value.endsWith('a') ||
38 commandInput.value.endsWith('c')
41 firstInsertInput.disabled = false
42 firstInsertInput.style.display = 'block'
43 firstInsertInput.value = ''
44 firstInsertInput.focus()
46 commandInput.value = ''
49 document.addEventListener('keypress', (e) => {
50 if (e.which == 13 && e.target.className == 'insert') {
51 if (e.target.value == '.') {
53 [...document.querySelectorAll('.insert')]
56 ;[...document.querySelectorAll('.insert')]
57 .filter((e) => e.id != 'full-input')
58 .map((e) => e.remove())
60 firstInsertInput.value = ''
61 firstInsertInput.style.display = 'none'
62 firstInsertInput.disabled = true
67 let next = document.createElement('input')
68 next.className = 'insert'
69 e.target.disabled = true
70 e.target.insertAdjacentElement('afterend', next)