Skip to content

Commit

Permalink
Merge pull request #9 from KSaiAkshit/master
Browse files Browse the repository at this point in the history
Added Keybindings
  • Loading branch information
plutoniumm authored Aug 12, 2021
2 parents 258740c + 549b7c4 commit 2f4ddc6
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 1 deletion.
3 changes: 2 additions & 1 deletion _layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<script type="text/javascript" src="{{ '/assets/js/lunr.min.js' | relative_url }}"></script>
{% endif %}
<script type="text/javascript" src="{{ '/assets/js/just-the-docs.js' | relative_url }}"></script>
<script type="text/javascript" src="{{ '/assets/js/keyboard_bind.js' | relative_url }}"></script>
<meta name="viewport" content="width=device-width, initial-scale=1">
{% seo %}
</head>
Expand Down Expand Up @@ -207,4 +208,4 @@ <h2 class="text-delta">Table of contents</h2>
</div>
</body>

</html>
</html>
77 changes: 77 additions & 0 deletions assets/js/keyboard_bind.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
const currentAddress = window.location.pathname;

const Address = [
"/", //Home
"/docs/General/general/", //General
"/docs/General/Security/",
"/docs/General/Javascript/",
"/docs/General/Styles/",
"/docs/General/css/",
"/docs/Korolev/korolev/", //Korolev
"/docs/Korolev/atomic/",
"/docs/Korolev/data/",
"/docs/Korolev/file-tree/",
"/docs/Edu/edu/", //Edu
"/docs/Thales/thales/", //Thales
"/docs/Thales/configuration/",
"/docs/Thales/ui-components/",
"/docs/Thales/navigation-structure/",
"/docs/Thales/layout-typo/",
"/docs/Thales/modifiers-color/",
];
console.log(currentAddress);

var index = Address.indexOf(currentAddress);
console.log(index);



window.addEventListener("keyup", function (event) {
event.preventDefault;
switch (true) {
case event.key === "k":
if (index === Address.length - 1) {
void 0;
} else {
index++;
}
window.location.replace(Address[index]);
console.log(index);

break;
case event.key === "j":
if (index <= 0) {
index = 0;
}
if (index > 0) {
index--;
}
window.location.replace(Address[index]);
console.log(index);

break;
case event.key === "1":
window.location.replace(Address[0]);
break;
case event.key === "2":
window.location.replace(Address[1]);
break;
case event.key === "3":
window.location.replace(Address[6]);
break;
case event.key === "4":
window.location.replace(Address[10]);
break;
case event.key === "5":
window.location.replace(Address[11]);
break;

case event.key === "/":
const search = document.querySelector(".search-input");
search.focus();
break;

default:
void 0;
}
});

0 comments on commit 2f4ddc6

Please sign in to comment.