diff --git a/VERSION.properties b/VERSION.properties index e8fae79c..2cd52084 100644 --- a/VERSION.properties +++ b/VERSION.properties @@ -1,2 +1,2 @@ -client.version=1.2.356 +client.version=1.2.357 server.version=1.2.341 diff --git a/shine-UI/js/pages/access-servers-view.js b/shine-UI/js/pages/access-servers-view.js index 653a4a4e..a620fa15 100644 --- a/shine-UI/js/pages/access-servers-view.js +++ b/shine-UI/js/pages/access-servers-view.js @@ -22,51 +22,15 @@ function createConfirmModal() { const root = document.getElementById('modal-root'); if (!(root instanceof HTMLElement)) return null; - const modal = document.createElement('div'); - modal.className = 'modal'; - modal.hidden = true; - modal.innerHTML = ` - - `; - root.append(modal); - - const titleEl = modal.querySelector('#access-servers-dialog-title'); - const textEl = modal.querySelector('#access-servers-dialog-text'); - const noteEl = modal.querySelector('#access-servers-dialog-note'); - const cancelBtn = modal.querySelector('#access-servers-dialog-cancel'); - const confirmBtn = modal.querySelector('#access-servers-dialog-confirm'); - let onConfirm = null; let onCancel = null; const close = () => { - modal.hidden = true; + root.innerHTML = ''; onConfirm = null; onCancel = null; }; - modal.addEventListener('click', (event) => { - if (event.target === modal) close(); - }); - cancelBtn?.addEventListener('click', async () => { - const handler = onCancel; - close(); - if (typeof handler === 'function') await handler(); - }); - confirmBtn?.addEventListener('click', async () => { - const handler = onConfirm; - close(); - if (typeof handler === 'function') await handler(); - }); - return { open({ title, @@ -77,6 +41,30 @@ function createConfirmModal() { onConfirm: confirmHandler, onCancel: cancelHandler, }) { + root.innerHTML = ` + + `; + const modal = root.querySelector('#access-servers-confirm-modal'); + const titleEl = root.querySelector('#access-servers-dialog-title'); + const textEl = root.querySelector('#access-servers-dialog-text'); + const noteEl = root.querySelector('#access-servers-dialog-note'); + const cancelBtn = root.querySelector('#access-servers-dialog-cancel'); + const confirmBtn = root.querySelector('#access-servers-dialog-confirm'); + if (!(modal instanceof HTMLElement) || !(titleEl instanceof HTMLElement) || !(textEl instanceof HTMLElement) || !(noteEl instanceof HTMLElement) || !(cancelBtn instanceof HTMLButtonElement) || !(confirmBtn instanceof HTMLButtonElement)) { + close(); + return; + } + titleEl.textContent = String(title || 'Подтверждение'); textEl.textContent = String(text || ''); if (note) { @@ -90,10 +78,23 @@ function createConfirmModal() { cancelBtn.textContent = String(cancelLabel || 'Нет'); onConfirm = confirmHandler || null; onCancel = cancelHandler || null; - modal.hidden = false; + + modal.addEventListener('click', (event) => { + if (event.target === modal) close(); + }); + cancelBtn.addEventListener('click', async () => { + const handler = onCancel; + close(); + if (typeof handler === 'function') await handler(); + }); + confirmBtn.addEventListener('click', async () => { + const handler = onConfirm; + close(); + if (typeof handler === 'function') await handler(); + }); }, destroy() { - modal.remove(); + close(); }, }; }