הכותרת שלי
`; document.getElementById("generatedCode").value = html; document.getElementById("generatedCode").style.display = "block"; showStatus("הקוד נוצר בהצלחה"); } /* ===================================================== יצירת JavaScript עבור האינטראקציות ===================================================== */ function generateInteractions(){ const elements = document.querySelectorAll(".builder-element"); let js = ""; elements.forEach(el=>{ const action = document.getElementById("clickAction").value; if(action === "alert" && el === selectedElement){ const msg = document.getElementById("alertText").value .replace(/\\/g,"\\\\") .replace(/"/g,'\\"'); js += ` document.addEventListener("DOMContentLoaded",function(){ const element=document.querySelector('[data-id="${el.dataset.id}"]'); if(element){ element.addEventListener("click",function(){ alert("${msg}"); }); } }); `; } }); return js; } /* ===================================================== HTML בטוח ===================================================== */ function escapeHTML(str){ return String(str) .replace(/&/g,"&") .replace(//g,">") .replace(/"/g,""") .replace(/'/g,"'"); } /* ===================================================== העתקת הקוד ===================================================== */ async function copyCode(){ const box = document.getElementById("generatedCode"); if(!box.value) generateCode(); try{ await navigator.clipboard.writeText( document.getElementById("generatedCode").value ); showStatus("✓ הקוד הועתק"); }catch(e){ const textarea = document.getElementById("generatedCode"); textarea.select(); document.execCommand("copy"); showStatus("✓ הקוד הועתק"); } } /* ===================================================== הודעת מצב ===================================================== */ function showStatus(message){ const status = document.getElementById("status"); status.textContent = message; status.style.display = "block"; setTimeout(()=>{ status.style.display = "none"; },1800); } /* ===================================================== בחירת רכיב ראשונית ===================================================== */ selectedElement = document.querySelector(".builder-element"); loadControls(); /* ===================================================== מניעת בחירה בטעות של אזור התצוגה ===================================================== */ document.getElementById("preview").addEventListener( "click", function(event){ if(event.target === this){ document.querySelectorAll( ".builder-element" ).forEach(x=>{ x.classList.remove("selected"); }); selectedElement = null; } } );