Skip to content

Commit

Permalink
small refactor for pagefind on focus
Browse files Browse the repository at this point in the history
  • Loading branch information
Jieiku committed Aug 6, 2024
1 parent 6c19503 commit 4e1c5e0
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 18 deletions.
2 changes: 1 addition & 1 deletion static/js/pagefind-entry.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version":"1.1.0","languages":{"en":{"hash":"en_9a3bf9aefa","wasm":"en","page_count":15},"fr":{"hash":"fr_6374b78f36","wasm":"fr","page_count":10},"es":{"hash":"es_f4a7172a38","wasm":"es","page_count":2}}}
{"version":"1.1.0","languages":{"es":{"hash":"es_7556d6166a","wasm":"es","page_count":2},"en":{"hash":"en_7dfb4d1ea2","wasm":"en","page_count":15},"fr":{"hash":"fr_51a156c78d","wasm":"fr","page_count":10}}}
25 changes: 10 additions & 15 deletions static/js/pagefind.search.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,32 +54,27 @@ window.onload = function () {

var suggestions = document.getElementById("suggestions");
var searchinput = document.getElementById("searchinput");
document.addEventListener("keydown", inputFocus);
document.addEventListener("click", function (event) { suggestions.contains(event.target) || suggestions.classList.add("d-none") });

document.getElementById('searchinput').onfocus = function() {
if (!loaded) {
lazyLoad();
loaded = true;
document.body.contains(document.goSearch) && (document.goSearch.onsubmit = function() { return goSearchNow() })
}
document.getElementById('searchinput').onfocus = '';
}

var lang = document.documentElement.getAttribute("lang");
var langOnly = lang.substring(0, 2);
var baseUrl = document.querySelector("meta[name='base']").getAttribute("content");
if (baseUrl.slice(-1) == "/") {
baseUrl = baseUrl.slice(0, -1);
}
options({
options({//pagefind options
basePath: baseUrl + '/js/'
});

var index;
searchinput.addEventListener('input', show_results, true);
suggestions.addEventListener('click', accept_suggestion, true);

document.addEventListener("keydown", inputFocus);
document.addEventListener("click", function (event) { suggestions.contains(event.target) || suggestions.classList.add("d-none") });
document.getElementById('searchinput').onfocus = function() {
if (!loaded) {
lazyLoad();
loaded = true;
}
document.getElementById('searchinput').onfocus = '';
}
async function lazyLoad() {
await init();
}
Expand Down
2 changes: 1 addition & 1 deletion static/sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Pwa {
const Version = new URL(location).searchParams.get("v");
this.CACHE_VERSION = Version;
//this.BASE_CACHE_FILES=['/js/theme.min.js','/js/theme_light.min.js','/abridge.css','/js/abridge.min.js','/','/404.html','/offline/','/manifest.json'];
this.BASE_CACHE_FILES = ['/404.html','/_headers','/abridge.css','/android-chrome-192x192.png','/android-chrome-512x512.png','/apple-touch-icon.png','/atom.xml','/banner.png','/browserconfig.xml','/demo.html','/elasticlunr.min.js','/favicon-16x16.png','/favicon-32x32.png','/favicon.ico','/favicon.svg','/','/katex.min.css','/m1024.png','/m128.png','/m192.png','/m384.png','/m48.png','/m512.png','/m72.png','/m96.png','/manifest.json','/manifest.min.json','/mstile-150x150.png','/nojs.css','/package.json','/robots.txt','/safari-pinned-tab.svg','/search_index.en.json','/search_index.es.json','/search_index.fr.json','/search_index.pt.json','/sitemap.xml','/tinysearch_engine.d.ts','/tinysearch_engine.js','/tinysearch_engine_bg.wasm','/tinysearch_engine_bg.wasm.d.ts','/about/','/archive/','/blog/','/contact/','/es/atom.xml','/es/','/fonts/KaTeX_AMS-Regular.woff2','/fonts/KaTeX_Caligraphic-Bold.woff2','/fonts/KaTeX_Caligraphic-Regular.woff2','/fonts/KaTeX_Fraktur-Bold.woff2','/fonts/KaTeX_Fraktur-Regular.woff2','/fonts/KaTeX_Main-Bold.woff2','/fonts/KaTeX_Main-BoldItalic.woff2','/fonts/KaTeX_Main-Italic.woff2','/fonts/KaTeX_Main-Regular.woff2','/fonts/KaTeX_Math-BoldItalic.woff2','/fonts/KaTeX_Math-Italic.woff2','/fonts/KaTeX_SansSerif-Bold.woff2','/fonts/KaTeX_SansSerif-Italic.woff2','/fonts/KaTeX_SansSerif-Regular.woff2','/fonts/KaTeX_Script-Regular.woff2','/fonts/KaTeX_Size1-Regular.woff2','/fonts/KaTeX_Size2-Regular.woff2','/fonts/KaTeX_Size3-Regular.woff2','/fonts/KaTeX_Size4-Regular.woff2','/fonts/KaTeX_Typewriter-Regular.woff2','/fonts/Roboto-Bold.woff2','/fonts/Roboto-Italic.woff2','/fonts/Roboto-Mono-Italic.woff2','/fonts/Roboto-Mono.woff2','/fonts/Roboto.woff2','/fr/atom.xml','/fr/','/images/ferris-gesture.svg','/images/ferris.svg','/js/abridge.min.js','/js/abridge_nopwa.min.js','/js/abridge_nosearch.min.js','/js/abridge_nosearch_nopwa.min.js','/js/codecopy.js','/js/elasticlunr.min.js','/js/email.js','/js/katex-auto-render.min.js','/js/katex.min.js','/js/katexbundle.min.js','/js/katexbundle.min.old.js','/js/katexoptions.js','/js/lunr.da.js','/js/lunr.da.min.js','/js/lunr.de.js','/js/lunr.de.min.js','/js/lunr.du.js','/js/lunr.du.min.js','/js/lunr.es.js','/js/lunr.es.min.js','/js/lunr.fi.js','/js/lunr.fi.min.js','/js/lunr.fr.js','/js/lunr.fr.min.js','/js/lunr.hu.js','/js/lunr.hu.min.js','/js/lunr.it.js','/js/lunr.it.min.js','/js/lunr.jp.js','/js/lunr.jp.min.js','/js/lunr.no.js','/js/lunr.no.min.js','/js/lunr.pt.js','/js/lunr.pt.min.js','/js/lunr.ro.js','/js/lunr.ro.min.js','/js/lunr.ru.js','/js/lunr.ru.min.js','/js/lunr.stemmer.support.js','/js/lunr.stemmer.support.min.js','/js/lunr.sv.js','/js/lunr.sv.min.js','/js/lunr.tr.js','/js/lunr.tr.min.js','/js/lunr.zh.js','/js/lunr.zh.min.js','/js/mathtex-script-type.min.js','/js/pagefind-entry.json','/js/pagefind-highlight.js','/js/pagefind-modular-ui.css','/js/pagefind-modular-ui.js','/js/pagefind-ui.css','/js/pagefind-ui.js','/js/pagefind.en_9a3bf9aefa.pf_meta','/js/pagefind.es_f4a7172a38.pf_meta','/js/pagefind.fr_6374b78f36.pf_meta','/js/pagefind.index.cjs','/js/pagefind.js','/js/pagefind.search.js','/js/prestyle.js','/js/search.js','/js/search_elasticlunr.min.js','/js/search_elasticlunr_jindex.min.js','/js/search_tinysearch.min.js','/js/searchjava.js','/js/searchjavaugly.js','/js/sw_load.js','/js/sw_load.min.js','/js/theme.js','/js/theme.min.js','/js/theme_button.js','/js/theme_light.js','/js/theme_light.min.js','/js/tinysearch.js','/js/wasm.en.pagefind','/js/wasm.es.pagefind','/js/wasm.fr.pagefind','/js/wasm.unknown.pagefind','/offline/','/overview-abridge/','/overview-abridge/lighthouse.png','/overview-code-blocks/','/overview-images/corro.svg','/overview-images/ferris-gesture.png','/overview-images/ferris-gesture.svg','/overview-images/ferris-happy.svg','/overview-images/ferris.svg','/overview-images/','/overview-markdown-and-style/','/overview-math/','/overview-rich-content/','/overview-rich-content/over9000-400.avif','/overview-rich-content/over9000-640.avif','/overview-rich-content/over9000-640.webp','/overview-rich-content/over9000-960.avif','/overview-rich-content/over9000.mp3','/overview-rich-content/over9000.ogg','/overview-rich-content/over9000_av1.mp4','/overview-rich-content/over9000_vp9.webm','/overview-showdata/','/privacy/','/pt/','/tags/','/es/archive/','/es/blog/','/es/tags/','/fr/about/','/fr/archive/','/fr/blog/','/fr/contact/','/fr/offline/','/fr/overview-code-blocks/','/fr/overview-images/corro.svg','/fr/overview-images/ferris-gesture.png','/fr/overview-images/ferris-gesture.svg','/fr/overview-images/ferris-happy.svg','/fr/overview-images/ferris.svg','/fr/overview-images/','/fr/overview-markdown-and-style/','/fr/overview-math/','/fr/overview-rich-content/','/fr/overview-rich-content/over9000-400.avif','/fr/overview-rich-content/over9000-640.avif','/fr/overview-rich-content/over9000-640.webp','/fr/overview-rich-content/over9000-960.avif','/fr/overview-rich-content/over9000.mp3','/fr/overview-rich-content/over9000.ogg','/fr/overview-rich-content/over9000_av1.mp4','/fr/overview-rich-content/over9000_vp9.webm','/fr/overview-showdata/','/fr/privacy/','/fr/tags/','/js/fragment/en_13419a6.pf_fragment','/js/fragment/en_2ac01ba.pf_fragment','/js/fragment/en_2d5f183.pf_fragment','/js/fragment/en_2e4fad3.pf_fragment','/js/fragment/en_5f16a37.pf_fragment','/js/fragment/en_7897259.pf_fragment','/js/fragment/en_8caec6c.pf_fragment','/js/fragment/en_8edb393.pf_fragment','/js/fragment/en_8f525ab.pf_fragment','/js/fragment/en_addec89.pf_fragment','/js/fragment/en_c821f77.pf_fragment','/js/fragment/en_eb58f87.pf_fragment','/js/fragment/en_f4821f1.pf_fragment','/js/fragment/en_f93465d.pf_fragment','/js/fragment/en_f96e4a8.pf_fragment','/js/fragment/es_3ec1224.pf_fragment','/js/fragment/es_591c668.pf_fragment','/js/fragment/fr_286d56a.pf_fragment','/js/fragment/fr_689c2d9.pf_fragment','/js/fragment/fr_7263c1f.pf_fragment','/js/fragment/fr_8418aed.pf_fragment','/js/fragment/fr_84444d8.pf_fragment','/js/fragment/fr_85d6df3.pf_fragment','/js/fragment/fr_8c1bc26.pf_fragment','/js/fragment/fr_8d4726b.pf_fragment','/js/fragment/fr_ba21b65.pf_fragment','/js/fragment/fr_f98357a.pf_fragment','/js/index/en_43498ed.pf_index','/js/index/es_29a1d7e.pf_index','/js/index/fr_b717c97.pf_index','/overview-images/img/ferris-gesture.svg','/overview-images/img/ferris.svg','/page/1/','/page/2/','/page/3/','/page/4/','/tags/audio/atom.xml','/tags/audio/','/tags/config/atom.xml','/tags/config/','/tags/data/atom.xml','/tags/data/','/tags/features/atom.xml','/tags/features/','/tags/images/atom.xml','/tags/images/','/tags/markdown/atom.xml','/tags/markdown/','/tags/mathematics/atom.xml','/tags/mathematics/','/tags/shortcodes/atom.xml','/tags/shortcodes/','/tags/video/atom.xml','/tags/video/','/video-streaming-sites/overview-embed-streamable/','/video-streaming-sites/overview-embed-vimeo/','/video-streaming-sites/overview-embed-youtube/','/blog/page/1/','/es/page/1/','/es/tags/features/atom.xml','/es/tags/features/','/es/tags/shortcodes/atom.xml','/es/tags/shortcodes/','/es/tags/video/atom.xml','/es/tags/video/','/es/video-streaming-sites/overview-embed-streamable/','/fr/overview-images/img/ferris-gesture.svg','/fr/overview-images/img/ferris.svg','/fr/page/1/','/fr/page/2/','/fr/page/3/','/fr/tags/audio/atom.xml','/fr/tags/audio/','/fr/tags/data/atom.xml','/fr/tags/data/','/fr/tags/features/atom.xml','/fr/tags/features/','/fr/tags/images/atom.xml','/fr/tags/images/','/fr/tags/markdown/atom.xml','/fr/tags/markdown/','/fr/tags/mathematics/atom.xml','/fr/tags/mathematics/','/fr/tags/shortcodes/atom.xml','/fr/tags/shortcodes/','/fr/tags/video/atom.xml','/fr/tags/video/','/fr/video-streaming-sites/overview-embed-streamable/','/fr/video-streaming-sites/overview-embed-vimeo/','/fr/video-streaming-sites/overview-embed-youtube/','/pt/page/1/','/es/blog/page/1/','/fr/blog/page/1/'];
this.BASE_CACHE_FILES = ['/404.html','/_headers','/abridge.css','/android-chrome-192x192.png','/android-chrome-512x512.png','/apple-touch-icon.png','/atom.xml','/banner.png','/browserconfig.xml','/demo.html','/elasticlunr.min.js','/favicon-16x16.png','/favicon-32x32.png','/favicon.ico','/favicon.svg','/','/katex.min.css','/m1024.png','/m128.png','/m192.png','/m384.png','/m48.png','/m512.png','/m72.png','/m96.png','/manifest.json','/manifest.min.json','/mstile-150x150.png','/nojs.css','/package.json','/robots.txt','/safari-pinned-tab.svg','/search_index.en.json','/search_index.es.json','/search_index.fr.json','/search_index.pt.json','/sitemap.xml','/tinysearch_engine.d.ts','/tinysearch_engine.js','/tinysearch_engine_bg.wasm','/tinysearch_engine_bg.wasm.d.ts','/about/','/archive/','/blog/','/contact/','/es/atom.xml','/es/','/fonts/KaTeX_AMS-Regular.woff2','/fonts/KaTeX_Caligraphic-Bold.woff2','/fonts/KaTeX_Caligraphic-Regular.woff2','/fonts/KaTeX_Fraktur-Bold.woff2','/fonts/KaTeX_Fraktur-Regular.woff2','/fonts/KaTeX_Main-Bold.woff2','/fonts/KaTeX_Main-BoldItalic.woff2','/fonts/KaTeX_Main-Italic.woff2','/fonts/KaTeX_Main-Regular.woff2','/fonts/KaTeX_Math-BoldItalic.woff2','/fonts/KaTeX_Math-Italic.woff2','/fonts/KaTeX_SansSerif-Bold.woff2','/fonts/KaTeX_SansSerif-Italic.woff2','/fonts/KaTeX_SansSerif-Regular.woff2','/fonts/KaTeX_Script-Regular.woff2','/fonts/KaTeX_Size1-Regular.woff2','/fonts/KaTeX_Size2-Regular.woff2','/fonts/KaTeX_Size3-Regular.woff2','/fonts/KaTeX_Size4-Regular.woff2','/fonts/KaTeX_Typewriter-Regular.woff2','/fonts/Roboto-Bold.woff2','/fonts/Roboto-Italic.woff2','/fonts/Roboto-Mono-Italic.woff2','/fonts/Roboto-Mono.woff2','/fonts/Roboto.woff2','/fr/atom.xml','/fr/','/images/ferris-gesture.svg','/images/ferris.svg','/js/abridge.min.js','/js/abridge_nopwa.min.js','/js/abridge_nosearch.min.js','/js/abridge_nosearch_nopwa.min.js','/js/codecopy.js','/js/elasticlunr.min.js','/js/email.js','/js/katex-auto-render.min.js','/js/katex.min.js','/js/katexbundle.min.js','/js/katexbundle.min.old.js','/js/katexoptions.js','/js/lunr.da.js','/js/lunr.da.min.js','/js/lunr.de.js','/js/lunr.de.min.js','/js/lunr.du.js','/js/lunr.du.min.js','/js/lunr.es.js','/js/lunr.es.min.js','/js/lunr.fi.js','/js/lunr.fi.min.js','/js/lunr.fr.js','/js/lunr.fr.min.js','/js/lunr.hu.js','/js/lunr.hu.min.js','/js/lunr.it.js','/js/lunr.it.min.js','/js/lunr.jp.js','/js/lunr.jp.min.js','/js/lunr.no.js','/js/lunr.no.min.js','/js/lunr.pt.js','/js/lunr.pt.min.js','/js/lunr.ro.js','/js/lunr.ro.min.js','/js/lunr.ru.js','/js/lunr.ru.min.js','/js/lunr.stemmer.support.js','/js/lunr.stemmer.support.min.js','/js/lunr.sv.js','/js/lunr.sv.min.js','/js/lunr.tr.js','/js/lunr.tr.min.js','/js/lunr.zh.js','/js/lunr.zh.min.js','/js/mathtex-script-type.min.js','/js/pagefind-entry.json','/js/pagefind-highlight.js','/js/pagefind-modular-ui.css','/js/pagefind-modular-ui.js','/js/pagefind-ui.css','/js/pagefind-ui.js','/js/pagefind.en_7dfb4d1ea2.pf_meta','/js/pagefind.es_7556d6166a.pf_meta','/js/pagefind.fr_51a156c78d.pf_meta','/js/pagefind.index.cjs','/js/pagefind.js','/js/pagefind.search.js','/js/prestyle.js','/js/search.js','/js/search_elasticlunr.min.js','/js/search_elasticlunr_jindex.min.js','/js/search_tinysearch.min.js','/js/searchjava.js','/js/searchjavaugly.js','/js/sw_load.js','/js/sw_load.min.js','/js/theme.js','/js/theme.min.js','/js/theme_button.js','/js/theme_light.js','/js/theme_light.min.js','/js/tinysearch.js','/js/wasm.en.pagefind','/js/wasm.es.pagefind','/js/wasm.fr.pagefind','/js/wasm.unknown.pagefind','/offline/','/overview-abridge/','/overview-abridge/lighthouse.png','/overview-code-blocks/','/overview-images/corro.svg','/overview-images/ferris-gesture.png','/overview-images/ferris-gesture.svg','/overview-images/ferris-happy.svg','/overview-images/ferris.svg','/overview-images/','/overview-markdown-and-style/','/overview-math/','/overview-rich-content/','/overview-rich-content/over9000-400.avif','/overview-rich-content/over9000-640.avif','/overview-rich-content/over9000-640.webp','/overview-rich-content/over9000-960.avif','/overview-rich-content/over9000.mp3','/overview-rich-content/over9000.ogg','/overview-rich-content/over9000_av1.mp4','/overview-rich-content/over9000_vp9.webm','/overview-showdata/','/privacy/','/pt/','/tags/','/es/archive/','/es/blog/','/es/tags/','/fr/about/','/fr/archive/','/fr/blog/','/fr/contact/','/fr/offline/','/fr/overview-code-blocks/','/fr/overview-images/corro.svg','/fr/overview-images/ferris-gesture.png','/fr/overview-images/ferris-gesture.svg','/fr/overview-images/ferris-happy.svg','/fr/overview-images/ferris.svg','/fr/overview-images/','/fr/overview-markdown-and-style/','/fr/overview-math/','/fr/overview-rich-content/','/fr/overview-rich-content/over9000-400.avif','/fr/overview-rich-content/over9000-640.avif','/fr/overview-rich-content/over9000-640.webp','/fr/overview-rich-content/over9000-960.avif','/fr/overview-rich-content/over9000.mp3','/fr/overview-rich-content/over9000.ogg','/fr/overview-rich-content/over9000_av1.mp4','/fr/overview-rich-content/over9000_vp9.webm','/fr/overview-showdata/','/fr/privacy/','/fr/tags/','/js/fragment/en_1ee6ca2.pf_fragment','/js/fragment/en_4162c19.pf_fragment','/js/fragment/en_539c351.pf_fragment','/js/fragment/en_53cb76b.pf_fragment','/js/fragment/en_58ea47d.pf_fragment','/js/fragment/en_5ad7d88.pf_fragment','/js/fragment/en_607247b.pf_fragment','/js/fragment/en_76e147a.pf_fragment','/js/fragment/en_85c365d.pf_fragment','/js/fragment/en_8ddff26.pf_fragment','/js/fragment/en_b37b30a.pf_fragment','/js/fragment/en_d3f49b7.pf_fragment','/js/fragment/en_e58b72c.pf_fragment','/js/fragment/en_eec2257.pf_fragment','/js/fragment/en_f847339.pf_fragment','/js/fragment/es_82b6e6e.pf_fragment','/js/fragment/es_8da16fd.pf_fragment','/js/fragment/fr_1e151a9.pf_fragment','/js/fragment/fr_4a39af5.pf_fragment','/js/fragment/fr_77f673c.pf_fragment','/js/fragment/fr_98dac9a.pf_fragment','/js/fragment/fr_a1cd89a.pf_fragment','/js/fragment/fr_b77cf83.pf_fragment','/js/fragment/fr_c2595bc.pf_fragment','/js/fragment/fr_db31d0d.pf_fragment','/js/fragment/fr_e048281.pf_fragment','/js/fragment/fr_f05ab69.pf_fragment','/js/index/en_8b2ae16.pf_index','/js/index/es_29a1d7e.pf_index','/js/index/fr_b717c97.pf_index','/overview-images/img/ferris-gesture.svg','/overview-images/img/ferris.svg','/page/1/','/page/2/','/page/3/','/page/4/','/tags/audio/atom.xml','/tags/audio/','/tags/config/atom.xml','/tags/config/','/tags/data/atom.xml','/tags/data/','/tags/features/atom.xml','/tags/features/','/tags/images/atom.xml','/tags/images/','/tags/markdown/atom.xml','/tags/markdown/','/tags/mathematics/atom.xml','/tags/mathematics/','/tags/shortcodes/atom.xml','/tags/shortcodes/','/tags/video/atom.xml','/tags/video/','/video-streaming-sites/overview-embed-streamable/','/video-streaming-sites/overview-embed-vimeo/','/video-streaming-sites/overview-embed-youtube/','/blog/page/1/','/es/page/1/','/es/tags/features/atom.xml','/es/tags/features/','/es/tags/shortcodes/atom.xml','/es/tags/shortcodes/','/es/tags/video/atom.xml','/es/tags/video/','/es/video-streaming-sites/overview-embed-streamable/','/fr/overview-images/img/ferris-gesture.svg','/fr/overview-images/img/ferris.svg','/fr/page/1/','/fr/page/2/','/fr/page/3/','/fr/tags/audio/atom.xml','/fr/tags/audio/','/fr/tags/data/atom.xml','/fr/tags/data/','/fr/tags/features/atom.xml','/fr/tags/features/','/fr/tags/images/atom.xml','/fr/tags/images/','/fr/tags/markdown/atom.xml','/fr/tags/markdown/','/fr/tags/mathematics/atom.xml','/fr/tags/mathematics/','/fr/tags/shortcodes/atom.xml','/fr/tags/shortcodes/','/fr/tags/video/atom.xml','/fr/tags/video/','/fr/video-streaming-sites/overview-embed-streamable/','/fr/video-streaming-sites/overview-embed-vimeo/','/fr/video-streaming-sites/overview-embed-youtube/','/pt/page/1/','/es/blog/page/1/','/fr/blog/page/1/'];
this.host = `${self.location.protocol}//${self.location.host}`;
console.info(`Host: ${this.host}`);
this.OFFLINE_PAGE = '/offline/';
Expand Down
Loading

0 comments on commit 4e1c5e0

Please sign in to comment.