30 lines
1.0 KiB
Python
30 lines
1.0 KiB
Python
"""Fix chat JS: remove duplicate _a() function, cleanup."""
|
|
path = "/home/ubuntu/ai-chat/app.py"
|
|
with open(path) as f:
|
|
content = f.read()
|
|
|
|
# Remove the second (old) _a function that's overwriting the markdown one
|
|
# It appears right after _md() returns
|
|
old_dup = """ return '<p>'+s+'</p>';
|
|
}
|
|
function _a(r,t){var d=document.createElement("div");d.className="msg "+r;
|
|
var b=document.createElement("div");b.className="bb";b.textContent=t;
|
|
d.appendChild(b);document.getElementById("cht").appendChild(d);
|
|
document.getElementById("cht").scrollTop=document.getElementById("cht").scrollHeight;}"""
|
|
|
|
new_clean = """ return '<p>'+s+'</p>';
|
|
}"""
|
|
|
|
content = content.replace(old_dup, new_clean)
|
|
|
|
with open(path, "w") as f:
|
|
f.write(content)
|
|
|
|
# Verify syntax: count _a definitions
|
|
count = content.count("function _a(r,t){")
|
|
print(f"Chat app fixed. _a definitions: {count} (should be 1)")
|
|
if count != 1:
|
|
print("WARNING: Still have duplicate _a functions!")
|
|
else:
|
|
print("OK - single _a function with markdown support")
|