From 0f9d778a27863641afdf33194880d59f26727010 Mon Sep 17 00:00:00 2001 From: Xaekai Date: Wed, 9 Feb 2022 13:42:47 -0800 Subject: [PATCH] Eliminate jQuery in index template microscript --- templates/index.pug | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/templates/index.pug b/templates/index.pug index 883cb8b4..bee17a29 100644 --- a/templates/index.pug +++ b/templates/index.pug @@ -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; + } } });