fix: скачивание pptx с проверкой загрузки библиотеки

This commit is contained in:
Anar 2026-08-19 14:19:35 +00:00
parent 7e545793f4
commit ce8553c819

View File

@ -167,11 +167,14 @@ document.addEventListener("keydown", function (e) {
if (e.key === "ArrowLeft") go(-1); if (e.key === "ArrowLeft") go(-1);
}); });
function downloadPptx() { function downloadPptx() {
// Динамически загружаем библиотеку if (typeof PptxGenJS === 'undefined') {
var script = document.createElement('script'); alert('Загрузка библиотеки... Повторите нажатие через 3 секунды');
script.src = 'https://cdn.jsdelivr.net/npm/pptxgenjs@3.12.0/dist/pptxgen.min.js'; var script = document.createElement('script');
script.onload = function() { script.src = 'https://cdn.jsdelivr.net/npm/pptxgenjs@3.12.0/dist/pptxgen.min.js';
var p = new PptxGenJS(); document.head.appendChild(script);
return;
}
var p = new PptxGenJS();
p.defineLayout({ name: "W", width: 13.33, height: 7.5 }); p.defineLayout({ name: "W", width: 13.33, height: 7.5 });
p.layout = "W"; p.layout = "W";
SLIDES.forEach(function (s) { SLIDES.forEach(function (s) {
@ -181,9 +184,7 @@ function downloadPptx() {
sl.addText(s.bullets.map(function (b) { return { text: b, options: { bullet: true, breakLine: true } }; }), sl.addText(s.bullets.map(function (b) { return { text: b, options: { bullet: true, breakLine: true } }; }),
{ x: 0.9, y: 1.8, w: 11.5, h: 5.2, fontSize: 16, color: "E4E4E7", lineSpacingMultiple: 1.3 }); { x: 0.9, y: 1.8, w: 11.5, h: 5.2, fontSize: 16, color: "E4E4E7", lineSpacingMultiple: 1.3 });
}); });
p.writeFile({ fileName: "Juniper_RE_Complete_Guide.pptx" }); p.writeFile({ fileName: "Juniper_RE_Complete_Guide.pptx" });
};
document.head.appendChild(script);
} }
render(); render();
</script> </script>