Added cumping to chat widget

This commit is contained in:
Андреев Григорий 2024-09-07 10:48:15 +03:00
parent 270549c21a
commit 6813c6249d
3 changed files with 24 additions and 11 deletions

View File

@ -76,13 +76,17 @@ iu9-ca-web-chat-admin-cli <server admin-control address> <command text> [<comman
`adduser <user nickname> <user name> <user password> <user bio>` - зарегистрировать пользователя сайта `adduser <user nickname> <user name> <user password> <user bio>` - зарегистрировать пользователя сайта
`8` - остановить сервис
Если нужно ввести пробел или символ `\ ` в любое из этих полей, перед ними нужно поставить `\ `; Если нужно ввести пробел или символ `\ ` в любое из этих полей, перед ними нужно поставить `\ `;
Если указать меньше полей, чем нужно, незаполненные поля станут пустыми строками.
Параметры конфигурации `config.lang.whitelist` и `config.lang.force-order` определяют на Параметры конфигурации `config.lang.whitelist` и `config.lang.force-order` определяют на
какие языки будет локализован сервер, и какие переводы приоритетнее каких. какие языки будет локализован сервер, и какие переводы приоритетнее каких.
На данный момент поддерживаются На данный момент поддерживаются
- `ru-RU` - `ru-RU`
- `en-US` - `en-US`
Все переводы хранятся в папке `assets/lang`. Все переводы хранятся в папке `assets/lang`.
# Список участников # Список участников

View File

@ -13,7 +13,8 @@ body, html {
position: absolute; position: absolute;
width: 100%; width: 100%;
left: 0; left: 0;
background-color: rgba(150, 0, 100, 50); /*background-color: rgba(150, 0, 100, 50);*/
background-color: rgba(0, 0, 0, 0);
/*display: flex;*/ /*display: flex;*/
/*flex-direction: row;*/ /*flex-direction: row;*/
/*justify-content: center;*/ /*justify-content: center;*/

View File

@ -18,7 +18,7 @@ let lastMsgId = -1;
let myRoleHere = null; // Dung local state updates should be updated first let myRoleHere = null; // Dung local state updates should be updated first
// Would start with true if opened `/chat/<>` // Would start with true if opened `/chat/<>`
let bumpedAtTheBottom = false; let bumpedAtBottom = false;
// Hidden variable. When deletion window popup is active // Hidden variable. When deletion window popup is active
// Persists from popup activation until popup deactivation // Persists from popup activation until popup deactivation
@ -27,6 +27,7 @@ let storeHiddenMsgIdForDeletionWin = -1;
// Positive in production, negative for debug // Positive in production, negative for debug
let softZoneSz = -150; let softZoneSz = -150;
let chatPadding = 300; let chatPadding = 300;
let msgGap = 5;
const msgErased = pres.chat.msgErased; const msgErased = pres.chat.msgErased;
function genSentBase(){ function genSentBase(){
@ -75,16 +76,16 @@ function updateOffsetsUpToTop(){
for (let curMsg = anchoredMsg; curMsg >= visibleMsgSegStart; curMsg--){ for (let curMsg = anchoredMsg; curMsg >= visibleMsgSegStart; curMsg--){
updateOffsetOfVisibleMsg(curMsg, offset); updateOffsetOfVisibleMsg(curMsg, offset);
let height = visibleMessages.get(curMsg).container.offsetHeight; let height = visibleMessages.get(curMsg).container.offsetHeight;
offset += height + 5; offset += height + msgGap;
} }
return offset; return offset - msgGap;
} }
function updateOffsetsDown(){ function updateOffsetsDown(){
let offset = offsetOfAnchor; let offset = offsetOfAnchor;
for (let curMsg = anchoredMsg + 1; curMsg <= visibleMsgSegEnd; curMsg++){ for (let curMsg = anchoredMsg + 1; curMsg <= visibleMsgSegEnd; curMsg++){
let height = visibleMessages.get(curMsg).container.offsetHeight; let height = visibleMessages.get(curMsg).container.offsetHeight;
offset -= (height + 5); offset -= (height + msgGap);
updateOffsetOfVisibleMsg(curMsg, offset); updateOffsetOfVisibleMsg(curMsg, offset);
} }
return offset; return offset;
@ -115,8 +116,9 @@ function updateOffsets(){
let [W, H] = getChatWgSz(); let [W, H] = getChatWgSz();
let lowestLowestPoint = isMissingBottomMsgHeap() ? lowestPoint - heightOfPreloadGhost(): lowestPoint; let lowestLowestPoint = isMissingBottomMsgHeap() ? lowestPoint - heightOfPreloadGhost(): lowestPoint;
let highestHighestPoint = isMissingTopMsgHeap() ? highestPoint + heightOfPreloadGhost() : highestPoint; let highestHighestPoint = isMissingTopMsgHeap() ? highestPoint + heightOfPreloadGhost() : highestPoint;
if (lowestLowestPoint > chatPadding || (highestHighestPoint - lowestLowestPoint) <= H - chatPadding * 2) { if (lowestLowestPoint > chatPadding || (highestHighestPoint - lowestLowestPoint) <= H - chatPadding * 2 ||
bumpedAtTheBottom = true; (!isMissingBottomMsgHeap() && bumpedAtBottom)) {
offsetOfAnchor += (-lowestLowestPoint + chatPadding); offsetOfAnchor += (-lowestLowestPoint + chatPadding);
updateOffsetsSane(); updateOffsetsSane();
} else if (highestHighestPoint < H - chatPadding) { } else if (highestHighestPoint < H - chatPadding) {
@ -357,7 +359,7 @@ async function loadWhitespaceMultitry(){
do { do {
try { try {
await tryLoadWhitespaceSingle(); await tryLoadWhitespaceSingle();
await sleep(100); await sleep(1100);
} catch (e) { } catch (e) {
console.error(e); console.error(e);
await sleep(1500); await sleep(1500);
@ -410,9 +412,13 @@ window.onload = function (){
console.log("Page was loaded"); console.log("Page was loaded");
document.body.addEventListener("wheel", function (event) { document.body.addEventListener("wheel", function (event) {
// event.preventDefault(); let offset = event.deltaY / 3;
bumpedAtTheBottom = false; if (offset < 0){
offsetOfAnchor += event.deltaY / 3; bumpedAtBottom = false;
} else if (offset > 0 && !isMissingBottomMsgHeap() && lowestPoint + offset > chatPadding){
bumpedAtBottom = true;
}
offsetOfAnchor += offset;
updateOffsets(); updateOffsets();
loadWhitespaceMultitry().then(dopDopYesYes); loadWhitespaceMultitry().then(dopDopYesYes);
}); });
@ -430,6 +436,8 @@ window.onload = function (){
} }
}); });
bumpedAtBottom = (openedchat.selectedMessageId < 0);
let chatWg = document.getElementById("chat-widget"); let chatWg = document.getElementById("chat-widget");
let chatWgDebugLinesFnc = function (){ let chatWgDebugLinesFnc = function (){
let H = chatWg.offsetHeight; let H = chatWg.offsetHeight;