import re with open("static/js/bottom-bar.js", "r") as f: text = f.read() # Update the rendering of the messages tab to include a user selector chat_html = """ const replyBox = document.createElement('div'); replyBox.className = 'mt-2 border-top pt-2 border-primary-subtle'; replyBox.innerHTML = `
`; chatContainer.appendChild(ul); chatContainer.appendChild(replyBox); """ text = re.sub( r" const replyBox = document\.createElement\('div'\);\n replyBox\.className = 'input-group mt-2 border-top pt-2 border-primary-subtle';\n replyBox\.innerHTML = '';\n \n chatContainer\.appendChild\(ul\);\n chatContainer\.appendChild\(replyBox\);", chat_html, text ) # And update the logic that sends it events_html = """ if (btn.id === 'btnSendMsg') { const input = byId('chatInputQuick'); const recipientObj = byId('chatRecipient'); if (input && input.value.trim() !== '') { const recipient = recipientObj ? recipientObj.options[recipientObj.selectedIndex].text : 'Alle'; console.log("-> Sender besked til " + recipient + ":", input.value); const msgVal = input.value; input.value = ''; const msgDiv = document.createElement('div'); msgDiv.className = 'mb-1 text-end'; msgDiv.innerHTML = '
Til: ' + recipient + '
Mig: ' + msgVal + '
'; listContainer.insertBefore(msgDiv, listContainer.lastElementChild); listContainer.scrollTop = listContainer.scrollHeight; } } """ text = re.sub( r" if \(btn\.id === 'btnSendMsg'\) \{\n const input = byId\('chatInputQuick'\);\n if \(input && input\.value\.trim\(\) !== ''\) \{\n console\.log\(\"-> Sender besked:\", input\.value\);\n input\.value = '';\n const msgDiv = document\.createElement\('div'\);\n msgDiv\.className = 'mb-1 text-end';\n msgDiv\.innerHTML = '
Mig: ' \+ msgDiv\.textContent \+ ' \(Mock\)
';\n listContainer\.insertBefore\(msgDiv, listContainer\.lastElementChild\);\n listContainer\.scrollTop = listContainer\.scrollHeight;\n \}\n \}", events_html.strip(), text ) with open("static/js/bottom-bar.js", "w") as f: f.write(text)