improve UI on web client to include features from penguinmod client
This commit is contained in:
parent
bc1e681c40
commit
b4e8ba7bd9
6 changed files with 61 additions and 10 deletions
|
@ -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);
|
||||
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);
|
Loading…
Add table
Add a link
Reference in a new issue