This commit is contained in:
2026-02-06 13:37:22 +01:00
parent 44a88dcfad
commit 73f47b161c
2 changed files with 36 additions and 12 deletions

View File

@@ -563,16 +563,25 @@ function handleChatMessage($data) {
if ($webhookResult['success']) {
// Try to parse response from webhook
$response = json_decode($webhookResult['response'], true);
$aiResponse = $response['message'] ?? 'Vielen Dank für Ihre Nachricht. Ich melde mich so schnell wie möglich bei Ihnen.';
$aiResponse = $response['message'] ?? $response['output'] ?? 'Vielen Dank für Ihre Nachricht. Ich melde mich so schnell wie möglich bei Ihnen.';
sendResponse(true, 'Nachricht gesendet', array_merge($debugData, [
sendResponse(true, 'Nachricht gesendet', array_merge($debugData ?? [], [
'session_id' => $sessionId,
'ai_response' => $aiResponse,
'timestamp' => date('c')
]));
} else {
error_log('Chat webhook failed: ' . json_encode($webhookResult));
sendResponse(false, 'Chat-Service derzeit nicht verfügbar. Bitte versuchen Sie es später erneut.', $debugData, 503);
// Log detailed error for debugging
error_log('Chat webhook failed - URL: ' . KI_CHAT_WEBHOOK_URL . ' - Result: ' . json_encode($webhookResult));
// Return a friendly message but still allow chat to work with fallback
$fallbackResponse = 'Vielen Dank für Ihre Nachricht. Unser Team wird sich in Kürze bei Ihnen melden.';
sendResponse(true, 'Nachricht empfangen', array_merge($debugData ?? [], [
'session_id' => $sessionId,
'ai_response' => $fallbackResponse,
'timestamp' => date('c'),
'fallback' => true
]));
}
}

View File

@@ -16,7 +16,7 @@
maxOpacity: 0.6,
magnetRadius: 200,
maxDisplacement: 12,
returnSpeed: 0.1,
returnSpeed: 0.25, // Faster return to prevent color lag
// Base color (neutral gray)
baseR: 119, baseG: 119, baseB: 100,
// Colors for proximity effect (teal to orange)
@@ -170,8 +170,12 @@
const horizSpacing = CONFIG.hexSize * Math.sqrt(3);
const vertSpacing = CONFIG.hexSize * 1.5;
const cols = Math.ceil(window.innerWidth / horizSpacing) + 3;
const rows = Math.ceil(window.innerHeight / vertSpacing) + 3;
// Use full screen dimensions
const width = Math.max(window.innerWidth, document.documentElement.clientWidth);
const height = Math.max(window.innerHeight, document.documentElement.clientHeight);
const cols = Math.ceil(width / horizSpacing) + 4;
const rows = Math.ceil(height / vertSpacing) + 4;
for (let row = -1; row < rows; row++) {
for (let col = -1; col < cols; col++) {
@@ -193,10 +197,17 @@
function resize() {
const dpr = window.devicePixelRatio || 1;
canvas.width = window.innerWidth * dpr;
canvas.height = window.innerHeight * dpr;
canvas.style.width = window.innerWidth + 'px';
canvas.style.height = window.innerHeight + 'px';
// Use full document dimensions to cover entire scrollable page
const width = Math.max(window.innerWidth, document.documentElement.clientWidth);
const height = Math.max(window.innerHeight, document.documentElement.clientHeight);
canvas.width = width * dpr;
canvas.height = height * dpr;
canvas.style.width = width + 'px';
canvas.style.height = height + 'px';
// Reset transform and apply new scale
ctx.setTransform(1, 0, 0, 1, 0, 0);
ctx.scale(dpr, dpr);
}
@@ -226,8 +237,12 @@
const dx = mouse.x - hex.originX;
const dy = mouse.y - hex.originY;
const distance = Math.sqrt(dx * dx + dy * dy);
// Check if position OR color needs to return to default
const isReturning = Math.abs(hex.currentX - hex.originX) > 0.1 ||
Math.abs(hex.currentY - hex.originY) > 0.1;
Math.abs(hex.currentY - hex.originY) > 0.1 ||
hex.colorInfluence > 0.01 ||
hex.opacity > CONFIG.baseOpacity + 0.01;
if (distance < updateRadius || isReturning) {
hex.update(mouse.x, mouse.y);