parrotmaker commited on
Commit
ca90ec6
·
verified ·
1 Parent(s): e545017

Update static/index.html

Browse files
Files changed (1) hide show
  1. static/index.html +43 -3
static/index.html CHANGED
@@ -68,12 +68,21 @@
68
  background: #eee;
69
  padding: 1rem;
70
  }
 
 
 
 
 
 
 
 
 
71
  </style>
72
  </head>
73
  <body>
74
  <!-- Left: Assistant -->
75
  <div class="sidebar">
76
- <input type="text" placeholder="Write what you want ✨" />
77
  </div>
78
 
79
  <!-- Right: Editor UI -->
@@ -89,8 +98,39 @@
89
  </div>
90
  </div>
91
  <div class="editor">
92
- <textarea style="width: 100%; height: 100%; border: none; outline: none; background: transparent;" placeholder="Your code..."></textarea>
93
  </div>
94
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95
  </body>
96
- </html>
 
68
  background: #eee;
69
  padding: 1rem;
70
  }
71
+ textarea {
72
+ width: 100%;
73
+ height: 100%;
74
+ border: none;
75
+ outline: none;
76
+ background: transparent;
77
+ font-family: monospace;
78
+ font-size: 14px;
79
+ }
80
  </style>
81
  </head>
82
  <body>
83
  <!-- Left: Assistant -->
84
  <div class="sidebar">
85
+ <input id="prompt" type="text" placeholder="Write what you want ✨" />
86
  </div>
87
 
88
  <!-- Right: Editor UI -->
 
98
  </div>
99
  </div>
100
  <div class="editor">
101
+ <textarea id="editor" placeholder="Your code..."></textarea>
102
  </div>
103
  </div>
104
+
105
+ <script>
106
+ const promptInput = document.getElementById("prompt");
107
+ const editor = document.getElementById("editor");
108
+
109
+ promptInput.addEventListener("keydown", async (e) => {
110
+ if (e.key === "Enter") {
111
+ e.preventDefault();
112
+ const prompt = promptInput.value.trim();
113
+ if (!prompt) return;
114
+
115
+ promptInput.disabled = true;
116
+ promptInput.value = "Thinking...";
117
+
118
+ const response = await fetch("/generate", {
119
+ method: "POST",
120
+ headers: { "Content-Type": "application/json" },
121
+ body: JSON.stringify({ data: [prompt] })
122
+ });
123
+
124
+ const json = await response.json();
125
+ const aiText = json.data[0];
126
+
127
+ // Append AI response to editor
128
+ editor.value += "\\n\\n// AI Suggestion:\\n" + aiText;
129
+ promptInput.value = "";
130
+ promptInput.disabled = false;
131
+ promptInput.focus();
132
+ }
133
+ });
134
+ </script>
135
  </body>
136
+ </html>