Virtual App Creator

Virtual App Creator

Your virtual app preview will appear here.

Go to 'App Configuration' to build your app.

My App

1. Global App Settings

2. Screen Management

Screen Name Action

3. Screen Editor

Error: Screen "${screenName}" not found.

`; return; } appScreenContent.innerHTML = ''; // Clear previous content const screen = vacAppData.screens[screenName]; screen.elements.forEach(el => { let htmlEl = null; switch(el.type) { case 'header': htmlEl = document.createElement('h2'); htmlEl.className = 'vac-app-header'; htmlEl.textContent = el.text; break; case 'text': htmlEl = document.createElement('p'); htmlEl.className = 'vac-app-text'; htmlEl.textContent = el.text; break; case 'button': htmlEl = document.createElement('button'); htmlEl.type = 'button'; htmlEl.className = 'vac-app-button'; htmlEl.textContent = el.text; htmlEl.setAttribute('onclick', `vacRenderScreen('${el.link}')`); break; } if (htmlEl) { appScreenContent.appendChild(htmlEl); } }); } // --- PDF Download Function --- async function vacDownloadPDF() { if (!pdfContentEl || !pdfDownloadBtn || !window.jspdf || !window.html2canvas) { console.error("PDF generation libraries or content not found."); alert("Error: PDF generation failed."); return; } const { jsPDF } = window.jspdf; const btnWrapper = document.getElementById('vac-pdf-btn-wrapper'); if(btnWrapper) btnWrapper.style.display = 'none'; // Hide button try { const canvas = await html2canvas(pdfContentEl, { scale: 2, // Higher quality useCORS: true, logging: false }); const imgData = canvas.toDataURL('image/png'); const doc = new jsPDF('p', 'mm'); // Portrait const pdfWidth = doc.internal.pageSize.getWidth(); const imgWidth = canvas.width; const imgHeight = canvas.height; const ratio = imgHeight / imgWidth; const margin = 10; const effectiveWidth = pdfWidth - (margin * 2); const effectiveHeight = effectiveWidth * ratio; doc.addImage(imgData, 'PNG', margin, margin, effectiveWidth, effectiveHeight); doc.save('Virtual_App_Screen.pdf'); } catch (error) { console.error("Error generating PDF: ", error); alert("An error occurred while generating the PDF."); } finally { if(btnWrapper) btnWrapper.style.display = 'block'; // Show button } } // --- Event Listeners --- if (nextBtn) nextBtn.addEventListener('click', vacNextTab); if (prevBtn) prevBtn.addEventListener('click', vacPrevTab); if (addScreenBtn) addScreenBtn.addEventListener('click', vacAddScreen); if (editScreenSelect) editScreenSelect.addEventListener('change', vacLoadScreenEditor); if (elementTypeSelect) elementTypeSelect.addEventListener('change', vacToggleElementInputs); if (addElementBtn) addElementBtn.addEventListener('click', vacAddElement); if (buildAppBtn) buildAppBtn.addEventListener('click', vacBuildApp); if (pdfDownloadBtn) pdfDownloadBtn.addEventListener('click', vacDownloadPDF); // --- Initialization --- function vacInit() { vacLoadSampleData(); vacToggleElementInputs(); vacUpdateNavButtons(); } vacInit(); }); // End of DOMContentLoaded