various updates

main
jerl 2024-05-04 20:13:37 -07:00
parent 03c0433c28
commit af690ebea9
3 changed files with 90 additions and 61 deletions

View File

@ -18,8 +18,6 @@ function chooseThread() {
else else
document.getElementById('msginput').classList.add('hidden'); document.getElementById('msginput').classList.add('hidden');
switchTab(document.getElementById(this.tab)); switchTab(document.getElementById(this.tab));
if (this.tab === 'spacetab')
loadSpace();
} }
function switchTab(tab) { function switchTab(tab) {
@ -39,13 +37,13 @@ function addMember() {
const name = document.getElementById('membername').value; const name = document.getElementById('membername').value;
window.threadmembers.push(name); window.threadmembers.push(name);
document document
.getElementById('memberlist') .getElementById('newmembers')
.appendChild(html.node`<p class='member'>${name}</p>`); .appendChild(html.node`<p class='member'>${name}</p>`);
document.getElementById('membername').value = ''; document.getElementById('membername').value = '';
} }
async function createThread(e) { async function createThread(event) {
e.preventDefault(); event.preventDefault();
let name = document.getElementById('newthreadname').value; let name = document.getElementById('newthreadname').value;
if (!name) { if (!name) {
document.getElementById('nameempty').classList.remove('hidden'); document.getElementById('nameempty').classList.remove('hidden');
@ -112,10 +110,14 @@ function newThread() {
let form = document.getElementById('createthread'); let form = document.getElementById('createthread');
if (form) { if (form) {
form.remove(); form.remove();
document.getElementById('createseparator').remove();
document.getElementById('newthread').textContent = 'create'; document.getElementById('newthread').textContent = 'create';
} else { } else {
window.threadmembers = [window.name]; window.threadmembers = [window.name];
document.getElementById('home').insertAdjacentElement('afterend', html.node` document.getElementById('home')
.insertAdjacentElement('afterend', html.node`
<hr id='createseparator' class='separator' color='#666'>`)
.insertAdjacentElement('afterend', html.node`
<form id='createthread' class='column' onsubmit=${createThread}> <form id='createthread' class='column' onsubmit=${createThread}>
<h3>create thread</h3> <h3>create thread</h3>
<label for='newthreadname' class='heading'>thread name</label> <label for='newthreadname' class='heading'>thread name</label>
@ -134,14 +136,14 @@ function newThread() {
<label for='private_view'>only members can view and post</label <label for='private_view'>only members can view and post</label
><br /><br /> ><br /><br />
<label class='heading' for='membername'>members</label> <label class='heading' for='membername'>members</label>
<input type='text' id='membername' placeholder='username' onkeydown=${(e) => { <input type='text' id='membername' placeholder='username' onkeydown=${event => {
if (e.key == 'Enter') { if (event.key === 'Enter') {
e.preventDefault(); event.preventDefault();
addMember(); addMember();
} }
}}/> }}/>
<button id='addmember' onclick=${addMember}>add</button> <button id='addmember' onclick=${addMember}>add</button>
<div id='memberlist'> <div id='newmembers'>
<p class='member'>${window.name}</p> <p class='member'>${window.name}</p>
</div> </div>
<br /> <br />
@ -157,6 +159,7 @@ function clickedTab(event) {
document.getElementById(`thread${window.threadId}`).tab = event.target.id; document.getElementById(`thread${window.threadId}`).tab = event.target.id;
} }
// main app html
document.body.append(html.node` document.body.append(html.node`
<div id='home' class='column'> <div id='home' class='column'>
<div id='threads'> <div id='threads'>
@ -169,22 +172,36 @@ document.body.append(html.node`
document.getElementById('profile').classList.toggle('hidden') document.getElementById('profile').classList.toggle('hidden')
}>${window.name}</div> }>${window.name}</div>
</div> </div>
<hr class='separator' color='#666'>
<div id='profile' class='column hidden'> <div id='profile' class='column hidden'>
<p><strong>authentication requests</strong></p> <p><strong>authentication requests</strong></p>
<div id='authrequests'></div> <div id='authrequests'></div>
</div> </div>
<hr class='separator' color='#666'> <hr class='separator' color='#666'>
<div id='thread' class='column'> <div id='thread' class='column'>
<div id='content'>
<div id='title'> <div id='title'>
thread: <strong id='threadname'>meow</strong> thread: <strong id='threadname'>meow</strong>
</div> </div>
<div id='buttons'>
<div id='tabs'> <div id='tabs'>
<button id='messagetab' class='tab active' onclick=${clickedTab}>messages <button id='messagetab' class='tab active' onclick=${clickedTab}>messages
</button><button id='spacetab' class='tab' onclick=${clickedTab}>space</button> </button><button id='spacetab' class='tab' onclick=${clickedTab}>space</button>
</div> </div>
<button id='showmembers' onclick=${() =>
document.getElementById('members').classList.toggle('hidden')
}>members</button>
</div>
<div id='message' class='tabcontent'></div> <div id='message' class='tabcontent'></div>
<div id='space' class='tabcontent hidden'></div> <div id='space' class='tabcontent hidden'></div>
</div> </div>
<hr class='separator' color='#666'>
<div id='members' class='hidden'>
<p id='visibility'></p>
<div id='memberlist'>
</div>
</div>
</div>
`); `);
function makeThread(thread) { function makeThread(thread) {

View File

@ -90,10 +90,15 @@
} }
.column { .column {
flex: 1; flex: 1;
margin: 2px;
} }
.separator { .separator {
margin: 8px 2px; margin: 8px 2px;
} }
.separator:has(+ .separator),
.separator:has(+ *.hidden) {
display: none;
}
#home { #home {
max-width: 250px; max-width: 250px;
display: flex; display: flex;
@ -101,17 +106,16 @@
justify-content: space-between; justify-content: space-between;
} }
#threads { #threads {
margin: 5px; margin: 3px;
} }
#user { #user {
margin: 3px;
padding: 6px; padding: 6px;
background-color: #191919; background-color: #191919;
} }
#profile { #profile {
max-width: 250px; max-width: 250px;
> * { > * {
margin: 5px; margin: 4px;
} }
} }
.authrequest { .authrequest {
@ -119,25 +123,32 @@
} }
.thread { .thread {
padding: 2px 4px; padding: 2px 4px;
white-space: pre;
} }
#newthread { #newthread {
margin-top: 5px; margin-top: 5px;
} }
#createthread { #createthread {
max-width: 350px; max-width: fit-content;
} }
#permissions { #permissions {
margin-bottom: 5px; margin-bottom: 5px;
} }
#thread { #thread {
display: flex; display: flex;
}
#content {
flex: 1;
display: flex;
flex-direction: column; flex-direction: column;
} }
#title { #title {
margin: 4px; margin: 4px;
} }
#tabs { #buttons {
margin: 4px 2px; margin: 4px 2px;
display: flex;
justify-content: space-between;
} }
.tab { .tab {
padding: 5px 7px; padding: 5px 7px;
@ -147,19 +158,22 @@
font-weight: 500; font-weight: 500;
} }
.tabcontent { .tabcontent {
flex-grow: 1; flex: 1;
margin: 2px;
} }
#message { #message {
margin: 2px;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
min-height: 0; /* flex makes this auto so it can't shrink */ min-height: 0; /* flex makes this auto so it can't shrink */
} }
#messages { #messages {
margin: 2px; flex: 1;
flex-grow: 1;
overflow: auto; overflow: auto;
} }
#members {
flex: 1;
max-width: 250px;
}
#msginput { #msginput {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
@ -177,14 +191,11 @@
#loadmore { #loadmore {
margin-bottom: 10px; margin-bottom: 10px;
} }
.channel {
font-weight: normal;
}
.member { .member {
margin: 5px 0; margin: 5px 0;
} }
#space { #space {
margin: 0; margin: -2px; /* offset column margin */
position: relative; position: relative;
overflow: auto; overflow: auto;
} }

View File

@ -68,10 +68,11 @@ function loadMessages() {
${message.message} ${message.message}
</div>`); </div>`);
} }
if (!msg.more) if (msg.more)
document.getElementById('loadmore').classList.add('hidden');
else
document.getElementById('loadmore').classList.remove('hidden'); document.getElementById('loadmore').classList.remove('hidden');
else
document.getElementById('loadmore').classList.add('hidden');
messages.scroll(0, messages.scrollHeight - messages.clientHeight);
} }
); );
} }