Skip to content

Commit 585616e

Browse files
committed
add search
1 parent f0cad58 commit 585616e

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

build/templates/header.template

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<div>
33
{{{include "build/templates/languages.template"}}}
44
<a href="#toc">{{langInfo.toc}}</a>
5+
<input type="search" placeholder="?" id="search">
56
</div>
67
</div>
78
<div class="webgl_header">

webgl/lessons/resources/lesson.css

+4
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ a>img {
132132
.webgl_navbar {
133133
background: black;
134134
color: white;
135+
color-scheme: dark;
135136
}
136137
.webgl_navbar a {
137138
color: white;
@@ -506,6 +507,9 @@ pre.prettyprint, code.prettyprint {
506507
li {
507508
margin-left: 5px;
508509
}
510+
#search {
511+
display: none;
512+
}
509513
}
510514

511515
@media (max-width: 720px) {

webgl/lessons/resources/lesson.js

+11
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,17 @@ $(document).ready(function($) {
8484
window.location.href = this.dataset.href;
8585
});
8686

87+
$('#search').on('keyup', function(e) {
88+
if (e.key !== 'Enter') {
89+
return;
90+
}
91+
const a = document.createElement('a');
92+
a.target = '_blank';
93+
const u = new URL('https://google.com/search');
94+
u.searchParams.set('q', `site:webgl2fundamentals.org ${this.value}`);
95+
a.href = u.toString();
96+
a.click();
97+
});
8798
});
8899
}(jQuery));
89100

0 commit comments

Comments
 (0)