Added reply.
This commit is contained in:
		
							parent
							
								
									c6c2766381
								
							
						
					
					
						commit
						5cfcafe082
					
				| @ -22,6 +22,10 @@ | |||||||
| <script> | <script> | ||||||
|     const channelUid = "{{ channel.uid.value }}"; |     const channelUid = "{{ channel.uid.value }}"; | ||||||
| 
 | 
 | ||||||
|  |     function getInputField(){ | ||||||
|  |         return document.querySelector("textarea") | ||||||
|  |     } | ||||||
|  |          | ||||||
|     function initInputField(textBox) { |     function initInputField(textBox) { | ||||||
|         textBox.addEventListener('change', (e) => { |         textBox.addEventListener('change', (e) => { | ||||||
|             e.preventDefault(); |             e.preventDefault(); | ||||||
| @ -41,9 +45,28 @@ | |||||||
|         textBox.focus(); |         textBox.focus(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     function replyMessage(message) { | ||||||
|  |         const field = getInputField()  | ||||||
|  |         field.value = "```\n" + (message || '') + "\n```\n"; | ||||||
|  |         field.focus(); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     function updateTimes() { |     function updateTimes() { | ||||||
|         document.querySelectorAll(".time").forEach((time) => { |         document.querySelectorAll(".time").forEach((container) => { | ||||||
|  |             const messageDiv = container.closest('.message'); | ||||||
|  |             const userNick = messageDiv.dataset.user_nick; | ||||||
|  |             const text = messageDiv.querySelector(".text").innerText; | ||||||
|  |             const time = document.createElement("span"); | ||||||
|             time.innerText = app.timeDescription(time.dataset.created_at); |             time.innerText = app.timeDescription(time.dataset.created_at); | ||||||
|  |             container.replaceChildren(time); | ||||||
|  |             const reply = document.createElement("a"); | ||||||
|  |             reply.innerText = " reply"; | ||||||
|  |             reply.href = "#reply"; | ||||||
|  |             container.appendChild(reply); | ||||||
|  |             reply.addEventListener('click', (e) => { | ||||||
|  |                 e.preventDefault(); | ||||||
|  |                 replyMessage(text); | ||||||
|  |             }) | ||||||
|         }); |         }); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -159,7 +182,7 @@ | |||||||
|         }, 1000); |         }, 1000); | ||||||
|     }); |     }); | ||||||
| 
 | 
 | ||||||
|     initInputField(document.querySelector("textarea")); |     initInputField(getInputField()); | ||||||
|     updateLayout(true); |     updateLayout(true); | ||||||
| </script> | </script> | ||||||
| {% endblock %} | {% endblock %} | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user