Ivan000 commited on
Commit
963800d
·
verified ·
1 Parent(s): e0e8d2f

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +301 -237
index.html CHANGED
@@ -1,291 +1,349 @@
1
- <html><head>
2
- <style>
 
 
 
 
 
 
3
  body {
4
- font-family: Arial, sans-serif;
5
- margin: 0;
6
- padding: 0;
7
- background-color: #f0f0f0;
8
  }
 
9
  #header {
10
- background-color: #333;
11
- color: white;
12
- padding: 10px;
13
- display: flex;
14
- justify-content: space-between;
15
- align-items: center;
16
  }
 
17
  #prompt-input {
18
- flex-grow: 1;
19
- margin-right: 10px;
20
- padding: 5px;
21
- font-size: 16px;
22
  }
23
- #generate-btn, #settings-btn {
24
- background-color: #4CAF50;
25
- border: none;
26
- color: white;
27
- padding: 5px 10px;
28
- text-align: center;
29
- text-decoration: none;
30
- display: inline-block;
31
- font-size: 16px;
32
- margin: 4px 2px;
33
- cursor: pointer;
 
 
34
  }
 
35
  #settings-modal {
36
- display: none;
37
- position: fixed;
38
- z-index: 1;
39
- left: 0;
40
- top: 0;
41
- width: 100%;
42
- height: 100%;
43
- overflow: auto;
44
- background-color: rgba(0,0,0,0.4);
45
  }
 
46
  .modal-content {
47
- background-color: #fefefe;
48
- margin: 15% auto;
49
- padding: 20px;
50
- border: 1px solid #888;
51
- width: 80%;
52
- max-width: 500px;
53
  }
 
54
  #result {
55
- margin: 20px;
56
- padding: 20px;
57
- background-color: white;
58
- border-radius: 5px;
59
- box-shadow: 0 0 10px rgba(0,0,0,0.1);
60
  }
 
61
  .close {
62
- color: #aaa;
63
- float: right;
64
- font-size: 28px;
65
- font-weight: bold;
66
  }
 
67
  .close:hover,
68
  .close:focus {
69
- color: black;
70
- text-decoration: none;
71
- cursor: pointer;
72
  }
 
73
  #system-prompt {
74
- width: 100%;
75
- height: 100px;
76
- margin-top: 10px;
77
  }
 
78
  #loading {
79
- display: none;
80
- position: fixed;
81
- top: 50%;
82
- left: 50%;
83
- transform: translate(-50%, -50%);
84
  }
 
85
  .spinner {
86
- width: 50px;
87
- height: 50px;
88
- border: 5px solid #f3f3f3;
89
- border-top: 5px solid #3498db;
90
- border-radius: 50%;
91
- animation: spin 1s linear infinite;
92
  }
 
93
  @keyframes spin {
94
- 0% { transform: rotate(0deg); }
95
- 100% { transform: rotate(360deg); }
 
 
 
 
 
96
  }
 
97
  #original-response {
98
- margin-top: 20px;
99
- padding: 10px;
100
- background-color: #f9f9f9;
101
- border: 1px solid #ddd;
102
- border-radius: 5px;
103
  }
104
- #copy-btn, #reset-settings-btn {
105
- margin-top: 10px;
106
- padding: 5px 10px;
107
- background-color: #008CBA;
108
- color: white;
109
- border: none;
110
- border-radius: 3px;
111
- cursor: pointer;
 
 
112
  }
 
113
  #reset-settings-btn {
114
- background-color: #f44336;
115
  }
116
- #max-tokens-value {
117
- display: inline-block;
118
- width: 50px;
119
- text-align: right;
 
120
  }
 
121
  #model-select {
122
- margin-top: 10px;
123
- padding: 5px;
124
- font-size: 16px;
125
  }
126
- </style>
127
  </head>
 
128
  <body>
