Skip to content

Commit 5471be2

Browse files
committed
UnityWebApp17.0Update(added send button)
1 parent 0b47436 commit 5471be2

File tree

4 files changed

+86
-10
lines changed

4 files changed

+86
-10
lines changed

ChatInterface.js

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -954,6 +954,31 @@ async function buildMessages(modelName, userMessage) {
954954
}
955955

956956
function setupEventListeners() {
957+
const input = document.getElementById("chat-input");
958+
const sendButton = document.getElementById("send-button");
959+
960+
// Enable/disable send button based on input
961+
input.addEventListener("input", function () {
962+
this.style.height = "auto";
963+
const newHeight = Math.min(this.scrollHeight, 150);
964+
this.style.height = newHeight + "px";
965+
966+
// Enable/disable send button
967+
sendButton.disabled = !this.value.trim();
968+
});
969+
970+
// Send message on button click
971+
sendButton.addEventListener("click", () => {
972+
const message = input.value.trim();
973+
if (message) {
974+
sendMessage(message).catch(console.error);
975+
input.value = "";
976+
input.style.height = "auto";
977+
sendButton.disabled = true; // Disable button after sending
978+
}
979+
});
980+
981+
// Existing code for Enter key
957982
input.addEventListener("keydown", (e) => {
958983
if (e.key === "Enter" && !e.shiftKey) {
959984
e.preventDefault();
@@ -962,16 +987,12 @@ async function buildMessages(modelName, userMessage) {
962987
sendMessage(message).catch(console.error);
963988
input.value = "";
964989
input.style.height = "auto";
990+
sendButton.disabled = true; // Disable button after sending
965991
}
966992
}
967993
});
968994

969-
input.addEventListener("input", function () {
970-
this.style.height = "auto";
971-
const newHeight = Math.min(this.scrollHeight, 150);
972-
this.style.height = newHeight + "px";
973-
});
974-
995+
// Existing code for voice toggle
975996
voiceToggle.addEventListener("click", () => {
976997
voiceEnabled = !voiceEnabled;
977998
voiceToggle.classList.add("button-press");
@@ -988,13 +1009,15 @@ async function buildMessages(modelName, userMessage) {
9881009
}, 150);
9891010
});
9901011

1012+
// Existing code for clear chat
9911013
clearChat.addEventListener("click", () => {
9921014
fadeOutAndClear();
9931015
conversationHistory = [];
9941016
localStorage.removeItem("conversationHistory");
9951017
stopTTS();
9961018
});
9971019

1020+
// Existing code for window resize
9981021
let resizeTimeout;
9991022
window.addEventListener("resize", () => {
10001023
clearTimeout(resizeTimeout);
@@ -1005,12 +1028,16 @@ async function buildMessages(modelName, userMessage) {
10051028
}, 250);
10061029
});
10071030

1031+
// Existing code for beforeunload
10081032
window.addEventListener("beforeunload", () => {
10091033
if (window.speechSynthesis) {
10101034
synth.cancel();
10111035
}
10121036
});
1013-
}
1037+
1038+
// Existing code for image handling
1039+
setupImageHandling();
1040+
}
10141041

10151042
function setupImageHandling() {
10161043
chatBox.addEventListener("dragenter", (e) => {

git_gui_state.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"repo_url": "https://github.com/Unity-Lab-AI/Unity-Lab-AI.github.io.git", "repo_name": "unity.unityailab.com", "feature_branch": "feature/UnityWebAppUpdate(theme,pausetoggle)"}
1+
{"repo_url": "https://github.com/Unity-Lab-AI/Unity-Lab-AI.github.io.git", "repo_name": "unity.unityailab.com", "feature_branch": "feature/UnityWebApp17.0Update"}

index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8" />
5-
<title>UnityWebApp14.0</title>
5+
<title>UnityWebApp17.0</title>
66

77
<!-- Prism CSS for code highlighting -->
88
<link
@@ -773,6 +773,7 @@
773773
id="chat-input"
774774
placeholder="Type your message... (Shift+Enter for new line, Enter to send) Want to buy us a coffee? Scroll down."
775775
></textarea>
776+
<button id="send-button" class="control-btn" disabled>Send</button>
776777
</div>
777778
<div class="controls">
778779
<div class="left-controls">

styles.css

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,55 @@ body.dark-mode {
223223
.toast.error {
224224
background-color: var(--toast-error);
225225
}
226-
226+
.input-area {
227+
position: relative;
228+
border: 1px solid var(--chat-primary);
229+
border-radius: 0.5rem;
230+
overflow: hidden;
231+
margin-bottom: 0.5rem;
232+
background: var(--chat-bg);
233+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
234+
display: flex;
235+
align-items: flex-end;
236+
}
237+
238+
#chat-input {
239+
width: 100%;
240+
min-height: 85px;
241+
max-height: 150px;
242+
padding: 0.75rem 1rem;
243+
margin: 0;
244+
background: var(--chat-bg);
245+
color: var(--chat-text);
246+
border: none;
247+
resize: none;
248+
outline: none;
249+
font-size: 15px;
250+
font-family: 'Helvetica Neue', Arial, sans-serif;
251+
box-sizing: border-box;
252+
line-height: 1.5;
253+
overflow-y: auto;
254+
}
255+
256+
#send-button {
257+
margin: 0.75rem 1rem;
258+
padding: 0.5rem 1rem;
259+
background-color: #6b7280; /* Greyed out color */
260+
color: #fff;
261+
border: none;
262+
border-radius: 0.375rem;
263+
cursor: not-allowed;
264+
transition: background-color 0.2s;
265+
}
266+
267+
#send-button:not(:disabled) {
268+
background-color: var(--chat-primary); /* Active color */
269+
cursor: pointer;
270+
}
271+
272+
#send-button:not(:disabled):hover {
273+
background-color: var(--chat-secondary); /* Hover color */
274+
}
227275
@keyframes fadeIn {
228276
to {
229277
opacity: 1;

0 commit comments

Comments
 (0)