diff --git a/package-lock.json b/package-lock.json index 7230ab0..66e832c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { - "name": "elem-proxy", + "name": "elemental-to-web", "lockfileVersion": 3, "requires": true, "packages": { diff --git a/static/arrows/left.svg b/static/arrows/left.svg new file mode 100644 index 0000000..216f5bc --- /dev/null +++ b/static/arrows/left.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/static/arrows/right.svg b/static/arrows/right.svg new file mode 100644 index 0000000..9145fe9 --- /dev/null +++ b/static/arrows/right.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/static/index.css b/static/index.css index ff7e240..d790b11 100644 --- a/static/index.css +++ b/static/index.css @@ -1,7 +1,7 @@ :root, input, button { - font-family: monospace; + font-family: sans-serif; } body { @@ -64,6 +64,18 @@ button, button a { padding: 0.5rem 1rem; white-space: pre-wrap; } +#messages>li>li { + margin: 0; + line-height: 1em; + height: 1em; + padding-bottom: 0.1em; + overflow: hidden; +} + + +#messages>li>li>img { + height: 1.1em; +} #messages>li:nth-child(odd) { background: #efefef; diff --git a/static/index.html b/static/index.html index 7caa9c4..4197018 100644 --- a/static/index.html +++ b/static/index.html @@ -13,11 +13,11 @@

Run /help for info; more clients are also here.

-

The web client is a demo and may not always be updated. Other clients will have better support for - features and interface elements.

+ +
diff --git a/static/index.js b/static/index.js index d9b96e0..25958a9 100644 --- a/static/index.js +++ b/static/index.js @@ -3,11 +3,43 @@ var messages = document.getElementById('messages'); var form = document.getElementById('form'); var input = document.getElementById('input'); +async function nextPage(e) { + input.value = ''; + main(new Event('click')); +} + +async function goPage(count) { + let counter = input.value.match(/[^\s]+$/g); + if (!counter) return; + + input.value = `${input.value.match(/^[^\s]+/g)[0]} ${counter[0] * 1 + count}`; + main(new Event('click')); +} + async function addMsg(msg) { - var item = document.createElement('li'); - item.textContent = msg; - messages.appendChild(item); - window.scrollTo(0, document.body.scrollHeight); + let lines = msg.split('\n'); + var wrap = document.createElement('li'); + + for (let line of lines) { + var item = document.createElement('li'); + item.textContent = line; + + if (line.startsWith('-') || line.startsWith('<')) { + let img = new Image(); + if (line.startsWith('<') || line[2] == '>') { + item.textContent = line.slice(3); + img.src = `arrows/left.svg`; + } else { + item.textContent = line.slice(2); + img.src = `arrows/right.svg`; + } + + item.insertBefore(img,item.childNodes[0]) + } + wrap.appendChild(item); + window.scrollTo(0, document.body.scrollHeight); + } + messages.appendChild(wrap); } async function main(e) { @@ -15,7 +47,7 @@ async function main(e) { if (!input.value) return; - let msg = await fetch("/", { + let msg = await fetch("https://elem.dervland.net/" /*"/"*/, { "method": "POST", "headers": { "content-type": "application/json", @@ -33,4 +65,9 @@ async function main(e) { form.addEventListener('submit', main); -document.querySelector('.send').addEventListener('click',main); \ No newline at end of file +document.querySelector('.send').addEventListener('click', main); +document.querySelector('.prev').addEventListener('click', () => goPage(1)); +document.querySelector('.next').addEventListener('click', () => goPage(-1)); + +input.value = '/inv 1'; +goPage(0); \ No newline at end of file