🧩 Live Preview

🗂 Generated Code

/* Waiting for generation... */
Toast
`; } function showToast(msg, ms=1800){ const t=document.getElementById('toast'); t.textContent=msg; t.style.display='block'; setTimeout(()=>t.style.display='none', ms); } function escapeHtml(s){return (s||'').replace(/&/g,'&').replace(/>>8)&255;return b} function numToFour(n){const b=new Uint8Array(4);b[0]=n&255;b[1]=(n>>>8)&255;b[2]=(n>>>16)&255;b[3]=(n>>>24)&255;return b} const crcTable = (()=>{const t=new Uint32Array(256);for(let n=0;n<256;n++){let c=n;for(let k=0;k<8;k++) c = (c&1)?0xedb88320^(c>>>1):(c>>>1);t[n]=c>>>0;}return t})(); function crc32(buf){let c=~0;for(let i=0;i>>8)^crcTable[(c^buf[i])&0xff];return (~c)>>>0} async function createZip(files){ const parts=[]; const fileRecords=[]; let offset=0; for(const [name,content] of Object.entries(files)){ const data = str2buf(content); const crc = crc32(data), size=data.length; const nameBuf = str2buf(name); // local file header parts.push(str2buf('PK\x03\x04')); parts.push(numToTwo(20)); parts.push(numToTwo(0)); parts.push(numToTwo(0)); // flags/method parts.push(numToTwo(0)); parts.push(numToTwo(0)); // modtime/moddate parts.push(numToFour(crc)); parts.push(numToFour(size)); parts.push(numToFour(size)); parts.push(numToTwo(nameBuf.length)); parts.push(numToTwo(0)); parts.push(nameBuf); parts.push(data); fileRecords.push({nameBuf,crc,size,offset}); offset += 30 + nameBuf.length + data.length; } const cdStart = offset; for(const fr of fileRecords){ parts.push(str2buf('PK\x01\x02')); parts.push(numToTwo(20)); parts.push(numToTwo(20)); parts.push(numToTwo(0)); parts.push(numToTwo(0)); parts.push(numToTwo(0)); parts.push(numToTwo(0)); parts.push(numToFour(fr.crc)); parts.push(numToFour(fr.size)); parts.push(numToFour(fr.size)); parts.push(numToTwo(fr.nameBuf.length)); parts.push(numToTwo(0)); parts.push(numToTwo(0)); parts.push(numToTwo(0)); parts.push(numToTwo(0)); parts.push(numToFour(0)); parts.push(numToFour(fr.offset)); parts.push(fr.nameBuf); offset += 46 + fr.nameBuf.length; } const cdEnd = offset; parts.push(str2buf('PK\x05\x06')); parts.push(numToTwo(0)); parts.push(numToTwo(0)); parts.push(numToTwo(fileRecords.length)); parts.push(numToTwo(fileRecords.length)); parts.push(numToFour(cdEnd-cdStart)); parts.push(numToFour(cdStart)); parts.push(numToTwo(0)); const totalLen = parts.reduce((a,p)=>a+p.length,0); const out = new Uint8Array(totalLen); let pos=0; for(const p of parts){ out.set(p,pos); pos += p.length; } return new Blob([out], {type:'application/zip'}); } /* init KPI from localStorage */ document.getElementById('kpi-downloads').textContent = localStorage.getItem('dl')||0; document.getElementById('kpi-clicks').textContent = localStorage.getItem('cl')||0; document.getElementById('kpi-gens').textContent = localStorage.getItem('gen')||0;