Merge pull request #55 from sgvictorino/separately-toggle-dupe-annotations
fix: don't collapse annotations for clicked lyrics elsewhere on page
This commit is contained in:
commit
e54ea8abec
@ -24,8 +24,9 @@ window.addEventListener("load", () => {
|
|||||||
function getAnnotation(e) {
|
function getAnnotation(e) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
//document.querySelector('.annotation')?.remove()
|
//document.querySelector('.annotation')?.remove()
|
||||||
const uri = e.target.parentElement.getAttribute("href")
|
const link = e.target.parentElement
|
||||||
const presentAnnotation = document.getElementById(uri)
|
const uri = link.getAttribute("href")
|
||||||
|
const presentAnnotation = link.nextElementSibling.matches(".annotation") && link.nextElementSibling
|
||||||
if (presentAnnotation) {
|
if (presentAnnotation) {
|
||||||
presentAnnotation.remove()
|
presentAnnotation.remove()
|
||||||
return
|
return
|
||||||
@ -41,8 +42,8 @@ function getAnnotation(e) {
|
|||||||
annotationDiv.innerHTML = parsedReponse.html
|
annotationDiv.innerHTML = parsedReponse.html
|
||||||
annotationDiv.id = uri
|
annotationDiv.id = uri
|
||||||
annotationDiv.className = "annotation"
|
annotationDiv.className = "annotation"
|
||||||
if (!document.getElementById(uri)) {
|
if (!link.nextElementSibling.matches(".annotation")) {
|
||||||
e.target.parentElement.insertAdjacentElement('afterend', annotationDiv)
|
link.insertAdjacentElement('afterend', annotationDiv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user