55 lines
2.0 KiB
Python
55 lines
2.0 KiB
Python
|
|
import re
|
||
|
|
|
||
|
|
with open("static/js/bottom-bar.js", "r") as f:
|
||
|
|
content = f.read()
|
||
|
|
|
||
|
|
events = """
|
||
|
|
function bindDynamicActions() {
|
||
|
|
const listContainer = byId('bbDynamicList');
|
||
|
|
if (!listContainer) return;
|
||
|
|
|
||
|
|
listContainer.addEventListener('click', function (e) {
|
||
|
|
const target = e.target;
|
||
|
|
const btn = target.closest('button');
|
||
|
|
if (!btn) return;
|
||
|
|
|
||
|
|
if (btn.id === 'btnNextTask') {
|
||
|
|
console.log("-> Beder backend om næste opgave...");
|
||
|
|
btn.innerHTML = '<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span> Henter...';
|
||
|
|
btn.disabled = true;
|
||
|
|
setTimeout(() => {
|
||
|
|
btn.innerHTML = '<i class="bi bi-magic me-2"></i>Du fik tildelt Sag #8192!';
|
||
|
|
btn.classList.add('btn-success');
|
||
|
|
btn.classList.remove('btn-primary');
|
||
|
|
}, 1000);
|
||
|
|
}
|
||
|
|
|
||
|
|
if (btn.id === 'btnSendMsg') {
|
||
|
|
const input = byId('chatInputQuick');
|
||
|
|
if (input && input.value.trim() !== '') {
|
||
|
|
console.log("-> Sender besked:", input.value);
|
||
|
|
input.value = '';
|
||
|
|
const msgDiv = document.createElement('div');
|
||
|
|
msgDiv.className = 'mb-1 text-end';
|
||
|
|
msgDiv.innerHTML = '<div class="d-inline-block bg-primary text-white p-2 rounded-3" style="max-width: 80%;"><strong>Mig:</strong> ' + msgDiv.textContent + ' (Mock)</div>';
|
||
|
|
listContainer.insertBefore(msgDiv, listContainer.lastElementChild);
|
||
|
|
listContainer.scrollTop = listContainer.scrollHeight;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
function init() {"""
|
||
|
|
|
||
|
|
content = re.sub(r' function init\(\) \{', events, content)
|
||
|
|
|
||
|
|
init_bindings = """
|
||
|
|
bindSideTabs();
|
||
|
|
bindDynamicActions();
|
||
|
|
"""
|
||
|
|
|
||
|
|
content = re.sub(r' bindSideTabs\(\);', init_bindings, content)
|
||
|
|
|
||
|
|
with open("static/js/bottom-bar.js", "w") as f:
|
||
|
|
f.write(content)
|