LiamKhoaLe commited on
Commit
7874196
·
1 Parent(s): 16ba0a7

Upd history MD parser

Browse files
Files changed (2) hide show
  1. static/index.html +3 -2
  2. static/projects.js +12 -9
static/index.html CHANGED
@@ -304,10 +304,11 @@
304
  </div>
305
  </div>
306
 
 
 
307
  <script src="/static/auth.js"></script>
308
  <script src="/static/sidebar.js"></script>
309
- <script src="/static/projects.js"></script>
310
  <script src="/static/script.js"></script>
311
- <script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
312
  </body>
313
  </html>
 
304
  </div>
305
  </div>
306
 
307
+ <!-- Load markdown parser first so appendMessage can use it -->
308
+ <script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
309
  <script src="/static/auth.js"></script>
310
  <script src="/static/sidebar.js"></script>
 
311
  <script src="/static/script.js"></script>
312
+ <script src="/static/projects.js"></script>
313
  </body>
314
  </html>
static/projects.js CHANGED
@@ -275,9 +275,18 @@
275
  const messagesContainer = document.getElementById('messages');
276
  messagesContainer.innerHTML = '';
277
 
278
- // Load chat history
279
  messages.forEach(msg => {
280
- appendMessage(msg.role, msg.content);
 
 
 
 
 
 
 
 
 
281
  });
282
 
283
  // Scroll to bottom
@@ -290,13 +299,7 @@
290
  }
291
  }
292
 
293
- function appendMessage(role, content) {
294
- const messagesContainer = document.getElementById('messages');
295
- const messageDiv = document.createElement('div');
296
- messageDiv.className = `msg ${role}`;
297
- messageDiv.textContent = content;
298
- messagesContainer.appendChild(messageDiv);
299
- }
300
 
301
  function enableChat() {
302
  const questionInput = document.getElementById('question');
 
275
  const messagesContainer = document.getElementById('messages');
276
  messagesContainer.innerHTML = '';
277
 
278
+ // Load chat history using global markdown-aware renderer
279
  messages.forEach(msg => {
280
+ if (typeof window.appendMessage === 'function') {
281
+ window.appendMessage(msg.role, msg.content);
282
+ } else {
283
+ // Fallback if not yet defined
284
+ const messagesContainer = document.getElementById('messages');
285
+ const messageDiv = document.createElement('div');
286
+ messageDiv.className = `msg ${msg.role}`;
287
+ messageDiv.textContent = msg.content;
288
+ messagesContainer.appendChild(messageDiv);
289
+ }
290
  });
291
 
292
  // Scroll to bottom
 
299
  }
300
  }
301
 
302
+ // Do not shadow global appendMessage from script.js
 
 
 
 
 
 
303
 
304
  function enableChat() {
305
  const questionInput = document.getElementById('question');