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

43 lines
1,004 B
JavaScript
Raw Normal View History

2018-10-01 17:11:20 -05:00
/* global Jets */ "use strict";
2018-08-01 17:18:39 -05:00
2018-10-01 17:11:20 -05:00
// Initiate search functionality
2018-08-01 17:18:39 -05:00
let jets = new Jets({
contentTag: "#toc",
searchTag: "#input-search"
2018-08-01 17:18:39 -05:00
});
2018-10-01 17:11:20 -05:00
// Reset search on page load
document.getElementById("input-search").value = "";
2018-08-01 17:18:39 -05:00
2018-10-01 17:11:20 -05: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-01 17:18:39 -05:00
});
2018-10-01 17:11:20 -05: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-01 17:18:39 -05:00
jets.destroy();
reinitJets();
});
// H E L P E R
function reinitJets() {
jets = new Jets({
contentTag: "#toc",
searchTag: "#input-search"
2018-08-01 17:18:39 -05:00
});
2018-10-01 17:11:20 -05:00
document.getElementById("input-search").focus();
2018-08-01 17:18:39 -05:00
}