diff --git a/assets/js/detectOS.js b/assets/js/detectOS.js deleted file mode 100644 index 4224834..0000000 --- a/assets/js/detectOS.js +++ /dev/null @@ -1,37 +0,0 @@ -export function detectOS(userAgent) { - const userAgentLower = userAgent.toLowerCase(); - - // Detect macOS - if ( - userAgentLower.indexOf("macintosh") !== -1 || - userAgentLower.indexOf("mac os x") !== -1 - ) { - return "macOS"; - } - - // Detect Windows - if (userAgentLower.indexOf("windows") !== -1) { - return "Windows"; - } - - // Detect Linux - if (userAgentLower.indexOf("linux") !== -1) { - return "Linux"; - } - - // Detect iOS - if (/iphone|ipad|ipod/i.test(userAgent)) { - return "iOS"; - } - - // Detect Android - if (/android/i.test(userAgent)) { - return "Android"; - } - - return "Unknown"; -} - -export function isMobile(userAgent) { - return detectOS(userAgent) === "iOS" || detectOS(userAgent) === "Android"; -} diff --git a/assets/js/hotkeys.js b/assets/js/hotkeys.js index 75a83f9..c207914 100644 --- a/assets/js/hotkeys.js +++ b/assets/js/hotkeys.js @@ -9,19 +9,22 @@ document.addEventListener("DOMContentLoaded", function () { userAgent.toLowerCase().indexOf("macintosh") !== -1 || userAgent.toLowerCase().indexOf("mac os x") !== -1; - // setup to search - const searchIcon = document.querySelector("button.search__toggle"); - if (searchIcon) { - if (!isMobile) { + if (!isMobile) { + // setup to search + const searchIcon = document.querySelector("button.search__toggle"); + if (searchIcon) { searchIcon.setAttribute("tooltip", "cmd/ctrl + k to open, esc to close"); searchIcon.setAttribute("tooltip-position", "left"); setupSearchHotkeys(searchIcon, isMac); } - } - - // Register focus hotkeys - setupFocusHotkeys(); + // Register focus hotkeys + setupFocusHotkeys(); - // Setup hotkeys popover hotkeys - setupHotkeysPopoverHotkeys(); + // Setup hotkeys popover hotkeys + setupHotkeysPopoverHotkeys(); + } else { + // Hide hotkeys popover on mobile + const hotkeysPopover = document.getElementById("hotkeys-popover"); + hotkeysPopover.style.display = "none"; + } });