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lang="en">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8" />
|
5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
|
6 |
+
<title>AI Coach Site Supervisor</title>
|
7 |
+
<style>
|
8 |
+
/* Reset and base */
|
9 |
+
* {
|
10 |
+
box-sizing: border-box;
|
11 |
+
}
|
12 |
+
body, html {
|
13 |
+
margin: 0; padding: 0;
|
14 |
+
height: 100%;
|
15 |
+
background: #1e2a38;
|
16 |
+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
17 |
+
color: #eef2f7;
|
18 |
+
display: flex;
|
19 |
+
justify-content: center;
|
20 |
+
align-items: center;
|
21 |
+
}
|
22 |
+
#app {
|
23 |
+
max-width: 350px;
|
24 |
+
width: 100%;
|
25 |
+
height: 600px;
|
26 |
+
background: #273849;
|
27 |
+
border-radius: 14px;
|
28 |
+
box-shadow: 0 8px 24px rgba(0,0,0,0.6);
|
29 |
+
display: flex;
|
30 |
+
flex-direction: column;
|
31 |
+
overflow: hidden;
|
32 |
+
}
|
33 |
+
header {
|
34 |
+
background: #3a5068;
|
35 |
+
padding: 16px;
|
36 |
+
text-align: center;
|
37 |
+
font-size: 1.25rem;
|
38 |
+
font-weight: 700;
|
39 |
+
letter-spacing: 0.03em;
|
40 |
+
color: #f0f4f8;
|
41 |
+
box-shadow: inset 0 -3px 8px rgba(0,0,0,0.3);
|
42 |
+
user-select: none;
|
43 |
+
}
|
44 |
+
main.chat-area {
|
45 |
+
flex-grow: 1;
|
46 |
+
padding: 10px 14px;
|
47 |
+
display: flex;
|
48 |
+
flex-direction: column;
|
49 |
+
overflow-y: auto;
|
50 |
+
overscroll-behavior: contain;
|
51 |
+
}
|
52 |
+
.message {
|
53 |
+
max-width: 80%;
|
54 |
+
margin-bottom: 12px;
|
55 |
+
padding: 10px 14px;
|
56 |
+
border-radius: 14px;
|
57 |
+
line-height: 1.3;
|
58 |
+
font-size: 0.9rem;
|
59 |
+
word-wrap: break-word;
|
60 |
+
}
|
61 |
+
.user-message {
|
62 |
+
background: #4a90e2;
|
63 |
+
align-self: flex-end;
|
64 |
+
border-bottom-right-radius: 2px;
|
65 |
+
}
|
66 |
+
.bot-message {
|
67 |
+
background: #485563;
|
68 |
+
align-self: flex-start;
|
69 |
+
border-bottom-left-radius: 2px;
|
70 |
+
}
|
71 |
+
footer {
|
72 |
+
background: #3a5068;
|
73 |
+
padding: 8px 12px;
|
74 |
+
display: flex;
|
75 |
+
align-items: center;
|
76 |
+
gap: 8px;
|
77 |
+
}
|
78 |
+
footer input[type="text"] {
|
79 |
+
flex-grow: 1;
|
80 |
+
padding: 10px 14px;
|
81 |
+
border: none;
|
82 |
+
border-radius: 10px;
|
83 |
+
font-size: 1rem;
|
84 |
+
outline: none;
|
85 |
+
background: #2f4154;
|
86 |
+
color: #e0e6ed;
|
87 |
+
user-select: text;
|
88 |
+
}
|
89 |
+
footer button {
|
90 |
+
padding: 10px 14px;
|
91 |
+
background: #4a90e2;
|
92 |
+
border: none;
|
93 |
+
border-radius: 10px;
|
94 |
+
color: white;
|
95 |
+
font-weight: 700;
|
96 |
+
font-size: 1rem;
|
97 |
+
cursor: pointer;
|
98 |
+
user-select: none;
|
99 |
+
transition: background-color 0.3s ease;
|
100 |
+
}
|
101 |
+
footer button:disabled {
|
102 |
+
opacity: 0.5;
|
103 |
+
cursor: default;
|
104 |
+
}
|
105 |
+
footer button:hover:not(:disabled) {
|
106 |
+
background-color: #357abd;
|
107 |
+
}
|
108 |
+
/* Scrollbar styling */
|
109 |
+
main.chat-area::-webkit-scrollbar {
|
110 |
+
width: 6px;
|
111 |
+
}
|
112 |
+
main.chat-area::-webkit-scrollbar-track {
|
113 |
+
background: #2f4154;
|
114 |
+
}
|
115 |
+
main.chat-area::-webkit-scrollbar-thumb {
|
116 |
+
background: #4a90e2;
|
117 |
+
border-radius: 3px;
|
118 |
+
}
|
119 |
+
@media (max-width: 360px) {
|
120 |
+
#app {
|
121 |
+
max-width: 100vw;
|
122 |
+
border-radius: 0;
|
123 |
+
height: 100vh;
|
124 |
+
}
|
125 |
+
}
|
126 |
+
</style>
|
127 |
+
</head>
|
128 |
+
<body>
|
129 |
+
<div id="app" role="main" aria-label="AI Coach Site Supervisor Chat Application">
|
130 |
+
<header>AI Coach Site Supervisor</header>
|
131 |
+
<main class="chat-area" id="chat" aria-live="polite" aria-relevant="additions"></main>
|
132 |
+
<footer>
|
133 |
+
<input type="text" id="userInput" placeholder="Describe an issue or ask for advice..." aria-label="Chat input"/>
|
134 |
+
<button id="sendBtn" aria-label="Send message">Send</button>
|
135 |
+
</footer>
|
136 |
+
</div>
|
137 |
+
|
138 |
+
<script>
|
139 |
+
// Basic conversational logic for AI Coach Site Supervisor
|
140 |
+
const chatArea = document.getElementById('chat');
|
141 |
+
const userInput = document.getElementById('userInput');
|
142 |
+
const sendBtn = document.getElementById('sendBtn');
|
143 |
+
|
144 |
+
// Predefined advice responses for keywords
|
145 |
+
const adviceDB = [
|
146 |
+
{
|
147 |
+
keywords: ['safety', 'helmet', 'ppe', 'gear'],
|
148 |
+
reply: 'Always wear the required PPE onsite, including helmet, gloves, and safety boots to prevent injuries.'
|
149 |
+
},
|
150 |
+
{
|
151 |
+
keywords: ['delay', 'schedule', 'late', 'time'],
|
152 |
+
reply: 'Review the project timeline and notify stakeholders immediately about delays to adjust workload effectively.'
|
153 |
+
},
|
154 |
+
{
|
155 |
+
keywords: ['equipment', 'machine', 'breakdown', 'repair'],
|
156 |
+
reply: 'Report equipment issues promptly to maintenance and avoid using faulty machinery to ensure safety.'
|
157 |
+
},
|
158 |
+
{
|
159 |
+
keywords: ['inspection', 'quality', 'check'],
|
160 |
+
reply: 'Ensure all phases pass quality inspections and document findings carefully for audits.'
|
161 |
+
},
|
162 |
+
{
|
163 |
+
keywords: ['team', 'worker', 'conflict', 'communication'],
|
164 |
+
reply: 'Maintain clear and respectful communication with your team to resolve conflicts and boost productivity.'
|
165 |
+
},
|
166 |
+
{
|
167 |
+
keywords: ['emergency', 'fire', 'accident', 'first aid'],
|
168 |
+
reply: 'Have an emergency response plan accessible and ensure everyone knows evacuation routes and emergency contacts.'
|
169 |
+
}
|
170 |
+
];
|
171 |
+
|
172 |
+
// Default reply for unmatched input
|
173 |
+
const defaultReply = "Thanks for your input. As a site supervisor AI coach, I'm here to assist with safety, scheduling, equipment, and team matters. Could you please provide more details?";
|
174 |
+
|
175 |
+
// Add message to chat area
|
176 |
+
function addMessage(text, type = 'bot-message') {
|
177 |
+
const msgDiv = document.createElement('div');
|
178 |
+
msgDiv.className = 'message ' + type;
|
179 |
+
msgDiv.textContent = text;
|
180 |
+
chatArea.appendChild(msgDiv);
|
181 |
+
chatArea.scrollTop = chatArea.scrollHeight;
|
182 |
+
}
|
183 |
+
|
184 |
+
// Process user input and generate bot reply
|
185 |
+
function processInput(input) {
|
186 |
+
if (!input.trim()) return;
|
187 |
+
|
188 |
+
// Show user message
|
189 |
+
addMessage(input, 'user-message');
|
190 |
+
|
191 |
+
// Convert input to lowercase for matching
|
192 |
+
const lowerInput = input.toLowerCase();
|
193 |
+
|
194 |
+
// Find matching advice
|
195 |
+
for (const entry of adviceDB) {
|
196 |
+
for (const keyword of entry.keywords) {
|
197 |
+
if (lowerInput.includes(keyword)) {
|
198 |
+
addMessage(entry.reply);
|
199 |
+
return;
|
200 |
+
}
|
201 |
+
}
|
202 |
+
}
|
203 |
+
|
204 |
+
// No keyword matched
|
205 |
+
addMessage(defaultReply);
|
206 |
+
}
|
207 |
+
|
208 |
+
// Event listeners
|
209 |
+
sendBtn.addEventListener('click', () => {
|
210 |
+
if (userInput.value.trim() === '') return;
|
211 |
+
processInput(userInput.value);
|
212 |
+
userInput.value = '';
|
213 |
+
userInput.focus();
|
214 |
+
});
|
215 |
+
|
216 |
+
userInput.addEventListener('keydown', e => {
|
217 |
+
if (e.key === 'Enter' && !e.shiftKey) {
|
218 |
+
e.preventDefault();
|
219 |
+
sendBtn.click();
|
220 |
+
}
|
221 |
+
});
|
222 |
+
|
223 |
+
// Initial greeting
|
224 |
+
window.onload = () => {
|
225 |
+
addMessage('Hello! I am your Site Supervisor AI Coach. Ask me about safety, scheduling, equipment, or team issues.');
|
226 |
+
};
|
227 |
+
</script>
|
228 |
+
</body>
|
229 |
+
</html>
|
230 |
+
|