Debug send failure - self-contained handler with visible error output
This commit is contained in:
parent
844ed05cf0
commit
c06b3706f2
1 changed files with 22 additions and 3 deletions
|
|
@ -16,10 +16,29 @@
|
||||||
<div id="chat"></div>
|
<div id="chat"></div>
|
||||||
|
|
||||||
<!-- Form for sending messages -->
|
<!-- Form for sending messages -->
|
||||||
<form id="message-form">
|
<form id="message-form" onsubmit="return false;">
|
||||||
<textarea id="message" placeholder="Type your message..." onkeydown="if(event.key==='Enter'&&!event.shiftKey){event.preventDefault();sendMessage();}"></textarea>
|
<textarea id="message" placeholder="Type your message..."></textarea>
|
||||||
<button type="submit" id="send-button">Send</button>
|
<button type="button" id="send-button" onclick="try{sendMessage();}catch(e){document.getElementById('chat').innerHTML+='<div style=color:red>Send error: '+e.message+'</div>';}">Send</button>
|
||||||
</form>
|
</form>
|
||||||
|
<script>
|
||||||
|
// Self-contained send logic — runs immediately after form exists
|
||||||
|
(function(){
|
||||||
|
var ta = document.getElementById('message');
|
||||||
|
if(!ta) return;
|
||||||
|
ta.addEventListener('keydown', function(e){
|
||||||
|
if(e.key === 'Enter' && !e.shiftKey){
|
||||||
|
e.preventDefault();
|
||||||
|
try {
|
||||||
|
sendMessage();
|
||||||
|
} catch(err) {
|
||||||
|
// Show error visibly in chat
|
||||||
|
var chat = document.getElementById('chat');
|
||||||
|
if(chat) chat.innerHTML += '<div style="color:red">Send error: ' + err.message + '</div>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="utility-belt">
|
<div class="utility-belt">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue