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);
});
function downloadPptx() {
// Динамически загружаем библиотеку
var script = document.createElement('script');
script.src = 'https://cdn.jsdelivr.net/npm/pptxgenjs@3.12.0/dist/pptxgen.min.js';
script.onload = function() {
var p = new PptxGenJS();
if (typeof PptxGenJS === 'undefined') {
alert('Загрузка библиотеки... Повторите нажатие через 3 секунды');
var script = document.createElement('script');
script.src = 'https://cdn.jsdelivr.net/npm/pptxgenjs@3.12.0/dist/pptxgen.min.js';
document.head.appendChild(script);
return;
}
var p = new PptxGenJS();
p.defineLayout({ name: "W", width: 13.33, height: 7.5 });
p.layout = "W";
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 } }; }),
{ 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" });
};
document.head.appendChild(script);
p.writeFile({ fileName: "Juniper_RE_Complete_Guide.pptx" });
}
render();
</script>