266 lines
9.6 KiB
HTML
266 lines
9.6 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="ru">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<title>Тест улучшений AI Drawer</title>
|
||
<style>
|
||
body { font-family: Arial, sans-serif; margin: 20px; }
|
||
.test-section { margin: 20px 0; padding: 15px; border: 1px solid #ddd; border-radius: 5px; }
|
||
.success { background-color: #d4edda; border-color: #c3e6cb; }
|
||
.error { background-color: #f8d7da; border-color: #f5c6cb; }
|
||
.info { background-color: #d1ecf1; border-color: #bee5eb; }
|
||
button { padding: 10px 20px; margin: 5px; cursor: pointer; }
|
||
pre { background: #f8f9fa; padding: 10px; border-radius: 3px; overflow-x: auto; }
|
||
|
||
/* Стили для демонстрации */
|
||
.demo-chat {
|
||
border: 1px solid #ddd;
|
||
border-radius: 10px;
|
||
padding: 15px;
|
||
margin: 10px 0;
|
||
background: #f9f9f9;
|
||
}
|
||
|
||
.message {
|
||
margin: 8px 0;
|
||
padding: 10px;
|
||
border-radius: 10px;
|
||
max-width: 80%;
|
||
}
|
||
|
||
.message.user {
|
||
background: #007bff;
|
||
color: white;
|
||
margin-left: auto;
|
||
}
|
||
|
||
.message.bot {
|
||
background: #e9ecef;
|
||
color: #333;
|
||
}
|
||
|
||
.typing-indicator {
|
||
display: none;
|
||
padding: 12px 16px;
|
||
background: #f8f9fa;
|
||
border: 1px solid #dee2e6;
|
||
border-radius: 15px;
|
||
margin: 8px 0;
|
||
max-width: 300px;
|
||
font-size: 14px;
|
||
color: #6c757d;
|
||
text-align: left;
|
||
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
||
}
|
||
|
||
.typing-indicator.show {
|
||
display: block;
|
||
}
|
||
|
||
.typing-indicator::before {
|
||
content: "🤖";
|
||
margin-right: 8px;
|
||
font-size: 16px;
|
||
}
|
||
|
||
.typing-text {
|
||
display: inline-block;
|
||
}
|
||
|
||
.typing-text::after {
|
||
content: "|";
|
||
animation: blink 1s infinite;
|
||
color: #007bff;
|
||
font-weight: bold;
|
||
}
|
||
|
||
@keyframes blink {
|
||
0%, 50% { opacity: 1; }
|
||
51%, 100% { opacity: 0; }
|
||
}
|
||
|
||
.ai-button {
|
||
display: inline-block;
|
||
padding: 8px 16px;
|
||
margin: 4px;
|
||
background: #007bff;
|
||
color: white;
|
||
border: none;
|
||
border-radius: 6px;
|
||
cursor: pointer;
|
||
font-size: 14px;
|
||
transition: background-color 0.2s;
|
||
}
|
||
|
||
.ai-button:hover {
|
||
background: #0056b3;
|
||
}
|
||
|
||
.ai-button.secondary {
|
||
background: #6c757d;
|
||
}
|
||
|
||
.ai-button.secondary:hover {
|
||
background: #545b62;
|
||
}
|
||
|
||
.ai-button.success {
|
||
background: #28a745;
|
||
}
|
||
|
||
.ai-button.success:hover {
|
||
background: #1e7e34;
|
||
}
|
||
|
||
.ai-buttons-container {
|
||
margin-top: 8px;
|
||
display: flex;
|
||
flex-wrap: wrap;
|
||
gap: 4px;
|
||
}
|
||
</style>
|
||
</head>
|
||
<body>
|
||
<h1>🎨 Тест улучшений AI Drawer</h1>
|
||
|
||
<div class="test-section info">
|
||
<h3>📋 Что тестируем</h3>
|
||
<ul>
|
||
<li>✅ <strong>Улучшенный индикатор печатания</strong> - больше размер, лучше стили, эмодзи робота</li>
|
||
<li>✅ <strong>Кнопки в сообщениях</strong> - интерактивные кнопки для быстрых действий</li>
|
||
<li>✅ <strong>Улучшенный эффект печатания</strong> - динамическая скорость</li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div class="test-section">
|
||
<h3>🤖 Демо чат с улучшениями</h3>
|
||
<div class="demo-chat">
|
||
<div id="demo-messages"></div>
|
||
<div class="typing-indicator">
|
||
<span class="typing-text">Обрабатываю запрос в n8n...</span>
|
||
</div>
|
||
</div>
|
||
<button onclick="testTypingIndicator()">Тест индикатора печатания</button>
|
||
<button onclick="testTypingEffect()">Тест эффекта печатания</button>
|
||
<button onclick="testButtons()">Тест кнопок</button>
|
||
<button onclick="clearDemo()">Очистить</button>
|
||
</div>
|
||
|
||
<div class="test-section">
|
||
<h3>📊 Результаты тестов</h3>
|
||
<div id="test-results"></div>
|
||
</div>
|
||
|
||
<script>
|
||
// Функция добавления сообщения в демо чат
|
||
function addDemoMessage(text, isUser = false) {
|
||
const messagesContainer = document.getElementById('demo-messages');
|
||
const messageDiv = document.createElement('div');
|
||
messageDiv.className = 'message ' + (isUser ? 'user' : 'bot');
|
||
|
||
if (isUser) {
|
||
messageDiv.textContent = text;
|
||
} else {
|
||
messageDiv.innerHTML = '<span class="typing-text"></span>';
|
||
typeMessage(messageDiv.querySelector('.typing-text'), text);
|
||
}
|
||
|
||
messagesContainer.appendChild(messageDiv);
|
||
messagesContainer.scrollTop = messagesContainer.scrollHeight;
|
||
}
|
||
|
||
// Функция эффекта печатания
|
||
function typeMessage(element, text, speed = 30) {
|
||
let i = 0;
|
||
element.textContent = '';
|
||
|
||
function typeChar() {
|
||
if (i < text.length) {
|
||
element.textContent += text.charAt(i);
|
||
i++;
|
||
|
||
// Динамическая скорость
|
||
const currentChar = text.charAt(i - 1);
|
||
const delay = (currentChar === ' ' || currentChar === '.' || currentChar === '!') ? speed * 0.5 : speed;
|
||
|
||
setTimeout(typeChar, delay);
|
||
}
|
||
}
|
||
|
||
typeChar();
|
||
}
|
||
|
||
// Функция добавления кнопок
|
||
function addButtonsToMessage(messageElement, buttons) {
|
||
if (!buttons || buttons.length === 0) return;
|
||
|
||
const buttonContainer = document.createElement('div');
|
||
buttonContainer.className = 'ai-buttons-container';
|
||
|
||
buttons.forEach(button => {
|
||
const btn = document.createElement('button');
|
||
btn.className = `ai-button ${button.type || 'secondary'}`;
|
||
btn.textContent = button.text;
|
||
btn.onclick = () => {
|
||
if (button.action) {
|
||
button.action();
|
||
}
|
||
};
|
||
buttonContainer.appendChild(btn);
|
||
});
|
||
|
||
messageElement.appendChild(buttonContainer);
|
||
}
|
||
|
||
// Тесты
|
||
function testTypingIndicator() {
|
||
const indicator = document.querySelector('.typing-indicator');
|
||
const results = document.getElementById('test-results');
|
||
|
||
indicator.classList.add('show');
|
||
results.innerHTML += '<div class="success">✅ Индикатор печатания показан</div>';
|
||
|
||
setTimeout(() => {
|
||
indicator.classList.remove('show');
|
||
results.innerHTML += '<div class="success">✅ Индикатор печатания скрыт</div>';
|
||
}, 3000);
|
||
}
|
||
|
||
function testTypingEffect() {
|
||
addDemoMessage('Это тестовое сообщение с эффектом печатания! Оно должно появляться постепенно.', false);
|
||
document.getElementById('test-results').innerHTML += '<div class="success">✅ Эффект печатания запущен</div>';
|
||
}
|
||
|
||
function testButtons() {
|
||
const messageDiv = document.createElement('div');
|
||
messageDiv.className = 'message bot';
|
||
messageDiv.textContent = 'Выберите действие:';
|
||
|
||
addButtonsToMessage(messageDiv, [
|
||
{ text: 'Найти документы', type: 'success', action: () => alert('Поиск документов') },
|
||
{ text: 'Создать отчет', type: 'secondary', action: () => alert('Создание отчета') },
|
||
{ text: 'Помощь', type: 'secondary', action: () => alert('Показать помощь') }
|
||
]);
|
||
|
||
document.getElementById('demo-messages').appendChild(messageDiv);
|
||
document.getElementById('test-results').innerHTML += '<div class="success">✅ Кнопки добавлены</div>';
|
||
}
|
||
|
||
function clearDemo() {
|
||
document.getElementById('demo-messages').innerHTML = '';
|
||
document.getElementById('test-results').innerHTML = '';
|
||
document.querySelector('.typing-indicator').classList.remove('show');
|
||
}
|
||
|
||
// Автозапуск демо
|
||
setTimeout(() => {
|
||
addDemoMessage('Привет! Я AI ассистент с улучшенным интерфейсом.', false);
|
||
setTimeout(() => {
|
||
addDemoMessage('Что ты умеешь?', true);
|
||
}, 2000);
|
||
}, 1000);
|
||
</script>
|
||
</body>
|
||
</html>
|