Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
chatbot canifa
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
chatbot canifa
Commits
c30f3c78
Commit
c30f3c78
authored
Jan 14, 2026
by
Vũ Hoàng Anh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: update static/index.html - persist user id and auto-load history
parent
91a24d89
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
3 deletions
+35
-3
index.html
backend/static/index.html
+35
-3
No files found.
backend/static/index.html
View file @
c30f3c78
...
...
@@ -441,7 +441,7 @@
<div
class=
"header"
>
<h2>
🤖 Canifa AI Chat
</h2>
<div
class=
"config-area"
>
<input
type=
"text"
id=
"userId"
placeholder=
"
User ID"
value=
"test_user_009
"
>
<input
type=
"text"
id=
"userId"
placeholder=
"
Enter User ID"
value=
""
onblur=
"saveUserId()"
onchange=
"saveUserId()
"
>
<button
onclick=
"loadHistory(true)"
>
↻ History
</button>
<button
onclick=
"clearUI()"
style=
"background: #d32f2f;"
>
✗ Clear UI
</button>
</div>
...
...
@@ -590,13 +590,20 @@
async
function
sendMessage
()
{
const
input
=
document
.
getElementById
(
'userInput'
);
const
userId
=
document
.
getElementById
(
'userId'
).
value
;
const
userIdInput
=
document
.
getElementById
(
'userId'
);
const
userId
=
userIdInput
.
value
.
trim
();
const
text
=
input
.
value
.
trim
();
const
sendBtn
=
document
.
getElementById
(
'sendBtn'
);
const
typingIndicator
=
document
.
getElementById
(
'typingIndicator'
);
const
chatBox
=
document
.
getElementById
(
'chatBox'
);
if
(
!
text
||
!
userId
)
return
;
if
(
!
userId
)
{
alert
(
'Please enter a User ID first!'
);
userIdInput
.
focus
();
return
;
}
if
(
!
text
)
return
;
// Disable input
input
.
disabled
=
true
;
...
...
@@ -613,6 +620,9 @@
input
.
value
=
''
;
chatBox
.
scrollTop
=
chatBox
.
scrollHeight
;
// Save user ID to localStorage
localStorage
.
setItem
(
'canifa_user_id'
,
userId
);
// Track response time
const
startTime
=
Date
.
now
();
...
...
@@ -819,6 +829,28 @@
function
clearUI
()
{
document
.
getElementById
(
'messagesArea'
).
innerHTML
=
''
;
}
// Save user ID to localStorage (called on input change/blur)
function
saveUserId
()
{
const
userIdInput
=
document
.
getElementById
(
'userId'
);
const
val
=
userIdInput
.
value
.
trim
();
if
(
val
)
{
localStorage
.
setItem
(
'canifa_user_id'
,
val
);
}
else
{
// If empty, remove saved id
localStorage
.
removeItem
(
'canifa_user_id'
);
}
}
// Load user ID from localStorage on page load and auto-load history
window
.
onload
=
function
()
{
const
savedUserId
=
localStorage
.
getItem
(
'canifa_user_id'
);
if
(
savedUserId
)
{
document
.
getElementById
(
'userId'
).
value
=
savedUserId
;
// Auto-load history for saved user id
setTimeout
(()
=>
loadHistory
(
true
),
50
);
}
};
</script>
</div>
<!-- Close main-content -->
</body>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment