You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function searchTunes(query) {
|
|
|
|
const resultsDiv = document.getElementById("AlgoliaResults");
|
|
|
|
|
|
|
|
resultsDiv.innerHTML = "";
|
|
|
|
|
|
|
|
tuneIndex.search(query).then(({ hits }) => {
|
|
|
|
if (hits.length > 0) {
|
|
|
|
hits.forEach(hit => {
|
|
|
|
const tuneDiv = document.createElement("div");
|
|
|
|
tuneDiv.className = "AlgoliaTuneHit";
|
|
|
|
tuneDiv.innerHTML = `
|
|
|
|
<h2><a href="/tune/${hit.objectID}">${hit.title}</a></h2>
|
|
|
|
<div class="TuneTimeSignature">time signature: ${hit.time_sig}</div>
|
|
|
|
<div class="TuneKeySignature">key signature: ${hit.key_sig}</div>
|
|
|
|
<div id="VerovioContainer-${hit.objectID}"></div>
|
|
|
|
<script>RenderVerovio("VerovioContainer-${hit.objectID}", '${hit.objectID}');</script>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
`;
|
|
|
|
resultsDiv.appendChild(tuneDiv);
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
resultsDiv.innerHTML = "<p>No tunes found. Try a different search!</p>";
|
|
|
|
}
|
|
|
|
}).catch(err => {
|
|
|
|
console.error('Error searching Algolia:', err);
|
|
|
|
resultsDiv.innerHTML = "<p>An error occurred. Please try again later.</p>";
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
|