mirror of
				https://github.com/Wonderfall/hugo-WonderMod.git
				synced 2025-10-30 19:35:26 +01:00 
			
		
		
		
	remove unnecessary js
This commit is contained in:
		| @@ -7,6 +7,7 @@ | |||||||
| html { | html { | ||||||
|     -webkit-tap-highlight-color: transparent; |     -webkit-tap-highlight-color: transparent; | ||||||
|     overflow-y: scroll; |     overflow-y: scroll; | ||||||
|  |     scroll-behavior: smooth; | ||||||
| } | } | ||||||
|  |  | ||||||
| a, | a, | ||||||
|   | |||||||
| @@ -1,45 +1,17 @@ | |||||||
| import * as params from '@params'; | import * as params from '@params'; | ||||||
|  |  | ||||||
| function initializeMenu() { |  | ||||||
|     let menu = document.getElementById('menu') |  | ||||||
|     if (menu) { |  | ||||||
|         menu.scrollLeft = localStorage.getItem("menu-scroll-position"); |  | ||||||
|         menu.onscroll = function () { |  | ||||||
|             localStorage.setItem("menu-scroll-position", menu.scrollLeft); |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     document.querySelectorAll('a[href^="#"]').forEach(anchor => { |  | ||||||
|         anchor.addEventListener("click", function (e) { |  | ||||||
|             e.preventDefault(); |  | ||||||
|             var id = this.getAttribute("href").substr(1); |  | ||||||
|             if (!window.matchMedia('(prefers-reduced-motion: reduce)').matches) { |  | ||||||
|                 document.querySelector(`[id='${decodeURIComponent(id)}']`).scrollIntoView({ |  | ||||||
|                     behavior: "smooth" |  | ||||||
|                 }); |  | ||||||
|             } else { |  | ||||||
|                 document.querySelector(`[id='${decodeURIComponent(id)}']`).scrollIntoView(); |  | ||||||
|             } |  | ||||||
|             if (id === "top") { |  | ||||||
|                 history.replaceState(null, null, " "); |  | ||||||
|             } else { |  | ||||||
|                 history.pushState(null, null, `#${id}`); |  | ||||||
|             } |  | ||||||
|         }); |  | ||||||
|     }); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| function scrollToTop() { | function scrollToTop() { | ||||||
|     var mybutton = document.getElementById("top-link"); |     var topButton = document.getElementById("top-link"); | ||||||
|     window.onscroll = function () { |  | ||||||
|         if (document.body.scrollTop > 800 || document.documentElement.scrollTop > 800) { |     document.addEventListener('scroll', () => { | ||||||
|             mybutton.style.visibility = "visible"; |         if (document.body.scrollTop > 600 || document.documentElement.scrollTop > 600) { | ||||||
|             mybutton.style.opacity = "1"; |             topButton.style.visibility = "visible"; | ||||||
|  |             topButton.style.opacity = "1"; | ||||||
|         } else { |         } else { | ||||||
|             mybutton.style.visibility = "hidden"; |             topButton.style.visibility = "hidden"; | ||||||
|             mybutton.style.opacity = "0"; |             topButton.style.opacity = "0"; | ||||||
|         } |         } | ||||||
|     }; |     }) | ||||||
| } | } | ||||||
|  |  | ||||||
| function themeToggle() { | function themeToggle() { | ||||||
| @@ -107,6 +79,8 @@ function showCodeCopyButtons() { | |||||||
| function openToc() { | function openToc() { | ||||||
|     var toc = document.getElementById("toc"); |     var toc = document.getElementById("toc"); | ||||||
|  |  | ||||||
|  |     if (!toc) return; | ||||||
|  |  | ||||||
|     if (window.innerWidth > 1500 && window.innerHeight > 800) { |     if (window.innerWidth > 1500 && window.innerHeight > 800) { | ||||||
|         toc.open = true; |         toc.open = true; | ||||||
|     } |     } | ||||||
| @@ -115,6 +89,8 @@ function openToc() { | |||||||
| function progressBar() { | function progressBar() { | ||||||
|     var bar = document.getElementById("progressBar"); |     var bar = document.getElementById("progressBar"); | ||||||
|  |  | ||||||
|  |     if (!bar) return; | ||||||
|  |  | ||||||
|     document.addEventListener('scroll', () => { |     document.addEventListener('scroll', () => { | ||||||
|         var scrollPercent = document.documentElement.scrollTop / (document.documentElement.scrollHeight - window.innerHeight) * 100; |         var scrollPercent = document.documentElement.scrollTop / (document.documentElement.scrollHeight - window.innerHeight) * 100; | ||||||
|         if (scrollPercent >= 99) { scrollPercent = 0 }; |         if (scrollPercent >= 99) { scrollPercent = 0 }; | ||||||
| @@ -122,9 +98,9 @@ function progressBar() { | |||||||
|     }) |     }) | ||||||
| } | } | ||||||
|  |  | ||||||
| initializeMenu(); |  | ||||||
| if (params.scrollToTop) scrollToTop(); | if (params.scrollToTop) scrollToTop(); | ||||||
| if (params.themeToggle) themeToggle(); | if (params.themeToggle) themeToggle(); | ||||||
| if (params.showCodeCopyButtons) showCodeCopyButtons(); | if (params.showCodeCopyButtons) showCodeCopyButtons(); | ||||||
| if (document.getElementById("toc")) openToc(); | openToc(); | ||||||
| if (document.getElementById("progressBar")) progressBar(); | progressBar(); | ||||||
		Reference in New Issue
	
	Block a user
	 Wonderfall
					Wonderfall