Mercurial Hosting > chat
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 21:5a56297713a3 | 22:949914955bfe |
|---|---|
| 122 let urlRegex = /(^|\s)(https?:\/\/\S+)/g; | 122 let urlRegex = /(^|\s)(https?:\/\/\S+)/g; |
| 123 | 123 |
| 124 function urlsToLinks(text) { | 124 function urlsToLinks(text) { |
| 125 return text.replace( urlRegex, '$1<a href="$2">$2</a>' ); | 125 return text.replace( urlRegex, '$1<a href="$2">$2</a>' ); |
| 126 } | 126 } |
| 127 | |
| 128 let currentPulldown = null; | |
| 129 let newPulldown = null; | |
| 130 | |
| 131 function clickMenu(clicked,display) { | |
| 132 //console.log("clickMenu"); | |
| 133 let pulldown = clicked.parentNode.querySelector('div'); | |
| 134 if( pulldown !== currentPulldown ) { | |
| 135 pulldown.style.display = display || "block"; | |
| 136 newPulldown = pulldown; | |
| 137 window.onclick = function() { | |
| 138 //console.log("window.onclick"); | |
| 139 if( currentPulldown ) { | |
| 140 currentPulldown.style.display = "none"; | |
| 141 if( !newPulldown ) | |
| 142 window.onclick = null; | |
| 143 } | |
| 144 currentPulldown = newPulldown; | |
| 145 newPulldown = null; | |
| 146 }; | |
| 147 pulldown.scrollIntoViewIfNeeded(false); | |
| 148 } | |
| 149 } |
