Mercurial Hosting > chat
comparison src/chat.js @ 112:77c8104d7053
add selectPost
| author | Franklin Schmidt <fschmidt@gmail.com> |
|---|---|
| date | Thu, 13 Nov 2025 12:35:14 -0700 |
| parents | 37ab261aee7b |
| children |
comparison
equal
deleted
inserted
replaced
| 111:37ab261aee7b | 112:77c8104d7053 |
|---|---|
| 430 function replyPost(el) { | 430 function replyPost(el) { |
| 431 let postId = getPostId(el); | 431 let postId = getPostId(el); |
| 432 let div = document.querySelector('div[reply]'); | 432 let div = document.querySelector('div[reply]'); |
| 433 div.removeAttribute('hidden'); | 433 div.removeAttribute('hidden'); |
| 434 div.setAttribute('reply',postId); | 434 div.setAttribute('reply',postId); |
| 435 document.querySelector('div[reply] div[text]').innerHTML = document.querySelector(`div[post="${postId}"] div[text]`).innerHTML | 435 document.querySelector('div[reply] div[text]').innerHTML = document.querySelector(`div[post="${postId}"] div[text]`).innerHTML; |
| 436 let a = document.querySelector('div[reply] a[when]'); | 436 let a = document.querySelector('div[reply] a[when]'); |
| 437 a.href = `#p${postId}`; | 437 a.href = `#p${postId}`; |
| 438 a.textContent = document.querySelector(`div[post="${postId}"] span[when]`).textContent; | 438 a.textContent = document.querySelector(`div[post="${postId}"] span[when]`).textContent; |
| 439 document.querySelector('div[input] textarea').focus(); | 439 document.querySelector('div[input] textarea').focus(); |
| 440 document.querySelector('div[input]').scrollIntoView({block: 'end'}); | 440 document.querySelector('div[input]').scrollIntoView({block: 'end'}); |
| 460 | 460 |
| 461 function addToChatError(msg) { | 461 function addToChatError(msg) { |
| 462 let dialog = document.querySelector('dialog[add]'); | 462 let dialog = document.querySelector('dialog[add]'); |
| 463 dialog.querySelector('span[error]').textContent = msg; | 463 dialog.querySelector('span[error]').textContent = msg; |
| 464 } | 464 } |
| 465 | |
| 466 function selectPost(el) { | |
| 467 let postId = getPostId(el); | |
| 468 let div = document.querySelector(`div[post="${postId}"] div[text]`); | |
| 469 let range = document.createRange(); | |
| 470 range.selectNodeContents(div); | |
| 471 let selection = window.getSelection(); | |
| 472 selection.removeAllRanges(); | |
| 473 selection.addRange(range); | |
| 474 } |
