DmitrMakeev commited on
Commit
07db342
·
verified ·
1 Parent(s): 4a4339a

Update builder.html

Browse files
Files changed (1) hide show
  1. builder.html +25 -49
builder.html CHANGED
@@ -169,8 +169,7 @@
169
  <label><input type="checkbox" id="script2-checkbox" value="https://example.com/your-additional-script2.js"> ВК + АП</label>
170
  <label><input type="checkbox" id="script3-checkbox" value="https://example.com/your-additional-script3.js"> Виджет Тильда</label>
171
  <label><input type="checkbox" id="script4-checkbox" value="https://example.com/your-additional-script4.js"> Виджет Геткурс</label>
172
- <button id="add-custom-script">Добавить свой скрипт</button>
173
- <button id="export-html">Скачать HTML</button>
174
  </div>
175
 
176
  <script type="text/javascript" src="https://huggingface.co/spaces/DMTuit/psy_vk/resolve/main/js/sav_html.js"></script>
@@ -211,7 +210,7 @@
211
  input: 'textarea',
212
  inputPlaceholder: 'Введите ваш скрипт здесь...',
213
  showCancelButton: true,
214
- confirmButtonText: 'Добавить',
215
  cancelButtonText: 'Отмена',
216
  inputValidator: (value) => {
217
  if (!value) {
@@ -224,55 +223,32 @@
224
  const htmlCode = editor.getHtml();
225
  const newHtml = htmlCode + script;
226
  editor.setComponents(newHtml);
227
- }
228
- });
229
- });
230
 
231
- document.getElementById('export-html').addEventListener('click', function() {
232
- const htmlCode = editor.getHtml();
233
- const cssCode = editor.getCss();
234
- const jsCode = editor.getJs();
235
 
236
- // Собираем выбранные скрипты
237
- const selectedScripts = [];
238
- if (document.getElementById('script1-checkbox').checked) {
239
- selectedScripts.push(document.getElementById('script1-checkbox').value);
240
- }
241
- if (document.getElementById('script2-checkbox').checked) {
242
- selectedScripts.push(document.getElementById('script2-checkbox').value);
243
- }
244
- if (document.getElementById('script3-checkbox').checked) {
245
- selectedScripts.push(document.getElementById('script3-checkbox').value);
246
- }
247
- if (document.getElementById('script4-checkbox').checked) {
248
- selectedScripts.push(document.getElementById('script4-checkbox').value);
249
- }
250
-
251
- // Собираем дополнительные скрипты
252
- const additionalScripts = selectedScripts.map(script => `<script src="${script}"><\/script>`).join('');
253
-
254
- // Объединение всего в один HTML-файл
255
- const fullHtml = `
256
- <!DOCTYPE html>
257
- <html>
258
- <head>
259
- <style>${cssCode}</style>
260
- </head>
261
- <body>
262
- ${htmlCode}
263
- <script>${jsCode}<\/script>
264
- ${additionalScripts}
265
- </body>
266
- </html>
267
- `;
268
 
269
- // Сохранение HTML-файла
270
- const blob = new Blob([fullHtml], { type: 'text/html' });
271
- const url = URL.createObjectURL(blob);
272
- const a = document.createElement('a');
273
- a.href = url;
274
- a.download = 'page.html';
275
- a.click();
 
276
  });
277
  </script>
278
 
 
169
  <label><input type="checkbox" id="script2-checkbox" value="https://example.com/your-additional-script2.js"> ВК + АП</label>
170
  <label><input type="checkbox" id="script3-checkbox" value="https://example.com/your-additional-script3.js"> Виджет Тильда</label>
171
  <label><input type="checkbox" id="script4-checkbox" value="https://example.com/your-additional-script4.js"> Виджет Геткурс</label>
172
+ <button id="add-custom-script">Добавить свой скрипт и скачать HTML</button>
 
173
  </div>
174
 
175
  <script type="text/javascript" src="https://huggingface.co/spaces/DMTuit/psy_vk/resolve/main/js/sav_html.js"></script>
 
210
  input: 'textarea',
211
  inputPlaceholder: 'Введите ваш скрипт здесь...',
212
  showCancelButton: true,
213
+ confirmButtonText: 'Сохранить и скачать',
214
  cancelButtonText: 'Отмена',
215
  inputValidator: (value) => {
216
  if (!value) {
 
223
  const htmlCode = editor.getHtml();
224
  const newHtml = htmlCode + script;
225
  editor.setComponents(newHtml);
 
 
 
226
 
227
+ // Скачивание HTML-файла с добавленным скриптом
228
+ const cssCode = editor.getCss();
229
+ const jsCode = editor.getJs();
 
230
 
231
+ const fullHtml = `
232
+ <!DOCTYPE html>
233
+ <html>
234
+ <head>
235
+ <style>${cssCode}</style>
236
+ </head>
237
+ <body>
238
+ ${newHtml}
239
+ <script>${jsCode}<\/script>
240
+ </body>
241
+ </html>
242
+ `;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
243
 
244
+ const blob = new Blob([fullHtml], { type: 'text/html' });
245
+ const url = URL.createObjectURL(blob);
246
+ const a = document.createElement('a');
247
+ a.href = url;
248
+ a.download = 'page.html';
249
+ a.click();
250
+ }
251
+ });
252
  });
253
  </script>
254