2022-10-08 22:46:48 +01:00
|
|
|
const fullAbout = document.querySelector("#about #full_about")
|
|
|
|
const summary = document.querySelector("#about #summary")
|
|
|
|
|
|
|
|
function showAbout() {
|
|
|
|
summary.classList.toggle("hidden")
|
|
|
|
fullAbout.classList.toggle("hidden")
|
|
|
|
}
|
|
|
|
|
|
|
|
[fullAbout, summary].forEach(item => item.onclick = showAbout)
|
|
|
|
|
2022-07-01 23:40:13 +01:00
|
|
|
document.querySelectorAll("#lyrics a").forEach(item => {
|
2022-06-30 21:32:56 +01:00
|
|
|
item.addEventListener("click", getAnnotation)
|
|
|
|
})
|
|
|
|
|
|
|
|
function getAnnotation(e) {
|
|
|
|
e.preventDefault()
|
2023-09-09 15:19:11 +02:00
|
|
|
const uri = e.target.parentElement.getAttribute("href")
|
2023-09-13 18:32:35 +02:00
|
|
|
const presentAnnotation = document.getElementById(uri)
|
|
|
|
if (presentAnnotation) {
|
|
|
|
presentAnnotation.remove()
|
|
|
|
return
|
|
|
|
}
|
2023-09-09 15:19:11 +02:00
|
|
|
|
|
|
|
xhr = new XMLHttpRequest()
|
|
|
|
xhr.open("GET", uri + "/annotations")
|
|
|
|
xhr.send()
|
|
|
|
xhr.onreadystatechange = function() {
|
|
|
|
if (this.readyState == 4 && this.status == 200) {
|
2023-09-09 18:11:00 +02:00
|
|
|
const parsedReponse = JSON.parse(this.responseText)
|
2023-09-13 18:32:35 +02:00
|
|
|
const annotationDiv = document.createElement('div');
|
|
|
|
annotationDiv.innerHTML = parsedReponse.html
|
|
|
|
annotationDiv.id = uri
|
|
|
|
annotationDiv.className = "annotation"
|
|
|
|
e.target.parentElement.insertAdjacentElement('afterend', annotationDiv)
|
2023-09-09 15:19:11 +02:00
|
|
|
}
|
|
|
|
}
|
2022-06-30 21:32:56 +01:00
|
|
|
}
|