const hideEmptyUploadFields = () => { document.querySelectorAll('[id^="elemID"]').forEach(elem => { const hasFileInput = elem.querySelector('input[type="file"]') !== null; if (!hasFileInput) return; const wrapper = elem.closest('.spacing'); if (wrapper) { const isHidden = getComputedStyle(elem).display === 'none'; wrapper.style.display = isHidden ? 'none' : 'inline-block'; } }); }; // הפעלה ראשונית hideEmptyUploadFields(); // הפעלה חוזרת כשיש שינויים בדף (כמו תנאים שמשנים תצוגה) const observer = new MutationObserver(() => { hideEmptyUploadFields(); }); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });