mirror of
https://github.com/tauri-apps/tauri-docs.git
synced 2026-01-31 00:35:16 +01:00
* merge conflicts resolved * fix: link validation * fix: ordering * fix: js renamed to javascript * fix: removed accidentally committed generated files * fix: removed tauri * fix: added tauri * fix: releases should only be built in prod
45 lines
1.3 KiB
JavaScript
45 lines
1.3 KiB
JavaScript
async function chapterNavigation() {
|
|
let navigating = false
|
|
document.addEventListener("keydown", function (e) {
|
|
if (navigating) return
|
|
if (e.altKey || e.ctrlKey || e.metaKey) {
|
|
return;
|
|
}
|
|
if (window.search && document.activeElement === window.search) {
|
|
return;
|
|
}
|
|
|
|
switch (e.key) {
|
|
case "ArrowLeft":
|
|
e.preventDefault();
|
|
let previousButton = document.querySelector('a[rel="prev"]');
|
|
if (!previousButton && window.location.pathname !== '/') previousButton = { href: '/' }
|
|
|
|
if (document.referrer.includes(window.location.host))
|
|
if (previousButton) {
|
|
window.location.href = previousButton.href;
|
|
navigating = true;
|
|
}
|
|
break;
|
|
case "ArrowRight":
|
|
e.preventDefault();
|
|
let nextButton = document.querySelector('a[rel="next"]');
|
|
if (!nextButton && window.location.pathname === '/') nextButton = { href: "/start/" }
|
|
|
|
if (nextButton) {
|
|
window.location.href = nextButton.href;
|
|
navigating = true;
|
|
}
|
|
break;
|
|
}
|
|
});
|
|
};
|
|
|
|
window.addEventListener('DOMContentLoaded', () => {
|
|
chapterNavigation()
|
|
})
|
|
|
|
window.onload = function () {
|
|
document.body.setAttribute('tabindex', '-1');
|
|
document.body.focus();
|
|
}; |