WIP
This commit is contained in:
@@ -99,6 +99,7 @@
|
|||||||
|
|
||||||
#log {
|
#log {
|
||||||
font-family: monospace;
|
font-family: monospace;
|
||||||
|
text-wrap: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.button {
|
.button {
|
||||||
|
|||||||
2
main.go
2
main.go
@@ -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)
|
||||||
|
|||||||
36
src/main.ts
36
src/main.ts
@@ -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();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user