This commit is contained in:
bobbydigitales
2024-02-15 22:57:26 -08:00
parent b07a93246f
commit 362876e167
5 changed files with 58 additions and 12 deletions

View File

@@ -38,6 +38,21 @@ class Post {
}
}
window.addEventListener('scroll', () => {
// Total height of the document
const totalPageHeight = document.body.scrollHeight;
// Current scroll position
const scrollPoint = window.scrollY + window.innerHeight;
// Check if scrolled to bottom
if (scrollPoint >= totalPageHeight) {
console.log('Scrolled to the bottom!');
console.log(scrollPoint, totalPageHeight);
// You can perform your action here
}
});
function initMarkdown() {
const renderer = new marked.Renderer();
@@ -252,6 +267,8 @@ function connectWebsocket(userID: string) {
websocket.onopen = function (evt) {
log("Websocket: CONNECTED");
websocket.send(`{"messageType":"connect", "id": "${userID}"}`);
let websocketPingInterval = window.setInterval(()=>{websocket.send(`{"messageType":"ping", "id": "${userID}"}`);}, 5000)
};
websocket.onclose = function (evt) {
@@ -269,15 +286,24 @@ function connectWebsocket(userID: string) {
return websocket;
}
function setFont(fontName: string) {
function setFont(fontName: string, fontSize: string) {
let content = document.getElementById('content');
if (!content) {
return;
}
content.style.fontFamily = fontName;
content.style.fontSize = fontSize;
document.body.style.fontFamily = fontName;
let textArea = document.getElementById('textarea_post');
if (!textArea) {
return;
}
textArea.style.fontFamily = fontName;
textArea.style.fontSize = fontSize;
}
function initOffline() {
@@ -295,8 +321,8 @@ function initButtons(userID: string, posts: Post[]) {
let font1Button = document.getElementById("button_font1") as HTMLButtonElement;
let font2Button = document.getElementById("button_font2") as HTMLButtonElement;
font1Button.addEventListener('click', () => { setFont('Bookerly'); });
font2Button.addEventListener('click', () => { setFont('Virgil') });
font1Button.addEventListener('click', () => { setFont('Bookerly', '16px') });
font2Button.addEventListener('click', () => { setFont('Virgil', '24px') });
let postButton = document.getElementById("button_post") as HTMLButtonElement;
@@ -349,7 +375,7 @@ async function main() {
log(`Persisted storage granted: ${isPersisted}`);
}
log(`Persisted: ${(await navigator.storage.persisted()).toString()}`);
log(`Persisted: ${(await navigator?.storage?.persisted())?.toString()}`);
initMarkdown();