129
- <div id="header">
130
- <input type="text" id="prompt-input" placeholder="Enter website description...">
131
- <button id="generate-btn">Generate</button>
132
- <button id="settings-btn">Settings</button>
133
- </div>
134
-
135
- <div id="settings-modal">
136
- <div class="modal-content">
137
- <span class="close">&times;</span>
138
- <h2>Settings</h2>
139
- <label for="huggingface-token">Hugging Face Token:</label>
140
- <input type="text" id="huggingface-token">
141
- <br><br>
142
- <label for="model-select">Select Model:</label>
143
- <select id="model-select">
144
- <option value="codellama/CodeLlama-34b-Instruct-hf">CodeLlama-34b-Instruct-hf</option>
145
- <option value="mistralai/Mistral-Small-Instruct-2409">Mistral-Small-Instruct-2409</option>
146
- <option value="microsoft/Phi-3.5-mini-instruct">Phi-3.5-mini-instruct</option>
147
- <option value="01-ai/Yi-1.5-34B-Chat">Yi-1.5-34B-Chat</option>
148
- </select>
149
- <br><br>
150
- <label for="max-tokens">Max Tokens: <span id="max-tokens-value">1000</span></label>
151
- <input type="range" id="max-tokens" min="500" max="1024" value="1000">
152
- <br><br>
153
- <label for="system-prompt">System prompt:</label>
154
- <textarea id="system-prompt">Do not write any comments to your code, do not write anything before or after the code itself. Write HTML, CSS, and JavaScript in a single file. Generate only complete, working code without abbreviations or omissions. Do not use markdown code blocks (```) or any similar formatting. You are strictly prohibited from providing any explanations, comments, or any text that is not part of the actual code, including any statements after the code.</textarea>
155
- <br><br>
156
- <button id="save-settings">Save</button>
157
- <button id="reset-settings-btn">Reset to Default</button>
158
- </div>
159
- </div>
160
-
161
- <div id="result"></div>
162
-
163
- <div id="original-response"></div>
164
- <button id="copy-btn" style="display: none;">Copy Original Response</button>
165
-
166
- <div id="loading">
167
- <div class="spinner"></div>
168
  </div>
 
169
 
170
- <script>
171
- let currentPrompt = '';
172
- let currentCode = '';
173
- let selectedModel = localStorage.getItem('selectedModel') || "codellama/CodeLlama-34b-Instruct-hf";
174
- let huggingFaceToken = localStorage.getItem('huggingFaceToken') || "";
175
- const defaultSystemPrompt = "Do not write any comments to your code, do not write anything before or after the code itself. Write HTML, CSS, and JavaScript in a single file. Generate only complete, working code without abbreviations or omissions. Do not use markdown code blocks (```) or any similar formatting. You are strictly prohibited from providing any explanations, comments, or any text that is not part of the actual code, including any statements after the code.";
176
- let systemPrompt = localStorage.getItem('systemPrompt') || defaultSystemPrompt;
177
- let maxTokens = localStorage.getItem('maxTokens') || 1000;
178
-
179
- document.getElementById('settings-btn').addEventListener('click', function() {
180
- document.getElementById('settings-modal').style.display = 'block';
181
- document.getElementById('huggingface-token').value = huggingFaceToken;
182
- document.getElementById('model-select').value = selectedModel;
183
- document.getElementById('system-prompt').value = systemPrompt;
184
- document.getElementById('max-tokens').value = maxTokens;
185
- document.getElementById('max-tokens-value').textContent = maxTokens;
186
- });
187
-
188
- document.getElementsByClassName('close')[0].addEventListener('click', function() {
189
- document.getElementById('settings-modal').style.display = 'none';
190
- });
191
-
192
- document.getElementById('save-settings').addEventListener('click', function() {
193
- huggingFaceToken = document.getElementById('huggingface-token').value;
194
- selectedModel = document.getElementById('model-select').value;
195
- systemPrompt = document.getElementById('system-prompt').value;
196
- maxTokens = document.getElementById('max-tokens').value;
197
- localStorage.setItem('huggingFaceToken', huggingFaceToken);
198
- localStorage.setItem('selectedModel', selectedModel);
199
- localStorage.setItem('systemPrompt', systemPrompt);
200
- localStorage.setItem('maxTokens', maxTokens);
201
- document.getElementById('settings-modal').style.display = 'none';
202
- console.log("Settings saved. Token:", huggingFaceToken, "Model:", selectedModel, "System Prompt:", systemPrompt, "Max Tokens:", maxTokens);
203
- });
204
-
205
- document.getElementById('reset-settings-btn').addEventListener('click', function() {
206
- selectedModel = "codellama/CodeLlama-34b-Instruct-hf";
207
- systemPrompt = defaultSystemPrompt;
208
- maxTokens = 1000;
209
- document.getElementById('model-select').value = selectedModel;
210
- document.getElementById('system-prompt').value = systemPrompt;
211
- document.getElementById('max-tokens').value = maxTokens;
212
- document.getElementById('max-tokens-value').textContent = maxTokens;
213
- localStorage.setItem('selectedModel', selectedModel);
214
- localStorage.setItem('systemPrompt', systemPrompt);
215
- localStorage.setItem('maxTokens', maxTokens);
216
- console.log("Settings reset to default. Model:", selectedModel, "System Prompt:", systemPrompt, "Max Tokens:", maxTokens);
217
- });
218
-
219
- document.getElementById('max-tokens').addEventListener('input', function() {
220
- document.getElementById('max-tokens-value').textContent = this.value;
221
- });
222
-
223
- document.getElementById('generate-btn').addEventListener('click', generateWebsite);
224
-
225
- document.getElementById('prompt-input').addEventListener('keypress', function(event) {
226
- if (event.key === 'Enter') {
227
- generateWebsite();
228
- }
229
- });
230
-
231
- document.getElementById('copy-btn').addEventListener('click', function() {
232
- const originalResponse = document.getElementById('original-response').textContent;
233
- navigator.clipboard.writeText(originalResponse).then(function() {
234
- alert('Original response copied to clipboard!');
235
- }, function(err) {
236
- console.error('Could not copy text: ', err);
237
  });
238
- });
239
 
