lbry.tech/app/dist/scripts/api.js

43 lines
1,004 B
JavaScript
Raw Normal View History

2018-10-02 00:11:20 +02:00
/* global Jets */ "use strict";
2018-08-02 00:18:39 +02:00
2018-10-02 00:11:20 +02:00
// Initiate search functionality
2018-08-02 00:18:39 +02:00
let jets = new Jets({
contentTag: "#toc",
searchTag: "#input-search"
2018-08-02 00:18:39 +02:00
});
2018-10-02 00:11:20 +02:00
// Reset search on page load
document.getElementById("input-search").value = "";
2018-08-02 00:18:39 +02:00
2018-10-02 00:11:20 +02:00
// Activate search
document.getElementById("input-search").addEventListener("keyup", () => {
if (document.getElementById("input-search").value)
document.querySelector(".api__toc__search__clear").classList.add("active");
else
document.querySelector(".api__toc__search__clear").classList.remove("active");
2018-08-02 00:18:39 +02:00
});
2018-10-02 00:11:20 +02:00
// Cancel search
document.querySelector(".api__toc__search__clear").addEventListener("click", () => {
document.getElementById("input-search").value = "";
document.querySelector(".api__toc__search__clear").classList.remove("active");
2018-08-02 00:18:39 +02:00
jets.destroy();
reinitJets();
});
// H E L P E R
function reinitJets() {
jets = new Jets({
contentTag: "#toc",
searchTag: "#input-search"
2018-08-02 00:18:39 +02:00
});
2018-10-02 00:11:20 +02:00
document.getElementById("input-search").focus();
2018-08-02 00:18:39 +02:00
}