Compare commits

..

No commits in common. "93b66b6a2693ebbd8eb234a9436b457b0bdaba12" and "8cd94b30f67f8eacf853fbc77bd60fb57a8262dc" have entirely different histories.

2 changed files with 23 additions and 55 deletions

View File

@ -26,7 +26,8 @@ As a unique bonus, you can launch a full text editor from within.
xP xP
-- --
The web frontend for 'xC', making use of its networked relay interface. The web frontend for 'xC', making use of its networked relay interface.
So far it's quite basic, yet usable. So far it's quite basic, yet usable. Build it using `make` in its directory,
and run it from within the _public_ subdirectory.
xF xF
-- --
@ -115,11 +116,6 @@ a Screen or tmux session.
file or something like `killall` if you want to terminate it. You can run it file or something like `killall` if you want to terminate it. You can run it
as a `forking` type systemd user service. as a `forking` type systemd user service.
xP
~~
Install the Go compiler, and build the server using `make` in its directory,
then run it from within the _public_ subdirectory.
Client Certificates Client Certificates
------------------- -------------------
'xC' will use the SASL EXTERNAL method to authenticate using the TLS client 'xC' will use the SASL EXTERNAL method to authenticate using the TLS client

View File

@ -24,8 +24,8 @@ class RelayRpc extends EventTarget {
} }
// It's going to be code 1006 with no further info. // It's going to be code 1006 with no further info.
ws.onclose = event => { ws.onclose = event => {
this.ws = undefined
reject() reject()
this.ws = undefined
} }
}) })
} }
@ -122,25 +122,15 @@ class RelayRpc extends EventTarget {
// ---- Event processing ------------------------------------------------------- // ---- Event processing -------------------------------------------------------
// TODO: Probably reset state on disconnect, and indicate to user.
let rpc = new RelayRpc(proxy) let rpc = new RelayRpc(proxy)
rpc.connect()
.then(result => {
rpc.send({command: 'Hello', version: 1})
})
let buffers = new Map() let buffers = new Map()
let bufferCurrent = undefined let bufferCurrent = undefined
let connecting = true
rpc.connect().then(result => {
buffers.clear()
bufferCurrent = undefined
rpc.send({command: 'Hello', version: 1})
connecting = false
m.redraw()
}).catch(error => {
connecting = false
m.redraw()
})
rpc.addEventListener('close', event => {
m.redraw()
})
rpc.addEventListener('BufferUpdate', event => { rpc.addEventListener('BufferUpdate', event => {
let e = event.detail, b = buffers.get(e.bufferName) let e = event.detail, b = buffers.get(e.bufferName)
@ -165,18 +155,14 @@ rpc.addEventListener('BufferRemove', event => {
rpc.addEventListener('BufferActivate', event => { rpc.addEventListener('BufferActivate', event => {
let e = event.detail let e = event.detail
bufferCurrent = e.bufferName bufferCurrent = e.bufferName
setTimeout(() => { // TODO: Somehow scroll to the end of it immediately.
let el = document.getElementById('input') // TODO: Focus the textarea.
if (el !== null)
el.focus()
})
}) })
rpc.addEventListener('BufferLine', event => { rpc.addEventListener('BufferLine', event => {
let e = event.detail, b = buffers.get(e.bufferName) let e = event.detail, b = buffers.get(e.bufferName)
if (b === undefined) if (b !== undefined)
return b.lines.push({when: e.when, rendition: e.rendition, items: e.items})
b.lines.push({when: e.when, rendition: e.rendition, items: e.items})
}) })
rpc.addEventListener('BufferClear', event => { rpc.addEventListener('BufferClear', event => {
@ -208,11 +194,11 @@ function applyColor(fg, bg, inverse) {
if (inverse) if (inverse)
[fg, bg] = [bg >= 0 ? bg : 15, fg >= 0 ? fg : 0] [fg, bg] = [bg >= 0 ? bg : 15, fg >= 0 ? fg : 0]
let style = {} let style = ''
if (fg >= 0) if (fg >= 0)
style.color = palette[fg] style += `color: ${palette[fg]};`
if (bg >= 0) if (bg >= 0)
style.backgroundColor = palette[bg] style += `background-color: ${palette[bg]};`
if (style) if (style)
return style return style
} }
@ -309,19 +295,6 @@ let Content = {
} }
let Buffer = { let Buffer = {
oncreate: vnode => {
if (vnode.dom === undefined)
return
let el = vnode.dom.children[1]
if (el !== null)
el.scrollTop = el.scrollHeight
},
onupdate: vnode => {
Buffer.oncreate(vnode)
},
view: vnode => { view: vnode => {
let lines = [] let lines = []
let b = buffers.get(bufferCurrent) let b = buffers.get(bufferCurrent)
@ -392,7 +365,7 @@ function onKeyDown(event) {
// and we'll probably have to intercept /all/ key presses. // and we'll probably have to intercept /all/ key presses.
let Input = { let Input = {
view: vnode => { view: vnode => {
return m('textarea#input', { return m('textarea', {
rows: 1, rows: 1,
onkeydown: onKeyDown, onkeydown: onKeyDown,
}) })
@ -401,14 +374,8 @@ let Input = {
let Main = { let Main = {
view: vnode => { view: vnode => {
let state = "Connected"
if (connecting)
state = "Connecting..."
else if (rpc.ws === undefined)
state = "Disconnected"
return m('.xP', {}, [ return m('.xP', {}, [
m('.title', {}, `xP (${state})`), m('.title', {}, "xP"),
m('.middle', {}, [m(BufferList), m(Buffer)]), m('.middle', {}, [m(BufferList), m(Buffer)]),
m('.status', {}, bufferCurrent), m('.status', {}, bufferCurrent),
m(Input), m(Input),
@ -416,4 +383,9 @@ let Main = {
}, },
} }
window.addEventListener('load', () => m.mount(document.body, Main)) // TODO: Buffer names should work as routes.
window.addEventListener('load', () => {
m.route(document.body, '/', {
'/': Main,
})
})