aboutsummaryrefslogtreecommitdiff
path: root/assets
diff options
context:
space:
mode:
Diffstat (limited to 'assets')
-rw-r--r--assets/search.js17
-rw-r--r--assets/sw-register.js6
2 files changed, 20 insertions, 3 deletions
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;
diff --git a/assets/sw-register.js b/assets/sw-register.js
new file mode 100644
index 0000000..583532c
--- /dev/null
+++ b/assets/sw-register.js
@@ -0,0 +1,6 @@
+if (navigator.serviceWorker) {
+ navigator.serviceWorker.register(
+ "{{ "/sw.js" | relURL }}",
+ { scope: "{{ "/" | relURL }}" }
+ );
+}