summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rw-r--r--js/xengineering.js71
1 files changed, 0 insertions, 71 deletions
diff --git a/js/xengineering.js b/js/xengineering.js
deleted file mode 100644
index d82db88..0000000
--- a/js/xengineering.js
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
-vim: shiftwidth=2 tabstop=2 expandtab
-
-libweb - reusable code for websites
-
- Copyright (C) 2021 xengineering
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <https://www.gnu.org/licenses/>.
-
-contact via mail: me@xengineering.eu
-*/
-
-// define menu state
-const MenuState = {
- Desktop: "Desktop",
- MobileCollapsed: "MobileCollapsed",
- MobileExpanded: "MobileExpanded"
-}
-var state;
-
-// init menu state and add mediaChange handler
-var isMobile = window.matchMedia("(max-aspect-ratio: 14/9)");
-mediaChange(isMobile);
-isMobile.addListener(mediaChange)
-
-function mediaChange(isMobile) {
- if (isMobile.matches) {
- state = MenuState.MobileCollapsed;
- handleState(state);
- } else {
- state = MenuState.Desktop;
- handleState(state);
- }
-}
-
-function toggleMenu() {
- switch (state) {
- case MenuState.MobileCollapsed:
- state = MenuState.MobileExpanded;
- handleState(state);
- break;
- case MenuState.MobileExpanded:
- state = MenuState.MobileCollapsed;
- handleState(state);
- break;
- }
-}
-
-function handleState(state) {
- var items = document.getElementsByTagName("a");
- for(var i=0; i<items.length; i++) {
- if (items[i].parentNode.tagName == "NAV") {
- if (state == MenuState.MobileCollapsed) {
- items[i].style.display = "none";
- } else {
- items[i].style.display = "block";
- }
- }
- }
-}