chansung commited on
Commit
d3ada92
·
verified ·
1 Parent(s): 6e56735

Update script.js

Browse files
Files changed (1) hide show
  1. script.js +79 -6
script.js CHANGED
@@ -636,14 +636,87 @@ function showSingleLargePreviewUI(htmlContent, titleText, fullPromptText) {
636
  }
637
 
638
  function showInitialPreviewStateUI() {
639
- previewGridWrapperEl.innerHTML = '<div class="col-span-2 row-span-2 flex items-center justify-center text-slate-500 text-lg"><p>Press Alt+O, then Alt+P to begin.</p></div>';
640
- previewGridWrapperEl.className = 'grid-mode';
641
- if(perspectiveViewportEl) perspectiveViewportEl.style.perspective = '1500px';
642
- updateMainContentTitles("Live Previews", "Powered by Open Models from Novita.AI Model API");
643
- if (codeOutputEl) codeOutputEl.innerHTML = '<code class="language-html">// Select a variation or history item to view its code.</code>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
644
  if (selectedCodeTitleH3El) selectedCodeTitleH3El.textContent = "Selected Code:";
645
  selectedVariationGridIndex = -1;
646
- // Reset subtitle state when going back to initial view
647
  if (mainContentSubtitleH2El) {
648
  mainContentSubtitleH2El.classList.remove('prompt-truncated');
649
  delete mainContentSubtitleH2El.dataset.fullPrompt;
 
636
  }
637
 
638
  function showInitialPreviewStateUI() {
639
+ previewGridWrapperEl.innerHTML = ''; // Clear existing content
640
+
641
+ const initialViewContainer = document.createElement('div');
642
+ initialViewContainer.id = 'initial-view-content';
643
+ // Added 'initial-view-animate' for entry animation
644
+ initialViewContainer.className = 'flex flex-col items-center justify-center text-slate-300 text-lg p-8 space-y-6 h-full initial-view-animate';
645
+
646
+ // API Key Input Section
647
+ const apiKeySection = document.createElement('div');
648
+ apiKeySection.className = 'w-full max-w-md text-center'; // Centered text for this section
649
+
650
+ const apiKeyInput = document.createElement('input');
651
+ apiKeyInput.type = 'password';
652
+ apiKeyInput.id = 'initial-api-key-input';
653
+ apiKeyInput.className = 'futuristic-input w-full text-center'; // Added text-center
654
+ apiKeyInput.placeholder = 'Paste Novita.AI API Key here'; // Changed placeholder
655
+ if (apiKeyEl && apiKeyEl.value) {
656
+ apiKeyInput.value = apiKeyEl.value;
657
+ }
658
+ apiKeyInput.addEventListener('input', (e) => {
659
+ if (apiKeyEl) {
660
+ apiKeyEl.value = e.target.value;
661
+ }
662
+ });
663
+ apiKeySection.appendChild(apiKeyInput);
664
+
665
+ const apiKeyLink = document.createElement('p');
666
+ apiKeyLink.className = 'text-xs text-slate-400 mt-2'; // Adjusted margin
667
+ apiKeyLink.innerHTML = 'Get your API Key from <a href="https://novita.ai/" target="_blank" class="text-cyan-400 hover:text-cyan-300 underline">Novita.AI</a>.';
668
+ apiKeySection.appendChild(apiKeyLink);
669
+ initialViewContainer.appendChild(apiKeySection);
670
+
671
+ // Example Prompts Section
672
+ const examplePromptsSection = document.createElement('div');
673
+ examplePromptsSection.className = 'w-full max-w-lg text-center pt-4'; // Centered text for this section, added padding top
674
+
675
+ const examplePromptsContainer = document.createElement('div');
676
+ examplePromptsContainer.id = 'example-prompts-container';
677
+ examplePromptsContainer.className = 'flex flex-wrap justify-center gap-3';
678
+
679
+ const examplePrompts = [
680
+ "A modern landing page for a new meditation app",
681
+ "A portfolio website for a photographer",
682
+ "A simple to-do list application",
683
+ "An e-commerce product card for a smartwatch"
684
+ ];
685
+
686
+ examplePrompts.forEach(promptText => {
687
+ const button = document.createElement('button');
688
+ button.className = 'example-prompt-button';
689
+ button.textContent = promptText;
690
+ button.addEventListener('click', () => {
691
+ if (modalUserPromptEl) {
692
+ modalUserPromptEl.value = promptText;
693
+ }
694
+ // Ensure API key from initial input is also considered if config one is empty
695
+ if (apiKeyEl && !apiKeyEl.value && apiKeyInput.value) {
696
+ apiKeyEl.value = apiKeyInput.value;
697
+ }
698
+ showPromptModal();
699
+ });
700
+ examplePromptsContainer.appendChild(button);
701
+ });
702
+ examplePromptsSection.appendChild(examplePromptsContainer);
703
+ initialViewContainer.appendChild(examplePromptsSection);
704
+
705
+ // Final instruction
706
+ const instructionText = document.createElement('p');
707
+ instructionText.className = 'text-sm text-slate-400 mt-6'; // Adjusted margin
708
+ instructionText.innerHTML = 'Once you have an API key and a prompt (either typed or from an example),<br>click the <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-pencil inline-block align-middle -mt-1"><path d="M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"/><path d="m15 5 4 4"/></svg> icon or press Alt+P to open the prompt window and generate.';
709
+ initialViewContainer.appendChild(instructionText);
710
+
711
+ previewGridWrapperEl.appendChild(initialViewContainer);
712
+
713
+ previewGridWrapperEl.className = 'grid-mode initial-view-active'; // Keep grid-mode, add a new class for styling
714
+ if(perspectiveViewportEl) perspectiveViewportEl.style.perspective = 'none'; // No perspective for initial flat view
715
+
716
+ updateMainContentTitles("Welcome!", "Setup your API Key and enter a prompt to begin.");
717
+ if (codeOutputEl) codeOutputEl.innerHTML = '<code class="language-html">// Code for the selected evolution will appear here.</code>';
718
  if (selectedCodeTitleH3El) selectedCodeTitleH3El.textContent = "Selected Code:";
719
  selectedVariationGridIndex = -1;
 
720
  if (mainContentSubtitleH2El) {
721
  mainContentSubtitleH2El.classList.remove('prompt-truncated');
722
  delete mainContentSubtitleH2El.dataset.fullPrompt;