240
- function generateWebsite() {
241
- currentPrompt = document.getElementById('prompt-input').value;
242
- if (currentPrompt) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
243
  generateWebsiteFromAPI(currentPrompt);
 
244
  }
245
- }
246
 
247
- async function generateWebsiteFromAPI(prompt) {
248
- if (!huggingFaceToken) {
249
  alert("Please set your Hugging Face token in the settings.");
250
  return;
251
- }
252
 
253
- const apiUrl = 'https://api-inference.huggingface.co/models/' + selectedModel + '/v1/chat/completions';
254
-
255
- let messages = [
256
- {"role": "system", "content": systemPrompt},
257
- {"role": "user", "content": "Generate a website based on this description: " + prompt}
258
- ];
259
 
260
- document.getElementById('loading').style.display = 'block';
 
 
 
 
 
 
 
 
 
 
 
261
 
262
- try {
263
  const response = await fetch(apiUrl, {
264
- method: 'POST',
265
- headers: {
266
- 'Authorization': 'Bearer ' + huggingFaceToken,
267
- 'Content-Type': 'application/json'
268
- },
269
- body: JSON.stringify({
270
- model: selectedModel,
271
- messages: messages,
272
- max_tokens: parseInt(maxTokens),
273
- stream: false
274
- })
275
  });
276
 
277
- document.getElementById('loading').style.display = 'none';
 
278
 
279
  if (!response.ok) {
280
- throw new Error(`HTTP error! status: ${response.status}`);
281
  }
282
 
283
  const data = await response.json();
284
  currentCode = data.choices[0].message.content;
285
-
286
  const resultDiv = document.getElementById('result');
287
  resultDiv.innerHTML = '';
288
-
289
  const sandbox = document.createElement('iframe');
290
  sandbox.style.width = '100%';
291
  sandbox.style.height = '500px';
@@ -297,15 +355,21 @@ async function generateWebsiteFromAPI(prompt) {
297
  sandboxContent.write(currentCode);
298
  sandboxContent.close();
299
 
300
- document.getElementById('original-response').textContent = currentCode;
301
- document.getElementById('copy-btn').style.display = 'block';
 
 
302
 
303
- } catch (error) {
304
- document.getElementById('loading').style.display = 'none';
 
305
  console.error('There was a problem with the fetch operation:', error);
306
- document.getElementById('result').innerHTML = `<p>An error occurred while generating the website: ${error.message}</p>`;
 
 
307
  }
308
- }
309
- </script>
 
310
 
311
- </body></html>
 
1
+ <html>
2
+
3
+ <head>
4
+ <base href="https://websim.ai/">
5
+ <meta charset="UTF-8">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <title>WebSim inside WebSim</title>
8
+ <style>
9
  body {
10
+ font-family: Arial, sans-serif;
11
+ margin: 0;
12
+ padding: 0;
13
+ background-color: #f0f0f0;
14
  }
15
+
16
  #header {
17
+ background-color: #333;
18
+ color: white;
19
+ padding: 10px;
20
+ display: flex;
21
+ justify-content: space-between;
22
+ align-items: center;
23
  }
