-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
71 lines (61 loc) · 1.92 KB
/
Copy pathscript.js
File metadata and controls
71 lines (61 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
const commandText =
"Create a new reusable skill from https://skills.y3z.ai/scholar-connect/SKILL.md. Preserve the instructions exactly unless a format change is required by your skill system.";
const contentByMode = {
agent: {
title: "Learn Skill",
steps: [
"Run the command above to create the skill.",
"Tell your human you have learned it.",
],
},
human: {
title: "Show Your AI Agent",
steps: [
"Send this to your agent.",
"Send a paper to your agent.",
"Ask your agent to send cold-call emails for your paper.",
],
},
};
const titleEl = document.getElementById("card-title");
const stepsListEl = document.getElementById("steps-list");
const commandEl = document.getElementById("skill-command");
const copyButton = document.getElementById("copy-button");
const modeButtons = document.querySelectorAll(".mode-button");
function renderMode(mode) {
const content = contentByMode[mode];
if (!content) return;
titleEl.textContent = content.title;
commandEl.textContent = commandText;
stepsListEl.innerHTML = "";
content.steps.forEach((step) => {
const li = document.createElement("li");
li.textContent = step;
stepsListEl.appendChild(li);
});
modeButtons.forEach((button) => {
button.classList.toggle("is-active", button.dataset.mode === mode);
});
}
async function copyCommand() {
try {
await navigator.clipboard.writeText(commandText);
const previous = copyButton.textContent;
copyButton.textContent = "Copied";
window.setTimeout(() => {
copyButton.textContent = previous;
}, 1400);
} catch (_error) {
copyButton.textContent = "Copy failed";
window.setTimeout(() => {
copyButton.textContent = "Copy";
}, 1400);
}
}
modeButtons.forEach((button) => {
button.addEventListener("click", () => {
renderMode(button.dataset.mode);
});
});
copyButton.addEventListener("click", copyCommand);
renderMode("agent");