// Function to send a message function sendMessage() { var messageInput = document.getElementById("messageInput"); var messageText = messageInput.value; if (messageText.trim() !== "") { const fullMessage = "User " + userId + " (You): " + messageText; ws.send(fullMessage); // Send message through WebSocket displayMessage(fullMessage); // Display message locally messageInput.value = ""; } } // Function to display a message in the chat area function displayMessage(message) { var chatArea = document.getElementById("chatArea"); if (chatArea) { var messageElement = document.createElement("div"); messageElement.innerHTML = message; chatArea.appendChild(messageElement); // Scroll to the bottom of the chat area chatArea.scrollTop = chatArea.scrollHeight; } } // Initialize the study function initialize() { // Display the subject ID showSubjectId(); // Create the Qualtrics iframe with the subject ID const subject = myid; // Use the subject ID we've retrieved or stored document.getElementById("qualFrame").src = "https://stevenshowe.co1.qualtrics.com/jfe/form/SV_8IGkN1l6FPpz7jE?subject=" + subject; document.getElementById("qualFrame").style.display = "block"; // Initialize the chat initializeChat(); } window.addEventListener('load', initialize);

Volunteer Science Survey