Updated generation pages.

This commit is contained in:
Aodhan Collins
2026-03-15 17:45:17 +00:00
parent 79bbf669e2
commit d756ea1d0e
30 changed files with 2033 additions and 189 deletions

View File

@@ -153,12 +153,29 @@
<button type="button" class="btn btn-sm btn-outline-secondary" id="clear-preview-btn">Clear</button>
</div>
</div>
<div class="tag-widget-container d-none" id="prompt-tags"></div>
<textarea class="form-control form-control-sm font-monospace" id="prompt-preview"
name="override_prompt" rows="5"
placeholder="Click Build to preview the auto-generated prompt — edit freely before generating."></textarea>
<div class="form-text" id="preview-status"></div>
</div>
<!-- ADetailer Prompt Previews -->
<div class="mb-3">
<label class="form-label mb-0">Face Detailer Prompt</label>
<div class="tag-widget-container d-none" id="face-tags"></div>
<textarea class="form-control form-control-sm font-monospace" id="face-preview"
name="override_face_prompt" rows="2"
placeholder="Auto-populated on Build — edit to override face detailer prompt."></textarea>
</div>
<div class="mb-3">
<label class="form-label mb-0">Hand Detailer Prompt</label>
<div class="tag-widget-container d-none" id="hand-tags"></div>
<textarea class="form-control form-control-sm font-monospace" id="hand-preview"
name="override_hand_prompt" rows="2"
placeholder="Auto-populated on Build — edit to override hand detailer prompt."></textarea>
</div>
<!-- Additional prompts -->
<div class="mb-3">
<label for="positive_prompt" class="form-label">Additional Positive Prompt</label>
@@ -246,7 +263,9 @@
randomizeCategory(field, key);
});
document.getElementById('prompt-preview').value = '';
clearTagWidgets('prompt-tags', 'prompt-preview');
clearTagWidgets('face-tags', 'face-preview');
clearTagWidgets('hand-tags', 'hand-preview');
document.getElementById('preview-status').textContent = '';
}
@@ -273,6 +292,51 @@
});
});
// --- Tag Widget System ---
function populateTagWidgets(containerId, textareaId, promptStr) {
const container = document.getElementById(containerId);
const textarea = document.getElementById(textareaId);
container.innerHTML = '';
if (!promptStr || !promptStr.trim()) {
container.classList.add('d-none');
return;
}
const tags = promptStr.split(',').map(t => t.trim()).filter(Boolean);
tags.forEach(tag => {
const el = document.createElement('span');
el.className = 'tag-widget active';
el.textContent = tag;
el.dataset.tag = tag;
el.addEventListener('click', () => {
el.classList.toggle('active');
el.classList.toggle('inactive');
rebuildFromTags(containerId, textareaId);
});
container.appendChild(el);
});
container.classList.remove('d-none');
textarea.classList.add('d-none');
}
function rebuildFromTags(containerId, textareaId) {
const container = document.getElementById(containerId);
const textarea = document.getElementById(textareaId);
const activeTags = Array.from(container.querySelectorAll('.tag-widget.active'))
.map(el => el.dataset.tag);
textarea.value = activeTags.join(', ');
}
function clearTagWidgets(containerId, textareaId) {
const container = document.getElementById(containerId);
const textarea = document.getElementById(textareaId);
container.innerHTML = '';
container.classList.add('d-none');
textarea.classList.remove('d-none');
textarea.value = '';
}
// --- Prompt preview ---
async function buildPromptPreview() {
const charVal = document.getElementById('character').value;
@@ -288,7 +352,12 @@
status.textContent = 'Error: ' + data.error;
} else {
document.getElementById('prompt-preview').value = data.prompt;
status.textContent = 'Auto-built — edit freely, or Clear to let the server rebuild on generate.';
document.getElementById('face-preview').value = data.face || '';
document.getElementById('hand-preview').value = data.hand || '';
populateTagWidgets('prompt-tags', 'prompt-preview', data.prompt);
populateTagWidgets('face-tags', 'face-preview', data.face || '');
populateTagWidgets('hand-tags', 'hand-preview', data.hand || '');
status.textContent = 'Click tags to toggle — Clear to reset.';
}
} catch (err) {
status.textContent = 'Request failed.';
@@ -297,7 +366,9 @@
document.getElementById('build-preview-btn').addEventListener('click', buildPromptPreview);
document.getElementById('clear-preview-btn').addEventListener('click', () => {
document.getElementById('prompt-preview').value = '';
clearTagWidgets('prompt-tags', 'prompt-preview');
clearTagWidgets('face-tags', 'face-preview');
clearTagWidgets('hand-tags', 'hand-preview');
document.getElementById('preview-status').textContent = '';
});