DmitrMakeev commited on
Commit
19eb269
·
verified ·
1 Parent(s): c92b4be

Create sav_html.js

Browse files
Files changed (1) hide show
  1. js/sav_html.js +43 -0
js/sav_html.js ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function exportHtml() {
2
+ const htmlCode = editor.getHtml();
3
+ const cssCode = editor.getCss();
4
+ const jsCode = editor.getJs();
5
+
6
+ // Собираем выбранные скрипты
7
+ const selectedScripts = [];
8
+ if (document.getElementById('script1-checkbox').checked) {
9
+ selectedScripts.push(document.getElementById('script1-checkbox').value);
10
+ }
11
+ if (document.getElementById('script2-checkbox').checked) {
12
+ selectedScripts.push(document.getElementById('script2-checkbox').value);
13
+ }
14
+ if (document.getElementById('script3-checkbox').checked) {
15
+ selectedScripts.push(document.getElementById('script3-checkbox').value);
16
+ }
17
+
18
+ // Собираем дополнительные скрипты
19
+ const additionalScripts = selectedScripts.map(script => `<script src="${script}"><\/script>`).join('');
20
+
21
+ // Объединение всего в один HTML-файл
22
+ const fullHtml = `
23
+ <!DOCTYPE html>
24
+ <html>
25
+ <head>
26
+ <style>${cssCode}</style>
27
+ </head>
28
+ <body>
29
+ ${htmlCode}
30
+ <script>${jsCode}<\/script>
31
+ ${additionalScripts}
32
+ </body>
33
+ </html>
34
+ `;
35
+
36
+ // Сохранение HTML-файла
37
+ const blob = new Blob([fullHtml], { type: 'text/html' });
38
+ const url = URL.createObjectURL(blob);
39
+ const a = document.createElement('a');
40
+ a.href = url;
41
+ a.download = 'page.html';
42
+ a.click();
43
+ }