From 9719692512325b5f88de666281ba286343408010 Mon Sep 17 00:00:00 2001 From: Alex Shpak Date: Sun, 12 Apr 2020 20:50:03 +0200 Subject: Introduce serviceWorker, disabled by default --- assets/search.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'assets/search.js') diff --git a/assets/search.js b/assets/search.js index d6ae18b..0393d2c 100644 --- a/assets/search.js +++ b/assets/search.js @@ -12,20 +12,27 @@ document.addEventListener('keypress', focusSearchFieldOnKeyPress); - function focusSearchFieldOnKeyPress(e) { + /** + * @param {Event} event + */ + function focusSearchFieldOnKeyPress(event) { if (input === document.activeElement) { return; } - const characterPressed = String.fromCharCode(e.charCode); + const characterPressed = String.fromCharCode(event.charCode); if (!isHotkey(characterPressed)) { return; } input.focus(); - e.preventDefault(); + event.preventDefault(); } + /** + * @param {String} character + * @returns {Boolean} + */ function isHotkey(character) { const dataHotkeys = input.getAttribute('data-hotkeys') || ''; return dataHotkeys.indexOf(character) >= 0; @@ -63,6 +70,10 @@ }); } + /** + * @param {String} src + * @param {Function} callback + */ function loadScript(src, callback) { const script = document.createElement('script'); script.defer = true; -- cgit v1.2.3