From 3af6d9131f6dfc138856d718ec96626344095ec8 Mon Sep 17 00:00:00 2001 From: Jieiku Date: Mon, 22 May 2023 23:24:44 -0700 Subject: Optimizations and Fixes --- static/js/stork_config.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 static/js/stork_config.js (limited to 'static/js/stork_config.js') diff --git a/static/js/stork_config.js b/static/js/stork_config.js new file mode 100644 index 0000000..3c589c2 --- /dev/null +++ b/static/js/stork_config.js @@ -0,0 +1,25 @@ +function loadStork() { + var baseUrl = document.querySelector("meta[name='base']").getAttribute("content"); + if (baseUrl.slice(-1) == "/") { + baseUrl = baseUrl.slice(0, -1); + } + stork.initialize(baseUrl + "/stork.wasm").then(() => { + console.log("Finished downloading WASM"); + }) + .catch(e => { + console.error(e); + }); // download WASM + stork.register("stork",baseUrl + "/stork.st"); +} +var loaded = false; +window.onload = function() { + document.body.contains(document.goSearch) && (document.goSearch.onsubmit = function() { return goSearchNow() }) + document.getElementById('searchinput').onfocus = function() { + if (!loaded) { + loadStork(); + loaded = true; + document.body.contains(document.goSearch) && (document.goSearch.onsubmit = function() { return goSearchNow() }) + } + document.getElementById('searchinput').onfocus = ''; + } +}; -- cgit v1.3.1