Update static/script.js
Browse files- static/script.js +10 -23
static/script.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
| 1 |
-
// === Dynamic Model Fetching ===
|
| 2 |
let MODEL_LIST = [];
|
| 3 |
|
| 4 |
async function fetchModelList() {
|
|
@@ -15,7 +14,6 @@ async function fetchModelList() {
|
|
| 15 |
}
|
| 16 |
}
|
| 17 |
|
| 18 |
-
// === Create Custom Dropdowns Dynamically ===
|
| 19 |
function createDropdown(dropdownId) {
|
| 20 |
const dropdown = document.getElementById(dropdownId);
|
| 21 |
const selected = dropdown.querySelector(".selected");
|
|
@@ -25,7 +23,6 @@ function createDropdown(dropdownId) {
|
|
| 25 |
|
| 26 |
MODEL_LIST.forEach(model => {
|
| 27 |
const option = document.createElement("div");
|
| 28 |
-
option.className = "p-2 hover:bg-visual_green rounded cursor-pointer";
|
| 29 |
option.textContent = model.name;
|
| 30 |
option.dataset.value = model.id;
|
| 31 |
options.appendChild(option);
|
|
@@ -34,27 +31,23 @@ function createDropdown(dropdownId) {
|
|
| 34 |
e.stopPropagation();
|
| 35 |
selected.textContent = model.name;
|
| 36 |
dropdown.dataset.value = model.id;
|
| 37 |
-
if (nameDisplay)
|
| 38 |
-
|
| 39 |
-
nameDisplay.classList.remove("hidden");
|
| 40 |
-
}
|
| 41 |
-
options.classList.add("hidden");
|
| 42 |
});
|
| 43 |
});
|
| 44 |
|
| 45 |
selected.addEventListener("click", (e) => {
|
| 46 |
e.stopPropagation();
|
| 47 |
-
options.classList.toggle("
|
| 48 |
});
|
| 49 |
|
| 50 |
document.addEventListener("click", (e) => {
|
| 51 |
if (!dropdown.contains(e.target)) {
|
| 52 |
-
options.classList.
|
| 53 |
}
|
| 54 |
});
|
| 55 |
}
|
| 56 |
|
| 57 |
-
// === Initialize All Dropdowns After Fetch ===
|
| 58 |
function initializeDropdowns() {
|
| 59 |
createDropdown("modelA");
|
| 60 |
createDropdown("modelB");
|
|
@@ -62,7 +55,6 @@ function initializeDropdowns() {
|
|
| 62 |
createDropdown("aggregator");
|
| 63 |
}
|
| 64 |
|
| 65 |
-
// === Theme, Config and Docs Buttons ===
|
| 66 |
const themeToggle = document.getElementById("themeToggle");
|
| 67 |
const toggleConfig = document.getElementById("toggleConfig");
|
| 68 |
const docsButton = document.getElementById("docsButton");
|
|
@@ -104,31 +96,28 @@ toggleConfig.addEventListener("click", () => {
|
|
| 104 |
} else if (configPanel.classList.contains("expanded")) {
|
| 105 |
configPanel.classList.remove("expanded");
|
| 106 |
configPanel.classList.add("minimal");
|
|
|
|
|
|
|
|
|
|
| 107 |
} else {
|
| 108 |
configPanel.classList.add("expanded");
|
| 109 |
configPanel.classList.remove("hidden");
|
| 110 |
}
|
| 111 |
-
|
| 112 |
-
// Force close all dropdowns when minimizing
|
| 113 |
-
if (configPanel.classList.contains("minimal")) {
|
| 114 |
-
document.querySelectorAll(".options").forEach(opt => opt.classList.add("hidden"));
|
| 115 |
-
}
|
| 116 |
});
|
| 117 |
|
| 118 |
docsButton.addEventListener("click", () => {
|
| 119 |
window.location.href = "/docs";
|
| 120 |
});
|
| 121 |
|
| 122 |
-
// === Per-model Loader Control ===
|
| 123 |
function showLoader(id) {
|
| 124 |
const loader = document.getElementById(`loader${id}`);
|
| 125 |
const modelZone = loader.closest(".model-zone");
|
| 126 |
loader.classList.remove("hidden");
|
| 127 |
modelZone.classList.add("loading");
|
| 128 |
loader.innerHTML = `
|
| 129 |
-
<div class="dot
|
| 130 |
-
<div class="dot
|
| 131 |
-
<div class="dot
|
| 132 |
`;
|
| 133 |
}
|
| 134 |
|
|
@@ -140,7 +129,6 @@ function hideLoader(id) {
|
|
| 140 |
loader.innerHTML = "";
|
| 141 |
}
|
| 142 |
|
| 143 |
-
// === Chat Handling ===
|
| 144 |
const chatForm = document.getElementById("chatForm");
|
| 145 |
const userInput = document.getElementById("userInput");
|
| 146 |
const chatContainer = document.getElementById("chatContainer");
|
|
@@ -202,5 +190,4 @@ chatForm.addEventListener("submit", async (e) => {
|
|
| 202 |
}
|
| 203 |
});
|
| 204 |
|
| 205 |
-
// === Kickstart ===
|
| 206 |
fetchModelList();
|
|
|
|
|
|
|
| 1 |
let MODEL_LIST = [];
|
| 2 |
|
| 3 |
async function fetchModelList() {
|
|
|
|
| 14 |
}
|
| 15 |
}
|
| 16 |
|
|
|
|
| 17 |
function createDropdown(dropdownId) {
|
| 18 |
const dropdown = document.getElementById(dropdownId);
|
| 19 |
const selected = dropdown.querySelector(".selected");
|
|
|
|
| 23 |
|
| 24 |
MODEL_LIST.forEach(model => {
|
| 25 |
const option = document.createElement("div");
|
|
|
|
| 26 |
option.textContent = model.name;
|
| 27 |
option.dataset.value = model.id;
|
| 28 |
options.appendChild(option);
|
|
|
|
| 31 |
e.stopPropagation();
|
| 32 |
selected.textContent = model.name;
|
| 33 |
dropdown.dataset.value = model.id;
|
| 34 |
+
if (nameDisplay) nameDisplay.textContent = model.name;
|
| 35 |
+
options.classList.remove("show");
|
|
|
|
|
|
|
|
|
|
| 36 |
});
|
| 37 |
});
|
| 38 |
|
| 39 |
selected.addEventListener("click", (e) => {
|
| 40 |
e.stopPropagation();
|
| 41 |
+
options.classList.toggle("show");
|
| 42 |
});
|
| 43 |
|
| 44 |
document.addEventListener("click", (e) => {
|
| 45 |
if (!dropdown.contains(e.target)) {
|
| 46 |
+
options.classList.remove("show");
|
| 47 |
}
|
| 48 |
});
|
| 49 |
}
|
| 50 |
|
|
|
|
| 51 |
function initializeDropdowns() {
|
| 52 |
createDropdown("modelA");
|
| 53 |
createDropdown("modelB");
|
|
|
|
| 55 |
createDropdown("aggregator");
|
| 56 |
}
|
| 57 |
|
|
|
|
| 58 |
const themeToggle = document.getElementById("themeToggle");
|
| 59 |
const toggleConfig = document.getElementById("toggleConfig");
|
| 60 |
const docsButton = document.getElementById("docsButton");
|
|
|
|
| 96 |
} else if (configPanel.classList.contains("expanded")) {
|
| 97 |
configPanel.classList.remove("expanded");
|
| 98 |
configPanel.classList.add("minimal");
|
| 99 |
+
|
| 100 |
+
// Force close any dropdowns
|
| 101 |
+
document.querySelectorAll(".options").forEach(opt => opt.classList.remove("show"));
|
| 102 |
} else {
|
| 103 |
configPanel.classList.add("expanded");
|
| 104 |
configPanel.classList.remove("hidden");
|
| 105 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
});
|
| 107 |
|
| 108 |
docsButton.addEventListener("click", () => {
|
| 109 |
window.location.href = "/docs";
|
| 110 |
});
|
| 111 |
|
|
|
|
| 112 |
function showLoader(id) {
|
| 113 |
const loader = document.getElementById(`loader${id}`);
|
| 114 |
const modelZone = loader.closest(".model-zone");
|
| 115 |
loader.classList.remove("hidden");
|
| 116 |
modelZone.classList.add("loading");
|
| 117 |
loader.innerHTML = `
|
| 118 |
+
<div class="dot"></div>
|
| 119 |
+
<div class="dot"></div>
|
| 120 |
+
<div class="dot"></div>
|
| 121 |
`;
|
| 122 |
}
|
| 123 |
|
|
|
|
| 129 |
loader.innerHTML = "";
|
| 130 |
}
|
| 131 |
|
|
|
|
| 132 |
const chatForm = document.getElementById("chatForm");
|
| 133 |
const userInput = document.getElementById("userInput");
|
| 134 |
const chatContainer = document.getElementById("chatContainer");
|
|
|
|
| 190 |
}
|
| 191 |
});
|
| 192 |
|
|
|
|
| 193 |
fetchModelList();
|