move scripts into js files

This commit is contained in:
Mylloon 2023-04-24 16:18:54 +02:00
parent 40f038bfb9
commit f6dfb9950c
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
8 changed files with 61 additions and 60 deletions

9
static/js/libs/hljs.js Normal file
View file

@ -0,0 +1,9 @@
window.addEventListener("load", () => {
hljs.configure({
noHighlightRe: /^$/i,
languageDetectRe: /\blanguage-hljs-([\w-]+)\b/i,
});
hljs.addPlugin(new CopyButtonPlugin());
hljs.highlightAll();
});

14
static/js/libs/jspdf.js Normal file
View file

@ -0,0 +1,14 @@
window.addEventListener("DOMContentLoaded", () => {
const { jsPDF } = window.jspdf;
const doc = new jsPDF();
doc.html(document.body, {
width: doc.internal.pageSize.getWidth() - 20,
windowWidth: 800,
margin: [15, 10, 10, 10],
callback: function (doc) {
doc.save(`${document.title}.pdf`);
},
});
});

26
static/js/libs/katex.js Normal file
View file

@ -0,0 +1,26 @@
window.addEventListener("load", () => {
const macros = {};
for (const item of new Map(
Object.entries({
N: "mathbb{N}",
R: "mathbb{R}",
Z: "mathbb{Z}",
O: "Theta",
ra: "rightarrow",
la: "leftarrow",
RA: "Rightarrow",
LA: "Leftarrow",
})
)[Symbol.iterator]()) {
macros[`\\${item[0]}`] = `\\${item[1]}`;
}
renderMathInElement(document.body, {
delimiters: [
{ left: "$$", right: "$$", display: true },
{ left: "$", right: "$", display: false },
],
throwOnError: false,
macros,
});
});

View file

@ -0,0 +1,8 @@
import mermaid from "https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs";
window.addEventListener("load", async () => {
mermaid.initialize({ startOnLoad: false });
await mermaid.run({
querySelector: ".language-mermaid",
});
});

View file

@ -1,11 +1,3 @@
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/highlight.min.js"></script>
<script src="//unpkg.com/highlightjs-copy/dist/highlightjs-copy.min.js"></script>
<script>
hljs.configure({
noHighlightRe: /^$/i,
languageDetectRe: /\blanguage-hljs-([\w-]+)\b/i,
});
hljs.addPlugin(new CopyButtonPlugin());
hljs.highlightAll();
</script>
<script src="/js/libs/hljs.js"></script>

View file

@ -5,19 +5,4 @@
crossorigin="anonymous"
referrerpolicy="no-referrer"
></script>
<script>
window.addEventListener("DOMContentLoaded", () => {
const { jsPDF } = window.jspdf;
const doc = new jsPDF();
doc.html(document.body, {
width: doc.internal.pageSize.getWidth() - 20,
windowWidth: 800,
margin: [15, 10, 10, 10],
callback: function (doc) {
doc.save(`${document.title}.pdf`);
},
});
});
</script>
<script src="/js/libs/jspdf.js"></script>

View file

@ -10,31 +10,4 @@
integrity="sha384-+VBxd3r6XgURycqtZ117nYw44OOcIax56Z4dCRWbxyPt0Koah1uHoK0o4+/RRE05"
crossorigin="anonymous"
></script>
<script>
window.addEventListener("load", () => {
const macros = {};
for (const item of new Map(
Object.entries({
N: "mathbb{N}",
R: "mathbb{R}",
Z: "mathbb{Z}",
O: "Theta",
ra: "rightarrow",
la: "leftarrow",
RA: "Rightarrow",
LA: "Leftarrow",
})
)[Symbol.iterator]()) {
macros[`\\${item[0]}`] = `\\${item[1]}`;
}
renderMathInElement(document.body, {
delimiters: [
{ left: "$$", right: "$$", display: true },
{ left: "$", right: "$", display: false },
],
throwOnError: false,
macros,
});
});
</script>
<script src="/js/libs/katex.js"></script>

View file

@ -1,7 +1 @@
<script type="module">
import mermaid from "https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs";
mermaid.initialize({ startOnLoad: false });
await mermaid.run({
querySelector: ".language-mermaid",
});
</script>
<script type="module" src="/js/libs/mermaid.js"></script>