Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2023-362
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
2023-362
2023-362
Commits
def9f82c
Commit
def9f82c
authored
Oct 30, 2023
by
Thathsarani R.P.H.S.R
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create js files.
parent
debd3363
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
92 additions
and
0 deletions
+92
-0
IT20201364/static/script.js
IT20201364/static/script.js
+66
-0
IT20201364/static/script2.js
IT20201364/static/script2.js
+26
-0
No files found.
IT20201364/static/script.js
0 → 100644
View file @
def9f82c
function
updateEmotionTable
(
emotionPercentages
)
{
var
tableBody
=
document
.
querySelector
(
"
#emotion-table tbody
"
);
tableBody
.
innerHTML
=
""
;
for
(
var
emotion
in
emotionPercentages
)
{
var
row
=
tableBody
.
insertRow
();
var
cell1
=
row
.
insertCell
(
0
);
var
cell2
=
row
.
insertCell
(
1
);
cell1
.
textContent
=
emotion
;
cell2
.
textContent
=
emotionPercentages
[
emotion
]
+
"
%
"
;
}
}
function
updateStressLevel
(
stressLevel
)
{
var
stressLevelElement
=
document
.
querySelector
(
"
#stress-level
"
);
stressLevelElement
.
textContent
=
stressLevel
;
}
function
startCounselling
()
{
window
.
location
.
href
=
'
/process_route
'
;
}
function
resetCounselling
()
{
var
xhr
=
new
XMLHttpRequest
();
xhr
.
open
(
"
POST
"
,
"
/reset
"
,
true
);
xhr
.
onreadystatechange
=
function
()
{
if
(
xhr
.
readyState
===
4
&&
xhr
.
status
===
200
)
{
// Redirect to the login page after resetting
window
.
location
.
href
=
'
/login
'
;
}
};
xhr
.
send
();
}
const
eventSource
=
new
EventSource
(
'
/stream
'
);
const
conversationElement
=
document
.
getElementById
(
"
conversation
"
);
eventSource
.
onmessage
=
function
(
event
)
{
const
newMessage
=
event
.
data
.
trim
();
// Trim any leading/trailing whitespace
if
(
newMessage
)
{
// Append the new message to the conversation list
appendMessageToConversation
(
newMessage
);
}
};
function
toggleRecords
()
{
const
recordsElement
=
document
.
querySelector
(
"
.previous-stress-level
"
);
recordsElement
.
classList
.
toggle
(
"
expanded
"
);
}
function
appendMessageToConversation
(
message
)
{
const
conversationList
=
document
.
querySelector
(
"
#conversation ul
"
);
const
messageElement
=
document
.
createElement
(
"
li
"
);
messageElement
.
classList
.
add
(
"
message
"
);
messageElement
.
textContent
=
message
;
conversationList
.
insertBefore
(
messageElement
,
conversationList
.
firstChild
);
}
function
togglePreviousRecords
()
{
const
previousRecords
=
document
.
getElementById
(
"
previous-records
"
);
if
(
previousRecords
.
style
.
display
===
"
block
"
)
{
previousRecords
.
style
.
display
=
"
none
"
;
}
else
{
previousRecords
.
style
.
display
=
"
block
"
;
}
}
\ No newline at end of file
IT20201364/static/script2.js
0 → 100644
View file @
def9f82c
document
.
addEventListener
(
"
DOMContentLoaded
"
,
function
()
{
// Get a reference to the conversation <div> element
const
conversationDiv
=
document
.
getElementById
(
"
conversation
"
);
// Function to add a message to the conversation
function
addMessageToConversation
(
message
,
sender
)
{
// Create a <p> element for the message
const
messageElement
=
document
.
createElement
(
"
p
"
);
// Set the text content based on the sender
if
(
sender
===
"
User
"
)
{
messageElement
.
textContent
=
"
User:
"
+
message
;
}
else
{
messageElement
.
textContent
=
"
zenBot:
"
+
message
;
}
// Append the <p> element to the conversation <div>
conversationDiv
.
appendChild
(
messageElement
);
// Scroll the conversation <div> to the bottom to show the latest message
conversationDiv
.
scrollTop
=
conversationDiv
.
scrollHeight
;
}
// Display a welcome message when the page loads
addMessageToConversation
(
"
Welcome to the Chat !
"
,
"
zenBot
"
);
});
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