pages/assets/js/common.js
Maruan beb6f27d59
format code with prettier.io (#2048)
summary:
- adds prettier formatter configuration
- formats the entire repo using prettier, ignoring minified files
(`*.min.css`) and heavy generated html
- changes extensions of all `.html` files to `.liquid`, which is more
correct and necessary for prettier to work correctly
- replaces "%-" and "-%" with just "%" — manual liquid formatting using
minus signs is superfluous since we are compressing and minifying the
code anyway
- adds CI action for running prettier check on PR and pushes to master
2024-01-10 00:10:51 -05:00

50 lines
1.5 KiB
JavaScript

$(document).ready(function () {
// add toggle functionality to abstract and bibtex buttons
$("a.abstract").click(function () {
$(this).parent().parent().find(".abstract.hidden").toggleClass("open");
$(this).parent().parent().find(".bibtex.hidden.open").toggleClass("open");
});
$("a.bibtex").click(function () {
$(this).parent().parent().find(".bibtex.hidden").toggleClass("open");
$(this).parent().parent().find(".abstract.hidden.open").toggleClass("open");
});
$("a").removeClass("waves-effect waves-light");
// bootstrap-toc
if ($("#toc-sidebar").length) {
var navSelector = "#toc-sidebar";
var $myNav = $(navSelector);
Toc.init($myNav);
$("body").scrollspy({
target: navSelector,
});
}
// add css to jupyter notebooks
const cssLink = document.createElement("link");
cssLink.href = "../css/jupyter.css";
cssLink.rel = "stylesheet";
cssLink.type = "text/css";
let theme = localStorage.getItem("theme");
if (theme == null || theme == "null") {
const userPref = window.matchMedia;
if (userPref && userPref("(prefers-color-scheme: dark)").matches) {
theme = "dark";
}
}
$(".jupyter-notebook-iframe-container iframe").each(function () {
$(this).contents().find("head").append(cssLink);
if (theme == "dark") {
$(this).bind("load", function () {
$(this).contents().find("body").attr({
"data-jp-theme-light": "false",
"data-jp-theme-name": "JupyterLab Dark",
});
});
}
});
});