מחולל אתרים חכם


`; } async function copyGeneratedCode(code) { try { if (navigator.clipboard && window.isSecureContext) { await navigator.clipboard.writeText(code); return true; } const helper = document.createElement("textarea"); helper.value = code; helper.style.position = "fixed"; helper.style.opacity = "0"; helper.style.pointerEvents = "none"; document.body.appendChild(helper); helper.focus(); helper.select(); const success = document.execCommand("copy"); helper.remove(); return success; } catch { return false; } } generateButton.addEventListener("click", async () => { const pages = collectPages(); if (pages.length === 0) { showStatus("הוסף לפחות עמוד אחד: פלייליסט או טקסט וקישורים.", "error"); return; } const emptyPages = pages.filter(page => !page.content.trim()); if (emptyPages.length === pages.length) { showStatus("יש להזין תוכן או קישור לפחות באחד העמודים.", "error"); return; } generateButton.disabled = true; generateButton.textContent = "יוצר אתר ומעתיק קוד..."; try { generatedHTML = createSiteHTML(siteTitle.value.trim(), pages); previewFrame.srcdoc = generatedHTML; previewPanel.classList.remove("hidden"); const copied = await copyGeneratedCode(generatedHTML); if (copied) { showStatus("האתר נוצר, כל העמודים נשמרו יחד בקובץ אחד, והקוד המלא הועתק ללוח.", "success"); } else { showStatus("האתר נוצר ומופיע בתצוגה המקדימה, אך הדפדפן לא אפשר העתקה אוטומטית. נסה להפעיל את האתר דרך HTTPS וללחוץ שוב.", "error"); } } catch (error) { console.error(error); showStatus("אירעה שגיאה ביצירת האתר. בדוק את הקלט ונסה שוב.", "error"); } finally { generateButton.disabled = false; generateButton.textContent = "צור אתר והעתק קוד"; } }); addContentButton.click(); })();