24
+
25
  #prompt-input {
26
+ flex-grow: 1;
27
+ margin-right: 10px;
28
+ padding: 5px;
29
+ font-size: 16px;
30
  }
31
+
32
+ #generate-btn,
33
+ #settings-btn {
34
+ background-color: #4CAF50;
35
+ border: none;
36
+ color: white;
37
+ padding: 5px 10px;
38
+ text-align: center;
39
+ text-decoration: none;
40
+ display: inline-block;
41
+ font-size: 16px;
42
+ margin: 4px 2px;
43
+ cursor: pointer;
44
  }
45
+
46
  #settings-modal {
47
+ display: none;
48
+ position: fixed;
49
+ z-index: 1;
50
+ left: 0;
51
+ top: 0;
52
+ width: 100%;
53
+ height: 100%;
54
+ overflow: auto;
55
+ background-color: rgba(0, 0, 0, 0.4);
56
  }
57
+
58
  .modal-content {
59
+ background-color: #fefefe;
60
+ margin: 15% auto;
61
+ padding: 20px;
62
+ border: 1px solid #888;
63
+ width: 80%;
64
+ max-width: 500px;
65
  }
66
+
67
  #result {
68
+ margin: 20px;
69
+ padding: 20px;
70
+ background-color: white;
71
+ border-radius: 5px;
72
+ box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
73
  }
74
+
75
  .close {
76
+ color: #aaa;
77
+ float: right;
78
+ font-size: 28px;
79
+ font-weight: bold;
80
  }
81
+
82
  .close:hover,
83
  .close:focus {
84
+ color: black;
85
+ text-decoration: none;
86
+ cursor: pointer;
87
  }
88
+
89
  #system-prompt {
90
+ width: 100%;
91
+ height: 100px;
92
+ margin-top: 10px;
93
  }
94
+
95
  #loading {
96
+ display: none;
97
+ position: fixed;
98
+ top: 50%;
99
+ left: 50%;
100
+ transform: translate(-50%, -50%);
101
  }
102
+
103
  .spinner {
104
+ width: 50px;
105
+ height: 50px;
106
+ border: 5px solid #f3f3f3;
107
+ border-top: 5px solid #3498db;
108
+ border-radius: 50%;
109
+ animation: spin 1s linear infinite;
110
  }
111
+
112
  @keyframes spin {
113
+ 0% {
114
+ transform: rotate(0deg);
115
+ }
116
+
117
+ 100% {
118
+ transform: rotate(360deg);
119
+ }
120
  }
121
+
122
  #original-response {
123
+ margin-top: 20px;
124
+ padding: 10px;
125
+ background-color: #f9f9f9;
126
+ border: 1px solid #ddd;
127
+ border-radius: 5px;
128
  }
129
+
130
+ #copy-btn,
131
+ #reset-settings-btn {
132
+ margin-top: 10px;
133
+ padding: 5px 10px;
134
+ background-color: #008CBA;
135
+ color: white;
136
+ border: none;
137
+ border-radius: 3px;
138
+ cursor: pointer;
139
  }
140
+
141
  #reset-settings-btn {
142
+ background-color: #f44336;
143
  }
144
+
145
+ #max-tokens {
146
+ width: 100px;
147
+ padding: 5px;
148
+ font-size: 16px;
149
  }
150
+
151
  #model-select {
152
+ margin-top: 10px;
153
+ padding: 5px;
154
+ font-size: 16px;
155
  }
156
+ </style>
157
  </head>
158
+
159
  <body>
