diff src/chat.js @ 22:949914955bfe

add menu
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 05 Nov 2024 14:29:16 -0700
parents dade6a560494
children c54c806fcc6e
line wrap: on
line diff
--- a/src/chat.js	Tue Nov 05 12:57:41 2024 -0700
+++ b/src/chat.js	Tue Nov 05 14:29:16 2024 -0700
@@ -124,3 +124,26 @@
 function urlsToLinks(text) {
 	return text.replace( urlRegex, '$1<a href="$2">$2</a>' );
 }
+
+let currentPulldown = null;
+let newPulldown = null;
+
+function clickMenu(clicked,display) {
+	//console.log("clickMenu");
+	let pulldown = clicked.parentNode.querySelector('div');
+	if( pulldown !== currentPulldown ) {
+		pulldown.style.display = display || "block";
+		newPulldown = pulldown;
+		window.onclick = function() {
+			//console.log("window.onclick");
+			if( currentPulldown ) {
+				currentPulldown.style.display = "none";
+				if( !newPulldown )
+					window.onclick = null;
+			}
+			currentPulldown = newPulldown;
+			newPulldown = null;
+		};
+		pulldown.scrollIntoViewIfNeeded(false);
+	}
+}