class HomeworkVocabularyTask extends HomeworkElement {
constructor (id) {
super()
this.innerHTML =
`
`
this.id = id
this.setAttribute("result", "unknown")
this.setAttribute("state", "edit")
this.deleteButton = this.querySelector('img#delete')
this.deleteButton.addEventListener("click", this.deleteTask.bind(this))
this.sourceText = this.querySelector("input#source")
this.targetText = this.querySelector("input#target")
}
connectedCallback() {
console.log("New task added to page")
}
deleteTask() {
console.log("Delete line")
this.dispatchEvent(new CustomEvent("delete", {detail:{id: this.id}, bubbles: true, cancelable: true}))
}
getId() {
return this.id
}
setSourceText(text) {
this.sourceText.value = text
}
setTargetText(text) {
this.targetText.value = text
}
}
customElements.define('homework-vocabulary-task', HomeworkVocabularyTask)