Files
i2p.i2p/apps/i2psnark/resources/js/search.js

48 lines
1.0 KiB
JavaScript
Raw Normal View History

/* @license http://www.gnu.org/licenses/gpl-2.0.html GPL-2.0 */
/* see also licenses/LICENSE-GPLv2.txt */
/**
* Search form helpers
*
* @since 0.9.58
*/
function initSearch()
{
var sch = document.getElementById("search");
if (sch != null) {
var box = document.getElementById("searchbox");
2023-01-21 16:38:10 -05:00
var cxl = document.getElementById("searchcancel");
cxl.addEventListener("click", function(event) {
if (box.value !== "") {
box.value = "";
requestAjax2(-1);
}
2023-01-21 16:38:10 -05:00
cxl.classList.add("disabled");
event.preventDefault();
});
box.addEventListener("input", function(event) {
2023-01-21 16:38:10 -05:00
if (box.value !== "") {
cxl.classList.remove("disabled");
} else {
cxl.classList.add("disabled");
}
requestAjax2(-1);
});
2023-01-21 16:38:10 -05:00
if (box.value !== "") {
cxl.classList.remove("disabled");
} else {
cxl.classList.add("disabled");
}
// so we don't get the link popup
cxl.removeAttribute("href");
}
}
document.addEventListener("DOMContentLoaded", function() {
initSearch();
}, true);
/* @license-end */