-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
144 lines (120 loc) · 4.67 KB
/
script.js
File metadata and controls
144 lines (120 loc) · 4.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
let currentSuggestionIndex = 0;
const suggestions = ["newSuggestion", "newSuggestion2", "newSuggestion3"];
function confirmAddEvent(eventDescription, confirmationMessage, button) {
const userConfirmed = confirm(confirmationMessage);
if (userConfirmed) {
addEventToCalendar(eventDescription);
replaceSuggestion(button); // Replace the suggestion after confirmation
}
}
function addEventToCalendar(eventDescription) {
// Add here the code to link it to the Microsoft API
}
function replaceSuggestion(button) {
const parentSuggestion = button.closest('.suggestion');
const newSuggestionId = suggestions[currentSuggestionIndex];
const newSuggestion = document.getElementById(newSuggestionId);
parentSuggestion.innerHTML = newSuggestion.innerHTML;
// Update the index for the next suggestion
currentSuggestionIndex = (currentSuggestionIndex + 1) % suggestions.length;
}
function highlightButtonClick() {
alert("Button clicked! Implement your desired functionality here.");
}
function addHighlight() {
const newHighlight = prompt("Enter the new highlight:");
if (newHighlight) {
const highlightsInfo = document.getElementById('highlights-info');
const newHighlightItem = document.createElement('li');
newHighlightItem.textContent = newHighlight;
highlightsInfo.appendChild(newHighlightItem);
}
}
async function sendMessage() {
const userInputElement = document.getElementById('userInput');
const userInput = userInputElement.value;
if (!userInput) return;
addMessage('You: ' + userInput, 'user-message');
// Clear the input field immediately after retrieving its value
userInputElement.value = '';
// Show the loading spinner in the chat
const loadingMessage = addMessage('HumAIn is typing...', 'loading');
const spinner = document.createElement('div');
spinner.className = 'spinner';
loadingMessage.appendChild(spinner);
const response = await fetch('http://127.0.0.1:5000/send-message', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ message: userInput })
});
// Remove the loading message
loadingMessage.remove();
const data = await response.json();
addMessage('HumAIn: ' + data.message, 'bot-message');
}
function addMessage(text, className) {
const messagesDiv = document.getElementById('messages');
const messageDiv = document.createElement('div');
messageDiv.className = 'message ' + className;
messageDiv.textContent = text;
messagesDiv.appendChild(messageDiv);
messagesDiv.scrollTop = messagesDiv.scrollHeight;
return messageDiv;
}
let zoomLevel = 1;
const highlightsData = {
week: [
"Charles P., Jennifier O., Liza T. are joining your yeam",
"Sofia Palini is celebrating 2 years at Infosys",
"Major product launch event",
"George Paul is due to complete his project",
"Ankit is on week 2 of onboarding",
"Suzan is signing an big contract with a client",
"Weekly training or skill development session."
],
day: [
"It's Luca's Birthday today",
"It's Michal Jo's last day in the company",
"Lunch with Coca Cola to finalize the deal",
"Suzan just gave birth to her second child",
"Check on the team morale",
"Sending daily reports to upper management"
],
month: [
"Project deadline approaching",
"Team outing scheduled",
"Monthly budget and expense review",
"Michal Jo is retiring next month",
"Client feedback session",
"New project kickoff",
"Celebrating employee work anniversaries"
],
year: [
"Celebrate the company's anniversary.",
"Year-end performance reviews",
"Holiday party planning",
"Annual client appreciation day",
"Budget planning for next year",
"Employee recognition awards",
"Annual performance review meetings"
]
};
function toggleDropdown() {
const dropdown = document.getElementById('dropdownMenu');
dropdown.classList.toggle('show');
}
function changeHighlights(period) {
const highlightsInfo = document.getElementById('highlights-info');
const title = document.getElementById('highlights-title');
title.textContent = `Highlights of the ${period}`;
const items = highlightsData[period].map(item => `<li>${item}</li>`).join('');
highlightsInfo.innerHTML = `<ul>${items}</ul>`;
// Hide the dropdown after selection
toggleDropdown();
}
// Initialize with weekly highlights
document.addEventListener('DOMContentLoaded', () => {
changeHighlights('week');
});