You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
939 B
JavaScript
37 lines
939 B
JavaScript
export class Project extends HTMLElement {
|
|
constructor() {
|
|
super()
|
|
const shadow = this.attachShadow({mode: 'open'})
|
|
const textArea = document.createElement('textarea')
|
|
const path = new URL(
|
|
window.location.hash.slice(1) || '/',
|
|
window.location
|
|
).pathname
|
|
const header = document.createElement('h1')
|
|
header.innerText = path
|
|
textArea.value = localStorage.getItem(
|
|
window.location.hash
|
|
) ?? ''
|
|
textArea.addEventListener('input', e => {
|
|
localStorage.setItem(
|
|
window.location.hash,
|
|
e.target.value
|
|
)
|
|
})
|
|
const div = document.createElement('div')
|
|
div.appendChild(header)
|
|
div.appendChild(textArea)
|
|
shadow.appendChild(div)
|
|
}
|
|
|
|
connectedCallback() {
|
|
const style = document.createElement('style')
|
|
style.textContent = `
|
|
textarea {
|
|
width: 80%;
|
|
height: 90dvh;
|
|
}
|
|
`
|
|
this.shadowRoot.append(style)
|
|
}
|
|
} |