File tree 4 files changed +32
-2
lines changed
4 files changed +32
-2
lines changed Original file line number Diff line number Diff line change @@ -68,6 +68,7 @@ def generate_nav(sections):
68
68
69
69
def generate_command_table ():
70
70
out = """
71
+ <input type="text" id="command-search" onkeyup="searchCommands()" placeholder="Search commands...">
71
72
<table class="commands">
72
73
<tr>
73
74
<th>Command</th>
Original file line number Diff line number Diff line change
1
+ function searchCommands ( ) {
2
+ let query = document . getElementById ( "command-search" ) . value . toLowerCase ( ) ;
3
+ let commands = document . querySelectorAll ( ".commands tr:not(:first-child)" ) ;
4
+ let anyMatch = false ;
5
+ commands . forEach ( command => {
6
+ let commandName = command . children [ 0 ] . textContent . toLowerCase ( ) ;
7
+ let commandType = command . children [ 1 ] . textContent . toLowerCase ( ) ;
8
+ let commandDescription = command . children [ 2 ] . textContent . toLowerCase ( ) ;
9
+ if ( commandName . includes ( query ) || commandType . includes ( query ) || commandDescription . includes ( query ) ) {
10
+ anyMatch = true ;
11
+ command . classList . remove ( 'hidden' ) ;
12
+ } else {
13
+ command . classList . add ( 'hidden' ) ;
14
+ }
15
+ } ) ;
16
+ // if no matches, display all
17
+ if ( ! anyMatch ) {
18
+ commands . forEach ( command => command . classList . remove ( 'hidden' ) ) ;
19
+ }
20
+ }
21
+
22
+ window . addEventListener ( 'load' , ( ) => {
23
+ searchCommands ( ) ;
24
+ } ) ;
Original file line number Diff line number Diff line change @@ -98,10 +98,14 @@ td, th {
98
98
text-align : left;
99
99
}
100
100
101
- tr : nth-child (odd) {
101
+ tr .hidden {
102
+ display : none;
103
+ }
104
+
105
+ : nth-child (odd of tr : not (.hidden )) {
102
106
background : # 383838 ;
103
107
}
104
- tr : nth-child (even) {
108
+ : nth-child (even of tr : not (. hidden ) ) {
105
109
background : # 2a2a2a ;
106
110
}
107
111
Original file line number Diff line number Diff line change @@ -23,4 +23,5 @@ <h1>Portal 2 Rules</h1>
23
23
24
24
< script src ="scroll.js "> </ script >
25
25
< script src ="mobile-menu.js "> </ script >
26
+ < script src ="command-table.js "> </ script >
26
27
</ html >
You can’t perform that action at this time.
0 commit comments