diff --git a/config.toml b/config.toml index 2670512..6c85a74 100644 --- a/config.toml +++ b/config.toml @@ -144,7 +144,7 @@ uglyurls = false # if set to true then links are generated with the full path. e integrity = true # increases site security, should normally be true. (setting to false is useful during js development) js_bundle = true # multiple javascript files combined into a single file (setting to false is useful during js development) -js_copycode = true # The copy button on code blocks that allows you to copy them to the clipboard. +js_copycode = false # The copy button on code blocks that allows you to copy them to the clipboard. js_email_encode = true # obfuscates email address in footer js_prestyle = true # used to preload: FontAwesome, Katex, external Google Fonts js_switcher = false # The button that allows manually changing between light/dark mode. diff --git a/package_abridge.js b/package_abridge.js index 70cb40c..197e10b 100644 --- a/package_abridge.js +++ b/package_abridge.js @@ -21,9 +21,6 @@ const search_library = data.extra.search_library; const index_format = data.search.index_format; const uglyurls = data.extra.uglyurls; const js_bundle = data.extra.js_bundle; -const offline = data.extra.offline; -const online_url = data.extra.online_url; -const online_indexformat = data.extra.online_indexformat; const pwa = data.extra.pwa; const pwa_VER = data.extra.pwa_VER; const pwa_NORM_TTL = data.extra.pwa_NORM_TTL; @@ -36,7 +33,19 @@ const pwa_BASE_CACHE_FILES = data.extra.pwa_BASE_CACHE_FILES; // This is used to pass arguments to zola via npm, for example: // npm run abridge -- "--base-url https://abridge.pages.dev" -const args = process.argv[2] ? ' '+process.argv[2] : ''; +var args = process.argv[2] ? ' '+process.argv[2] : ''; + +// check if abridge is used directly or as a theme. +bpath = ''; +if (fs.existsSync('./themes')) { + bpath = 'themes/abridge/'; +} +// cleanup pagefind files from old builds. +_rmRegex(path.join(bpath, "static/js/"),/^wasm.*pagefind$/); +_rmRegex(path.join(bpath, "static/js/"),/^pagefind.*pf_meta$/); +_rmRegex(path.join(bpath, "static/js/"),/^pagefind-entry.*json$/); +_rmRecursive(path.join(bpath, "static/js/index")); +_rmRecursive(path.join(bpath, "static/js/fragment")); async function execWrapper(cmd) { const { stdout, stderr } = await execPromise(cmd); @@ -51,18 +60,18 @@ async function execWrapper(cmd) { async function abridge() { await sync(); const { replaceInFileSync } = await import('replace-in-file'); - if (offline === false) { - if (typeof online_url !== 'undefined' && typeof online_indexformat !== 'undefined') { - replaceInFileSync({files: 'config.toml', from: /base_url.*=.*/g, to: "base_url = \""+online_url+"\""}); - replaceInFileSync({files: 'config.toml', from: /index_format.*=.*/g, to: "index_format = \""+online_indexformat+"\""}); - } - } else if (offline === true) { - if (typeof online_url !== 'undefined' && typeof online_indexformat !== 'undefined') { - replaceInFileSync({files: 'config.toml', from: /base_url.*=.*/g, to: "base_url = \""+__dirname+"\/public\""}); - replaceInFileSync({files: 'config.toml', from: /index_format.*=.*/g, to: "index_format = \"elasticlunr_javascript\""}); - } else { - throw new Error('ERROR: offline = true requires that online_url and online_indexformat are set in config.toml, so that the base_url and index_format can be restored if offline is later set to false.'); - } + // set index_format for chosen search_library accordingly. + if (search_library === 'offline') { + replaceInFileSync({files: 'config.toml', from: /index_format.*=.*/g, to: "index_format = \"elasticlunr_javascript\""}); + args = args + " -u \""+__dirname+"\/public\""//set base_url to the path on disk for offline site. + } else if (search_library === 'elasticlunrjava') { + replaceInFileSync({files: 'config.toml', from: /index_format.*=.*/g, to: "index_format = \"elasticlunr_javascript\""}); + } else if (search_library === 'elasticlunr') { + replaceInFileSync({files: 'config.toml', from: /index_format.*=.*/g, to: "index_format = \"elasticlunr_json\""}); + } else if (search_library === 'pagefind') { + replaceInFileSync({files: 'config.toml', from: /index_format.*=.*/g, to: "index_format = \"fuse_json\""}); + } else if (search_library === 'tinysearch') { + replaceInFileSync({files: 'config.toml', from: /index_format.*=.*/g, to: "index_format = \"fuse_json\""}); } console.log('Zola Build to generate files for minification:'); @@ -76,59 +85,37 @@ async function abridge() { if (e.code != 'EEXIST') throw e; } - // check if abridge is used directly or as a theme. - bpath = ''; - if (fs.existsSync('./themes')) { - bpath = 'themes/abridge/'; - } - base_url = data.base_url; if (base_url.slice(-1) == "/") { base_url = base_url.slice(0, -1); } - if (search_library === 'elasticlunr') { - if (fs.existsSync('content/static/stork_toml.md')) { - replaceInFileSync({files: 'content/static/stork_toml.md', from: /draft.*=.*/g, to: "draft = true"}); - } - if (fs.existsSync('content/static/tinysearch_json.md')) { - replaceInFileSync({files: 'content/static/tinysearch_json.md', from: /draft.*=.*/g, to: "draft = true"}); - } - } else if (search_library === 'tinysearch') { - if (!fs.existsSync('content/static/tinysearch_json.md')) {// 'content/static/tinysearch_json.md' file is missing, copy from abridge theme. - fs.copyFileSync(bpath+'content/static/tinysearch_json.md', 'content/static/tinysearch_json.md',fs.constants.COPYFILE_EXCL); - } - if (fs.existsSync('content/static/stork_toml.md')) { - replaceInFileSync({files: 'content/static/stork_toml.md', from: /draft.*=.*/g, to: "draft = true"}); - } - if (fs.existsSync('content/static/tinysearch_json.md')) { - replaceInFileSync({files: 'content/static/tinysearch_json.md', from: /draft.*=.*/g, to: "draft = false"}); - } - // zola build && mkdir -p tmp && tinysearch --optimize --path tmp public/data_tinysearch/index.html && rsync -avz tmp/*.wasm static/ && rm -rf tmp - } else if (search_library === 'stork') { - - if (!fs.existsSync('content/static/stork_toml.md')) {// 'content/static/stork_toml.md' file is missing, copy from abridge theme. - fs.copyFileSync(bpath+'content/static/stork_toml.md', 'content/static/stork_toml.md',fs.constants.COPYFILE_EXCL); - } - if (fs.existsSync('content/static/stork_toml.md')) { - replaceInFileSync({files: 'content/static/stork_toml.md', from: /draft.*=.*/g, to: "draft = false"}); - } - if (fs.existsSync('content/static/tinysearch_json.md')) { - replaceInFileSync({files: 'content/static/tinysearch_json.md', from: /draft.*=.*/g, to: "draft = true"}); - } - // zola build && stork build --input public/data_stork/index.html --output static/stork.st - } else if (search_library === 'pagefind') { - if (fs.existsSync('content/static/stork_toml.md')) { - replaceInFileSync({files: 'content/static/stork_toml.md', from: /draft.*=.*/g, to: "draft = true"}); - } - if (fs.existsSync('content/static/tinysearch_json.md')) { - replaceInFileSync({files: 'content/static/tinysearch_json.md', from: /draft.*=.*/g, to: "draft = true"}); - } - - // Run the pagefind script to generate the index files. - // Has to happen at start otherwise, it happens too late asyncronously. - const createIndex = require('./static/js/pagefind.index.js'); // run the pagefind index.js script - await createIndex(); // makes program wait for pagefind build execution + if (search_library === 'pagefind') { + // Generate pagefind index at start, otherwise it happens too late asyncronously. + await createPagefindIndex(); // makes program wait for pagefind build execution + _rmRegex(path.join(bpath, "static/js/"),/^pagefind\.js$/);//pagefind temporary intermediate files + _rmRegex(path.join(bpath, "static/js/"),/^pagefind-.*\.js$/);//pagefind temporary intermediate files + _rmRegex(path.join(bpath, "static/js/"),/^pagefind-.*\.css$/);//pagefind temporary intermediate files + + // This line in pagefind is causing a problem for the PWA: + // var e = await (await fetch(this.basePath + "pagefind-entry.json?ts=" + Date.now())).json(); + // instead generate an epoch timestamp at build and add it to the filename. + var hash = Math.floor(new Date().getTime() / 1000); + fs.renameSync(path.join(bpath, "static/js/pagefind-entry.json"), path.join(bpath, "static/js/pagefind-entry-"+hash+".json")); + + // original: var e=await(await fetch(this.basePath+"pagefind-entry.json?ts="+Date.now())).json(); + // new: var e=await(await fetch(this.basePath+"pagefind-entry-1723268715.json")).json(); + // Tricky regex, so I split it into two replaceInFileSync() calls, pull requests welcome if you can improve this. + replaceInFileSync({files: path.join(bpath, "static/js/pagefind_search.js"), from: /pagefind-entry\.json\?ts=/g, to: "pagefind-entry-"+hash+"\.json"}); + replaceInFileSync({files: path.join(bpath, "static/js/pagefind_search.js"), from: /Date.now\(\)/g, to: "\"\""}); + + //copy to public so the files are included in the PWA cache list if necessary. + fs.copyFileSync(path.join(bpath, "static/js/pagefind-entry-"+hash+".json"), path.join(bpath, "public/js/pagefind-entry-"+hash+".json")) + _cpRegex(path.join(bpath, "static/js/"),path.join(bpath, "public/js/"),/^pagefind-entry\.json$/); + _cpRegex(path.join(bpath, "static/js/"),path.join(bpath, "public/js/"),/^pagefind.*pf_meta$/); + _cpRegex(path.join(bpath, "static/js/"),path.join(bpath, "public/js/"),/^wasm.*pagefind$/); + _cpRecursive(path.join(bpath, "static/js/index"),path.join(bpath, "public/js/index")); + _cpRecursive(path.join(bpath, "static/js/fragment"),path.join(bpath, "public/js/fragment")); } if (pwa) {// Update pwa settings, file list, and hashes. @@ -163,7 +150,7 @@ async function abridge() { if (e.code != 'EEXIST') throw e; } const path = './public/'; - cache = 'this.BASE_CACHE_FILES = ['; + cache = ''; files = fs.readdirSync(path, { recursive: true, withFileTypes: false }) .forEach( (file) => { @@ -173,6 +160,7 @@ async function abridge() { item = "/"+file.replace(/index\.html$/i,'');// strip index.html from path item = item.replace(/\\/g,'/');// replace backslash with forward slash for Windows item = item.replace(/^\/sw(\.min)?\.js/i,'');// dont cache service worker + item = item.replace(/^\/_headers/i,'');// dont cache the cloudflare _headers file // if formatted output is not empty line then append it to cache var if (item != '') {// skip empty lines @@ -181,11 +169,13 @@ async function abridge() { } } ); - cache = cache.slice(0, -1)+'];'// remove the last comma and close the array + cache = cache.slice(0, -1)// remove the last comma } else if (pwa_BASE_CACHE_FILES) { - cache = 'this.BASE_CACHE_FILES = ['+pwa_BASE_CACHE_FILES+'];'; + cache = pwa_BASE_CACHE_FILES; } + cache = cache.split(",").sort().join(",")//sort the cache list, this should help keep the commit history cleaner. + cache = 'this.BASE_CACHE_FILES = ['+cache+'];'; // update the BASE_CACHE_FILES variable in the sw.js service worker file results = replaceInFileSync({ files: 'static/sw.js', @@ -199,13 +189,13 @@ async function abridge() { } if (bpath === '') {// abridge used directly + _headersWASM(); // These are truely static js files, so they should only need to be updated by the abridge maintainer or contributors. minify(['static/js/theme.js']); minify(['static/js/theme_light.js']); // Something went wrong with minifying katexbundle, so commenting this out for now // minify(['static/js/katex.min.js','static/js/mathtex-script-type.min.js','static/js/katex-auto-render.min.js','static/js/katexoptions.js'],'static/js/katexbundle.min.js'); minify(['static/js/elasticlunr.min.js','static/js/search.js'],'static/js/search_elasticlunr.min.js'); - minify(['static/js/stork.js','static/js/stork_config.js'],'static/js/search_stork.min.js'); minify(['static/js/tinysearch.js'],'static/js/search_tinysearch.min.js'); minify(['static/js/prestyle.js','static/js/theme_button.js','static/js/email.js','static/js/codecopy.js','static/js/sw_load.js'],'static/js/abridge_nosearch.min.js'); minify(['static/js/prestyle.js','static/js/theme_button.js','static/js/email.js','static/js/codecopy.js'],'static/js/abridge_nosearch_nopwa.min.js'); @@ -233,10 +223,63 @@ async function abridge() { abridge_bundle = bundle(bpath,js_prestyle,js_switcher,js_email_encode,js_copycode,search_library,index_format,uglyurls,pwa); minify(abridge_bundle,'static/js/abridge.min.js'); + // cleanup + _rmRegex(path.join(bpath, "static/js/"),/^pagefind_search\.js$/);//pagefind intermediate file that is now in bundle. + console.log('Zola Build to generate new integrity hashes for the previously minified files:'); await execWrapper('zola build'+args); } +async function _headersWASM() { + // running WASM in the browser requires wasm-unsafe-eval if using Content-Security-Policy: + // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src#unsafe_webassembly_execution + // This function adds wasm-unsafe-eval to the pagefind and tinysearch demos without adding it to the elasticlunr demo. + const { replaceInFileSync } = await import('replace-in-file'); + if (search_library === 'pagefind') { + replaceInFileSync({files: 'static/_headers', from: /script-src 'self'/g, to: "script-src 'wasm-unsafe-eval' 'self'"}); + } else if (search_library === 'tinysearch') { + replaceInFileSync({files: 'static/_headers', from: /script-src 'self'/g, to: "script-src 'wasm-unsafe-eval' 'self'"}); + } else { + replaceInFileSync({files: 'static/_headers', from: /script-src 'wasm-unsafe-eval' 'self'/g, to: "script-src 'self'"}); + } +} + +function _rmRecursive(targetFiles) { + try { + fs.rmSync(targetFiles, { recursive: true }); + } catch (error) { + if (error.code !== 'ENOENT') {// Ignore if does not exist, that is the desired result. + console.error("An error occurred:", error); + } + } +} + +function _cpRecursive(source,dest) { + try { + fs.cpSync(source, dest, { recursive: true }); + } catch (error) { + console.error("An error occurred:", error); + } +} + +function _rmRegex(path,regex) { + try { + fs.readdirSync(path).filter(f => regex.test(f)).forEach(f => fs.unlinkSync(path + f)); + } catch (error) { + if (error.code !== 'ENOENT') {// Ignore if does not exist, that is the desired result. + console.error("An error occurred:", error); + } + } +} + +function _cpRegex(source,dest,regex) { + try { + fs.readdirSync(source).filter(f => regex.test(f)).forEach(f => fs.copyFileSync(source + f, dest + f)); + } catch (error) { + console.error("An error occurred:", error); + } +} + function bundle(bpath,js_prestyle,js_switcher,js_email_encode,js_copycode,search_library,index_format,uglyurls,pwa) { minify_files = []; @@ -253,25 +296,21 @@ function bundle(bpath,js_prestyle,js_switcher,js_email_encode,js_copycode,search minify_files.push(bpath+'static/js/codecopy.js'); } if (search_library) { - if ((search_library === 'elasticlunr' && offline === true) || (search_library === 'elasticlunr' && index_format === 'elasticlunr_javascript' && uglyurls === true)) { + if ((search_library === 'offline' || (search_library === 'elasticlunrjava' && uglyurls === true))) { minify_files.push('public/search_index.en.js'); minify_files.push(bpath+'static/js/elasticlunr.min.js'); minify_files.push(bpath+'static/js/searchjavaugly.js'); - } else if (search_library === 'elasticlunr' && index_format === 'elasticlunr_javascript') { + } else if (search_library === 'elasticlunrjava') { minify_files.push('public/search_index.en.js'); minify_files.push(bpath+'static/js/elasticlunr.min.js'); minify_files.push(bpath+'static/js/searchjava.js'); } else if (search_library === 'elasticlunr') {//abridge default minify_files.push(bpath+'static/js/elasticlunr.min.js'); minify_files.push(bpath+'static/js/search.js'); - } else if (search_library === 'stork') { - minify_files.push(bpath+'static/js/stork.js'); - minify_files.push(bpath+'static/js/stork_config.js'); + } else if (search_library === 'pagefind') { + minify_files.push(bpath+'static/js/pagefind_search.js'); } else if (search_library === 'tinysearch') { minify_files.push(bpath+'static/js/tinysearch.js'); - } else if (search_library === 'pagefind') { - minify_files.push(bpath+'static/js/pagefind.js'); - minify_files.push(bpath+'static/js/pagefind.search.js'); } } if (pwa) { @@ -311,7 +350,105 @@ function minify(fileA,outfile) { } -abridge(); +async function searchChange(searchOption) { + const { replaceInFileSync } = await import('replace-in-file'); + replaceInFileSync({files: 'config.toml', from: /search_library.*=.*/g, to: 'search_library = \"'+searchOption+'\"'}); +} + +if (args === ' offline') { + searchChange('offline'); +} else if (args === ' elasticlunrjava') { + searchChange('elasticlunrjava'); +} else if (args === ' elasticlunr') { + searchChange('elasticlunr'); +} else if (args === ' pagefind') { + searchChange('pagefind'); +} else if (args === ' tinysearch') { + searchChange('tinysearch'); +} else { + abridge(); +} + +async function createPagefindIndex() { + console.log("Creating Pagefind index..."); + const pagefind = await import("pagefind");// Dynamically import the pagefind module + const publicFolder = path.join(__dirname, "public"); + const files = fs.readdirSync(publicFolder); + let langArray = []; + + files.forEach((file) => { + if (file.startsWith("search_index")) { + langArray.push(file.split(".")[1]); + } + }); + + const { index } = await pagefind.createIndex(); + // Assuming index, fs, and path are already defined and properly imported + + // Convert each lang in langArray to a promise that performs the desired operations + const promises = langArray.map((lang) => + (async () => { + const filePath = path.join(__dirname,"public/search_index." + lang + ".json"); + + // Read the file content synchronously (consider using async readFile for better performance) + const fileContent = fs.readFileSync(filePath); + const data = JSON.parse(fileContent); + + // Add each record to the index asynchronously + for (const record of data) { + await index.addCustomRecord({ + url: record.url, + content: record.body, + language: lang, + meta: { + title: record.title, + description: record.meta, + }, + }); + } + })() + ); + + // Execute all promises concurrently + await Promise.all(promises) + .then(async () => { + // Write the index files to disk + const { errors } = await index.writeFiles({ + outputPath: "./static/js/", + }); + if (errors.length > 0) { + console.log("Errors: ", errors); + } + }) + .then(async () => { + // Edit the pagefind to convert from MJS to CJS + const pagefindPath = path.join(__dirname, "static/js/pagefind.js");//source pagefind from node module + let pagefindContent = fs.readFileSync(pagefindPath, "utf8"); + // Remove 'import.meta.url' from the pagefind file and exports + pagefindContent = pagefindContent + .replace( + /initPrimary\(\)\{([^{}]*\{[^{}]*\})*[^{}]*\}/g, + `initPrimary(){}` + ) // Remove annoying function + .replace(/;export\{[^}]*\}/g, ""); + fs.writeFileSync(pagefindPath, pagefindContent); + + // now insert the CJS into the anonymous function within pagefind.search.js + const pagefind_searchPath = path.join(__dirname, "static/js/pagefind.search.js");//file to insert into + const search_pagefindPath = path.join(__dirname, "static/js/pagefind_search.js");//output + let pagefind_searchContent = fs.readFileSync(pagefind_searchPath, "utf8"); + // Now insert into pagefind.search.js at this location: //insertHere + pagefind_searchContent = pagefind_searchContent.replace(/\/\/insertHere/g, pagefindContent); + fs.writeFileSync(search_pagefindPath, pagefind_searchContent); + + }) + .then(async () => { + await pagefind.close(); + }) + .catch((error) => { + console.error("An error occurred:", error); + }); +} async function sync() { // Check if the submodule is present, if not skip entire function @@ -368,6 +505,11 @@ async function sync() { })).sort((a, b) => a.name.localeCompare(b.name)); }; + if (packageJsonContent !== submodulePackageJsonContent) { + console.log("Updating package.json from submodule"); + fs.copyFileSync(submodulePackageJson, packageJson); + } + const packageVersionLocal = checkPackageVersion(packageJsonContent); const packageVersionSubmodule = checkPackageVersion(submodulePackageJsonContent); if (JSON.stringify(packageVersionLocal) !== JSON.stringify(packageVersionSubmodule)) { @@ -378,12 +520,7 @@ async function sync() { ); exit(1); } - console.log(packageVersionLocal, packageVersionSubmodule); - if (packageJsonContent !== submodulePackageJsonContent) { - console.log("Updating package.json from submodule"); - fs.copyFileSync(submodulePackageJson, packageJson); - } const configToml = path.join(__dirname, "config.toml"); const submoduleConfigToml = path.join( __dirname, diff --git a/sass/abridge.scss b/sass/abridge.scss index f9844a0..fa4fadb 100644 --- a/sass/abridge.scss +++ b/sass/abridge.scss @@ -9,7 +9,7 @@ //$mb: 1200px,// value at which to switch from fluid layout to max-width $abridgeMode: "switcher",//valid values: switcher, auto, dark, light - $syntax-mode: "auto",// Force syntax mode: auto, dark, light + $syntax-mode: "light",// Force syntax mode: auto, dark, light $switcherDefault: "light",// default nojs switcher mode: dark, light (make sure to also set js_switcher_default in config.toml) $color: "orange",// color template to use/override: orange, blue, blueshade @@ -22,17 +22,17 @@ $icon-rss: true, $icon-mail: false,// e-mail - $icon-mastodon: false, + $icon-mastodon: true, $icon-element: false, $icon-matrix: false, $icon-buymeacoffee: false, $icon-kofi: false, - $icon-twitter: false, + $icon-twitter: true, $icon-facebook: false, $icon-linkedin: false, $icon-codeberg: false, $icon-gitlab: false, - $icon-github: false, + $icon-github: true, $icon-github-sponsor: false, $icon-bitbucket: false, $icon-python: false, diff --git a/static/js/abridge.min.js b/static/js/abridge.min.js index 71801f2..f6e8e55 100644 --- a/static/js/abridge.min.js +++ b/static/js/abridge.min.js @@ -1 +1 @@ -let items=document.querySelectorAll(".preStyle"),changeIcon=(items.forEach(e=>{e.rel="stylesheet"}),!function(){for(var e=document.getElementsByClassName("m-protected"),t=0;t{e.classList.add(t),setTimeout(()=>e.classList.remove(t),2500)}),copyCodeAndChangeIcon=async(t,e)=>{e=(e.querySelector("table")?getTableCode:getNonTableCode)(e);try{await navigator.clipboard.writeText(e),changeIcon(t,"yes")}catch(e){changeIcon(t,"err")}},getNonTableCode=e=>[...e.querySelectorAll("code")].map(e=>e.textContent).join(""),getTableCode=e=>[...e.querySelectorAll("tr")].map(e=>e.querySelector("td:last-child")?.innerText??"").join("");document.querySelectorAll("pre").forEach(e=>{let t=document.createElement("div");t.className="cc svgs svgh copy",t.innerHTML=" ",e.prepend(t),t.addEventListener("click",()=>copyCodeAndChangeIcon(t,e))}),function(){function g(e){var t=new g.Index;return t.pipeline.add(g.trimmer,g.stopWordFilter,g.stemmer),e&&e.call(t,t),t}var l,c,e,t,d,h,f,p,m,v,y,S,x,b,w,I,E,C,D,F,k,_,N,L,n;g.version="0.9.5",((lunr=g).utils={}).warn=(n=this,function(e){n.console}),g.utils.toString=function(e){return null==e?"":e.toString()},(g.EventEmitter=function(){this.events={}}).prototype.addListener=function(){var e=[].slice.call(arguments),t=e.pop();if("function"!=typeof t)throw new TypeError("last argument must be a function");e.forEach(function(e){this.hasHandler(e)||(this.events[e]=[]),this.events[e].push(t)},this)},g.EventEmitter.prototype.removeListener=function(e,t){this.hasHandler(e)&&-1!=(t=this.events[e].indexOf(t))&&(this.events[e].splice(t,1),0==this.events[e].length)&&delete this.events[e]},g.EventEmitter.prototype.emit=function(e){var t;this.hasHandler(e)&&(t=[].slice.call(arguments,1),this.events[e].forEach(function(e){e.apply(void 0,t)},this))},g.EventEmitter.prototype.hasHandler=function(e){return e in this.events},(g.tokenizer=function(e){var t,n;return arguments.length&&null!=e?Array.isArray(e)?(t=(t=e.filter(function(e){return null!=e})).map(function(e){return g.utils.toString(e).toLowerCase()}),n=[],t.forEach(function(e){e=e.split(g.tokenizer.seperator);n=n.concat(e)},this),n):e.toString().trim().toLowerCase().split(g.tokenizer.seperator):[]}).defaultSeperator=/[\s\-]+/,g.tokenizer.seperator=g.tokenizer.defaultSeperator,g.tokenizer.setSeperator=function(e){null!=e&&"object"==typeof e&&(g.tokenizer.seperator=e)},g.tokenizer.resetSeperator=function(){g.tokenizer.seperator=g.tokenizer.defaultSeperator},g.tokenizer.getSeperator=function(){return g.tokenizer.seperator},(g.Pipeline=function(){this._queue=[]}).registeredFunctions={},g.Pipeline.registerFunction=function(e,t){t in g.Pipeline.registeredFunctions&&g.utils.warn("Overwriting existing registered function: "+t),e.label=t,g.Pipeline.registeredFunctions[t]=e},g.Pipeline.getRegisteredFunction=function(e){return e in g.Pipeline.registeredFunctions!=1?null:g.Pipeline.registeredFunctions[e]},g.Pipeline.warnIfFunctionNotRegistered=function(e){e.label&&e.label in this.registeredFunctions||g.utils.warn("Function is not registered with pipeline. This may cause problems when serialising the index.\n",e)},g.Pipeline.load=function(e){var n=new g.Pipeline;return e.forEach(function(e){var t=g.Pipeline.getRegisteredFunction(e);if(!t)throw Error("Cannot load un-registered function: "+e);n.add(t)}),n},g.Pipeline.prototype.add=function(){[].slice.call(arguments).forEach(function(e){g.Pipeline.warnIfFunctionNotRegistered(e),this._queue.push(e)},this)},g.Pipeline.prototype.after=function(e,t){g.Pipeline.warnIfFunctionNotRegistered(t);e=this._queue.indexOf(e);if(-1==e)throw Error("Cannot find existingFn");this._queue.splice(1+e,0,t)},g.Pipeline.prototype.before=function(e,t){g.Pipeline.warnIfFunctionNotRegistered(t);e=this._queue.indexOf(e);if(-1==e)throw Error("Cannot find existingFn");this._queue.splice(e,0,t)},g.Pipeline.prototype.remove=function(e){e=this._queue.indexOf(e);-1!=e&&this._queue.splice(e,1)},g.Pipeline.prototype.run=function(e){for(var t=[],n=e.length,o=this._queue.length,i=0;i=n&&r-1>=o;)s[n]!==u[o]?s[n]u[o]&&o++:(t.add(s[n]),n++,o++);return t},lunr.SortedSet.prototype.clone=function(){var e=new lunr.SortedSet;return e.elements=this.toArray(),e.length=e.elements.length,e},lunr.SortedSet.prototype.union=function(e){for(var t,e=this.length

