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