Skip to content

Commit

Permalink
It didn't work!
Browse files Browse the repository at this point in the history
  • Loading branch information
cjburkey01 committed Aug 8, 2024
1 parent b2c9181 commit d42d386
Show file tree
Hide file tree
Showing 2 changed files with 369 additions and 57 deletions.
58 changes: 1 addition & 57 deletions theme/index.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE HTML>
<html lang="{{ language }}" class="sidebar-visible no-js {{ default_theme }}" dir="{{ text_direction }}">
<html lang="{{ language }}" class="sidebar-visible no-js {{ default_theme }}">
<head>
<!-- Book generated using mdBook -->
<meta charset="UTF-8">
Expand Down Expand Up @@ -138,62 +138,6 @@
<h1 class="menu-title">{{ book_title }}</h1>

<div class="right-buttons">
<button id="language-toggle" class="icon-button" type="button"
title="Change language" aria-label="Change language"
aria-haspopup="true" aria-expanded="false"
aria-controls="language-list">
<i class="fa fa-globe"></i>
</button>
<ul id="language-list" class="theme-popup" aria-label="Languages" role="menu">
<li role="none"><button role="menuitem" class="theme">
<a id="en">English</a>
</button></li>
<!--<li role="none"><button role="menuitem" class="theme">
<a id="de">Deutsch</a>
</button></li>-->
</ul>

<script>
let langToggle = document.getElementById("language-toggle");
let langList = document.getElementById("language-list");
langToggle.addEventListener("click", (event) => {
langList.style.display = langList.style.display == "block" ? "none" : "block";
});
let selectedLang = document.getElementById("{{ language }}");
if (selectedLang) {
selectedLang.parentNode.classList.add("theme-selected");
}
// The path to the root, taking the current
// language into account.
{{#if (eq language "en")}}
let full_path_to_root = "{{ path_to_root }}";
{{else}}
let full_path_to_root = "{{ path_to_root }}../";
{{/if}}
// The page path (mdbook only gives us
// access to the path to the Markdown file).
let path = "{{ path }}".replace(/\.md$/, ".html");
for (let lang of langList.querySelectorAll("a")) {
if (lang.id == "en") {
lang.href = `${full_path_to_root}${path}`;
} else {
lang.href = `${full_path_to_root}${lang.id}/${path}`;
}
}
// When the user clicks a list item, the page jump is performed, just like clicking the internal <a> tag.
langList.querySelectorAll("li").forEach(function(li) {
li.addEventListener("click", function(event) {
event.preventDefault();
let link = this.querySelector("a");
if (link && window.location.href !== link.href) {
window.location.href = link.href;
}
});
});
</script>

{{#if print_enable}}
<a href="{{ path_to_root }}print.html" title="Print this book" aria-label="Print this book">
<i id="print-button" class="fa fa-print"></i>
Expand Down
Loading

0 comments on commit d42d386

Please sign in to comment.