fix: кнопки с обработкой ошибок
This commit is contained in:
parent
316894059c
commit
fba7822f2b
34
index.html
34
index.html
@ -30,7 +30,7 @@
|
||||
<div class="nav">
|
||||
<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 class="num" id="num"></div>
|
||||
<script>
|
||||
@ -168,17 +168,27 @@ document.addEventListener("keydown", function (e) {
|
||||
if (e.key === "ArrowLeft") go(-1);
|
||||
});
|
||||
function downloadPptx() {
|
||||
var p = new PptxGenJS();
|
||||
p.defineLayout({ name: "W", width: 13.33, height: 7.5 });
|
||||
p.layout = "W";
|
||||
SLIDES.forEach(function (s) {
|
||||
var sl = p.addSlide();
|
||||
sl.background = { color: "0F1218" };
|
||||
sl.addText(s.title, { x: 0.7, y: 0.5, w: 12, h: 1.2, fontSize: 32, bold: true, color: "F4F4F5" });
|
||||
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" });
|
||||
var btn = document.getElementById('dlbtn');
|
||||
try {
|
||||
var p = new PptxGenJS();
|
||||
btn.textContent = '⏳ Загрузка...';
|
||||
p.defineLayout({ name: "W", width: 13.33, height: 7.5 });
|
||||
p.layout = "W";
|
||||
SLIDES.forEach(function (s) {
|
||||
var sl = p.addSlide();
|
||||
sl.background = { color: "0F1218" };
|
||||
sl.addText(s.title, { x: 0.7, y: 0.5, w: 12, h: 1.2, fontSize: 32, bold: true, color: "F4F4F5" });
|
||||
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" });
|
||||
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();
|
||||
</script>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user