160
+ <div id="header">
161
+ <input type="text" id="prompt-input" placeholder="Enter website description...">
162
+ <button id="generate-btn">Generate</button>
163
+ <button id="settings-btn">Settings</button>
164
+ </div>
165
+
166
+ <div id="settings-modal">
167
+ <div class="modal-content">
168
+ <span class="close">&times;</span>
169
+ <h2>Settings</h2>
170
+ <label for="huggingface-token">Hugging Face Token:</label>
171
+ <input type="text" id="huggingface-token">
172
+ <br><br>
173
+ <label for="model-select">Select Model:</label>
174
+ <select id="model-select">
175
+ <option value="codellama/CodeLlama-34b-Instruct-hf">CodeLlama-34b-Instruct-hf</option>
176
+ <option value="mistralai/Mistral-Small-Instruct-2409">Mistral-Small-Instruct-2409</option>
177
+ <option value="microsoft/Phi-3.5-mini-instruct">Phi-3.5-mini-instruct</option>
178
+ <option value="01-ai/Yi-1.5-34B-Chat">Yi-1.5-34B-Chat</option>
179
+ <option value="google/gemma-2-27b-it">Gemma-2-27b-it</option>
180
+ <option value="meta-llama/Meta-Llama-3-8B-Instruct">Meta-Llama-3-8B-Instruct</option>
181
+ <option value="HuggingFaceH4/zephyr-7b-beta">Zephyr-7b-beta</option>
182
+ </select>
183
+ <br><br>
184
+ <label for="max-tokens">Max Tokens:</label>
185
+ <input type="number" id="max-tokens" min="1" value="1000">
186
+ <br><br>
187
+ <label for="system-prompt">System prompt:</label>
188
+ <textarea id="system-prompt">Do not write any comments to your code, do not write anything before or after the code itself. Write HTML, CSS, and JavaScript in a single file. Generate only complete, working code without abbreviations or omissions. Do not use markdown code blocks (```) or any similar formatting. You are strictly prohibited from providing any explanations, comments, or any text that is not part of the actual code, including any statements after the code.</textarea>
189
+ <br><br>
190
+ <button id="save-settings">Save</button>
191
+ <button id="reset-settings-btn">Reset to Default</button>
 
 
 
 
 
 
 
192
  </div>
193
+ </div>
194
 
195
+ <div id="result"></div>
196
+
197
+ <div id="original-response"></div>
198
+ <button id="copy-btn" style="display: none;">Copy Original Response</button>
199
+
200
+ <div id="loading">
201
+ <div class="spinner"></div>
202
+ </div>
203
+
204
+ <script>
205
+ let currentPrompt = '';
206
+ let currentCode = '';
207
+ let selectedModel = localStorage.getItem('selectedModel') || "codellama/CodeLlama-34b-Instruct-hf";
208
+ let huggingFaceToken = localStorage.getItem('huggingFaceToken') || "";
209
+ const defaultSystemPrompt = "Do not write any comments to your code, do not write anything before or after the code itself. Write HTML, CSS, and JavaScript in a single file. Generate only complete, working code without abbreviations or omissions. Do not use markdown code blocks (```) or any similar formatting. You are strictly prohibited from providing any explanations, comments, or any text that is not part of the actual code, including any statements after the code.";
210
+ let systemPrompt = localStorage.getItem('systemPrompt') || defaultSystemPrompt;
211
+ let maxTokens = localStorage.getItem('maxTokens') || 1000;
212
+
213
+ document.getElementById('settings-btn')
214
+ .addEventListener('click', function() {
215
+ document.getElementById('settings-modal')
216
+ .style.display = 'block';
217
+ document.getElementById('huggingface-token')
218
+ .value = huggingFaceToken;
219
+ document.getElementById('model-select')
220
+ .value = selectedModel;
221
+ document.getElementById('system-prompt')
222
+ .value = systemPrompt;
223
+ document.getElementById('max-tokens')
224
+ .value = maxTokens;
225
+ });
226
+
227
+ document.getElementsByClassName('close')[0].addEventListener('click', function() {
228
+ document.getElementById('settings-modal')
229
+ .style.display = 'none';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
230
  });
 
231
 
