UntilDot commited on
Commit
55969ce
·
verified ·
1 Parent(s): 66222eb

Update static/script.js

Browse files
Files changed (1) hide show
  1. static/script.js +25 -3
static/script.js CHANGED
@@ -44,7 +44,7 @@ function createDropdown(dropdownId) {
44
  });
45
  }
46
 
47
- // === Theme Toggle ===
48
  const themeToggle = document.getElementById("themeToggle");
49
  const toggleConfig = document.getElementById("toggleConfig");
50
  const docsButton = document.getElementById("docsButton");
@@ -87,6 +87,27 @@ docsButton.addEventListener("click", () => {
87
  window.location.href = "/docs";
88
  });
89
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
  // === Chat Handling ===
91
  const chatForm = document.getElementById("chatForm");
92
  const userInput = document.getElementById("userInput");
@@ -116,7 +137,8 @@ chatForm.addEventListener("submit", async (e) => {
116
  appendMessage("user", prompt);
117
  userInput.value = "";
118
 
119
- appendMessage("bot", "Thinking...");
 
120
 
121
  const settings = {
122
  models: {
@@ -133,7 +155,7 @@ chatForm.addEventListener("submit", async (e) => {
133
  body: JSON.stringify({ prompt, settings })
134
  });
135
 
136
- chatContainer.lastChild.remove(); // remove 'Thinking...'
137
 
138
  if (response.ok) {
139
  const data = await response.json();
 
44
  });
45
  }
46
 
47
+ // === Theme, Config and Docs Buttons ===
48
  const themeToggle = document.getElementById("themeToggle");
49
  const toggleConfig = document.getElementById("toggleConfig");
50
  const docsButton = document.getElementById("docsButton");
 
87
  window.location.href = "/docs";
88
  });
89
 
90
+ // === Show/Hide Loaders ===
91
+ function showLoaders() {
92
+ ["A", "B", "C"].forEach(id => {
93
+ const loader = document.getElementById(`loader${id}`);
94
+ loader.classList.remove("hidden");
95
+ loader.innerHTML = `
96
+ <div class="dot bg-aqua"></div>
97
+ <div class="dot bg-aqua animation-delay-150"></div>
98
+ <div class="dot bg-aqua animation-delay-300"></div>
99
+ `;
100
+ });
101
+ }
102
+
103
+ function hideLoaders() {
104
+ ["A", "B", "C"].forEach(id => {
105
+ const loader = document.getElementById(`loader${id}`);
106
+ loader.classList.add("hidden");
107
+ loader.innerHTML = "";
108
+ });
109
+ }
110
+
111
  // === Chat Handling ===
112
  const chatForm = document.getElementById("chatForm");
113
  const userInput = document.getElementById("userInput");
 
137
  appendMessage("user", prompt);
138
  userInput.value = "";
139
 
140
+ configPanel.classList.add("hidden"); // Auto close config
141
+ showLoaders(); // Show bouncing dots
142
 
143
  const settings = {
144
  models: {
 
155
  body: JSON.stringify({ prompt, settings })
156
  });
157
 
158
+ hideLoaders(); // Hide bouncing dots
159
 
160
  if (response.ok) {
161
  const data = await response.json();