Spaces:
Running
Running
Upload folder using huggingface_hub
Browse files- frontend/app.js +50 -5
- frontend/court/court.html +33 -33
frontend/app.js
CHANGED
|
@@ -245,10 +245,11 @@ function appendAIBubble(data, scroll = true) {
|
|
| 245 |
// Handle different response structures
|
| 246 |
const answer = data.answer || data.response || data.text || JSON.stringify(data);
|
| 247 |
const verified = data.verification_status === true || data.verification_status === "verified";
|
| 248 |
-
const
|
|
|
|
| 249 |
|
| 250 |
const sourcesBtn = sourceCount > 0 ? `
|
| 251 |
-
<button class="text-[10px] font-bold text-secondary uppercase tracking-wider flex items-center gap-1 hover:underline">
|
| 252 |
<span class="material-symbols-outlined text-xs">description</span> ${sourceCount} Citation${sourceCount > 1 ? "s" : ""}
|
| 253 |
</button>` : "";
|
| 254 |
|
|
@@ -265,13 +266,16 @@ function appendAIBubble(data, scroll = true) {
|
|
| 265 |
</div>
|
| 266 |
<div class="mt-4 pt-3 border-t border-primary/5 flex gap-3 flex-wrap">
|
| 267 |
${sourcesBtn}
|
| 268 |
-
<button class="text-[10px] font-bold text-secondary uppercase tracking-wider flex items-center gap-1 hover:underline">
|
| 269 |
-
<span class="material-symbols-outlined text-xs">picture_as_pdf</span> Export
|
| 270 |
-
</button>
|
| 271 |
</div>
|
| 272 |
</div>
|
| 273 |
`;
|
| 274 |
messagesList.appendChild(div);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 275 |
console.log("AI message appended to DOM");
|
| 276 |
if (scroll) scrollBottom();
|
| 277 |
}
|
|
@@ -381,3 +385,44 @@ function loadAnalytics() {
|
|
| 381 |
})
|
| 382 |
.catch(err => console.error("Analytics load failed:", err));
|
| 383 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 245 |
// Handle different response structures
|
| 246 |
const answer = data.answer || data.response || data.text || JSON.stringify(data);
|
| 247 |
const verified = data.verification_status === true || data.verification_status === "verified";
|
| 248 |
+
const sources = data.sources || data.source_judgments || [];
|
| 249 |
+
const sourceCount = sources.length;
|
| 250 |
|
| 251 |
const sourcesBtn = sourceCount > 0 ? `
|
| 252 |
+
<button onclick="showCitationsModal('sources-${Date.now()}')" class="text-[10px] font-bold text-secondary uppercase tracking-wider flex items-center gap-1 hover:underline" data-sources='${JSON.stringify(sources)}'>
|
| 253 |
<span class="material-symbols-outlined text-xs">description</span> ${sourceCount} Citation${sourceCount > 1 ? "s" : ""}
|
| 254 |
</button>` : "";
|
| 255 |
|
|
|
|
| 266 |
</div>
|
| 267 |
<div class="mt-4 pt-3 border-t border-primary/5 flex gap-3 flex-wrap">
|
| 268 |
${sourcesBtn}
|
|
|
|
|
|
|
|
|
|
| 269 |
</div>
|
| 270 |
</div>
|
| 271 |
`;
|
| 272 |
messagesList.appendChild(div);
|
| 273 |
+
|
| 274 |
+
// Attach click handler to citations button if it exists
|
| 275 |
+
if (sourceCount > 0) {
|
| 276 |
+
div.querySelector('button').onclick = () => showCitationsModal(sources);
|
| 277 |
+
}
|
| 278 |
+
|
| 279 |
console.log("AI message appended to DOM");
|
| 280 |
if (scroll) scrollBottom();
|
| 281 |
}
|
|
|
|
| 385 |
})
|
| 386 |
.catch(err => console.error("Analytics load failed:", err));
|
| 387 |
}
|
| 388 |
+
|
| 389 |
+
function showCitationsModal(sources) {
|
| 390 |
+
console.log("showCitationsModal called with sources:", sources);
|
| 391 |
+
if (!sources || sources.length === 0) {
|
| 392 |
+
alert("No citations available");
|
| 393 |
+
return;
|
| 394 |
+
}
|
| 395 |
+
|
| 396 |
+
// Build citations list
|
| 397 |
+
let citationsHTML = "";
|
| 398 |
+
sources.forEach((src, idx) => {
|
| 399 |
+
const title = src.title || src.name || "Unknown Case";
|
| 400 |
+
const year = src.year || src.date || "";
|
| 401 |
+
const citation = src.citation || src.ref || "";
|
| 402 |
+
const court = src.court || "";
|
| 403 |
+
|
| 404 |
+
citationsHTML += `<div class="pb-3 border-b border-primary/5 last:border-0"><p class="text-sm font-medium text-primary">${escHtml(title)}</p><p class="text-xs text-primary/60">${escHtml(citation)} ${year ? `(${year})` : ""}</p>${court ? `<p class="text-xs text-primary/50">${escHtml(court)}</p>` : ""}</div>`;
|
| 405 |
+
});
|
| 406 |
+
|
| 407 |
+
// Create modal
|
| 408 |
+
const modal = document.createElement("div");
|
| 409 |
+
modal.className = "fixed inset-0 bg-black/30 backdrop-blur-sm flex items-center justify-center z-50";
|
| 410 |
+
modal.onclick = () => modal.remove();
|
| 411 |
+
modal.innerHTML = `
|
| 412 |
+
<div class="clay-card p-6 max-w-2xl w-full mx-4 max-h-[70vh] overflow-y-auto" onclick="event.stopPropagation()">
|
| 413 |
+
<div class="flex items-center justify-between mb-4">
|
| 414 |
+
<h2 class="font-headline text-xl font-bold text-primary flex items-center gap-2">
|
| 415 |
+
<span class="material-symbols-outlined text-secondary">description</span>
|
| 416 |
+
Citations
|
| 417 |
+
</h2>
|
| 418 |
+
<button onclick="this.closest('.fixed').remove()" class="text-primary/40 hover:text-primary">
|
| 419 |
+
<span class="material-symbols-outlined">close</span>
|
| 420 |
+
</button>
|
| 421 |
+
</div>
|
| 422 |
+
<div class="space-y-3">
|
| 423 |
+
${citationsHTML}
|
| 424 |
+
</div>
|
| 425 |
+
</div>
|
| 426 |
+
`;
|
| 427 |
+
document.body.appendChild(modal);
|
| 428 |
+
}
|
frontend/court/court.html
CHANGED
|
@@ -79,60 +79,60 @@
|
|
| 79 |
|
| 80 |
<!-- Nav -->
|
| 81 |
<header class="fixed top-0 left-0 right-0 z-50 bg-[#F5F0E8]/90 backdrop-blur-md shadow-[0_8px_20px_rgba(0,0,0,0.08)]">
|
| 82 |
-
<nav class="flex justify-between items-center w-full px-
|
| 83 |
-
<div class="flex items-center gap-
|
| 84 |
-
<a href="/static/index.html" class="font-serif text-
|
| 85 |
-
<div class="hidden md:flex gap-
|
| 86 |
-
<a href="/static/index.html" class="font-serif font-bold text-
|
| 87 |
-
<span class="font-serif font-bold text-
|
| 88 |
</div>
|
| 89 |
</div>
|
| 90 |
<div class="flex items-center gap-4">
|
| 91 |
-
<span class="font-mono text-
|
| 92 |
</div>
|
| 93 |
</nav>
|
| 94 |
</header>
|
| 95 |
|
| 96 |
-
<main class="relative z-10 pt-
|
| 97 |
<!-- Centre card -->
|
| 98 |
<div class="col-span-12 lg:col-span-7 flex justify-center items-center">
|
| 99 |
-
<div class="clay-card p-
|
| 100 |
<!-- Gavel icon -->
|
| 101 |
-
<div class="mb-
|
| 102 |
-
<span class="material-symbols-outlined text-secondary text-
|
| 103 |
</div>
|
| 104 |
-
<h1 class="font-serif text-
|
| 105 |
-
<p class="font-sans text-
|
| 106 |
|
| 107 |
-
<div class="flex flex-col sm:flex-row gap-
|
| 108 |
-
<button onclick="showScreen('setup')" class="clay-btn-primary flex items-center justify-center gap-
|
| 109 |
-
<span class="material-symbols-outlined">scale</span>
|
| 110 |
-
|
| 111 |
</button>
|
| 112 |
-
<button onclick="showImportFlow()" class="clay-btn-secondary flex items-center justify-center gap-
|
| 113 |
-
<span class="material-symbols-outlined">folder_open</span>
|
| 114 |
-
Continue
|
| 115 |
</button>
|
| 116 |
</div>
|
| 117 |
-
<a onclick="showScreen('sessions')" class="text-secondary font-sans font-bold text-
|
| 118 |
<span class="material-symbols-outlined text-sm">list_alt</span>
|
| 119 |
-
|
| 120 |
</a>
|
| 121 |
-
<div class="pt-
|
| 122 |
-
<p class="text-primary/40 text-
|
| 123 |
</div>
|
| 124 |
</div>
|
| 125 |
</div>
|
| 126 |
|
| 127 |
<!-- Recent sessions sidebar -->
|
| 128 |
-
<div class="col-span-12 lg:col-span-5 flex flex-col gap-
|
| 129 |
-
<div class="flex items-center justify-between px-
|
| 130 |
-
<h3 class="font-serif text-
|
| 131 |
-
<span class="text-
|
| 132 |
</div>
|
| 133 |
-
<div id="recent-sessions-list" class="space-y-
|
| 134 |
-
<div class="clay-card p-
|
| 135 |
-
Loading
|
| 136 |
</div>
|
| 137 |
</div>
|
| 138 |
</div>
|
|
@@ -359,9 +359,9 @@
|
|
| 359 |
</div>
|
| 360 |
</nav>
|
| 361 |
|
| 362 |
-
<div class="pt-
|
| 363 |
<!-- Left panel: Bench + Concessions + Precedents -->
|
| 364 |
-
<aside class="w-
|
| 365 |
|
| 366 |
<!-- Judge panel -->
|
| 367 |
<div class="clay-card p-5 rounded-xl">
|
|
|
|
| 79 |
|
| 80 |
<!-- Nav -->
|
| 81 |
<header class="fixed top-0 left-0 right-0 z-50 bg-[#F5F0E8]/90 backdrop-blur-md shadow-[0_8px_20px_rgba(0,0,0,0.08)]">
|
| 82 |
+
<nav class="flex justify-between items-center w-full px-8 py-3 max-w-[1920px] mx-auto">
|
| 83 |
+
<div class="flex items-center gap-6">
|
| 84 |
+
<a href="/static/index.html" class="font-serif text-xl font-bold text-primary italic">NyayaSetu</a>
|
| 85 |
+
<div class="hidden md:flex gap-6 items-center">
|
| 86 |
+
<a href="/static/index.html" class="font-serif font-bold text-sm text-primary/70 hover:text-primary transition-colors">Research</a>
|
| 87 |
+
<span class="font-serif font-bold text-sm text-secondary border-b-2 border-secondary pb-0.5">Moot Court</span>
|
| 88 |
</div>
|
| 89 |
</div>
|
| 90 |
<div class="flex items-center gap-4">
|
| 91 |
+
<span class="font-mono text-[10px] text-primary/40 bg-surface-container px-2 py-0.5 rounded-full">Educational Simulation Only</span>
|
| 92 |
</div>
|
| 93 |
</nav>
|
| 94 |
</header>
|
| 95 |
|
| 96 |
+
<main class="relative z-10 pt-28 pb-12 px-8 grid grid-cols-12 gap-8 max-w-6xl mx-auto items-center min-h-screen">
|
| 97 |
<!-- Centre card -->
|
| 98 |
<div class="col-span-12 lg:col-span-7 flex justify-center items-center">
|
| 99 |
+
<div class="clay-card p-8 lg:p-10 rounded-xl w-full max-w-2xl text-center">
|
| 100 |
<!-- Gavel icon -->
|
| 101 |
+
<div class="mb-6 inline-flex items-center justify-center w-16 h-16 rounded-full bg-surface-container clay-puffy">
|
| 102 |
+
<span class="material-symbols-outlined text-secondary text-3xl" style="font-variation-settings:'FILL' 1">gavel</span>
|
| 103 |
</div>
|
| 104 |
+
<h1 class="font-serif text-4xl lg:text-5xl font-bold text-primary tracking-tight mb-3">MOOT COURT</h1>
|
| 105 |
+
<p class="font-sans text-base text-primary/60 mb-8 uppercase tracking-widest">Practice. Argue. Master.</p>
|
| 106 |
|
| 107 |
+
<div class="flex flex-col sm:flex-row gap-4 justify-center mb-8">
|
| 108 |
+
<button onclick="showScreen('setup')" class="clay-btn-primary flex items-center justify-center gap-2 px-6 py-3 rounded-lg font-sans font-bold text-sm text-white">
|
| 109 |
+
<span class="material-symbols-outlined text-lg">scale</span>
|
| 110 |
+
New Case
|
| 111 |
</button>
|
| 112 |
+
<button onclick="showImportFlow()" class="clay-btn-secondary flex items-center justify-center gap-2 border-2 border-secondary/30 px-6 py-3 rounded-lg font-sans font-bold text-sm text-secondary">
|
| 113 |
+
<span class="material-symbols-outlined text-lg">folder_open</span>
|
| 114 |
+
Continue
|
| 115 |
</button>
|
| 116 |
</div>
|
| 117 |
+
<a onclick="showScreen('sessions')" class="text-secondary font-sans font-bold text-sm hover:underline flex items-center justify-center gap-2 mb-6 cursor-pointer">
|
| 118 |
<span class="material-symbols-outlined text-sm">list_alt</span>
|
| 119 |
+
Past Sessions
|
| 120 |
</a>
|
| 121 |
+
<div class="pt-4 border-t border-primary/5">
|
| 122 |
+
<p class="text-primary/40 text-xs font-sans italic">For educational simulation only. Not legal advice.</p>
|
| 123 |
</div>
|
| 124 |
</div>
|
| 125 |
</div>
|
| 126 |
|
| 127 |
<!-- Recent sessions sidebar -->
|
| 128 |
+
<div class="col-span-12 lg:col-span-5 flex flex-col gap-4">
|
| 129 |
+
<div class="flex items-center justify-between px-3">
|
| 130 |
+
<h3 class="font-serif text-lg font-bold text-primary">Recent Sessions</h3>
|
| 131 |
+
<span class="text-[10px] font-mono text-secondary bg-secondary-fixed/30 px-1.5 py-0.5 rounded">LIVE</span>
|
| 132 |
</div>
|
| 133 |
+
<div id="recent-sessions-list" class="space-y-3">
|
| 134 |
+
<div class="clay-card p-4 rounded-lg text-center text-primary/40 text-xs font-sans">
|
| 135 |
+
Loading...
|
| 136 |
</div>
|
| 137 |
</div>
|
| 138 |
</div>
|
|
|
|
| 359 |
</div>
|
| 360 |
</nav>
|
| 361 |
|
| 362 |
+
<div class="pt-16 flex h-screen">
|
| 363 |
<!-- Left panel: Bench + Concessions + Precedents -->
|
| 364 |
+
<aside class="w-56 flex-shrink-0 flex flex-col gap-3 p-3 overflow-y-auto bg-primary/5 border-r border-primary/10 shadow-[inset_-4px_0_8px_rgba(0,0,0,0.04)]">
|
| 365 |
|
| 366 |
<!-- Judge panel -->
|
| 367 |
<div class="clay-card p-5 rounded-xl">
|