232
+ document.getElementById('save-settings')
233
+ .addEventListener('click', function() {
234
+ huggingFaceToken = document.getElementById('huggingface-token')
235
+ .value;
236
+ selectedModel = document.getElementById('model-select')
237
+ .value;
238
+ systemPrompt = document.getElementById('system-prompt')
239
+ .value;
240
+ maxTokens = document.getElementById('max-tokens')
241
+ .value;
242
+ localStorage.setItem('huggingFaceToken', huggingFaceToken);
243
+ localStorage.setItem('selectedModel', selectedModel);
244
+ localStorage.setItem('systemPrompt', systemPrompt);
245
+ localStorage.setItem('maxTokens', maxTokens);
246
+ document.getElementById('settings-modal')
247
+ .style.display = 'none';
248
+ console.log("Settings saved. Token:", huggingFaceToken, "Model:", selectedModel, "System Prompt:", systemPrompt, "Max Tokens:", maxTokens);
249
+ });
250
+
251
+ document.getElementById('reset-settings-btn')
252
+ .addEventListener('click', function() {
253
+ selectedModel = "codellama/CodeLlama-34b-Instruct-hf";
254
+ systemPrompt = defaultSystemPrompt;
255
+ maxTokens = 1000;
256
+ document.getElementById('model-select')
257
+ .value = selectedModel;
258
+ document.getElementById('system-prompt')
259
+ .value = systemPrompt;
260
+ document.getElementById('max-tokens')
261
+ .value = maxTokens;
262
+ localStorage.setItem('selectedModel', selectedModel);
263
+ localStorage.setItem('systemPrompt', systemPrompt);
264
+ localStorage.setItem('maxTokens', maxTokens);
265
+ console.log("Settings reset to default. Model:", selectedModel, "System Prompt:", systemPrompt, "Max Tokens:", maxTokens);
266
+ });
267
+
268
+ document.getElementById('generate-btn')
269
+ .addEventListener('click', generateWebsite);
270
+
271
+ document.getElementById('prompt-input')
272
+ .addEventListener('keypress', function(event) {
273
+ if (event.key === 'Enter') {
274
+ generateWebsite();
275
+ }
276
+ });
277
+
278
+ document.getElementById('copy-btn')
279
+ .addEventListener('click', function() {
280
+ const originalResponse = document.getElementById('original-response')
281
+ .textContent;
282
+ navigator.clipboard.writeText(originalResponse)
283
+ .then(function() {
284
+ alert('Original response copied to clipboard!');
285
+ }, function(err) {
286
+ console.error('Could not copy text: ', err);
287
+ });
288
+ });
289
+
290
+ function generateWebsite() {
291
+ currentPrompt = document.getElementById('prompt-input')
292
+ .value;
293
+ if (currentPrompt) {
294
  generateWebsiteFromAPI(currentPrompt);
295
+ }
296
  }
 
297
 
298
+ async function generateWebsiteFromAPI(prompt) {
299
+ if (!huggingFaceToken) {
300
  alert("Please set your Hugging Face token in the settings.");
301
  return;
302
+ }
303
 
304
+ const apiUrl = 'https://api-inference.huggingface.co/models/' + selectedModel + '/v1/chat/completions';
 
 
 
 
 
305
 
306
+ let messages = [{
307
+ "role": "system",
308
+ "content": systemPrompt
309
+ },
310
+ {
311
+ "role": "user",
312
+ "content": "Generate a website based on this description: " + prompt
313
+ }
314
+ ];
315
+
316
+ document.getElementById('loading')
317
+ .style.display = 'block';
318
 
319
+ try {
320
  const response = await fetch(apiUrl, {
321
+ method: 'POST',
322
+ headers: {
323
+ 'Authorization': 'Bearer ' + huggingFaceToken,
324
+ 'Content-Type': 'application/json'
325
+ },
326
+ body: JSON.stringify({
327
+ model: selectedModel,
328
+ messages: messages,
329
+ max_tokens: parseInt(maxTokens),
330
+ stream: false
331
+ })
332
  });
333
 
334
+ document.getElementById('loading')
335
+ .style.display = 'none';
336
 
337
  if (!response.ok) {
338
+ throw new Error(`HTTP error! status: ${response.status}`);
339
  }
340
 
341
  const data = await response.json();
342
  currentCode = data.choices[0].message.content;
343
+
344
  const resultDiv = document.getElementById('result');
345
  resultDiv.innerHTML = '';
346
+
347
  const sandbox = document.createElement('iframe');
348
  sandbox.style.width = '100%';
349
  sandbox.style.height = '500px';
 
355
  sandboxContent.write(currentCode);
356
  sandboxContent.close();
357
 
358
+ document.getElementById('original-response')
359
+ .textContent = currentCode;
360
+ document.getElementById('copy-btn')
361
+ .style.display = 'block';
362
 
363
+ } catch (error) {
364
+ document.getElementById('loading')
365
+ .style.display = 'none';
366
  console.error('There was a problem with the fetch operation:', error);
367
+ document.getElementById('result')
368
+ .innerHTML = `<p>An error occurred while generating the website: ${error.message}</p>`;
369
+ }
370
  }
371
+ </script>
372
+
373
+ </body>
374
 
375
+ </html>