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

@@ -99,6 +99,7 @@
#log { #log {
font-family: monospace; font-family: monospace;
text-wrap: nowrap;
} }
.button { .button {

BIN
main

Binary file not shown.

View File

@@ -73,7 +73,7 @@ func noDirListing(h http.Handler, root string) http.HandlerFunc {
func main() { func main() {
dir := "./" dir := "./"
port := 80 port := 6789
addr := ":" + strconv.Itoa(port) addr := ":" + strconv.Itoa(port)
log.Printf("Starting server on %s", addr) log.Printf("Starting server on %s", addr)

31
main.js

File diff suppressed because one or more lines are too long

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() { function initMarkdown() {
const renderer = new marked.Renderer(); const renderer = new marked.Renderer();
@@ -252,6 +267,8 @@ function connectWebsocket(userID: string) {
websocket.onopen = function (evt) { websocket.onopen = function (evt) {
log("Websocket: CONNECTED"); log("Websocket: CONNECTED");
websocket.send(`{"messageType":"connect", "id": "${userID}"}`); websocket.send(`{"messageType":"connect", "id": "${userID}"}`);
let websocketPingInterval = window.setInterval(()=>{websocket.send(`{"messageType":"ping", "id": "${userID}"}`);}, 5000)
}; };
websocket.onclose = function (evt) { websocket.onclose = function (evt) {
@@ -269,15 +286,24 @@ function connectWebsocket(userID: string) {
return websocket; 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'); let textArea = document.getElementById('textarea_post');
if (!textArea) { if (!textArea) {
return; return;
} }
textArea.style.fontFamily = fontName; textArea.style.fontFamily = fontName;
textArea.style.fontSize = fontSize;
} }
function initOffline() { function initOffline() {
@@ -295,8 +321,8 @@ function initButtons(userID: string, posts: Post[]) {
let font1Button = document.getElementById("button_font1") as HTMLButtonElement; let font1Button = document.getElementById("button_font1") as HTMLButtonElement;
let font2Button = document.getElementById("button_font2") as HTMLButtonElement; let font2Button = document.getElementById("button_font2") as HTMLButtonElement;
font1Button.addEventListener('click', () => { setFont('Bookerly'); }); font1Button.addEventListener('click', () => { setFont('Bookerly', '16px') });
font2Button.addEventListener('click', () => { setFont('Virgil') }); font2Button.addEventListener('click', () => { setFont('Virgil', '24px') });
let postButton = document.getElementById("button_post") as HTMLButtonElement; let postButton = document.getElementById("button_post") as HTMLButtonElement;
@@ -349,7 +375,7 @@ async function main() {
log(`Persisted storage granted: ${isPersisted}`); log(`Persisted storage granted: ${isPersisted}`);
} }
log(`Persisted: ${(await navigator.storage.persisted()).toString()}`); log(`Persisted: ${(await navigator?.storage?.persisted())?.toString()}`);
initMarkdown(); initMarkdown();