// deno-fmt-ignore-file // deno-lint-ignore-file // This code was bundled using `deno bundle` and it's not recommended to edit it manually (function() { const url = self.location.href.split("#")[0]; let settings = { pager: {} }; self.addEventListener("DOMContentLoaded", function() { if (history.scrollRestoration) history.scrollRestoration = "manual"; if (localStorage["settings"]) { settings = JSON.parse(localStorage["settings"]); } if (self.location.href.indexOf("#") >= 0) { settings["pager"][url] = self.pageYOffset; localStorage["settings"] = JSON.stringify(settings); document.getElementById(location.hash.slice(1)).scrollIntoView(); return; } if (settings["pager"][url] > 0) { self.scrollTo(0, settings["pager"][url]); return; } settings["pager"][url] = self.pageYOffset; localStorage["settings"] = JSON.stringify(settings); }); self.addEventListener("scroll", function() { const currentPosition = self.pageYOffset; settings["pager"][url] = currentPosition; localStorage["settings"] = JSON.stringify(settings); }); self.addEventListener("DOMContentLoaded", function() { const up = document.getElementById("top"); const back = document.getElementById("back"); if (document.body.contains(up)) up.href = "javascript: void(0)"; if (document.body.contains(back)) back.href = "javascript: void(0)"; self.addEventListener("click", function(event) { if (document.body.contains(up) && up.contains(event.target)) { window.scrollTo(0, 0); } if (document.body.contains(back) && back.contains(event.target)) { history.go(-1); } }); }); })(); (function() { const options = "targetWindow,width=700,height=500,toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes"; self.addEventListener("keydown", function(event) { if (event.repeat && event.key === "d") { selection(dictionary); } if (event.repeat && event.key === "s") { selection(search); } if (event.repeat && event.key === "m") { selection(manual); } }); function selection(execute) { let phrase = "" + window.getSelection(); phrase = phrase.replace(/[!.:?,;"]/g, ""); phrase = phrase.replace(/^\s*(\S*?)\s*$/g, "$1"); if (phrase && phrase > "" && phrase.length > 1) { execute(phrase); } } function dictionary(word) { window.open("https://www.merriam-webster.com/dictionary/" + encodeURIComponent(word), "Definitions", options); } function search(phrase) { window.open("https://lite.duckduckgo.com/lite/?q=" + encodeURIComponent(phrase), "Search", options); } function manual(program) { window.open("https://man.archlinux.org/search?q=" + encodeURIComponent(program), "Manual", options); } })(); (function() { self.addEventListener("DOMContentLoaded", function() { let mouseoverTimer; let lastTouchTimestamp; const prefetches = new Set(); const prefetchElement = document.createElement("link"); const isSupported = prefetchElement.relList && prefetchElement.relList.supports && prefetchElement.relList.supports("prefetch") && window.IntersectionObserver && "isIntersecting" in IntersectionObserverEntry.prototype; const allowQueryString = "instantAllowQueryString" in document.body.dataset; const allowExternalLinks = "instantAllowExternalLinks" in document.body.dataset; const useWhitelist = "instantWhitelist" in document.body.dataset; const mousedownShortcut = "instantMousedownShortcut" in document.body.dataset; let delayOnHover = 65; let useMousedown = false; let useMousedownOnly = false; let useViewport = false; if ("instantIntensity" in document.body.dataset) { const intensity = document.body.dataset.instantIntensity; if (intensity.substr(0, "mousedown".length) == "mousedown") { useMousedown = true; if (intensity == "mousedown-only") { useMousedownOnly = true; } } else if (intensity.substr(0, "viewport".length) == "viewport") { if (!(navigator.connection && (navigator.connection.saveData || navigator.connection.effectiveType && navigator.connection.effectiveType.includes("2g")))) { if (intensity == "viewport") { if (document.documentElement.clientWidth * document.documentElement.clientHeight < 450000) { useViewport = true; } } else if (intensity == "viewport-all") { useViewport = true; } } } else { const milliseconds = parseInt(intensity); if (!isNaN(milliseconds)) { delayOnHover = milliseconds; } } } if (isSupported) { const eventListenersOptions = { capture: true, passive: true }; if (!useMousedownOnly) { document.addEventListener("touchstart", touchstartListener, eventListenersOptions); } if (!useMousedown) { document.addEventListener("mouseover", mouseoverListener, eventListenersOptions); } else if (!mousedownShortcut) { document.addEventListener("mousedown", mousedownListener, eventListenersOptions); } if (mousedownShortcut) { document.addEventListener("mousedown", mousedownShortcutListener, eventListenersOptions); } if (useViewport) { let triggeringFunction; if (window.requestIdleCallback) { triggeringFunction = function(callback) { requestIdleCallback(callback, { timeout: 1500 }); }; } else { triggeringFunction = function(callback) { callback(); }; } triggeringFunction(function() { const intersectionObserver = new IntersectionObserver(function(entries) { entries.forEach(function(entry) { if (entry.isIntersecting) { const linkElement = entry.target; intersectionObserver.unobserve(linkElement); preload(linkElement.href); } }); }); document.querySelectorAll("a").forEach(function(linkElement) { if (isPreloadable(linkElement)) { intersectionObserver.observe(linkElement); } }); }); } } function touchstartListener(event) { lastTouchTimestamp = performance.now(); const linkElement = event.target.closest("a"); if (!isPreloadable(linkElement)) { return; } preload(linkElement.href); } function mouseoverListener(event) { if (performance.now() - lastTouchTimestamp < 1111) { return; } const linkElement = event.target.closest("a"); if (!isPreloadable(linkElement)) { return; } linkElement.addEventListener("mouseout", mouseoutListener, { passive: true }); mouseoverTimer = setTimeout(function() { preload(linkElement.href); mouseoverTimer = undefined; }, delayOnHover); } function mousedownListener(event) { const linkElement = event.target.closest("a"); if (!isPreloadable(linkElement)) { return; } preload(linkElement.href); } function mouseoutListener(event) { if (event.relatedTarget && event.target.closest("a") == event.relatedTarget.closest("a")) { return; } if (mouseoverTimer) { clearTimeout(mouseoverTimer); mouseoverTimer = undefined; } } function mousedownShortcutListener(event1) { if (performance.now() - lastTouchTimestamp < 1111) { return; } const linkElement = event1.target.closest("a"); if (event1.which > 1 || event1.metaKey || event1.ctrlKey) { return; } if (!linkElement) { return; } linkElement.addEventListener("click", function(event) { if (event.detail == 1337) { return; } event.preventDefault(); }, { capture: true, passive: false, once: true }); const customEvent = new MouseEvent("click", { view: window, bubbles: true, cancelable: false, detail: 1337 }); linkElement.dispatchEvent(customEvent); } function isPreloadable(linkElement) { if (!linkElement || !linkElement.href) { return; } if (useWhitelist && !("instant" in linkElement.dataset)) { return; } if (!allowExternalLinks && linkElement.origin != location.origin && !("instant" in linkElement.dataset)) { return; } if (![ "http:", "https:" ].includes(linkElement.protocol)) { return; } if (linkElement.protocol == "http:" && location.protocol == "https:") { return; } if (!allowQueryString && linkElement.search && !("instant" in linkElement.dataset)) { return; } if (linkElement.hash && linkElement.pathname + linkElement.search == location.pathname + location.search) { return; } if ("noInstant" in linkElement.dataset) { return; } return true; } function preload(url) { if (prefetches.has(url)) { return; } const prefetcher = document.createElement("link"); prefetcher.rel = "prefetch"; prefetcher.href = url; document.head.appendChild(prefetcher); prefetches.add(url); } }); })(); (function() { self.addEventListener("DOMContentLoaded", function() { const form = document.getElementById("search-form"); const query = document.getElementById("search-input"); document.getElementById("search-submit"); const dropdown = document.getElementById("search-results"); form.addEventListener("focusin", function() { initialize(); }); form.addEventListener("submit", function(event) { event.preventDefault(); return false; }); form.addEventListener("keydown", function(event) { const head = dropdown.firstChild.nextElementSibling.firstChild.nextElementSibling; const tail = dropdown.lastElementChild.firstChild.nextElementSibling; if (query.contains(event.target)) { if (event.keyCode == 27) { document.activeElement.blur(); dropdown.setAttribute("hidden", ""); } } if (event.keyCode == 40) { event.preventDefault(); if (document.activeElement == query) head.focus(); else if (document.activeElement == tail) query.focus(); else { document.activeElement.parentElement.nextElementSibling.firstChild.nextElementSibling.focus(); } } if (event.keyCode == 38) { event.preventDefault(); if (document.activeElement == query) tail.focus(); else if (document.activeElement == head) query.focus(); else { document.activeElement.parentElement.previousElementSibling.firstChild.nextElementSibling.focus(); } } if (event.keyCode == 8) { if (document.activeElement != query) { event.preventDefault(); query.focus(); } } if (event.keyCode == 13) { if (dropdown && document.activeElement == query) { event.preventDefault(); head.focus(); self.window.location = document.activeElement.href; } } }); let scrolls = 0; self.addEventListener("scroll", function() { if (scrolls > 3) { scrolls = 0; document.activeElement.blur(); dropdown.setAttribute("hidden", ""); } scrolls++; }); document.addEventListener("click", function(event) { if (!form.contains(event.target)) { dropdown.setAttribute("hidden", ""); } }); function fetch_JSON(path, callback) { const httpRequest = new XMLHttpRequest(); httpRequest.onreadystatechange = function() { if (httpRequest.readyState === 4) { if (httpRequest.status === 200) { const data = JSON.parse(httpRequest.responseText); if (callback) callback(data); } } }; httpRequest.open("GET", path); httpRequest.send(); } function load_script(url) { return new Promise(function(resolve, reject) { const script = document.createElement("script"); script.onerror = reject; script.onload = resolve; if (document.currentScript) { document.currentScript.parentNode.insertBefore(script, document.currentScript); } else { document.head.appendChild(script); } script.src = url; }); } let first_run = true; function initialize() { if (first_run) { load_script(window.location.origin + "/js/fuzzysort.js").then(()=>{ first_run = false; fetch_JSON("/index.json", function(data) { const options = { key: [ "title" ] }; query.addEventListener("keyup", function() { search(query.value, data.items, options); }); query.addEventListener("focusin", function() { search(query.value, data.items, options); }); search(query.value, data.items, options); }); }).catch((error)=>{ console.log("Error failed to load fuzzy sort: " + error); }); } } function search(term, data, options) { const results = fuzzysort.go(term, data, options); let items = ""; if (results.length === 0 && term.length >= 0) { let separator = "—"; if (term.length === 0) separator = ""; items = `
  • ${term} ${separator} No Results Found
  • `; dropdown.removeAttribute("hidden"); } else { dropdown.removeAttribute("hidden"); for(const string in results.slice(0, 10)){ const decode = document.createElement("textarea"); decode.innerHTML = results[string].obj.title; let highlight = fuzzysort.highlight(fuzzysort.single(term, decode.value), "", ""); if (highlight === null) { highlight = decode.value; } items = items + `
  • ${highlight}
  • `; } } dropdown.innerHTML = items; } }); })(); console.log("Surface Control: OK");