|
|
@ -227,21 +227,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() |
|
|
dialog.close() |
|
|
location.hash = newPath |
|
|
vlocation.hash = newPath |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
}) |
|
|
dialog.footerEl.replaceChildren( |
|
|
dialog.footerEl.replaceChildren( |
|
|
cancelBtn, confirmBtn |
|
|
cancelBtn, confirmBtn |
|
|
@ -266,7 +271,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) |
|
|
vlocation.hash = '/' |
|
|
location.hash = '/' |
|
|
dialog.close() |
|
|
dialog.close() |
|
|
}) |
|
|
}) |
|
|
dialog.footerEl.replaceChildren( |
|
|
dialog.footerEl.replaceChildren( |
|
|
@ -330,15 +335,8 @@ 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, '') |
|
|
|
|
|
} |
|
|
|
|
|
dialog.close() |
|
|
dialog.close() |
|
|
vlocation.hash = newPath |
|
|
|
|
|
}) |
|
|
}) |
|
|
dialog.footerEl.replaceChildren( |
|
|
dialog.footerEl.replaceChildren( |
|
|
cancelBtn, confirmBtn |
|
|
cancelBtn, confirmBtn |
|
|
|