1
This commit is contained in:
parent
bcb003a43d
commit
94b10ba1f5
497
index.php
497
index.php
@ -3,46 +3,85 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>Marketplace Manager Assistant</title>
|
<title>Marketplace Business Assistant</title>
|
||||||
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||||
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||||
|
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600&display=swap" rel="stylesheet">
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
||||||
<style>
|
<style>
|
||||||
:root {
|
:root {
|
||||||
--primary-color: #4F46E5;
|
--font-family: 'Poppins', sans-serif;
|
||||||
--background-color: #F3F4F6;
|
--pastel-grey: #EAEAEA;
|
||||||
--surface-color: #FFFFFF;
|
--pastel-blue: #d1e3f3;
|
||||||
--text-color: #1F2937;
|
--text-light: #888;
|
||||||
--subtle-text-color: #6B7280;
|
--text-dark: #333;
|
||||||
--bot-bg: #E0E7FF;
|
--card-bg: rgba(255, 255, 255, 0.85);
|
||||||
--user-bg: #D1FAE5;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
font-family: var(--font-family);
|
||||||
background-color: var(--background-color);
|
|
||||||
margin: 0;
|
margin: 0;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
|
color: var(--text-dark);
|
||||||
|
overflow: hidden;
|
||||||
|
background: linear-gradient(45deg, var(--pastel-grey), var(--pastel-blue));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.background-container {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
z-index: -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#lava-canvas {
|
||||||
|
position: absolute;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
z-index: 0;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.chat-container {
|
.chat-container {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
max-width: 800px;
|
max-width: 800px;
|
||||||
height: 90vh;
|
height: 90vh;
|
||||||
background-color: var(--surface-color);
|
max-height: 800px;
|
||||||
border-radius: 0.75rem;
|
|
||||||
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
background: var(--card-bg);
|
||||||
|
backdrop-filter: blur(10px);
|
||||||
|
border-radius: 24px;
|
||||||
|
box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.2);
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.18);
|
||||||
|
overflow: hidden;
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-main {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
flex-grow: 1;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
header {
|
|
||||||
background-color: var(--primary-color);
|
.chat-header {
|
||||||
color: white;
|
background: rgba(255, 255, 255, 0.5);
|
||||||
padding: 1rem 1.5rem;
|
padding: 1rem 1.5rem;
|
||||||
font-size: 1.25rem;
|
|
||||||
font-weight: 600;
|
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
font-size: 1.2rem;
|
||||||
|
font-weight: 600;
|
||||||
|
border-bottom: 1px solid rgba(255, 255, 255, 0.3);
|
||||||
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
.chat-box {
|
|
||||||
|
.chat-messages {
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
padding: 1.5rem;
|
padding: 1.5rem;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
@ -50,142 +89,388 @@
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 1rem;
|
gap: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.message {
|
.message {
|
||||||
padding: 0.75rem 1.25rem;
|
padding: 0.75rem 1.25rem;
|
||||||
border-radius: 0.75rem;
|
border-radius: 18px;
|
||||||
max-width: 80%;
|
max-width: 85%;
|
||||||
line-height: 1.5;
|
line-height: 1.6;
|
||||||
|
font-weight: 400;
|
||||||
|
box-shadow: 0 2px 8px rgba(0,0,0,0.05);
|
||||||
}
|
}
|
||||||
.message.bot {
|
|
||||||
background-color: var(--bot-bg);
|
.message.assistant {
|
||||||
color: var(--text-color);
|
background-color: rgba(255, 255, 255, 0.9);
|
||||||
align-self: flex-start;
|
align-self: flex-start;
|
||||||
border-bottom-left-radius: 0;
|
border-bottom-left-radius: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.message.user {
|
.message.user {
|
||||||
background-color: var(--user-bg);
|
background: linear-gradient(45deg, #a8e6cf, #bde6d9);
|
||||||
color: var(--text-color);
|
color: var(--text-dark);
|
||||||
align-self: flex-end;
|
align-self: flex-end;
|
||||||
border-bottom-right-radius: 0;
|
border-bottom-right-radius: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.quick-actions-container {
|
||||||
|
padding: 1rem 1.5rem 0.5rem;
|
||||||
|
border-top: 1px solid rgba(255, 255, 255, 0.3);
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.quick-actions {
|
.quick-actions {
|
||||||
padding: 1rem 1.5rem;
|
|
||||||
border-top: 1px solid #E5E7EB;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
gap: 0.5rem;
|
gap: 0.75rem;
|
||||||
|
justify-content: flex-start;
|
||||||
}
|
}
|
||||||
.quick-actions button {
|
|
||||||
background-color: #E0E7FF;
|
.quick-action {
|
||||||
color: var(--primary-color);
|
background-color: rgba(255, 255, 255, 0.7);
|
||||||
border: 1px solid var(--primary-color);
|
border: 1px solid transparent;
|
||||||
padding: 0.5rem 1rem;
|
color: var(--text-dark);
|
||||||
border-radius: 9999px;
|
padding: 0.6rem 1.1rem;
|
||||||
|
border-radius: 16px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
font-size: 0.875rem;
|
font-size: 0.85rem;
|
||||||
transition: background-color 0.2s;
|
font-weight: 500;
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
box-shadow: 0 1px 4px rgba(0,0,0,0.05);
|
||||||
}
|
}
|
||||||
.quick-actions button:hover {
|
|
||||||
background-color: #C7D2FE;
|
.quick-action:hover {
|
||||||
|
transform: translateY(-2px);
|
||||||
|
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
|
||||||
|
background: white;
|
||||||
}
|
}
|
||||||
.chat-input {
|
|
||||||
border-top: 1px solid #E5E7EB;
|
.chat-input-container {
|
||||||
padding: 1rem 1.5rem;
|
padding: 1rem 1.5rem;
|
||||||
|
border-top: 1px solid rgba(255, 255, 255, 0.2);
|
||||||
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
.chat-input form {
|
|
||||||
|
.chat-input {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 1rem;
|
align-items: center;
|
||||||
|
background: white;
|
||||||
|
border-radius: 25px;
|
||||||
|
padding: 0.25rem;
|
||||||
|
box-shadow: 0 2px 10px rgba(0,0,0,0.08);
|
||||||
}
|
}
|
||||||
.chat-input input {
|
|
||||||
|
.chat-input input[type="text"] {
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
border: 1px solid #D1D5DB;
|
border: none;
|
||||||
border-radius: 0.375rem;
|
background: transparent;
|
||||||
padding: 0.75rem;
|
border-radius: 20px;
|
||||||
|
padding: 0.75rem 1rem;
|
||||||
font-size: 1rem;
|
font-size: 1rem;
|
||||||
|
outline: none;
|
||||||
|
color: var(--text-dark);
|
||||||
}
|
}
|
||||||
.chat-input button {
|
|
||||||
background-color: var(--primary-color);
|
.chat-input input[type="file"] {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-input button, .chat-input .file-upload-label {
|
||||||
|
background: linear-gradient(45deg, #ffd3b6, #d2b4de);
|
||||||
color: white;
|
color: white;
|
||||||
border: none;
|
border: none;
|
||||||
padding: 0.75rem 1.5rem;
|
border-radius: 50%;
|
||||||
border-radius: 0.375rem;
|
width: 40px;
|
||||||
font-size: 1rem;
|
height: 40px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
transition: background-color 0.2s;
|
font-size: 1.5rem;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
transition: transform 0.2s ease;
|
||||||
|
margin-left: 5px;
|
||||||
}
|
}
|
||||||
.chat-input button:hover {
|
.chat-input button:hover, .chat-input .file-upload-label:hover {
|
||||||
background-color: #4338CA;
|
transform: scale(1.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.file-upload-label {
|
||||||
|
background: transparent;
|
||||||
|
color: #888;
|
||||||
|
font-size: 1.2rem;
|
||||||
|
}
|
||||||
|
.file-upload-label:hover {
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="chat-container">
|
|
||||||
<header>Marketplace Manager Assistant</header>
|
<div class="background-container">
|
||||||
<div class="chat-box" id="chat-box">
|
<canvas id="lava-canvas"></canvas>
|
||||||
<div class="message bot">Hello! I'm your assistant. How can I help you manage the marketplace today? You can use the quick actions below to get started.</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="chat-container" id="chat-container">
|
||||||
|
<div class="chat-main">
|
||||||
|
<div class="chat-header">
|
||||||
|
Marketplace Business Assistant
|
||||||
</div>
|
</div>
|
||||||
<div class="quick-actions">
|
<div class="chat-messages" id="chat-messages">
|
||||||
<button data-prompt="Summarize buyer and seller feedback">Summarize feedback</button>
|
<div class="message assistant">
|
||||||
<button data-prompt="Generate a report of frequently asked questions">Report FAQs</button>
|
Hello! I'm your Marketplace Assistant. How can I help you today? You can select one of the quick actions below or upload a file to analyze.
|
||||||
<button data-prompt="Create a standardized dispute resolution checklist">Create dispute checklist</button>
|
|
||||||
<button data-prompt="Provide automated message templates for common inquiries">Get message templates</button>
|
|
||||||
<button data-prompt="Send reminders to sellers to update their stock">Remind sellers about stock</button>
|
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="quick-actions-container">
|
||||||
|
<div class="quick-actions" id="quick-actions">
|
||||||
|
<button class="quick-action" data-task="summarize_feedback_weekly">Summarize feedback</button>
|
||||||
|
<button class="quick-action" data-task="analyze_complaints">Analyze complaints</button>
|
||||||
|
<button class="quick-action" data-task="generate_seller_dashboard">Generate seller dashboard</button>
|
||||||
|
<button class="quick-action" data-task="summarize_refunds">Summarize refunds</button>
|
||||||
|
<button class="quick-action" data-task="draft_response_templates">Draft response templates</button>
|
||||||
|
<button class="quick-action" data-task="generate_sales_chart">Generate sales chart</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="chat-input-container">
|
||||||
<div class="chat-input">
|
<div class="chat-input">
|
||||||
<form id="chat-form">
|
<input type="file" id="file-input" accept=".txt,.csv">
|
||||||
<input type="text" id="message-input" placeholder="Type your message..." autocomplete="off">
|
<label for="file-input" class="file-upload-label">
|
||||||
<button type="submit">Send</button>
|
<svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"></path></svg>
|
||||||
</form>
|
</label>
|
||||||
|
<input type="text" id="user-input" placeholder="Type your message...">
|
||||||
|
<button id="send-button">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="22" y1="2" x2="11" y2="13"></line><polygon points="22 2 15 22 11 13 2 9 22 2"></polygon></svg>
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const chatBox = document.getElementById('chat-box');
|
const chatMessages = document.getElementById('chat-messages');
|
||||||
const chatForm = document.getElementById('chat-form');
|
const userInput = document.getElementById('user-input');
|
||||||
const messageInput = document.getElementById('message-input');
|
const sendButton = document.getElementById('send-button');
|
||||||
const quickActionButtons = document.querySelectorAll('.quick-actions button');
|
const quickActionsContainer = document.getElementById('quick-actions');
|
||||||
|
const fileInput = document.getElementById('file-input');
|
||||||
|
|
||||||
const botResponses = {
|
const assistantResponses = {
|
||||||
"Summarize buyer and seller feedback": "Of course. Here is a summary of recent feedback:<br><br><strong>Key Insights:</strong><br>- <strong>Positive:</strong> Buyers praise the fast shipping times from top-rated sellers.<br>- <strong>Negative:</strong> Multiple users have reported confusion regarding the return process.<br>- <strong>Suggestion:</strong> We should simplify the returns page and create a clearer FAQ section for it.",
|
summarize_feedback_weekly: "This week’s customer feedback summary: Top 5 issues are 1. Late deliveries (23%), 2. Incorrect item received (15%), 3. Product not as described (12%), 4. Difficulty applying discounts (8%), 5. Slow seller response time (7%).",
|
||||||
"Generate a report of frequently asked questions": "Here are the most frequently asked questions this week:<br><br>1. How do I track my order?<br>2. What is your return policy?<br>3. Do you ship internationally?<br><br>I suggest we create automated message templates for these.",
|
draft_response_templates: "Here are some automated response templates: \n**Refunds:** 'We’ve received your refund request for order #[Order ID] and are processing it. You’ll receive an update within 2-3 business days.' \n**Shipping Delays:** 'We apologize for the delay in your order #[Order ID]. We are looking into it and will provide a status update shortly.'",
|
||||||
"Create a standardized dispute resolution checklist": "Here is a checklist for resolving disputes fairly:<br><br>1. Acknowledge receipt of the dispute to both parties.<br>2. Request evidence from both buyer and seller (e.g., photos, messages).<br>3. Review communication history between the two parties.<br>4. Check against marketplace policies.<br>5. Make a decision and communicate it clearly, citing the specific policies.",
|
analyze_complaints: "Analysis of customer complaints shows that 65% of delivery time issues are concentrated in the West region, primarily with one shipping carrier. I recommend diversifying our shipping partners in that region.",
|
||||||
"Provide automated message templates for common inquiries": "Here are some templates you can use:<br><br><strong>Shipping Inquiry:</strong><br><em>'Hello! You can track your order here: [Tracking Link]. Please allow 24-48 hours for the tracking to update.'</em><br><br><strong>Refund Status:</strong><br><em>'Hi there, your refund was processed on [Date] and should appear in your account within 5-7 business days.'</em>",
|
generate_seller_dashboard: "Weekly Seller Performance Dashboard: \n**Top Performers:** SellerA (99% positive feedback), SellerB (fastest shipping), SellerC (most new products). \n**Needs Attention:** SellerX (rating dropped to 85%), SellerY (2 open disputes).",
|
||||||
"Send reminders to sellers to update their stock": "I will now send a reminder to all sellers with low stock (less than 5 items) for listings that have been active for more than 30 days. Is that okay?",
|
summarize_refunds: "Monthly Refund Summary: A total of 152 refunds were processed this month. Top reasons: 1. Item arrived damaged (45%), 2. Item not as described (30%), 3. Accidental order (15%). There is a 20% increase in 'damaged item' refunds for electronics.",
|
||||||
"default": "I'm sorry, I can only respond to the predefined actions right now. Please select one of the quick actions."
|
generate_sales_chart: 'Here is the sales report for the last 6 months:<br><canvas id="salesChart" width="400" height="200"></canvas>'
|
||||||
};
|
};
|
||||||
|
|
||||||
chatForm.addEventListener('submit', function(e) {
|
const taskMap = {};
|
||||||
e.preventDefault();
|
document.querySelectorAll('.quick-action').forEach(button => {
|
||||||
const userInput = messageInput.value.trim();
|
taskMap[button.textContent] = button.dataset.task;
|
||||||
if (userInput) {
|
|
||||||
addMessage(userInput, 'user');
|
|
||||||
messageInput.value = '';
|
|
||||||
handleBotResponse(userInput);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
quickActionButtons.forEach(button => {
|
function renderChart() {
|
||||||
button.addEventListener('click', function() {
|
const chartCanvas = document.getElementById('salesChart');
|
||||||
const prompt = this.dataset.prompt;
|
if (!chartCanvas) return;
|
||||||
addMessage(prompt, 'user');
|
const ctx = chartCanvas.getContext('2d');
|
||||||
handleBotResponse(prompt);
|
new Chart(ctx, {
|
||||||
});
|
type: 'bar',
|
||||||
|
data: {
|
||||||
|
labels: ['January', 'February', 'March', 'April', 'May', 'June'],
|
||||||
|
datasets: [{
|
||||||
|
label: 'Sales',
|
||||||
|
data: [12, 19, 3, 5, 2, 3],
|
||||||
|
backgroundColor: 'rgba(75, 192, 192, 0.2)',
|
||||||
|
borderColor: 'rgba(75, 192, 192, 1)',
|
||||||
|
borderWidth: 1
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
options: { scales: { y: { beginAtZero: true } } }
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function addMessage(text, sender) {
|
function addMessage(text, sender) {
|
||||||
const messageElement = document.createElement('div');
|
const messageElement = document.createElement('div');
|
||||||
messageElement.classList.add('message', sender);
|
messageElement.classList.add('message', sender);
|
||||||
|
|
||||||
|
if (sender === 'assistant' && text.includes('<canvas')) {
|
||||||
messageElement.innerHTML = text;
|
messageElement.innerHTML = text;
|
||||||
chatBox.appendChild(messageElement);
|
} else {
|
||||||
chatBox.scrollTop = chatBox.scrollHeight;
|
messageElement.innerHTML = text.replace(/\n/g, '<br>');
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleBotResponse(userInput) {
|
chatMessages.appendChild(messageElement);
|
||||||
const response = botResponses[userInput] || botResponses['default'];
|
chatMessages.scrollTop = chatMessages.scrollHeight;
|
||||||
setTimeout(() => {
|
|
||||||
addMessage(response, 'bot');
|
|
||||||
}, 500);
|
|
||||||
}
|
}
|
||||||
</script>
|
|
||||||
|
function processMessage(text) {
|
||||||
|
const trimmedText = text.trim();
|
||||||
|
if (!trimmedText) return;
|
||||||
|
|
||||||
|
addMessage(trimmedText, 'user');
|
||||||
|
userInput.value = '';
|
||||||
|
|
||||||
|
const task = taskMap[trimmedText];
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
const response = assistantResponses[task] || "I'm a demo assistant. My capabilities are limited to the quick actions for now. Please select one of the options or upload a file.";
|
||||||
|
addMessage(response, 'assistant');
|
||||||
|
|
||||||
|
if (task === 'generate_sales_chart') {
|
||||||
|
setTimeout(renderChart, 10);
|
||||||
|
}
|
||||||
|
}, 1200);
|
||||||
|
}
|
||||||
|
|
||||||
|
function analyzeFile(file) {
|
||||||
|
const reader = new FileReader();
|
||||||
|
reader.onload = (e) => {
|
||||||
|
const content = e.target.result;
|
||||||
|
let analysis = '';
|
||||||
|
if (file.type === 'text/csv') {
|
||||||
|
const lines = content.split('\n').filter(line => line.trim() !== '');
|
||||||
|
const rowCount = lines.length;
|
||||||
|
const columnCount = lines.length > 0 ? lines[0].split(',').length : 0;
|
||||||
|
analysis = `**File Analysis: ${file.name}**\n- **Type:** CSV\n- **Rows:** ${rowCount}\n- **Columns:** ${columnCount}`;
|
||||||
|
} else { // Default to text
|
||||||
|
const lineCount = content.split('\n').length;
|
||||||
|
const wordCount = content.split(/\s+/).filter(Boolean).length;
|
||||||
|
analysis = `**File Analysis: ${file.name}**\n- **Type:** Text File\n- **Lines:** ${lineCount}\n- **Words:** ${wordCount}`;
|
||||||
|
}
|
||||||
|
addMessage(analysis, 'assistant');
|
||||||
|
};
|
||||||
|
reader.readAsText(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
fileInput.addEventListener('change', (event) => {
|
||||||
|
const file = event.target.files[0];
|
||||||
|
if (file) {
|
||||||
|
addMessage(`You uploaded ${file.name}. Analyzing...`, 'user');
|
||||||
|
setTimeout(() => analyzeFile(file), 1200);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
quickActionsContainer.addEventListener('click', (event) => {
|
||||||
|
if (event.target.classList.contains('quick-action')) {
|
||||||
|
processMessage(event.target.textContent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
sendButton.addEventListener('click', () => processMessage(userInput.value));
|
||||||
|
userInput.addEventListener('keypress', (event) => {
|
||||||
|
if (event.key === 'Enter') {
|
||||||
|
processMessage(userInput.value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Lava lamp animation script
|
||||||
|
const canvas = document.getElementById('lava-canvas');
|
||||||
|
const ctx = canvas.getContext('2d');
|
||||||
|
canvas.width = window.innerWidth;
|
||||||
|
canvas.height = window.innerHeight;
|
||||||
|
|
||||||
|
class Blob {
|
||||||
|
constructor(x, y, size, color) {
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
this.size = size;
|
||||||
|
this.color = color;
|
||||||
|
this.vx = (Math.random() - 0.5) * 0.8;
|
||||||
|
this.vy = (Math.random() - 0.5) * 0.8;
|
||||||
|
|
||||||
|
this.numPoints = Math.floor(Math.random() * 5) + 5;
|
||||||
|
this.radii = [];
|
||||||
|
this.angles = [];
|
||||||
|
this.angleOffsets = [];
|
||||||
|
|
||||||
|
for (let i = 0; i < this.numPoints; i++) {
|
||||||
|
this.radii.push(Math.random() * 0.2 + 0.9);
|
||||||
|
this.angles.push((i / this.numPoints) * Math.PI * 2);
|
||||||
|
this.angleOffsets.push(Math.random() * Math.PI * 2);
|
||||||
|
}
|
||||||
|
this.time = Math.random() * 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
update() {
|
||||||
|
this.x += this.vx;
|
||||||
|
this.y += this.vy;
|
||||||
|
this.time += 0.01;
|
||||||
|
|
||||||
|
if (this.x < this.size || this.x > canvas.width - this.size) this.vx *= -1;
|
||||||
|
if (this.y < this.size || this.y > canvas.height - this.size) this.vy *= -1;
|
||||||
|
|
||||||
|
for (let i = 0; i < this.numPoints; i++) {
|
||||||
|
const phase = Math.sin(this.time + this.angleOffsets[i]);
|
||||||
|
this.radii[i] = 0.9 + 0.1 * phase;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
draw() {
|
||||||
|
ctx.save();
|
||||||
|
ctx.translate(this.x, this.y);
|
||||||
|
ctx.fillStyle = this.color;
|
||||||
|
|
||||||
|
ctx.beginPath();
|
||||||
|
const startAngle = this.angles[this.numPoints - 1];
|
||||||
|
const startRadius = this.radii[this.numPoints - 1] * this.size;
|
||||||
|
ctx.moveTo(Math.cos(startAngle) * startRadius, Math.sin(startAngle) * startRadius);
|
||||||
|
|
||||||
|
for (let i = 0; i < this.numPoints; i++) {
|
||||||
|
const radius = this.radii[i] * this.size;
|
||||||
|
const nextRadius = this.radii[(i + 1) % this.numPoints] * this.size;
|
||||||
|
const angle = this.angles[i];
|
||||||
|
const nextAngle = this.angles[(i + 1) % this.numPoints];
|
||||||
|
|
||||||
|
const xc = (Math.cos(angle) * radius + Math.cos(nextAngle) * nextRadius) / 2;
|
||||||
|
const yc = (Math.sin(angle) * radius + Math.sin(nextAngle) * nextRadius) / 2;
|
||||||
|
|
||||||
|
ctx.quadraticCurveTo(Math.cos(angle) * radius, Math.sin(angle) * radius, xc, yc);
|
||||||
|
}
|
||||||
|
ctx.closePath();
|
||||||
|
ctx.fill();
|
||||||
|
ctx.restore();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let blobs = [];
|
||||||
|
const colors = [
|
||||||
|
'rgba(234, 234, 234, 0.4)',
|
||||||
|
'rgba(209, 227, 243, 0.4)',
|
||||||
|
'rgba(192, 217, 234, 0.4)',
|
||||||
|
'rgba(175, 207, 225, 0.4)'
|
||||||
|
];
|
||||||
|
|
||||||
|
function init() {
|
||||||
|
blobs = [];
|
||||||
|
let numBlobs = Math.floor(window.innerWidth / 150);
|
||||||
|
for (let i = 0; i < numBlobs; i++) {
|
||||||
|
let size = Math.random() * 80 + 80;
|
||||||
|
let x = Math.random() * (canvas.width - size * 2) + size;
|
||||||
|
let y = Math.random() * (canvas.height - size * 2) + size;
|
||||||
|
let color = colors[i % colors.length];
|
||||||
|
blobs.push(new Blob(x, y, size, color));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function animate() {
|
||||||
|
requestAnimationFrame(animate);
|
||||||
|
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
||||||
|
|
||||||
|
ctx.globalCompositeOperation = 'lighter';
|
||||||
|
|
||||||
|
blobs.forEach(blob => {
|
||||||
|
blob.update();
|
||||||
|
blob.draw();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
window.addEventListener('resize', () => {
|
||||||
|
canvas.width = window.innerWidth;
|
||||||
|
canvas.height = window.innerHeight;
|
||||||
|
init();
|
||||||
|
});
|
||||||
|
|
||||||
|
init();
|
||||||
|
animate();
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
Loading…
x
Reference in New Issue
Block a user