diff src/chat.js @ 35:27c41f22d2a9

improve fixPosts
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 12 Nov 2024 17:17:59 -0700
parents 62d04ca486dd
children 436216d17a1b
line wrap: on
line diff
--- a/src/chat.js	Tue Nov 12 16:08:24 2024 -0700
+++ b/src/chat.js	Tue Nov 12 17:17:59 2024 -0700
@@ -5,6 +5,7 @@
 let eventSource;
 let lastUpdate;
 let hasUnseen = false;
+let userId;
 
 function evalEvent(event) {
 	// console.log(event);
@@ -71,14 +72,14 @@
 }
 
 function fixPosts() {
-	let spans = document.querySelectorAll('span[when][fix]');
-	for( let span of spans ) {
-		span.textContent = new Date(Number(span.textContent)).toLocaleString();
-		span.removeAttribute('fix');
-	}
-	let divs = document.querySelectorAll('div[text][fix]');
+	let divs = document.querySelectorAll('div[post][fix]');
 	for( let div of divs ) {
-		div.innerHTML = urlsToLinks(div.innerHTML);
+		let whenSpan = div.querySelector('span[when]');
+		whenSpan.textContent = new Date(Number(whenSpan.textContent)).toLocaleString();
+		let textDiv = div.querySelector('div[text]');
+		textDiv.innerHTML = urlsToLinks(textDiv.innerHTML);
+		if( div.getAttribute('author') === userId )
+			div.querySelector('span[pulldown]').innerHTML = document.querySelector('div[hidden] span[pulldown]').innerHTML;
 		div.removeAttribute('fix');
 	}
 }