class CustomRecordEditor extends HTMLElement { connectedCallback() { this.attachShadow({ mode: 'open' }); this.shadowRoot.innerHTML = `
`; this.modal = this.shadowRoot.getElementById('modal'); this.closeButton = this.shadowRoot.getElementById('close-modal'); this.cancelButton = this.shadowRoot.getElementById('cancel-btn'); this.recordTypeSelect = this.shadowRoot.getElementById('record-type'); this.priorityField = this.shadowRoot.getElementById('priority-field'); this.closeButton.addEventListener('click', () => this.hide()); this.cancelButton.addEventListener('click', () => this.hide()); this.recordTypeSelect.addEventListener('change', () => { if (['MX', 'SRV'].includes(this.recordTypeSelect.value)) { this.priorityField.classList.remove('hidden'); } else { this.priorityField.classList.add('hidden'); } }); } static get observedAttributes() { return ['visible', 'mode', 'record-id']; } attributeChangedCallback(name, oldValue, newValue) { if (name === 'visible') { if (newValue === 'true') { this.show(); } else { this.hide(); } } if (name === 'mode') { const title = this.shadowRoot.getElementById('modal-title'); if (newValue === 'add') { title.textContent = 'Add DNS Record'; } else { title.textContent = 'Edit DNS Record'; } } } show() { this.modal.classList.remove('hidden'); feather.replace(); } hide() { this.modal.classList.add('hidden'); this.removeAttribute('visible'); } } customElements.define('custom-record-editor', CustomRecordEditor);