summaryrefslogtreecommitdiff
path: root/assets/js
diff options
context:
space:
mode:
authoreltrac <hi@eltr.ac>2026-04-07 14:53:17 +0800
committereltrac <hi@eltr.ac>2026-04-07 14:53:17 +0800
commit10431bd8f5ff71690ae4e5444e8d7894fd401ae5 (patch)
tree62b7fd1b6c1f68d2804f380eb522bcebeb2c8d9f /assets/js
parent3e0edacc4a0cafa53ede57ebb6f0378c93f3123b (diff)
chore: move templates out of site repo
Diffstat (limited to 'assets/js')
-rw-r--r--assets/js/back2top.js60
-rw-r--r--assets/js/darkmode.js36
-rw-r--r--assets/js/fediform.js42
-rw-r--r--assets/js/instantpage.min.js2
-rw-r--r--assets/js/toc.js40
-rw-r--r--assets/js/tooltip.js54
6 files changed, 0 insertions, 234 deletions
diff --git a/assets/js/back2top.js b/assets/js/back2top.js
deleted file mode 100644
index 6d7501e1..00000000
--- a/assets/js/back2top.js
+++ /dev/null
@@ -1,60 +0,0 @@
-// Back2top, the Batrick
-// author: Eltrac
-
-const backToTop = document.getElementById("back2top")
-const backToTopButton = document.getElementById("back2top-button")
-const backToTopInstruction = document.getElementById("back2top-instruction")
-const seenAndUsedBat = localStorage.getItem("geedeapro.ui.seenAndUsedBat")
-
-if (backToTopInstruction && backToTopButton) {
- function hideInstruction() {
- backToTopInstruction.remove()
- }
- if (seenAndUsedBat) hideInstruction()
-
- // listen to button click and scroll to top
- backToTopButton.addEventListener("click", () => {
- window.scrollTo({ top: 0, behavior: "smooth" })
- if (!seenAndUsedBat) {
- localStorage.setItem("geedeapro.ui.seenAndUsedBat", true);
- hideInstruction();
- }
- })
-
- // listen to scroll and toggle button visibility
- let lastOffset = window.scrollY
-
- window.addEventListener("scroll", () => {
- const offset = window.scrollY
- const batIsHidden = backToTop.classList.contains("-top-25")
- const enoughHeight = offset >= 2000
- const isScrollingUp = offset < lastOffset
- const isScrollingDown = offset > lastOffset
-
- function hide() {
- backToTop.classList.remove("top-0")
- backToTop.classList.add("-top-25")
- backToTop.classList.remove("animate-head-shake")
- }
-
- function show() {
- backToTop.classList.remove("-top-25")
- backToTop.classList.add("top-0")
- backToTop.classList.add("animate-head-shake")
- }
-
- if (enoughHeight && isScrollingUp && batIsHidden) {
- // show only when scrolling up
- show()
- } else if (isScrollingDown && !batIsHidden) {
- // hide as soon as user scrolls down again
- hide()
- }
-
- // hide no matter what if too close to top
- if (!enoughHeight) hide()
-
- lastOffset = offset
- })
-}
-
diff --git a/assets/js/darkmode.js b/assets/js/darkmode.js
deleted file mode 100644
index 6057f357..00000000
--- a/assets/js/darkmode.js
+++ /dev/null
@@ -1,36 +0,0 @@
-(() => {
- const THEME = 'geedeapro.theme' // auto | light | dakr
- const mql = window.matchMedia('(prefers-color-scheme: dark)')
-
- function useDarkMode(store) {
- document.documentElement.classList.add('dark')
- if (localStorage.getItem(THEME) != 'auto') mql.onchange = null
- if (store) localStorage.setItem(THEME, 'dark')
- }
-
- function useLightMode(store) {
- document.documentElement.classList.remove('dark')
- if (localStorage.getItem(THEME) != 'auto') mql.onchange = null
- if (store) localStorage.setItem(THEME, 'light')
- }
-
- function useSystem(store) {
- if (mql.matches) useDarkMode()
- else useLightMode()
- mql.onchange = e => {
- console.log("changed when system changed")
- if (e.matches) useDarkMode()
- else useLightMode()
- }
- if (store) localStorage.setItem(THEME, 'auto')
- }
-
- window.switchTheme = (theme, store) => {
- if (!theme || theme === 'auto') useSystem(store)
- else if (theme === 'dark') useDarkMode(store)
- else if (theme === 'light') useLightMode(store)
- }
-
- // use preferred theme immediately upon DOM loaded
- window.switchTheme(localStorage.getItem(THEME), false)
-})();
diff --git a/assets/js/fediform.js b/assets/js/fediform.js
deleted file mode 100644
index 30c2815c..00000000
--- a/assets/js/fediform.js
+++ /dev/null
@@ -1,42 +0,0 @@
-document.addEventListener("DOMContentLoaded", () => {
- // open toot in fediverse
- const instanceInput = document.getElementById('fediverse-instance')
- if (instanceInput) {
- const savedInstance = localStorage.getItem("geedeapro.fediInstance")
- if (savedInstance) instanceInput.value = savedInstance
-
- function openInFediverse() {
- const instance = instanceInput.value.trim();
-
- let url = tootUrl
- if (instance) {
- url = 'https://' + instance + '/authorize_interaction?uri=' + encodeURIComponent(tootUrl);
- // save instance url to localStorage
- localStorage.setItem("geedeapro.fediInstance", instance)
- }
- window.open(url, '_blank');
- }
-
- const fediformButton = document.getElementById('fediform-button');
- fediformButton.addEventListener("click", openInFediverse)
-
- instanceInput.addEventListener('keypress', function(event) {
- if (event.key === 'Enter') {
- event.preventDefault();
- openInFediverse();
- }
- });
- }
-
-
- // copy toot link:
- const copyBtn = document.getElementById("fediform-copy-button")
- if (copyBtn) {
- function copyTootLink() {
- navigator.clipboard.writeText(tootUrl)
- copyBtn.innerText = 'βœ…'
- setTimeout(() => copyBtn.innerText = 'πŸ“‹', 3000)
- }
- copyBtn.addEventListener("click", copyTootLink)
- }
-})
diff --git a/assets/js/instantpage.min.js b/assets/js/instantpage.min.js
deleted file mode 100644
index 761f9d34..00000000
--- a/assets/js/instantpage.min.js
+++ /dev/null
@@ -1,2 +0,0 @@
-/*! instant.page v5.2.0 - (C) 2019-2025 Alexandre Dieulot - https://instant.page/license */
-let t,e,n,o,i,r,a=null,s=65,c=new Set;function u(t){i=t;const e=t.target.closest("a");g(e)&&v(e.href,"high")}function d(t){i=t}function l(t){if(h(t))return;if(!("closest"in t.target))return;const e=t.target.closest("a");g(e)&&(e.addEventListener("mouseout",p,{passive:!0}),r=setTimeout(()=>{v(e.href,"high"),r=null},s))}function f(t){if(h(t))return;const e=t.target.closest("a");g(e)&&v(e.href,"high")}function p(t){t.relatedTarget&&t.target.closest("a")==t.relatedTarget.closest("a")||r&&(clearTimeout(r),r=null)}function m(t){if(h(t))return;const e=t.target.closest("a");if(t.which>1||t.metaKey||t.ctrlKey)return;if(!e)return;e.addEventListener("click",function(t){1337!=t.detail&&t.preventDefault()},{capture:!0,passive:!1,once:!0});const n=new MouseEvent("click",{view:window,bubbles:!0,cancelable:!1,detail:1337});e.dispatchEvent(n)}function h(t){if(!i||!t)return!1;if(t.target!=i.target)return!1;return t.timeStamp-i.timeStamp<2500}function g(t){if(t&&t.href&&(!o||"instant"in t.dataset)){if(t.origin!=location.origin){if(!(n||"instant"in t.dataset)||!a)return}if(["http:","https:"].includes(t.protocol)&&("http:"!=t.protocol||"https:"!=location.protocol)&&(e||!t.search||"instant"in t.dataset)&&!(t.hash&&t.pathname+t.search==location.pathname+location.search||"noInstant"in t.dataset))return!0}}function v(e,n="auto"){c.has(e)||("none"!=t?function(e){const n=document.createElement("script");n.type="speculationrules",n.textContent=JSON.stringify({[t]:[{source:"list",urls:[e]}]}),document.head.appendChild(n)}(e):function(t,e="auto"){const n=document.createElement("link");n.rel="prefetch",n.href=t,n.fetchPriority=e,n.as="document",document.head.appendChild(n)}(e,n),c.add(e))}!function(){const i=document.createElement("link").relList;if(!i.supports("prefetch"))return;const r="throwIfAborted"in AbortSignal.prototype,c=i.supports("modulepreload"),p=Intl.PluralRules&&"selectRange"in Intl.PluralRules.prototype;if(!r||!c&&!p)return;const h="instantVaryAccept"in document.body.dataset||"Shopify"in window,y=navigator.userAgent.indexOf("Chrome/");y>-1&&(a=parseInt(navigator.userAgent.substring(y+"Chrome/".length)));if(h&&a&&a<110)return;if(t="none",HTMLScriptElement.supports&&HTMLScriptElement.supports("speculationrules")){const e=document.body.dataset.instantSpecrules;"prerender"==e?t="prerender":"no"!=e&&(t="prefetch")}const w="instantMousedownShortcut"in document.body.dataset;e="instantAllowQueryString"in document.body.dataset,n="instantAllowExternalLinks"in document.body.dataset,o="instantWhitelist"in document.body.dataset;let b=!1,E=!1,S=!1;if("instantIntensity"in document.body.dataset){const t=document.body.dataset.instantIntensity;if("mousedown"!=t||w||(b=!0),"mousedown-only"!=t||w||(b=!0,E=!0),"viewport"==t){const t=document.documentElement.clientWidth*document.documentElement.clientHeight<45e4,e=navigator.connection&&navigator.connection.saveData,n=navigator.connection&&navigator.connection.effectiveType&&navigator.connection.effectiveType.includes("2g"),o=!e&&!n;t&&o&&(S=!0)}"viewport-all"==t&&(S=!0);const e=parseInt(t);isNaN(e)||(s=e)}const I={capture:!0,passive:!0};E?document.addEventListener("touchstart",d,I):document.addEventListener("touchstart",u,I);b||document.addEventListener("mouseover",l,I);b&&document.addEventListener("mousedown",f,I);w&&document.addEventListener("mousedown",m,I);if(S){let t=window.requestIdleCallback;t||(t=(t=>{t()})),t(function(){const t=new IntersectionObserver(e=>{e.forEach(e=>{if(e.isIntersecting){const n=e.target;t.unobserve(n),v(n.href)}})});document.querySelectorAll("a").forEach(e=>{g(e)&&t.observe(e)})},{timeout:1500})}}(); \ No newline at end of file
diff --git a/assets/js/toc.js b/assets/js/toc.js
deleted file mode 100644
index ec0028db..00000000
--- a/assets/js/toc.js
+++ /dev/null
@@ -1,40 +0,0 @@
-// Animate Hugo-built TOC
-// author: Eltrac
-
-document.addEventListener('DOMContentLoaded', () => {
- const toc = document.getElementById('toc');
- if (!toc) return;
-
- const headings = document.querySelectorAll('h2, h3');
- const observer = new IntersectionObserver(entries => {
- entries.forEach(entry => {
- if (!entry.isIntersecting) return;
-
- const id = entry.target.id;
- const tocLink = toc.querySelector(`a[href="#${id}"]`);
- if (!tocLink) return;
-
- const listItem = tocLink.parentElement;
- const isH2 = entry.target.tagName === 'H2';
-
- // Clear all active states when a new H2 is encountered
- if (isH2) {
- toc.querySelectorAll('li.active').forEach(el => el.classList.remove('active'));
- }
-
- // Set current item as active
- listItem.classList.add('active');
-
- // If this is an H3, find and activate its parent H2
- if (!isH2) {
- const parentH2Item = listItem.closest('ul').previousElementSibling?.closest('li');
- if (parentH2Item) parentH2Item.classList.add('active');
- }
- });
- }, {
- rootMargin: '0px 0px -50% 0px',
- threshold: 0.5
- });
-
- headings.forEach(heading => observer.observe(heading));
-});
diff --git a/assets/js/tooltip.js b/assets/js/tooltip.js
deleted file mode 100644
index eea5b350..00000000
--- a/assets/js/tooltip.js
+++ /dev/null
@@ -1,54 +0,0 @@
-(() => {
- const allTooltipped = document.querySelectorAll('[data-tooltip]');
-
- const createOrUpdateTooltip = (element) => {
- const tooltipText = element.getAttribute('data-tooltip') || element.getAttribute('title');
-
- if (!tooltipText) return;
-
- let tooltipElement = element.querySelector('.__generated-tooltip');
- if (!tooltipElement) {
- element.classList.add('group', 'relative', 'tooltipped');
-
- tooltipElement = document.createElement('div');
- tooltipElement.classList.add(
- '__generated-tooltip',
- ...'absolute bottom-full left-1/2 transform -translate-x-1/2 translate-y-1 bg-black/80 text-white px-2.5 py-1.5 rounded text-xs whitespace-nowrap opacity-0 invisible transition-all duration-300 pointer-events-none mb-2 z-1000 group-hover:opacity-100 group-hover:visible group-hover:translate-y-0 dark:bg-white/90 dark:text-black'.split(' ')
- );
- element.appendChild(tooltipElement);
- }
-
- tooltipElement.textContent = tooltipText;
- };
-
- const observer = new IntersectionObserver((entries, obs) => {
- entries.forEach(entry => {
- if (!entry.isIntersecting) return;
-
- const element = entry.target;
- createOrUpdateTooltip(element);
-
- // listen to tooltip text changes
- const mutationObserver = new MutationObserver(mutations => {
- for (const mutation of mutations) {
- if (mutation.type === 'attributes' &&
- (mutation.attributeName === 'title' || mutation.attributeName === 'data-tooltip')) {
- createOrUpdateTooltip(element);
- }
- }
- });
-
- mutationObserver.observe(element, {
- attributes: true,
- attributeFilter: ['title', 'data-tooltip'],
- });
-
- obs.unobserve(element); // δΈε†ιœ€θ¦ Intersection 监听
- });
- }, {
- rootMargin: '100px',
- threshold: 0.1,
- });
-
- allTooltipped.forEach(el => observer.observe(el));
-})();