'.concat(document.getElementById("searchinput").value,"

");return o.innerHTML=i,n.insertBefore(o,n.firstChild),e.innerHTML=n.outerHTML,t.innerHTML="",document.getElementById("searchinput").value="",document.body.contains(document.closeSearch)&&(document.closeSearch.onsubmit=function(){document.querySelector("main").innerHTML=window.main}),!1}function b(e){return[0,1,2,3,4][Math.ceil(parseInt(e,16).toString(2).length/8)]}var u,r,l,c,h;document.body.contains(document.goSearch)&&(document.goSearch.onsubmit=function(){return goSearchNow()},u=document.getElementById("suggestions"),r=document.getElementById("searchinput"),document.addEventListener("keydown",function(t){if(191===t.keyCode&&"INPUT"!==document.activeElement.tagName&&"TEXTAREA"!==document.activeElement.tagName&&(t.preventDefault(),r.focus(),u.classList.remove("d-none")),27===t.keyCode){r.blur(),u.classList.add("d-none");for(var e=document.getElementById("suggestions");e.firstChild;)e.removeChild(e.firstChild)}var n=u.querySelectorAll("a");if(!u.classList.contains("d-none")&&0!==n.length){var o=[...n],i=o.indexOf(document.activeElement);let e=0;38===t.keyCode?(t.preventDefault(),n[e=0",a=n.querySelector("a"),t=n.querySelector("span:first-child"),d=n.querySelector("span:nth-child(2)"),a.href=e.ref,t.textContent=e.doc.title,d.innerHTML=function(e,t){var n=t.map(function(e){return elasticlunr.stemmer(e.toLowerCase())}),o=!1,i=0,r=[],s=e.toLowerCase().split(". ");for(p in s){var u,a=s[p].split(/[\s\n]/),l=8;for(u in a){if(0<(S=a[u]).length){for(var c in n)elasticlunr.stemmer(S).startsWith(n[c])&&(l=40,o=!0);r.push([S,l,i]),l=2}i=i+S.length+1}i+=1}if(0===r.length)return void 0!==e.length&&300"),y=S[2]+S[0].length;40===S[1]||S[0].length<12||/^[\x00-\xff]+$/.test(S[0])?v.push(e.substring(S[2],y)):(x=function(e,t){for(var n="",o=!1,i=0,r=0,s=0,u=0;u")}return v.push("…"),v.join("")}(e.doc.body,s),u.appendChild(n))});i.length>r;)u.removeChild(i[0])},!0),u.addEventListener("click",function(){for(;u.lastChild;)u.removeChild(u.lastChild);return!1},!0),document.goSearch.onsubmit=e)},"serviceWorker"in navigator&&(navigator.serviceWorker.register("/sw.min.js?v=3.11.0",{scope:"/"}).then(()=>{},e=>{}),navigator.serviceWorker.ready.then(()=>{})); \ No newline at end of file +let items=document.querySelectorAll(".preStyle");items.forEach(e=>{e.rel="stylesheet"}),(()=>{for(var e=document.getElementsByClassName("m-protected"),t=0;t{if(null===e||"object"!=typeof e)return e;var t,n=e.constructor();for(t in e)e.hasOwnProperty(t)&&(n[t]=e[t]);return n})(t):null},g.DocumentStore.prototype.getDoc=function(e){return!1===this.hasDoc(e)?null:this.docs[e]},g.DocumentStore.prototype.hasDoc=function(e){return e in this.docs},g.DocumentStore.prototype.removeDoc=function(e){this.hasDoc(e)&&(delete this.docs[e],delete this.docInfo[e],this.length--)},g.DocumentStore.prototype.addFieldLength=function(e,t,n){null!=e&&0!=this.hasDoc(e)&&(this.docInfo[e]||(this.docInfo[e]={}),this.docInfo[e][t]=n)},g.DocumentStore.prototype.updateFieldLength=function(e,t,n){null!=e&&0!=this.hasDoc(e)&&this.addFieldLength(e,t,n)},g.DocumentStore.prototype.getFieldLength=function(e,t){return null!=e&&e in this.docs&&t in this.docInfo[e]?this.docInfo[e][t]:0},g.DocumentStore.prototype.toJSON=function(){return{docs:this.docs,docInfo:this.docInfo,length:this.length,save:this._save}},a={ational:"ate",tional:"tion",enci:"ence",anci:"ance",izer:"ize",bli:"ble",alli:"al",entli:"ent",eli:"e",ousli:"ous",ization:"ize",ation:"ate",ator:"ate",alism:"al",iveness:"ive",fulness:"ful",ousness:"ous",aliti:"al",iviti:"ive",biliti:"ble",logi:"log"},c={icate:"ic",ative:"",alize:"al",iciti:"ic",ical:"ic",ful:"",ness:""},d=/^([^aeiou][^aeiouy]*)?[aeiouy][aeiou]*[^aeiou][^aeiouy]*/,h=/^([^aeiou][^aeiouy]*)?[aeiouy][aeiou]*[^aeiou][^aeiouy]*[aeiouy][aeiou]*[^aeiou][^aeiouy]*/,f=/^([^aeiou][^aeiouy]*)?[aeiouy][aeiou]*[^aeiou][^aeiouy]*([aeiouy][aeiou]*)?$/,p=/^([^aeiou][^aeiouy]*)?[aeiouy]/,m=/^(.+?)(ss|i)es$/,v=/^(.+?)([^s])s$/,y=/^(.+?)eed$/,S=/^(.+?)(ed|ing)$/,x=/.$/,b=/(at|bl|iz)$/,w=/([^aeiouylsz])\1$/,I=RegExp("^"+(t="[^aeiou][^aeiouy]*")+(e="[aeiouy]")+"[^aeiouwxy]$"),E=/^(.+?[^aeiou])y$/,D=/^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/,F=/^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/,C=/^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/,k=/^(.+?)(s|t)(ion)$/,_=/^(.+?)e$/,N=/ll$/,P=RegExp("^"+t+e+"[^aeiouwxy]$"),g.Pipeline.registerFunction(g.stemmer=function(e){var t,n,o,i,r,s,u,l;return e.length<3||("y"==(n=e.substr(0,1))&&(e=n.toUpperCase()+e.substr(1)),u=v,(r=m).test(e)?e=e.replace(r,"$1$2"):u.test(e)&&(e=e.replace(u,"$1$2")),u=S,(r=y).test(e)?(l=r.exec(e),(r=d).test(l[1])&&(e=e.replace(r=x,""))):u.test(e)&&(s=(l=u.exec(e))[1],(u=p).test(s))&&(e=s,o=w,i=I,(u=b).test(e)?e+="e":o.test(e)?e=e.replace(r=x,""):i.test(e)&&(e+="e")),(r=E).test(e)&&(e=(s=(l=r.exec(e))[1])+"i"),(r=D).test(e)&&(s=(l=r.exec(e))[1],t=l[2],(r=d).test(s))&&(e=s+a[t]),(r=F).test(e)&&(s=(l=r.exec(e))[1],t=l[2],(r=d).test(s))&&(e=s+c[t]),u=k,(r=C).test(e)?(s=(l=r.exec(e))[1],(r=h).test(s)&&(e=s)):u.test(e)&&(s=(l=u.exec(e))[1]+l[2],(u=h).test(s))&&(e=s),(r=_).test(e)&&(s=(l=r.exec(e))[1],u=f,o=P,(r=h).test(s)||u.test(s)&&!o.test(s))&&(e=s),u=h,(r=N).test(e)&&u.test(e)&&(e=e.replace(r=x,"")),"y"==n&&(e=n.toLowerCase()+e.substr(1))),e},"stemmer"),g.stopWordFilter=function(e){return e&&!0!==g.stopWordFilter.stopWords[e]?e:void 0},g.clearStopWords=function(){g.stopWordFilter.stopWords={}},g.addStopWords=function(e){null!=e&&!1!==Array.isArray(e)&&e.forEach(function(e){g.stopWordFilter.stopWords[e]=!0},this)},g.resetStopWords=function(){g.stopWordFilter.stopWords=g.defaultStopWords},g.stopWordFilter.stopWords=g.defaultStopWords={"":!0,a:!0,able:!0,about:!0,across:!0,after:!0,all:!0,almost:!0,also:!0,am:!0,among:!0,an:!0,and:!0,any:!0,are:!0,as:!0,at:!0,be:!0,because:!0,been:!0,but:!0,by:!0,can:!0,cannot:!0,could:!0,dear:!0,did:!0,do:!0,does:!0,either:!0,else:!0,ever:!0,every:!0,for:!0,from:!0,get:!0,got:!0,had:!0,has:!0,have:!0,he:!0,her:!0,hers:!0,him:!0,his:!0,how:!0,however:!0,i:!0,if:!0,in:!0,into:!0,is:!0,it:!0,its:!0,just:!0,least:!0,let:!0,like:!0,likely:!0,may:!0,me:!0,might:!0,most:!0,must:!0,my:!0,neither:!0,no:!0,nor:!0,not:!0,of:!0,off:!0,often:!0,on:!0,only:!0,or:!0,other:!0,our:!0,own:!0,rather:!0,said:!0,say:!0,says:!0,she:!0,should:!0,since:!0,so:!0,some:!0,than:!0,that:!0,the:!0,their:!0,them:!0,then:!0,there:!0,these:!0,they:!0,this:!0,tis:!0,to:!0,too:!0,twas:!0,us:!0,wants:!0,was:!0,we:!0,were:!0,what:!0,when:!0,where:!0,which:!0,while:!0,who:!0,whom:!0,why:!0,will:!0,with:!0,would:!0,yet:!0,you:!0,your:!0},g.Pipeline.registerFunction(g.stopWordFilter,"stopWordFilter"),g.Pipeline.registerFunction(g.trimmer=function(e){if(null==e)throw Error("token should not be undefined");return e.replace(/^\W+/,"").replace(/\W+$/,"")},"trimmer"),(g.InvertedIndex=function(){this.root={docs:{},df:0}}).load=function(e){var t=new this;return t.root=e.root,t},g.InvertedIndex.prototype.addToken=function(e,t,n){for(var n=n||this.root,o=0;o<=e.length-1;){var i=e[o];i in n||(n[i]={docs:{},df:0}),o+=1,n=n[i]}var r=t.ref;n.docs[r]?n.docs[r]={tf:t.tf}:(n.docs[r]={tf:t.tf},n.df+=1)},g.InvertedIndex.prototype.hasToken=function(e){if(!e)return!1;for(var t=this.root,n=0;n=n&&r-1>=o;)s[n]!==u[o]?s[n]u[o]&&o++:(t.add(s[n]),n++,o++);return t},lunr.SortedSet.prototype.clone=function(){var e=new lunr.SortedSet;return e.elements=this.toArray(),e.length=e.elements.length,e},lunr.SortedSet.prototype.union=function(e){for(var t,e=this.length

'.concat(document.getElementById("searchinput").value,"

");return o.innerHTML=i,n.insertBefore(o,n.firstChild),e.innerHTML=n.outerHTML,t.innerHTML="",document.getElementById("searchinput").value="",document.body.contains(document.closeSearch)&&(document.closeSearch.onsubmit=function(){document.querySelector("main").innerHTML=window.main}),!1}function b(e){return[0,1,2,3,4][Math.ceil(parseInt(e,16).toString(2).length/8)]}var u,r,l,c,h;document.body.contains(document.goSearch)&&(document.goSearch.onsubmit=function(){return goSearchNow()},u=document.getElementById("suggestions"),r=document.getElementById("searchinput"),document.addEventListener("keydown",function(t){if(191===t.keyCode&&"INPUT"!==document.activeElement.tagName&&"TEXTAREA"!==document.activeElement.tagName&&(t.preventDefault(),r.focus(),u.classList.remove("d-none")),27===t.keyCode){r.blur(),u.classList.add("d-none");for(var e=document.getElementById("suggestions");e.firstChild;)e.removeChild(e.firstChild)}var n=u.querySelectorAll("a");if(!u.classList.contains("d-none")&&0!==n.length){var o=[...n],i=o.indexOf(document.activeElement);let e=0;38===t.keyCode?(t.preventDefault(),n[e=0",a=n.querySelector("a"),t=n.querySelector("span:first-child"),d=n.querySelector("span:nth-child(2)"),a.href=e.ref,t.textContent=e.doc.title,d.innerHTML=((e,t)=>{var n=t.map(function(e){return elasticlunr.stemmer(e.toLowerCase())}),o=!1,i=0,r=[],s=e.toLowerCase().split(". ");for(p in s){var u,l=s[p].split(/[\s\n]/),a=8;for(u in l){if(0<(v=l[u]).length){for(var c in n)elasticlunr.stemmer(v).startsWith(n[c])&&(a=40,o=!0);r.push([v,a,i]),a=2}i=i+v.length+1}i+=1}if(0===r.length)return void 0!==e.length&&300"),x=v[2]+v[0].length;40===v[1]||v[0].length<12||/^[\x00-\xff]+$/.test(v[0])?S.push(e.substring(v[2],x)):(y=((e,t)=>{for(var n="",o=!1,i=0,r=0,s=0,u=0;u")}return S.push("…"),S.join("")})(e.doc.body,s),u.appendChild(n))});i.length>r;)u.removeChild(i[0])},!0),u.addEventListener("click",function(){for(;u.lastChild;)u.removeChild(u.lastChild);return!1},!0),document.goSearch.onsubmit=e)}; \ No newline at end of file diff --git a/static/js/abridge_nopwa.min.js b/static/js/abridge_nopwa.min.js index 0f0be92..f6e8e55 100644 --- a/static/js/abridge_nopwa.min.js +++ b/static/js/abridge_nopwa.min.js @@ -1 +1 @@ -let items=document.querySelectorAll(".preStyle"),changeIcon=(items.forEach(e=>{e.rel="stylesheet"}),!function(){for(var e=document.getElementsByClassName("m-protected"),t=0;t{e.classList.add(t),setTimeout(()=>e.classList.remove(t),2500)}),copyCodeAndChangeIcon=async(t,e)=>{e=(e.querySelector("table")?getTableCode:getNonTableCode)(e);try{await navigator.clipboard.writeText(e),changeIcon(t,"yes")}catch(e){changeIcon(t,"err")}},getNonTableCode=e=>[...e.querySelectorAll("code")].map(e=>e.textContent).join(""),getTableCode=e=>[...e.querySelectorAll("tr")].map(e=>e.querySelector("td:last-child")?.innerText??"").join("");document.querySelectorAll("pre").forEach(e=>{let t=document.createElement("div");t.className="cc svgs svgh copy",t.innerHTML=" ",e.prepend(t),t.addEventListener("click",()=>copyCodeAndChangeIcon(t,e))}),function(){function g(e){var t=new g.Index;return t.pipeline.add(g.trimmer,g.stopWordFilter,g.stemmer),e&&e.call(t,t),t}var a,c,e,t,d,h,f,p,m,v,y,S,x,b,w,I,E,C,D,F,_,k,N,L,n;g.version="0.9.5",((lunr=g).utils={}).warn=(n=this,function(e){n.console}),g.utils.toString=function(e){return null==e?"":e.toString()},(g.EventEmitter=function(){this.events={}}).prototype.addListener=function(){var e=[].slice.call(arguments),t=e.pop();if("function"!=typeof t)throw new TypeError("last argument must be a function");e.forEach(function(e){this.hasHandler(e)||(this.events[e]=[]),this.events[e].push(t)},this)},g.EventEmitter.prototype.removeListener=function(e,t){this.hasHandler(e)&&-1!=(t=this.events[e].indexOf(t))&&(this.events[e].splice(t,1),0==this.events[e].length)&&delete this.events[e]},g.EventEmitter.prototype.emit=function(e){var t;this.hasHandler(e)&&(t=[].slice.call(arguments,1),this.events[e].forEach(function(e){e.apply(void 0,t)},this))},g.EventEmitter.prototype.hasHandler=function(e){return e in this.events},(g.tokenizer=function(e){var t,n;return arguments.length&&null!=e?Array.isArray(e)?(t=(t=e.filter(function(e){return null!=e})).map(function(e){return g.utils.toString(e).toLowerCase()}),n=[],t.forEach(function(e){e=e.split(g.tokenizer.seperator);n=n.concat(e)},this),n):e.toString().trim().toLowerCase().split(g.tokenizer.seperator):[]}).defaultSeperator=/[\s\-]+/,g.tokenizer.seperator=g.tokenizer.defaultSeperator,g.tokenizer.setSeperator=function(e){null!=e&&"object"==typeof e&&(g.tokenizer.seperator=e)},g.tokenizer.resetSeperator=function(){g.tokenizer.seperator=g.tokenizer.defaultSeperator},g.tokenizer.getSeperator=function(){return g.tokenizer.seperator},(g.Pipeline=function(){this._queue=[]}).registeredFunctions={},g.Pipeline.registerFunction=function(e,t){t in g.Pipeline.registeredFunctions&&g.utils.warn("Overwriting existing registered function: "+t),e.label=t,g.Pipeline.registeredFunctions[t]=e},g.Pipeline.getRegisteredFunction=function(e){return e in g.Pipeline.registeredFunctions!=1?null:g.Pipeline.registeredFunctions[e]},g.Pipeline.warnIfFunctionNotRegistered=function(e){e.label&&e.label in this.registeredFunctions||g.utils.warn("Function is not registered with pipeline. This may cause problems when serialising the index.\n",e)},g.Pipeline.load=function(e){var n=new g.Pipeline;return e.forEach(function(e){var t=g.Pipeline.getRegisteredFunction(e);if(!t)throw Error("Cannot load un-registered function: "+e);n.add(t)}),n},g.Pipeline.prototype.add=function(){[].slice.call(arguments).forEach(function(e){g.Pipeline.warnIfFunctionNotRegistered(e),this._queue.push(e)},this)},g.Pipeline.prototype.after=function(e,t){g.Pipeline.warnIfFunctionNotRegistered(t);e=this._queue.indexOf(e);if(-1==e)throw Error("Cannot find existingFn");this._queue.splice(1+e,0,t)},g.Pipeline.prototype.before=function(e,t){g.Pipeline.warnIfFunctionNotRegistered(t);e=this._queue.indexOf(e);if(-1==e)throw Error("Cannot find existingFn");this._queue.splice(e,0,t)},g.Pipeline.prototype.remove=function(e){e=this._queue.indexOf(e);-1!=e&&this._queue.splice(e,1)},g.Pipeline.prototype.run=function(e){for(var t=[],n=e.length,o=this._queue.length,i=0;i=n&&r-1>=o;)s[n]!==u[o]?s[n]u[o]&&o++:(t.add(s[n]),n++,o++);return t},lunr.SortedSet.prototype.clone=function(){var e=new lunr.SortedSet;return e.elements=this.toArray(),e.length=e.elements.length,e},lunr.SortedSet.prototype.union=function(e){for(var t,e=this.length

'.concat(document.getElementById("searchinput").value,"

");return o.innerHTML=i,n.insertBefore(o,n.firstChild),e.innerHTML=n.outerHTML,t.innerHTML="",document.getElementById("searchinput").value="",document.body.contains(document.closeSearch)&&(document.closeSearch.onsubmit=function(){document.querySelector("main").innerHTML=window.main}),!1}function b(e){return[0,1,2,3,4][Math.ceil(parseInt(e,16).toString(2).length/8)]}var u,r,l,c,h;document.body.contains(document.goSearch)&&(document.goSearch.onsubmit=function(){return goSearchNow()},u=document.getElementById("suggestions"),r=document.getElementById("searchinput"),document.addEventListener("keydown",function(t){if(191===t.keyCode&&"INPUT"!==document.activeElement.tagName&&"TEXTAREA"!==document.activeElement.tagName&&(t.preventDefault(),r.focus(),u.classList.remove("d-none")),27===t.keyCode){r.blur(),u.classList.add("d-none");for(var e=document.getElementById("suggestions");e.firstChild;)e.removeChild(e.firstChild)}var n=u.querySelectorAll("a");if(!u.classList.contains("d-none")&&0!==n.length){var o=[...n],i=o.indexOf(document.activeElement);let e=0;38===t.keyCode?(t.preventDefault(),n[e=0",a=n.querySelector("a"),t=n.querySelector("span:first-child"),d=n.querySelector("span:nth-child(2)"),a.href=e.ref,t.textContent=e.doc.title,d.innerHTML=function(e,t){var n=t.map(function(e){return elasticlunr.stemmer(e.toLowerCase())}),o=!1,i=0,r=[],s=e.toLowerCase().split(". ");for(p in s){var u,l=s[p].split(/[\s\n]/),a=8;for(u in l){if(0<(S=l[u]).length){for(var c in n)elasticlunr.stemmer(S).startsWith(n[c])&&(a=40,o=!0);r.push([S,a,i]),a=2}i=i+S.length+1}i+=1}if(0===r.length)return void 0!==e.length&&300"),y=S[2]+S[0].length;40===S[1]||S[0].length<12||/^[\x00-\xff]+$/.test(S[0])?v.push(e.substring(S[2],y)):(x=function(e,t){for(var n="",o=!1,i=0,r=0,s=0,u=0;u")}return v.push("…"),v.join("")}(e.doc.body,s),u.appendChild(n))});i.length>r;)u.removeChild(i[0])},!0),u.addEventListener("click",function(){for(;u.lastChild;)u.removeChild(u.lastChild);return!1},!0),document.goSearch.onsubmit=e)}; \ No newline at end of file +let items=document.querySelectorAll(".preStyle");items.forEach(e=>{e.rel="stylesheet"}),(()=>{for(var e=document.getElementsByClassName("m-protected"),t=0;t{if(null===e||"object"!=typeof e)return e;var t,n=e.constructor();for(t in e)e.hasOwnProperty(t)&&(n[t]=e[t]);return n})(t):null},g.DocumentStore.prototype.getDoc=function(e){return!1===this.hasDoc(e)?null:this.docs[e]},g.DocumentStore.prototype.hasDoc=function(e){return e in this.docs},g.DocumentStore.prototype.removeDoc=function(e){this.hasDoc(e)&&(delete this.docs[e],delete this.docInfo[e],this.length--)},g.DocumentStore.prototype.addFieldLength=function(e,t,n){null!=e&&0!=this.hasDoc(e)&&(this.docInfo[e]||(this.docInfo[e]={}),this.docInfo[e][t]=n)},g.DocumentStore.prototype.updateFieldLength=function(e,t,n){null!=e&&0!=this.hasDoc(e)&&this.addFieldLength(e,t,n)},g.DocumentStore.prototype.getFieldLength=function(e,t){return null!=e&&e in this.docs&&t in this.docInfo[e]?this.docInfo[e][t]:0},g.DocumentStore.prototype.toJSON=function(){return{docs:this.docs,docInfo:this.docInfo,length:this.length,save:this._save}},a={ational:"ate",tional:"tion",enci:"ence",anci:"ance",izer:"ize",bli:"ble",alli:"al",entli:"ent",eli:"e",ousli:"ous",ization:"ize",ation:"ate",ator:"ate",alism:"al",iveness:"ive",fulness:"ful",ousness:"ous",aliti:"al",iviti:"ive",biliti:"ble",logi:"log"},c={icate:"ic",ative:"",alize:"al",iciti:"ic",ical:"ic",ful:"",ness:""},d=/^([^aeiou][^aeiouy]*)?[aeiouy][aeiou]*[^aeiou][^aeiouy]*/,h=/^([^aeiou][^aeiouy]*)?[aeiouy][aeiou]*[^aeiou][^aeiouy]*[aeiouy][aeiou]*[^aeiou][^aeiouy]*/,f=/^([^aeiou][^aeiouy]*)?[aeiouy][aeiou]*[^aeiou][^aeiouy]*([aeiouy][aeiou]*)?$/,p=/^([^aeiou][^aeiouy]*)?[aeiouy]/,m=/^(.+?)(ss|i)es$/,v=/^(.+?)([^s])s$/,y=/^(.+?)eed$/,S=/^(.+?)(ed|ing)$/,x=/.$/,b=/(at|bl|iz)$/,w=/([^aeiouylsz])\1$/,I=RegExp("^"+(t="[^aeiou][^aeiouy]*")+(e="[aeiouy]")+"[^aeiouwxy]$"),E=/^(.+?[^aeiou])y$/,D=/^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/,F=/^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/,C=/^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/,k=/^(.+?)(s|t)(ion)$/,_=/^(.+?)e$/,N=/ll$/,P=RegExp("^"+t+e+"[^aeiouwxy]$"),g.Pipeline.registerFunction(g.stemmer=function(e){var t,n,o,i,r,s,u,l;return e.length<3||("y"==(n=e.substr(0,1))&&(e=n.toUpperCase()+e.substr(1)),u=v,(r=m).test(e)?e=e.replace(r,"$1$2"):u.test(e)&&(e=e.replace(u,"$1$2")),u=S,(r=y).test(e)?(l=r.exec(e),(r=d).test(l[1])&&(e=e.replace(r=x,""))):u.test(e)&&(s=(l=u.exec(e))[1],(u=p).test(s))&&(e=s,o=w,i=I,(u=b).test(e)?e+="e":o.test(e)?e=e.replace(r=x,""):i.test(e)&&(e+="e")),(r=E).test(e)&&(e=(s=(l=r.exec(e))[1])+"i"),(r=D).test(e)&&(s=(l=r.exec(e))[1],t=l[2],(r=d).test(s))&&(e=s+a[t]),(r=F).test(e)&&(s=(l=r.exec(e))[1],t=l[2],(r=d).test(s))&&(e=s+c[t]),u=k,(r=C).test(e)?(s=(l=r.exec(e))[1],(r=h).test(s)&&(e=s)):u.test(e)&&(s=(l=u.exec(e))[1]+l[2],(u=h).test(s))&&(e=s),(r=_).test(e)&&(s=(l=r.exec(e))[1],u=f,o=P,(r=h).test(s)||u.test(s)&&!o.test(s))&&(e=s),u=h,(r=N).test(e)&&u.test(e)&&(e=e.replace(r=x,"")),"y"==n&&(e=n.toLowerCase()+e.substr(1))),e},"stemmer"),g.stopWordFilter=function(e){return e&&!0!==g.stopWordFilter.stopWords[e]?e:void 0},g.clearStopWords=function(){g.stopWordFilter.stopWords={}},g.addStopWords=function(e){null!=e&&!1!==Array.isArray(e)&&e.forEach(function(e){g.stopWordFilter.stopWords[e]=!0},this)},g.resetStopWords=function(){g.stopWordFilter.stopWords=g.defaultStopWords},g.stopWordFilter.stopWords=g.defaultStopWords={"":!0,a:!0,able:!0,about:!0,across:!0,after:!0,all:!0,almost:!0,also:!0,am:!0,among:!0,an:!0,and:!0,any:!0,are:!0,as:!0,at:!0,be:!0,because:!0,been:!0,but:!0,by:!0,can:!0,cannot:!0,could:!0,dear:!0,did:!0,do:!0,does:!0,either:!0,else:!0,ever:!0,every:!0,for:!0,from:!0,get:!0,got:!0,had:!0,has:!0,have:!0,he:!0,her:!0,hers:!0,him:!0,his:!0,how:!0,however:!0,i:!0,if:!0,in:!0,into:!0,is:!0,it:!0,its:!0,just:!0,least:!0,let:!0,like:!0,likely:!0,may:!0,me:!0,might:!0,most:!0,must:!0,my:!0,neither:!0,no:!0,nor:!0,not:!0,of:!0,off:!0,often:!0,on:!0,only:!0,or:!0,other:!0,our:!0,own:!0,rather:!0,said:!0,say:!0,says:!0,she:!0,should:!0,since:!0,so:!0,some:!0,than:!0,that:!0,the:!0,their:!0,them:!0,then:!0,there:!0,these:!0,they:!0,this:!0,tis:!0,to:!0,too:!0,twas:!0,us:!0,wants:!0,was:!0,we:!0,were:!0,what:!0,when:!0,where:!0,which:!0,while:!0,who:!0,whom:!0,why:!0,will:!0,with:!0,would:!0,yet:!0,you:!0,your:!0},g.Pipeline.registerFunction(g.stopWordFilter,"stopWordFilter"),g.Pipeline.registerFunction(g.trimmer=function(e){if(null==e)throw Error("token should not be undefined");return e.replace(/^\W+/,"").replace(/\W+$/,"")},"trimmer"),(g.InvertedIndex=function(){this.root={docs:{},df:0}}).load=function(e){var t=new this;return t.root=e.root,t},g.InvertedIndex.prototype.addToken=function(e,t,n){for(var n=n||this.root,o=0;o<=e.length-1;){var i=e[o];i in n||(n[i]={docs:{},df:0}),o+=1,n=n[i]}var r=t.ref;n.docs[r]?n.docs[r]={tf:t.tf}:(n.docs[r]={tf:t.tf},n.df+=1)},g.InvertedIndex.prototype.hasToken=function(e){if(!e)return!1;for(var t=this.root,n=0;n=n&&r-1>=o;)s[n]!==u[o]?s[n]u[o]&&o++:(t.add(s[n]),n++,o++);return t},lunr.SortedSet.prototype.clone=function(){var e=new lunr.SortedSet;return e.elements=this.toArray(),e.length=e.elements.length,e},lunr.SortedSet.prototype.union=function(e){for(var t,e=this.length

'.concat(document.getElementById("searchinput").value,"

");return o.innerHTML=i,n.insertBefore(o,n.firstChild),e.innerHTML=n.outerHTML,t.innerHTML="",document.getElementById("searchinput").value="",document.body.contains(document.closeSearch)&&(document.closeSearch.onsubmit=function(){document.querySelector("main").innerHTML=window.main}),!1}function b(e){return[0,1,2,3,4][Math.ceil(parseInt(e,16).toString(2).length/8)]}var u,r,l,c,h;document.body.contains(document.goSearch)&&(document.goSearch.onsubmit=function(){return goSearchNow()},u=document.getElementById("suggestions"),r=document.getElementById("searchinput"),document.addEventListener("keydown",function(t){if(191===t.keyCode&&"INPUT"!==document.activeElement.tagName&&"TEXTAREA"!==document.activeElement.tagName&&(t.preventDefault(),r.focus(),u.classList.remove("d-none")),27===t.keyCode){r.blur(),u.classList.add("d-none");for(var e=document.getElementById("suggestions");e.firstChild;)e.removeChild(e.firstChild)}var n=u.querySelectorAll("a");if(!u.classList.contains("d-none")&&0!==n.length){var o=[...n],i=o.indexOf(document.activeElement);let e=0;38===t.keyCode?(t.preventDefault(),n[e=0",a=n.querySelector("a"),t=n.querySelector("span:first-child"),d=n.querySelector("span:nth-child(2)"),a.href=e.ref,t.textContent=e.doc.title,d.innerHTML=((e,t)=>{var n=t.map(function(e){return elasticlunr.stemmer(e.toLowerCase())}),o=!1,i=0,r=[],s=e.toLowerCase().split(". ");for(p in s){var u,l=s[p].split(/[\s\n]/),a=8;for(u in l){if(0<(v=l[u]).length){for(var c in n)elasticlunr.stemmer(v).startsWith(n[c])&&(a=40,o=!0);r.push([v,a,i]),a=2}i=i+v.length+1}i+=1}if(0===r.length)return void 0!==e.length&&300"),x=v[2]+v[0].length;40===v[1]||v[0].length<12||/^[\x00-\xff]+$/.test(v[0])?S.push(e.substring(v[2],x)):(y=((e,t)=>{for(var n="",o=!1,i=0,r=0,s=0,u=0;u")}return S.push("…"),S.join("")})(e.doc.body,s),u.appendChild(n))});i.length>r;)u.removeChild(i[0])},!0),u.addEventListener("click",function(){for(;u.lastChild;)u.removeChild(u.lastChild);return!1},!0),document.goSearch.onsubmit=e)}; \ No newline at end of file diff --git a/static/js/sw_load.js b/static/js/sw_load.js index 0759338..57cb540 100644 --- a/static/js/sw_load.js +++ b/static/js/sw_load.js @@ -1,6 +1,6 @@ if ("serviceWorker" in navigator) { navigator.serviceWorker - .register("/sw.min.js?v=3.11.0", + .register("/sw.min.js?v=3.12.1", { scope: "/" }) .then(() => { console.info("SW Loaded");