Eliminate jQuery in index template microscript

This commit is contained in:
Xaekai 2022-02-09 13:42:47 -08:00
parent 0226d73272
commit ef0a04ddcb
1 changed files with 9 additions and 2 deletions

View File

@ -21,8 +21,15 @@ block content
append footer
script(type="text/javascript").
$("#channelname").keydown(function (ev) {
const entrance = document.querySelector('#channelname');
entrance.addEventListener('keydown', function (ev) {
if (ev.keyCode === 13) {
location.href = "/#{channelPath}/" + $("#channelname").val();
const channel = `/${CHANNELPATH}/${entrance.value}`;
if (ev.shiftKey || ev.ctrlKey) {
window.open(channel, '_blank');
entrance.value = '';
} else {
location.href = channel;
}
}
});