diff --git a/api/chat.php b/api/chat.php new file mode 100644 index 0000000..0d86e33 --- /dev/null +++ b/api/chat.php @@ -0,0 +1,44 @@ + 5) { + addMessage('Please enter a number between 1 and 5.', 'bot'); + return; + } + + addMessage(userInput, 'user'); + chatInput.value = ''; + chatInput.disabled = true; + sendBtn.disabled = true; + + const data = await getNextQuestion(rating); + + if (data.question) { + addMessage(data.question, 'bot'); + } 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); + chatInput.addEventListener('keypress', function (e) { + if (e.key === 'Enter') { + handleUserInput(); + } + }); + + async function startConversation() { + const data = await getNextQuestion(); + if (data.question) { + addMessage("Welcome to the Burnout Survey. I'll ask you a series of questions. Please rate each one on a scale of 1 (Strongly Disagree) to 5 (Strongly Agree).", 'bot'); + addMessage(data.question, 'bot'); + } + } + + startConversation(); +}); \ No newline at end of file diff --git a/index.php b/index.php index 7205f3d..f6101e5 100644 --- a/index.php +++ b/index.php @@ -1,150 +1,51 @@ - - + - - - New Style - - - - - - - - - - - - - - - - - - - + + + Burnout Adviser + + + + + + + + + + -
-
-

Analyzing your requirements and generating your website…

-
- Loading… -
-

AI is collecting your requirements and applying the first changes.

-

This page will update automatically as the plan is implemented.

-

Runtime: PHP — UTC

-
-
- + + +
+
+
+
+
+

AI Assistant

+
+
+ +
+ +
+
+
+
+ + +