Spaces:
Running
Running
Update script.js
Browse files
script.js
CHANGED
|
@@ -51,6 +51,7 @@ let confirmModalOverlayEl, confirmModalMessageEl, confirmModalConfirmBtnEl, conf
|
|
| 51 |
let currentConfirmCallback = null;
|
| 52 |
let historyNavLeftBtnEl, historyNavRightBtnEl;
|
| 53 |
let modalThinkingBudgetSliderEl, modalThinkingBudgetValueDisplayEl;
|
|
|
|
| 54 |
|
| 55 |
|
| 56 |
// --- Constants ---
|
|
@@ -494,7 +495,7 @@ function showFourGridPreviewUI() {
|
|
| 494 |
updateSelectedGridItemUI();
|
| 495 |
}
|
| 496 |
|
| 497 |
-
function showSingleLargePreviewUI(htmlContent, titleText,
|
| 498 |
previewGridWrapperEl.innerHTML = '';
|
| 499 |
previewGridWrapperEl.className = 'single-mode';
|
| 500 |
if(perspectiveViewportEl) perspectiveViewportEl.style.perspective = 'none';
|
|
@@ -515,17 +516,34 @@ function showSingleLargePreviewUI(htmlContent, titleText, subtitleText = "Evolut
|
|
| 515 |
item.appendChild(bodyEl);
|
| 516 |
previewGridWrapperEl.appendChild(item);
|
| 517 |
|
| 518 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 519 |
}
|
| 520 |
|
| 521 |
function showInitialPreviewStateUI() {
|
| 522 |
-
previewGridWrapperEl.innerHTML = '<div class="col-span-2 row-span-2 flex items-center justify-center text-slate-500 text-lg"><p>Press Alt+P to enter prompt and click "Generate" to begin.</p></div>';
|
| 523 |
previewGridWrapperEl.className = 'grid-mode';
|
| 524 |
if(perspectiveViewportEl) perspectiveViewportEl.style.perspective = '1500px';
|
| 525 |
updateMainContentTitles("Live Previews", "Powered by Gemini Models");
|
| 526 |
if (codeOutputEl) codeOutputEl.innerHTML = '<code class="language-html">// Select a variation or history item to view its code.</code>';
|
| 527 |
if (selectedCodeTitleH3El) selectedCodeTitleH3El.textContent = "Selected Code:";
|
| 528 |
selectedVariationGridIndex = -1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 529 |
}
|
| 530 |
|
| 531 |
function updateMainContentTitles(title, subtitle) {
|
|
@@ -1093,6 +1111,31 @@ Return ONLY the JSON object. Do not include any other explanatory text or markdo
|
|
| 1093 |
}
|
| 1094 |
}
|
| 1095 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1096 |
// --- Initialization ---
|
| 1097 |
document.addEventListener('DOMContentLoaded', () => {
|
| 1098 |
console.log("DOMContentLoaded event fired.");
|
|
@@ -1146,11 +1189,15 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
| 1146 |
historyNavRightBtnEl = document.getElementById('history-nav-right-button');
|
| 1147 |
modalThinkingBudgetSliderEl = document.getElementById('modal-thinking-budget-slider');
|
| 1148 |
modalThinkingBudgetValueDisplayEl = document.getElementById('modal-thinking-budget-value');
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1149 |
|
| 1150 |
|
| 1151 |
// --- Check if all required elements exist ---
|
| 1152 |
let missingElements = [];
|
| 1153 |
-
const requiredElements = { apiKeyEl, modelSelEl, codeOutputEl, errorMessageEl, refinementLoadingIndicator, mainContentEl, configButtonEl, intervalSliderEl, intervalValueDisplayEl, fullscreenOverlayEl, fullscreenIframeEl, exitFullscreenBtnEl, perspectiveViewportEl, previewGridWrapperEl, historyPanelEl, historyPanelPlaceholderEl, selectedCodeTitleH3El, mainContentTitleH1El, mainContentSubtitleH2El, fullscreenHistoryNavEl, historyNavPrevBtnEl, historyNavNextBtnEl, promptModalOverlayEl, promptModalContentEl, modalUserPromptEl, modalGenerateBtnEl, modalCancelBtnEl, modalLoadingIndicatorEl, modalRefinementCheckboxEl, numVariationsSliderEl, numVariationsValueDisplayEl, configModalOverlayEl, configModalContentEl, configModalCloseBtnEl, copyCodeButtonEl, exportCodeButtonEl, historyToggleButtonEl, historyArrowDownEl, historyArrowUpEl, newButtonEl, confirmModalOverlayEl, confirmModalMessageEl, confirmModalConfirmBtnEl, confirmModalCancelBtnEl, historyNavLeftBtnEl, historyNavRightBtnEl, modalThinkingBudgetSliderEl, modalThinkingBudgetValueDisplayEl };
|
| 1154 |
for (const key in requiredElements) { if (!requiredElements[key]) { missingElements.push(key); } }
|
| 1155 |
|
| 1156 |
if (missingElements.length > 0) {
|
|
@@ -1194,6 +1241,22 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
| 1194 |
confirmModalOverlayEl.addEventListener('click', (e) => {
|
| 1195 |
if (e.target === confirmModalOverlayEl) { hideConfirmModal(); }
|
| 1196 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1197 |
}
|
| 1198 |
if (modalUserPromptEl) modalUserPromptEl.addEventListener('keydown', (event) => {
|
| 1199 |
if (event.key === 'Enter' && (event.ctrlKey || event.metaKey)) {
|
|
@@ -1351,6 +1414,8 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
| 1351 |
hidePromptModal();
|
| 1352 |
} else if (confirmModalOverlayEl.style.display !== 'none' && !confirmModalOverlayEl.classList.contains('modal-anim-fade-out')) { // Add Escape handler for confirm modal
|
| 1353 |
hideConfirmModal();
|
|
|
|
|
|
|
| 1354 |
} else if (document.body.classList.contains('fullscreen-active')) {
|
| 1355 |
exitFullscreen();
|
| 1356 |
}
|
|
|
|
| 51 |
let currentConfirmCallback = null;
|
| 52 |
let historyNavLeftBtnEl, historyNavRightBtnEl;
|
| 53 |
let modalThinkingBudgetSliderEl, modalThinkingBudgetValueDisplayEl;
|
| 54 |
+
let promptDisplayModalOverlayEl, promptDisplayModalContentEl, fullPromptTextEl, promptDisplayModalCloseBtnEl;
|
| 55 |
|
| 56 |
|
| 57 |
// --- Constants ---
|
|
|
|
| 495 |
updateSelectedGridItemUI();
|
| 496 |
}
|
| 497 |
|
| 498 |
+
function showSingleLargePreviewUI(htmlContent, titleText, fullPromptText) {
|
| 499 |
previewGridWrapperEl.innerHTML = '';
|
| 500 |
previewGridWrapperEl.className = 'single-mode';
|
| 501 |
if(perspectiveViewportEl) perspectiveViewportEl.style.perspective = 'none';
|
|
|
|
| 516 |
item.appendChild(bodyEl);
|
| 517 |
previewGridWrapperEl.appendChild(item);
|
| 518 |
|
| 519 |
+
// Handle subtitle truncation and clickability
|
| 520 |
+
const maxPromptLength = 50;
|
| 521 |
+
let displaySubtitle = fullPromptText;
|
| 522 |
+
mainContentSubtitleH2El.classList.remove('prompt-truncated');
|
| 523 |
+
delete mainContentSubtitleH2El.dataset.fullPrompt;
|
| 524 |
+
|
| 525 |
+
if (fullPromptText && fullPromptText.length > maxPromptLength) {
|
| 526 |
+
displaySubtitle = fullPromptText.substring(0, maxPromptLength) + "... (click to view full)";
|
| 527 |
+
mainContentSubtitleH2El.classList.add('prompt-truncated');
|
| 528 |
+
mainContentSubtitleH2El.dataset.fullPrompt = fullPromptText; // Store full prompt
|
| 529 |
+
}
|
| 530 |
+
|
| 531 |
+
updateMainContentTitles(titleText, displaySubtitle); // Use potentially truncated text
|
| 532 |
}
|
| 533 |
|
| 534 |
function showInitialPreviewStateUI() {
|
| 535 |
+
previewGridWrapperEl.innerHTML = '<div class="col-span-2 row-span-2 flex items-center justify-center text-slate-500 text-lg"><p>Press Alt+P to enter prompt and click \"Generate\" to begin.</p></div>';
|
| 536 |
previewGridWrapperEl.className = 'grid-mode';
|
| 537 |
if(perspectiveViewportEl) perspectiveViewportEl.style.perspective = '1500px';
|
| 538 |
updateMainContentTitles("Live Previews", "Powered by Gemini Models");
|
| 539 |
if (codeOutputEl) codeOutputEl.innerHTML = '<code class="language-html">// Select a variation or history item to view its code.</code>';
|
| 540 |
if (selectedCodeTitleH3El) selectedCodeTitleH3El.textContent = "Selected Code:";
|
| 541 |
selectedVariationGridIndex = -1;
|
| 542 |
+
// Reset subtitle state when going back to initial view
|
| 543 |
+
if (mainContentSubtitleH2El) {
|
| 544 |
+
mainContentSubtitleH2El.classList.remove('prompt-truncated');
|
| 545 |
+
delete mainContentSubtitleH2El.dataset.fullPrompt;
|
| 546 |
+
}
|
| 547 |
}
|
| 548 |
|
| 549 |
function updateMainContentTitles(title, subtitle) {
|
|
|
|
| 1111 |
}
|
| 1112 |
}
|
| 1113 |
|
| 1114 |
+
// --- Full Prompt Display Modal Logic ---
|
| 1115 |
+
function showFullPromptModal(fullPrompt) {
|
| 1116 |
+
if (!promptDisplayModalOverlayEl || !fullPromptTextEl) return;
|
| 1117 |
+
|
| 1118 |
+
fullPromptTextEl.textContent = fullPrompt;
|
| 1119 |
+
|
| 1120 |
+
// Animation handling
|
| 1121 |
+
promptDisplayModalOverlayEl.classList.remove('modal-anim-fade-out');
|
| 1122 |
+
promptDisplayModalOverlayEl.style.display = 'flex';
|
| 1123 |
+
promptDisplayModalOverlayEl.classList.add('modal-anim-fade-in');
|
| 1124 |
+
}
|
| 1125 |
+
|
| 1126 |
+
function hideFullPromptModal() {
|
| 1127 |
+
if (!promptDisplayModalOverlayEl) return;
|
| 1128 |
+
|
| 1129 |
+
promptDisplayModalOverlayEl.classList.remove('modal-anim-fade-in');
|
| 1130 |
+
promptDisplayModalOverlayEl.classList.add('modal-anim-fade-out');
|
| 1131 |
+
|
| 1132 |
+
const handleAnimationEnd = () => {
|
| 1133 |
+
promptDisplayModalOverlayEl.style.display = 'none';
|
| 1134 |
+
promptDisplayModalOverlayEl.removeEventListener('animationend', handleAnimationEnd);
|
| 1135 |
+
};
|
| 1136 |
+
promptDisplayModalOverlayEl.addEventListener('animationend', handleAnimationEnd);
|
| 1137 |
+
}
|
| 1138 |
+
|
| 1139 |
// --- Initialization ---
|
| 1140 |
document.addEventListener('DOMContentLoaded', () => {
|
| 1141 |
console.log("DOMContentLoaded event fired.");
|
|
|
|
| 1189 |
historyNavRightBtnEl = document.getElementById('history-nav-right-button');
|
| 1190 |
modalThinkingBudgetSliderEl = document.getElementById('modal-thinking-budget-slider');
|
| 1191 |
modalThinkingBudgetValueDisplayEl = document.getElementById('modal-thinking-budget-value');
|
| 1192 |
+
promptDisplayModalOverlayEl = document.getElementById('prompt-display-modal-overlay');
|
| 1193 |
+
promptDisplayModalContentEl = document.getElementById('prompt-display-modal-content');
|
| 1194 |
+
fullPromptTextEl = document.getElementById('full-prompt-text');
|
| 1195 |
+
promptDisplayModalCloseBtnEl = document.getElementById('prompt-display-modal-close-button');
|
| 1196 |
|
| 1197 |
|
| 1198 |
// --- Check if all required elements exist ---
|
| 1199 |
let missingElements = [];
|
| 1200 |
+
const requiredElements = { apiKeyEl, modelSelEl, codeOutputEl, errorMessageEl, refinementLoadingIndicator, mainContentEl, configButtonEl, intervalSliderEl, intervalValueDisplayEl, fullscreenOverlayEl, fullscreenIframeEl, exitFullscreenBtnEl, perspectiveViewportEl, previewGridWrapperEl, historyPanelEl, historyPanelPlaceholderEl, selectedCodeTitleH3El, mainContentTitleH1El, mainContentSubtitleH2El, fullscreenHistoryNavEl, historyNavPrevBtnEl, historyNavNextBtnEl, promptModalOverlayEl, promptModalContentEl, modalUserPromptEl, modalGenerateBtnEl, modalCancelBtnEl, modalLoadingIndicatorEl, modalRefinementCheckboxEl, numVariationsSliderEl, numVariationsValueDisplayEl, configModalOverlayEl, configModalContentEl, configModalCloseBtnEl, copyCodeButtonEl, exportCodeButtonEl, historyToggleButtonEl, historyArrowDownEl, historyArrowUpEl, newButtonEl, confirmModalOverlayEl, confirmModalMessageEl, confirmModalConfirmBtnEl, confirmModalCancelBtnEl, historyNavLeftBtnEl, historyNavRightBtnEl, modalThinkingBudgetSliderEl, modalThinkingBudgetValueDisplayEl, promptDisplayModalOverlayEl, promptDisplayModalContentEl, fullPromptTextEl, promptDisplayModalCloseBtnEl };
|
| 1201 |
for (const key in requiredElements) { if (!requiredElements[key]) { missingElements.push(key); } }
|
| 1202 |
|
| 1203 |
if (missingElements.length > 0) {
|
|
|
|
| 1241 |
confirmModalOverlayEl.addEventListener('click', (e) => {
|
| 1242 |
if (e.target === confirmModalOverlayEl) { hideConfirmModal(); }
|
| 1243 |
});
|
| 1244 |
+
}
|
| 1245 |
+
if (promptDisplayModalOverlayEl) { // Listener for full prompt display modal overlay click
|
| 1246 |
+
promptDisplayModalOverlayEl.addEventListener('click', (e) => {
|
| 1247 |
+
if (e.target === promptDisplayModalOverlayEl) { hideFullPromptModal(); }
|
| 1248 |
+
});
|
| 1249 |
+
}
|
| 1250 |
+
if (promptDisplayModalCloseBtnEl) { // Listener for full prompt display modal close button
|
| 1251 |
+
promptDisplayModalCloseBtnEl.addEventListener('click', hideFullPromptModal);
|
| 1252 |
+
}
|
| 1253 |
+
if (mainContentSubtitleH2El) { // Listener for clicking the subtitle
|
| 1254 |
+
mainContentSubtitleH2El.addEventListener('click', (e) => {
|
| 1255 |
+
const fullPrompt = e.target.dataset.fullPrompt;
|
| 1256 |
+
if (fullPrompt) { // Check if the data attribute exists (meaning it was truncated)
|
| 1257 |
+
showFullPromptModal(fullPrompt);
|
| 1258 |
+
}
|
| 1259 |
+
});
|
| 1260 |
}
|
| 1261 |
if (modalUserPromptEl) modalUserPromptEl.addEventListener('keydown', (event) => {
|
| 1262 |
if (event.key === 'Enter' && (event.ctrlKey || event.metaKey)) {
|
|
|
|
| 1414 |
hidePromptModal();
|
| 1415 |
} else if (confirmModalOverlayEl.style.display !== 'none' && !confirmModalOverlayEl.classList.contains('modal-anim-fade-out')) { // Add Escape handler for confirm modal
|
| 1416 |
hideConfirmModal();
|
| 1417 |
+
} else if (promptDisplayModalOverlayEl.style.display !== 'none' && !promptDisplayModalOverlayEl.classList.contains('modal-anim-fade-out')) { // Add Escape handler for prompt display modal
|
| 1418 |
+
hideFullPromptModal();
|
| 1419 |
} else if (document.body.classList.contains('fullscreen-active')) {
|
| 1420 |
exitFullscreen();
|
| 1421 |
}
|