diff --git a/api/chat.php b/api/chat.php index e0d634e..d2c8190 100644 --- a/api/chat.php +++ b/api/chat.php @@ -45,30 +45,7 @@ if ($_SESSION['question_index'] < count($questions)) { $formatted_answers[] = "Q: " . $questions[$index] . "\nA: " . $answer; } $prompt = <<, - "Cynicism": , - "Inefficacy": - }, - "analysis": { - "overallSummary": "", - "exhaustionSummary": "", - "cynicismSummary": "", - "inefficacySummary": "" - }, - "recommendations": [ - { - "title": "", - "description": "" - } - ], - "nextSteps": [ - "" - ] -} +Analyze the user's survey answers and return ONLY a raw JSON object with the specified structure. Do not include any other text or formatting. User's Answers: EOT; diff --git a/assets/js/main.js b/assets/js/main.js index 1c93a44..9073b8c 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -2,6 +2,8 @@ document.addEventListener('DOMContentLoaded', function () { const chatWindow = document.getElementById('chat-window'); const chatInput = document.getElementById('chat-input'); const sendBtn = document.getElementById('send-btn'); + const progressContainer = document.getElementById('progress-container'); + const inputContainer = document.getElementById('input-container'); function addMessage(message, sender) { const messageElement = document.createElement('div'); @@ -50,17 +52,22 @@ document.addEventListener('DOMContentLoaded', function () { const data = await getNextQuestion(rating); if (data.redirect) { - window.location.href = data.redirect; + inputContainer.style.display = 'none'; + progressContainer.style.display = 'block'; + // Wait a bit for the user to see the progress bar + setTimeout(() => { + window.location.href = data.redirect; + }, 2000); } else if (data.question) { addMessage(data.question, 'bot'); + chatInput.disabled = false; + sendBtn.disabled = false; + chatInput.focus(); } else if (data.message) { addMessage(data.message, 'bot'); chatInput.style.display = 'none'; sendBtn.style.display = 'none'; } - chatInput.disabled = false; - sendBtn.disabled = false; - chatInput.focus(); } sendBtn.addEventListener('click', handleUserInput); @@ -79,4 +86,4 @@ document.addEventListener('DOMContentLoaded', function () { } startConversation(); -}); +}); \ No newline at end of file diff --git a/index.php b/index.php index 8f1836e..9ebaab7 100644 --- a/index.php +++ b/index.php @@ -25,8 +25,11 @@ if (session_status() == PHP_SESSION_NONE) {
-