Reaperxxxx commited on
Commit
27574b3
·
verified ·
1 Parent(s): 1e7d8bd

Update public/chat.html

Browse files
Files changed (1) hide show
  1. public/chat.html +44 -34
public/chat.html CHANGED
@@ -73,42 +73,52 @@
73
 
74
  // Add a message to the chat box
75
  function addMessageToChat(msg) {
76
- const messageDiv = document.createElement('div');
77
- messageDiv.style = `
78
- max-width: 70%;
79
- padding: 10px;
80
- border-radius: 8px;
81
- background-color: ${msg.sender === 'You' ? '#4caf50' : '#2c2c2c'};
82
- color: #ffffff;
83
- align-self: ${msg.sender === 'You' ? 'flex-end' : 'flex-start'};
84
- word-wrap: break-word;
85
- cursor: pointer;
86
- `;
87
-
88
- // Add reply thumbnail if applicable
89
- if (msg.replyTo) {
90
- const replyDiv = document.createElement('div');
91
- replyDiv.style = `
92
- margin-bottom: 8px;
93
- padding: 5px;
94
- border-left: 4px solid #888;
95
- font-size: 0.85rem;
96
- color: #bbb;
97
- `;
98
- replyDiv.textContent = msg.replyTo;
99
- messageDiv.appendChild(replyDiv);
100
- }
101
 
102
- messageDiv.innerHTML += `<strong>${msg.sender}</strong><br>${msg.content}`;
103
- messageDiv.addEventListener('click', () => {
104
- replyTo = msg.content;
105
- replyPreview.textContent = `Replying to: ${msg.content}`;
106
- replyPreview.style.display = 'block';
107
- });
 
 
108
 
109
- chatBox.appendChild(messageDiv);
110
- chatBox.scrollTop = chatBox.scrollHeight;
111
- }
 
 
 
 
 
 
 
 
112
 
113
  // Load chat messages
114
  async function loadMessages() {
 
73
 
74
  // Add a message to the chat box
75
  function addMessageToChat(msg) {
76
+ const messageDiv = document.createElement('div');
77
+ messageDiv.style = `
78
+ max-width: 70%;
79
+ padding: 10px;
80
+ border-radius: 8px;
81
+ background-color: ${msg.sender === 'You' ? '#4caf50' : '#2c2c2c'};
82
+ color: #ffffff;
83
+ align-self: ${msg.sender === 'You' ? 'flex-end' : 'flex-start'};
84
+ word-wrap: break-word;
85
+ cursor: pointer;
86
+ `;
87
+
88
+ // Add reply thumbnail if applicable
89
+ if (msg.replyTo) {
90
+ const replyDiv = document.createElement('div');
91
+ replyDiv.style = `
92
+ margin-bottom: 8px;
93
+ padding: 5px;
94
+ border-left: 4px solid #888;
95
+ font-size: 0.85rem;
96
+ color: #bbb;
97
+ `;
98
+ replyDiv.textContent = msg.replyTo;
99
+ messageDiv.appendChild(replyDiv);
100
+ }
101
 
102
+ // Add image if available
103
+ if (msg.imageUrl) {
104
+ const img = document.createElement('img');
105
+ img.src = msg.imageUrl;
106
+ img.alt = 'Image';
107
+ img.style = 'max-width: 100%; border-radius: 8px; margin-top: 10px;';
108
+ messageDiv.appendChild(img);
109
+ }
110
 
111
+ // Add sender and content
112
+ messageDiv.innerHTML += `<strong>${msg.sender}</strong><br>${msg.content || ''}`;
113
+ messageDiv.addEventListener('click', () => {
114
+ replyTo = msg.content;
115
+ replyPreview.textContent = `Replying to: ${msg.content}`;
116
+ replyPreview.style.display = 'block';
117
+ });
118
+
119
+ chatBox.appendChild(messageDiv);
120
+ chatBox.scrollTop = chatBox.scrollHeight;
121
+ }
122
 
123
  // Load chat messages
124
  async function loadMessages() {