From d9fc110207a1403ae38c3e27bb82758f89d4fb81 Mon Sep 17 00:00:00 2001 From: renat_togussov Date: Thu, 15 Oct 2026 12:37:06 +0000 Subject: [PATCH] PDF/print tools + Kazakh i18n, pdfmake vector export --- index.html | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) diff --git a/index.html b/index.html index b0b5700..2adac2b 100644 --- a/index.html +++ b/index.html @@ -9,6 +9,9 @@ + + + @@ -172,6 +202,14 @@ + @@ -181,6 +219,10 @@
Инструктаж перед каждым выездом + + +

Осмотр 360°

@@ -309,6 +351,60 @@ var I18N = { document.querySelectorAll(".lang-btn").forEach(function(b){ b.addEventListener("click", function(){ apply(b.getAttribute("data-lang")); }); }); + function curLang(){ + var a = document.querySelector(".lang-btn.active"); + return a ? a.getAttribute("data-lang") : "ru"; + } + function renderPdf(lang, filename){ + if (typeof pdfMake === "undefined") { alert("PDF-движок ещё не загрузился — повторите через пару секунд, или используйте кнопку «Печать»."); return; } + var d = I18N[lang] || I18N.ru; + function tile(n, t, p, back){ + return { + width:1, margin:10, + border: back ? {color:RED, width:2, style:"solid"} : null, + background: back ? "#fff5f5" : PAPER, + stack:[ + {text:n, color:(back?RED:BLUE), fontSize:30, bold:true, alignment:"center", margin:[0,0,0,0]}, + {text:t, color:INK, fontSize:21, bold:true, alignment:"center", margin:[0,8,0,8]}, + {text:p, color:MUT, fontSize:12.5, alignment:"center", lineHeight:1.35} + ] + }; + } + var docDef = { + content:[ + {text:d.chip, color:PAPER, fontSize:13, bold:true, alignment:"center", + backgroundColor:BLUE2, margin:[0,0,0,14]}, + {text:d.title, color:BLUE, fontSize:56, bold:true, alignment:"center", + margin:[0,0,0,10]}, + {text:d.sectionSub, color:MUT, fontSize:16, alignment:"center", + lineHeight:1.4, margin:[24,0,24,16]}, + {columns:[ + tile("01", d.side1, d.side1p, false), + tile("02", d.side2, d.side2p, false), + tile("03", d.side3, d.side3p, true), + tile("04", d.side4, d.side4p, false) + ], margin:[16,0,16,16]}, + {border:{color:RED, width:2, style:"solid"}, background:"#fff5f5", + margin:[16,0,16,16], + stack:[ + {text:d.warn1, color:INK, fontSize:15, bold:true, lineHeight:1.35, margin:[0,0,0,4]}, + {text:d.warn2, color:MUT, fontSize:12, lineHeight:1.3} + ]}, + {text:[ + {text:d.slogan1+" — ", color:INK, bold:true}, + {text:d.slogan2, color:BLUE, bold:true} + ], fontSize:34, alignment:"center", margin:[0,20,0,0]} + ] + }; + pdfMake.createPdf(docDef).download(filename); + } + function doPdf(){ + var l = curLang(); + var name = l==="kk" ? "plakat-360-kk.pdf" : "plakat-360-ru.pdf"; + renderPdf(l, name); + } + document.getElementById("btn-print").addEventListener("click", function(){ window.print(); }); + document.getElementById("btn-pdf").addEventListener("click", doPdf); apply(saved); })();