Update builder.html
Browse files- 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">Добавить свой
|
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 |
-
|
232 |
-
|
233 |
-
|
234 |
-
const jsCode = editor.getJs();
|
235 |
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
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 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
|
|
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 |
|