Skip to content

Commit

Permalink
add search
Browse files Browse the repository at this point in the history
  • Loading branch information
greggman committed Sep 23, 2024
1 parent f0cad58 commit 585616e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions build/templates/header.template
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<div>
{{{include "build/templates/languages.template"}}}
<a href="#toc">{{langInfo.toc}}</a>
<input type="search" placeholder="?" id="search">
</div>
</div>
<div class="webgl_header">
Expand Down
4 changes: 4 additions & 0 deletions webgl/lessons/resources/lesson.css
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ a>img {
.webgl_navbar {
background: black;
color: white;
color-scheme: dark;
}
.webgl_navbar a {
color: white;
Expand Down Expand Up @@ -506,6 +507,9 @@ pre.prettyprint, code.prettyprint {
li {
margin-left: 5px;
}
#search {
display: none;
}
}

@media (max-width: 720px) {
Expand Down
11 changes: 11 additions & 0 deletions webgl/lessons/resources/lesson.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,17 @@ $(document).ready(function($) {
window.location.href = this.dataset.href;
});

$('#search').on('keyup', function(e) {
if (e.key !== 'Enter') {
return;
}
const a = document.createElement('a');
a.target = '_blank';
const u = new URL('https://google.com/search');
u.searchParams.set('q', `site:webgl2fundamentals.org ${this.value}`);
a.href = u.toString();
a.click();
});
});
}(jQuery));

0 comments on commit 585616e

Please sign in to comment.