fix: кнопки с обработкой ошибок

This commit is contained in:
Anar 2026-08-19 14:23:23 +00:00
parent 316894059c
commit fba7822f2b

View File

@ -30,7 +30,7 @@
<div class="nav"> <div class="nav">
<button class="prev-next" onclick="go(-1)">← Назад</button> <button class="prev-next" onclick="go(-1)">← Назад</button>
<button class="prev-next" onclick="go(1)">Вперёд →</button> <button class="prev-next" onclick="go(1)">Вперёд →</button>
<button class="pptx" onclick="downloadPptx()">📥 Скачать .pptx</button> <button class="pptx" onclick="downloadPptx()" id="dlbtn">📥 Скачать .pptx</button>
</div> </div>
<div class="num" id="num"></div> <div class="num" id="num"></div>
<script> <script>
@ -168,7 +168,10 @@ document.addEventListener("keydown", function (e) {
if (e.key === "ArrowLeft") go(-1); if (e.key === "ArrowLeft") go(-1);
}); });
function downloadPptx() { function downloadPptx() {
var btn = document.getElementById('dlbtn');
try {
var p = new PptxGenJS(); var p = new PptxGenJS();
btn.textContent = '⏳ Загрузка...';
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) {
@ -179,6 +182,13 @@ function downloadPptx() {
{ 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" });
btn.textContent = '✅ Готово!';
setTimeout(function() { btn.textContent = '📥 Скачать .pptx'; }, 3000);
} catch(e) {
btn.textContent = '❌ Ошибка';
alert('Не удалось скачать: ' + e.message + '\\n\\nПопробуй Ctrl+P → Сохранить как PDF');
setTimeout(function() { btn.textContent = '📥 Скачать .pptx'; }, 3000);
}
} }
render(); render();
</script> </script>