aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJieiku2023-02-21 18:06:29 -0800
committerJieiku2023-02-21 18:06:29 -0800
commitcfe23e2d8eb9d2b198b58b4ec5464b209189418f (patch)
tree0a27a0f702edaf870825a8aa5b0d24541b35d5f5
parentdbe8c84a65ad2290c06fe8c1193f8d9563a9ab53 (diff)
downloadabridge-cfe23e2d8eb9d2b198b58b4ec5464b209189418f.tar.gz
abridge-cfe23e2d8eb9d2b198b58b4ec5464b209189418f.tar.bz2
abridge-cfe23e2d8eb9d2b198b58b4ec5464b209189418f.zip
Add js Bundle option for Search Facade noswitcher
-rw-r--r--package.json3
-rw-r--r--static/abridge.min.js1
-rw-r--r--templates/macros/head.html6
3 files changed, 9 insertions, 1 deletions
diff --git a/package.json b/package.json
index 7aef962..5a437f5 100644
--- a/package.json
+++ b/package.json
@@ -24,11 +24,12 @@
"sha384-demo": "sha384=$(openssl dgst -sha384 -binary 'static/search_bundle.min.js' | openssl base64) && echo $sha384 && sed -i \"s|sha384='.*'|sha384='$sha384'|\" 'static/search_facade.js'",
"sha384-stork": "sha384=$(openssl dgst -sha384 -binary 'static/search_bundle_stork.min.js' | openssl base64) && echo $sha384 && sed -i \"s|sha384='.*'|sha384='$sha384'|\" 'static/search_facade_stork.js'",
"sha384-tinysearch": "sha384=$(openssl dgst -sha384 -binary 'static/search_bundle_tinysearch.min.js' | openssl base64) && echo $sha384 && sed -i \"s|sha384='.*'|sha384='$sha384'|\" 'static/search_facade_tinysearch.js'",
+ "abridge-bundle-noswitcher": "uglifyjs themes/abridge/static/prestyle.js themes/abridge/static/search_facade.js themes/abridge/static/email.js themes/abridge/static/codecopy.js -c -m -o static/abridge.min.js",
"abridge-bundle": "uglifyjs themes/abridge/static/prestyle.js themes/abridge/static/theme_button.js themes/abridge/static/search_facade.js themes/abridge/static/email.js themes/abridge/static/codecopy.js -c -m -o static/abridge-bundle.min.js",
"abridge-bundle-demo": "uglifyjs static/prestyle.js static/theme_button.js static/search_facade.js static/email.js static/codecopy.js -c -m -o static/abridge-bundle.min.js",
"abridge-bundle-stork": "uglifyjs static/prestyle.js static/theme_button.js static/search_facade_stork.js static/email.js static/codecopy.js -c -m -o static/abridge-bundle-stork.min.js",
"abridge-bundle-tinysearch": "uglifyjs static/prestyle.js static/theme_button.js static/search_facade_tinysearch.js static/email.js static/codecopy.js -c -m -o static/abridge-bundle-tinysearch.min.js",
- "abridge": "npm run search-bundle && npm run sha256 && npm run sha384 && npm run abridge-bundle",
+ "abridge": "npm run search-bundle && npm run sha256 && npm run sha384 && npm run abridge-bundle && npm run abridge-bundle-noswitcher",
"abridge-demo": "npm run search-bundle && npm run sha256-demo && npm run sha384-demo && npm run abridge-bundle-demo",
"abridge-stork": "npm run search-bundle-stork && npm run sha256-stork && npm run sha384-stork && npm run abridge-bundle-stork",
"abridge-tinysearch": "npm run search-bundle-tinysearch && npm run sha256-tinysearch && npm run sha384-tinysearch && npm run abridge-bundle-tinysearch",
diff --git a/static/abridge.min.js b/static/abridge.min.js
new file mode 100644
index 0000000..17c6ce2
--- /dev/null
+++ b/static/abridge.min.js
@@ -0,0 +1 @@
+const items=document.querySelectorAll(".preStyle");items.forEach(e=>{e.rel="stylesheet"}),window.onload=function(){document.getElementById("searchinput").onclick=function(){var e=document.querySelector("meta[name='base']").getAttribute("content"),t=("/"==e.slice(-1)&&(e=e.slice(0,-1)),document.createElement("script"));t.src=e+"/search_bundle.min.js?h=76e65002d7da460de8f632427edc6d7d78332c34253012931b71179995418c35",t.setAttribute("integrity","sha384-sFalNeH0DxM4NNZpgi1nVlggG/Q0VN3CcRufOgPOXLtpmfWbJFYQ7cVkFkBnLTsw"),document.head.appendChild(t),document.getElementById("searchinput").onclick=""}},function(){for(var e=document.getElementsByClassName("m-protected"),t=0;t<e.length;t++){var n=e[t].getAttribute("href"),n=atob(n.substring(1));e[t].href="mailto:"+n}}(),function(){function t(e){const t=document.createElement("button");t.className="cc ",t.type="button",t.innerHTML="Copy",t.addEventListener("click",()=>async function(e,t){var n=t.querySelectorAll("table")["length"];let c="";0<n?t.querySelectorAll(":last-child > tr > td:last-child").forEach(e=>{c+=e.innerText}):c=t.querySelector(":last-child > code").innerText;try{"granted"==(result=await navigator.permissions.query({name:"clipboard-write"})).state||"prompt"==result.state?await navigator.clipboard.writeText(c):a(c,t)}catch(e){a(c,t)}finally{e.innerHTML="Copied",setTimeout(function(){e.innerHTML="Copy"},2e3)}}(t,e));var n=document.createElement("div");n.className="ccw",n.appendChild(t),e.parentNode.insertBefore(n,e),n.appendChild(e)}function a(e,t){var n=document.createElement("textArea"),e=(n.contentEditable="true",n.readOnly="false",n.className="copyable-text-area",n.value=e,t.insertBefore(n,t.firstChild),document.createRange()),c=(e.selectNodeContents(n),window.getSelection());c.removeAllRanges(),c.addRange(e),n.setSelectionRange(0,999999),document.execCommand("copy"),t.removeChild(n)}document.querySelectorAll("pre").forEach(e=>t(e))}(); \ No newline at end of file
diff --git a/templates/macros/head.html b/templates/macros/head.html
index d778fce..880e005 100644
--- a/templates/macros/head.html
+++ b/templates/macros/head.html
@@ -95,7 +95,13 @@
{%- elif config.extra.search_library == "stork" %}
<script defer src="{{ get_url(path='abridge-bundle-stork.min.js', trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_file_hash(path='abridge-bundle-stork.min.js', sha_type=384, base64=true) | safe }}"{%- endif %}></script>
{%- else %}
+
+ {%- if config.extra.js_switcher %}
<script defer src="{{ get_url(path='abridge-bundle.min.js', trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_file_hash(path='abridge-bundle.min.js', sha_type=384, base64=true) | safe }}"{%- endif %}></script>
+ {%- else %}
+ <script defer src="{{ get_url(path='abridge.min.js', trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_file_hash(path='abridge.min.js', sha_type=384, base64=true) | safe }}"{%- endif %}></script>
+ {%- endif %}
+
{%- endif %}