Folder reorganize 1
This commit is contained in:
287
test/uimodel/test2.html
Normal file
287
test/uimodel/test2.html
Normal file
@@ -0,0 +1,287 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Unified AI Chat</title>
|
||||
<script src="https://cdn.tailwindcss.com"></script>
|
||||
<!-- Font Awesome for icons -->
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
|
||||
<style>
|
||||
body {
|
||||
font-family: 'Inter', sans-serif;
|
||||
background-color: #F9FAFB; /* Light gray background */
|
||||
color: #1F2937; /* Dark charcoal text */
|
||||
overflow: hidden; /* Prevent body scroll */
|
||||
}
|
||||
.chat-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100vh; /* Full viewport height */
|
||||
max-height: 100vh; /* Ensure it doesn't exceed viewport */
|
||||
width: 100%;
|
||||
background-color: white;
|
||||
border-radius: 1rem;
|
||||
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
|
||||
overflow: hidden; /* Hide internal scrollbars */
|
||||
}
|
||||
.chat-header {
|
||||
background-color: #3B82F6; /* Blue */
|
||||
color: white;
|
||||
padding: 1.5rem;
|
||||
border-top-left-radius: 1rem;
|
||||
border-top-right-radius: 1rem;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
font-weight: 600;
|
||||
font-size: 1.25rem;
|
||||
}
|
||||
.chat-messages {
|
||||
flex-grow: 1;
|
||||
padding: 1.5rem;
|
||||
overflow-y: auto; /* Enable scrolling for messages */
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
.message-bubble {
|
||||
max-width: 80%;
|
||||
padding: 0.75rem 1rem;
|
||||
border-radius: 0.75rem;
|
||||
line-height: 1.4;
|
||||
}
|
||||
.message-bubble.user {
|
||||
background-color: #3B82F6;
|
||||
color: white;
|
||||
align-self: flex-end;
|
||||
}
|
||||
.message-bubble.agent {
|
||||
background-color: #E0E7FF; /* Light blue */
|
||||
color: #1F2937;
|
||||
align-self: flex-start;
|
||||
}
|
||||
.message-bubble.agent .agent-icon {
|
||||
color: #3B82F6;
|
||||
}
|
||||
.chat-input {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 1rem 1.5rem;
|
||||
border-top: 1px solid #E5E7EB;
|
||||
background-color: #F9FAFB;
|
||||
}
|
||||
.chat-input input {
|
||||
flex-grow: 1;
|
||||
border: 1px solid #D1D5DB;
|
||||
border-radius: 0.5rem;
|
||||
padding: 0.75rem 1rem;
|
||||
outline: none;
|
||||
font-size: 1rem;
|
||||
}
|
||||
.chat-input button {
|
||||
background-color: #3B82F6;
|
||||
color: white;
|
||||
padding: 0.75rem 1rem;
|
||||
border-radius: 0.5rem;
|
||||
margin-left: 0.75rem;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.2s ease;
|
||||
}
|
||||
.chat-input button:hover {
|
||||
background-color: #2563EB;
|
||||
}
|
||||
|
||||
/* Agent Selection Area */
|
||||
.agent-selection {
|
||||
background-color: #F9FAFB;
|
||||
padding: 1rem;
|
||||
border-bottom: 1px solid #E5E7EB;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.75rem;
|
||||
overflow-x: auto; /* Enable horizontal scrolling for agents */
|
||||
-ms-overflow-style: none; /* IE and Edge */
|
||||
scrollbar-width: none; /* Firefox */
|
||||
}
|
||||
.agent-selection::-webkit-scrollbar {
|
||||
display: none; /* Chrome, Safari, Opera */
|
||||
}
|
||||
.agent-btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 0.5rem 1rem;
|
||||
border-radius: 0.5rem;
|
||||
font-size: 0.9rem;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.2s ease;
|
||||
white-space: nowrap; /* Prevent text wrapping */
|
||||
}
|
||||
.agent-btn:hover {
|
||||
background-color: #E0E7FF;
|
||||
}
|
||||
.agent-btn.active {
|
||||
background-color: #3B82F6;
|
||||
color: white;
|
||||
}
|
||||
.agent-btn.active:hover {
|
||||
background-color: #2563EB;
|
||||
}
|
||||
.agent-btn .agent-icon {
|
||||
margin-right: 0.5rem;
|
||||
}
|
||||
|
||||
/* Responsive adjustments */
|
||||
@media (max-width: 768px) {
|
||||
.chat-header {
|
||||
font-size: 1.125rem;
|
||||
padding: 1rem;
|
||||
}
|
||||
.chat-messages {
|
||||
padding: 1rem;
|
||||
}
|
||||
.message-bubble {
|
||||
max-width: 90%;
|
||||
}
|
||||
.chat-input {
|
||||
padding: 0.75rem 1rem;
|
||||
}
|
||||
.agent-selection {
|
||||
padding: 0.5rem;
|
||||
}
|
||||
.agent-btn {
|
||||
padding: 0.4rem 0.8rem;
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="chat-container mx-auto w-full max-w-3xl">
|
||||
<!-- Agent Selection Area -->
|
||||
<div class="agent-selection">
|
||||
<button class="agent-btn active" data-agent-id="default">
|
||||
<i class="fas fa-search agent-icon"></i> General Search
|
||||
</button>
|
||||
<button class="agent-btn" data-agent-id="support">
|
||||
<i class="fas fa-headset agent-icon"></i> IT Support
|
||||
</button>
|
||||
<button class="agent-btn" data-agent-id="data">
|
||||
<i class="fas fa-chart-line agent-icon"></i> Data Analysis
|
||||
</button>
|
||||
<button class="agent-btn" data-agent-id="security">
|
||||
<i class="fas fa-shield-alt agent-icon"></i> Security
|
||||
</button>
|
||||
<button class="agent-btn" data-agent-id="project">
|
||||
<i class="fas fa-tasks agent-icon"></i> Project Mgmt
|
||||
</button>
|
||||
<button class="agent-btn" data-agent-id="customer">
|
||||
<i class="fas fa-comments agent-icon"></i> Customer Support
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Chat Header -->
|
||||
<div class="chat-header">
|
||||
<span id="current-agent-display">General Search</span>
|
||||
<div class="flex items-center space-x-2">
|
||||
<button class="text-white hover:text-gray-200 text-lg"><i class="fas fa-cog"></i></button>
|
||||
<button class="text-white hover:text-gray-200 text-lg"><i class="fas fa-ellipsis-v"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Chat Messages -->
|
||||
<div class="chat-messages" id="chat-messages">
|
||||
<!-- Messages will be appended here by JavaScript -->
|
||||
</div>
|
||||
|
||||
<!-- Chat Input -->
|
||||
<div class="chat-input">
|
||||
<input type="text" id="message-input" placeholder="Type a message..." class="flex-grow">
|
||||
<button id="send-button" class="flex-shrink-0">
|
||||
<i class="fas fa-paper-plane"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const agentButtons = document.querySelectorAll('.agent-btn');
|
||||
const currentAgentDisplay = document.getElementById('current-agent-display');
|
||||
const messageInput = document.getElementById('message-input');
|
||||
const sendButton = document.getElementById('send-button');
|
||||
const chatMessages = document.getElementById('chat-messages');
|
||||
|
||||
let selectedAgentId = 'default'; // Default agent
|
||||
|
||||
// Function to display a message in the chat
|
||||
function addMessage(text, sender) {
|
||||
const messageDiv = document.createElement('div');
|
||||
messageDiv.classList.add('message-bubble');
|
||||
if (sender === 'user') {
|
||||
messageDiv.classList.add('user');
|
||||
messageDiv.innerHTML = `<p>${text}</p>`;
|
||||
} else {
|
||||
messageDiv.classList.add('agent');
|
||||
messageDiv.innerHTML = `<div class="flex items-center"><i class="fas agent-icon mr-2" id="${sender}-icon"></i><p>${text}</p></div>`;
|
||||
// Dynamically set icon based on agent
|
||||
const iconElement = messageDiv.querySelector('.agent-icon');
|
||||
if (sender === 'default') iconElement.classList.add('fa-search');
|
||||
else if (sender === 'support') iconElement.classList.add('fa-headset');
|
||||
else if (sender === 'data') iconElement.classList.add('fa-chart-line');
|
||||
else if (sender === 'security') iconElement.classList.add('fa-shield-alt');
|
||||
else if (sender === 'project') iconElement.classList.add('fa-tasks');
|
||||
else if (sender === 'customer') iconElement.classList.add('fa-comments');
|
||||
}
|
||||
chatMessages.appendChild(messageDiv);
|
||||
chatMessages.scrollTop = chatMessages.scrollHeight; // Scroll to bottom
|
||||
}
|
||||
|
||||
// Function to handle agent selection
|
||||
function selectAgent(agentId) {
|
||||
agentButtons.forEach(btn => {
|
||||
btn.classList.remove('active');
|
||||
});
|
||||
document.querySelector(`.agent-btn[data-agent-id="${agentId}"]`).classList.add('active');
|
||||
selectedAgentId = agentId;
|
||||
currentAgentDisplay.textContent = document.querySelector(`.agent-btn[data-agent-id="${agentId}"]`).textContent.trim();
|
||||
// Clear chat history when switching agents for simplicity
|
||||
chatMessages.innerHTML = '';
|
||||
}
|
||||
|
||||
// Event listeners for agent buttons
|
||||
agentButtons.forEach(button => {
|
||||
button.addEventListener('click', () => {
|
||||
selectAgent(button.dataset.agentId);
|
||||
});
|
||||
});
|
||||
|
||||
// Event listener for sending messages
|
||||
sendButton.addEventListener('click', () => {
|
||||
const messageText = messageInput.value.trim();
|
||||
if (messageText) {
|
||||
addMessage(messageText, 'user');
|
||||
messageInput.value = ''; // Clear input field
|
||||
|
||||
// Simulate agent response
|
||||
setTimeout(() => {
|
||||
let agentResponse = "I'm here to help! What would you like to ask?";
|
||||
if (selectedAgentId !== 'default') {
|
||||
agentResponse = `Hello! I'm your ${selectedAgentId} agent. How can I assist you today?`;
|
||||
}
|
||||
addMessage(agentResponse, selectedAgentId);
|
||||
}, 1000); // Simulate network delay
|
||||
}
|
||||
});
|
||||
|
||||
// Allow sending message with Enter key
|
||||
messageInput.addEventListener('keypress', (e) => {
|
||||
if (e.key === 'Enter') {
|
||||
sendButton.click();
|
||||
}
|
||||
});
|
||||
|
||||
// Initialize with default agent selected
|
||||
selectAgent('default');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user