Files
katenary/doc/docs/statics/addons.js

49 lines
1.4 KiB
JavaScript
Raw Normal View History

2024-04-10 04:48:51 +02:00
// Install the highlight.js in the documentation. Then
// highlight all the source code.
2022-06-14 09:25:43 +02:00
function hljsInstall() {
2024-04-10 04:48:51 +02:00
const version = "11.9.0";
2022-06-14 09:25:43 +02:00
const theme = "github-dark";
const script = document.createElement("script");
script.src = `//cdnjs.cloudflare.com/ajax/libs/highlight.js/${version}/highlight.min.js`;
script.onload = () => {
const style = document.createElement("link");
style.rel = "stylesheet";
style.href = `//cdnjs.cloudflare.com/ajax/libs/highlight.js/${version}/styles/${theme}.min.css`;
document.head.appendChild(style);
2022-06-14 10:08:22 +02:00
hljs.highlightAll();
2022-06-14 09:25:43 +02:00
};
document.head.appendChild(script);
}
2024-04-10 04:48:51 +02:00
// All images in an .zoomable div is zoomable, that
// meanse that we can click to zoom and unzoom.
// This needs specific CSS (see main.css).
function makeImagesZoomable() {
const zone = document.querySelectorAll(".zoomable");
zone.forEach((z, i) => {
const im = z.querySelectorAll("img,svg");
2024-04-10 04:48:51 +02:00
if (im.length == 0) {
return;
}
const input = document.createElement("input");
input.setAttribute("type", "checkbox");
input.setAttribute("id", `image-zoom-${i}`);
z.appendChild(input);
const label = document.createElement("label");
label.setAttribute("for", `image-zoom-${i}`);
z.appendChild(label);
label.appendChild(im[0]);
});
}
2022-06-13 13:18:31 +02:00
document.addEventListener("DOMContentLoaded", () => {
2022-06-14 09:25:43 +02:00
hljsInstall();
2024-04-10 04:48:51 +02:00
makeImagesZoomable();
2022-06-13 13:18:31 +02:00
});