From 4fde75a4b8777cfcf9c0dcf57f266a750a693ba3 Mon Sep 17 00:00:00 2001 From: Fini Jastrow Date: Thu, 4 Apr 2024 18:28:55 +0200 Subject: [PATCH] cheat-sheet: Allow direct url to search result Will be used by the Wiki for example to show the glyph-sets. Signed-off-by: Fini Jastrow --- cheat-sheet.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/cheat-sheet.js b/cheat-sheet.js index 602d89a23..72a505875 100644 --- a/cheat-sheet.js +++ b/cheat-sheet.js @@ -4,6 +4,23 @@ document.addEventListener('DOMContentLoaded', function () { const elementGlyphCheatSheet = document.getElementById('glyphCheatSheet'); const maxSearchResults = 250; + // Find the value of one query string + function querySt(ji) { + const hu = window.location.search.substring(1); + const gy = hu.split('&'); + for (i = 0; i < gy.length; i++) { + ft = gy[i].split('='); + if (ft[0] == ji) { + return ft[1]; + } + } + } + // Jump to search for provided query key, e.g. https://www.nerdfonts.com/cheat-sheet?q=cpu + const fieldName = querySt('q'); + if (fieldName != null) { + elementGlyphSearch.value = fieldName; + } + // Storage for not-yet-rendered search results. More results will are rendered when scrolled to the bottom. let remainingSearchResults = [];