|
|
@ -230,21 +230,26 @@ export class Header extends HTMLElement { |
|
|
const confirmBtn = document.createElement('button') |
|
|
const confirmBtn = document.createElement('button') |
|
|
confirmBtn.innerText = this.text.rename |
|
|
confirmBtn.innerText = this.text.rename |
|
|
confirmBtn.style.marginLeft = '3px' |
|
|
confirmBtn.style.marginLeft = '3px' |
|
|
|
|
|
let errorEl |
|
|
confirmBtn.addEventListener('click', () => { |
|
|
confirmBtn.addEventListener('click', () => { |
|
|
const newPath = input.value |
|
|
const newPath = input.value |
|
|
const exists = localStorage.getItem(newPath) |
|
|
const v = localStorage.getItem(newPath) |
|
|
if (exists ?? true === true) { |
|
|
if (v !== null || newPath === this.path) { |
|
|
|
|
|
if (!errorEl) { |
|
|
|
|
|
errorEl = document.createElement('p') |
|
|
|
|
|
errorEl.style.color = 'red' |
|
|
|
|
|
errorEl.innerText = this.text.alreadyExists |
|
|
|
|
|
dialog.bodyEl.appendChild(errorEl) |
|
|
|
|
|
} |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
if (newPath !== this.path) { |
|
|
localStorage.setItem( |
|
|
localStorage.setItem( |
|
|
newPath, |
|
|
newPath, |
|
|
localStorage.getItem(this.path) |
|
|
localStorage.getItem(this.path) |
|
|
) |
|
|
) |
|
|
localStorage.removeItem(this.path) |
|
|
localStorage.removeItem(this.path) |
|
|
dialog.close() |
|
|
window.location.hash = newPath |
|
|
location.hash = newPath |
|
|
dialog.close() |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
}) |
|
|
dialog.footerEl.replaceChildren( |
|
|
dialog.footerEl.replaceChildren( |
|
|
cancelBtn, confirmBtn |
|
|
cancelBtn, confirmBtn |
|
|
@ -269,7 +274,7 @@ export class Header extends HTMLElement { |
|
|
confirmBtn.style.marginLeft = '3px' |
|
|
confirmBtn.style.marginLeft = '3px' |
|
|
confirmBtn.addEventListener('click', () => { |
|
|
confirmBtn.addEventListener('click', () => { |
|
|
localStorage.removeItem(this.path) |
|
|
localStorage.removeItem(this.path) |
|
|
window.location.hash = '/' |
|
|
location.hash = '/' |
|
|
dialog.close() |
|
|
dialog.close() |
|
|
}) |
|
|
}) |
|
|
dialog.footerEl.replaceChildren( |
|
|
dialog.footerEl.replaceChildren( |
|
|
@ -333,17 +338,7 @@ export class Header extends HTMLElement { |
|
|
confirmBtn.style.marginLeft = '3px' |
|
|
confirmBtn.style.marginLeft = '3px' |
|
|
confirmBtn.addEventListener('click', () => { |
|
|
confirmBtn.addEventListener('click', () => { |
|
|
const newPath = this.encodePath(input.value) |
|
|
const newPath = this.encodePath(input.value) |
|
|
const exists = localStorage.getItem(newPath) |
|
|
location.hash = newPath |
|
|
if (exists ?? true === true) { |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
if (newPath !== this.path) { |
|
|
|
|
|
localStorage.setItem( |
|
|
|
|
|
newPath, |
|
|
|
|
|
'' |
|
|
|
|
|
) |
|
|
|
|
|
} |
|
|
|
|
|
window.location.hash = newPath |
|
|
|
|
|
dialog.close() |
|
|
dialog.close() |
|
|
}) |
|
|
}) |
|
|
dialog.footerEl.replaceChildren( |
|
|
dialog.footerEl.replaceChildren( |
|
|
|