Skip to content

Commit

Permalink
cheat-sheet: Allow direct url to search result
Browse files Browse the repository at this point in the history
Will be used by the Wiki for example to show the glyph-sets.

Signed-off-by: Fini Jastrow <[email protected]>
  • Loading branch information
Finii committed Apr 4, 2024
1 parent e86aed2 commit 4fde75a
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions cheat-sheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];

Expand Down

0 comments on commit 4fde75a

Please sign in to comment.