Connect prompt creation flow and document API
This commit is contained in:
1 parent
863cf3e0ef
commit
691bc72681
16 files changed
+567
-54
No files matched your search
@@ -156,6 +156,17 @@
|
||||
></div>
|
||||
</div>
|
||||
|
||||
<!-- Example Output -->
|
||||
<div class="example-section" id="example-section" style="display: none">
|
||||
<h2>EXAMPLE OUTPUT</h2>
|
||||
<div class="example-content">
|
||||
<div id="example-output-text" class="example-output-text" style="white-space: pre-wrap"></div>
|
||||
<div id="example-image" class="example-image" style="display: none">
|
||||
<img id="example-image-img" src="" alt="Example output image">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Locked section (shown instead of prompt if no access) -->
|
||||
<div
|
||||
id="locked-section"
|
||||
@@ -274,15 +285,20 @@
|
||||
day: "numeric",
|
||||
});
|
||||
document.getElementById("prompt-title").textContent = p.title;
|
||||
document.getElementById("prompt-category").textContent =
|
||||
p.categoryName || "Uncategorized";
|
||||
document.getElementById("prompt-updated").textContent =
|
||||
`Updated: ${new Date(p.timeStamp).toLocaleDateString()}`;
|
||||
document.getElementById("prompt-description").textContent =
|
||||
p.description;
|
||||
document.getElementById("prompt-body").textContent = p.content;
|
||||
renderExamples(p);
|
||||
|
||||
// Tier badge
|
||||
const badge = document.getElementById("tier-badge");
|
||||
if (p.tierName) {
|
||||
if (p.price != null && Number(p.price) > 0) {
|
||||
badge.innerHTML = `<span style="background:#fef3c7;color:#92400e;border-radius:20px;padding:4px 14px;font-size:0.8rem;font-weight:600;">$${Number(p.price).toFixed(2)}</span>`;
|
||||
} else if (p.tierName) {
|
||||
badge.innerHTML = `<span style="background:#f1f5f9;color:#475569;border-radius:20px;padding:4px 14px;font-size:0.8rem;font-weight:600;"><i class="bi bi-lock-fill"></i> ${p.tierName}</span>`;
|
||||
} else {
|
||||
badge.innerHTML = `<span style="background:#dcfce7;color:#166534;border-radius:20px;padding:4px 14px;font-size:0.8rem;font-weight:600;">Free</span>`;
|
||||
@@ -321,6 +337,30 @@
|
||||
document.getElementById("detail-body").style.display = "block";
|
||||
}
|
||||
|
||||
function renderExamples(p) {
|
||||
const section = document.getElementById("example-section");
|
||||
const text = document.getElementById("example-output-text");
|
||||
const imageWrap = document.getElementById("example-image");
|
||||
const image = document.getElementById("example-image-img");
|
||||
|
||||
if (!p.exampleOutput && !p.exampleImageUrl) {
|
||||
section.style.display = "none";
|
||||
return;
|
||||
}
|
||||
|
||||
section.style.display = "block";
|
||||
text.textContent = p.exampleOutput || "";
|
||||
text.style.display = p.exampleOutput ? "block" : "none";
|
||||
|
||||
if (p.exampleImageUrl) {
|
||||
image.src = p.exampleImageUrl;
|
||||
imageWrap.style.display = "block";
|
||||
} else {
|
||||
image.removeAttribute("src");
|
||||
imageWrap.style.display = "none";
|
||||
}
|
||||
}
|
||||
|
||||
function showError(title, msg) {
|
||||
document.getElementById("detail-loading").style.display = "none";
|
||||
document.getElementById("detail-error").style.display = "block";
|
||||
|
||||
Reference in new issue
Block a user