-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin-ai-panel.js
More file actions
23 lines (20 loc) · 809 Bytes
/
Copy pathadmin-ai-panel.js
File metadata and controls
23 lines (20 loc) · 809 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import { askAI } from "./ai-service.js";
export function attachAdminAI(panelElement) {
panelElement.innerHTML = `
<div class="card">
<h2>Admin AI Console</h2>
<textarea id="aiPrompt" rows="3" style="width:100%;"></textarea>
<button id="aiSend" style="margin-top:8px;">Ask AI</button>
<pre id="aiResponse" style="margin-top:12px; white-space:pre-wrap;"></pre>
</div>
`;
const promptEl = panelElement.querySelector("#aiPrompt");
const sendBtn = panelElement.querySelector("#aiSend");
const respEl = panelElement.querySelector("#aiResponse");
sendBtn.addEventListener("click", () => {
const prompt = promptEl.value.trim();
if (!prompt) return;
const result = askAI(prompt);
respEl.textContent = `${result.response}\n\n(${result.timestamp})`;
});
}