@@ -110,7 +110,8 @@ function initSearchBar() {
110110 document . querySelector ( 'header > input' ) . addEventListener ( 'input' , function ( event ) {
111111 var results = [ ] ,
112112 first = null ,
113- cursor_position = this . selectionStart ;
113+ cursor_position = this . selectionStart ,
114+ r = new RegExp ( '[^\w]' + this . value ) ;
114115
115116 search_results_element . innerHTML = '' ;
116117
@@ -132,9 +133,10 @@ function initSearchBar() {
132133 }*/
133134
134135 for ( var i = 0 , l = SEARCH . length ; i < l ; i ++ ) {
135- var item = SEARCH [ i ] ;
136+ var item = SEARCH [ i ] ,
137+ m = item [ 2 ] . match ( r ) ;
136138
137- if ( item [ 0 ] . indexOf ( this . value ) === 0 ) {
139+ if ( m ) {
138140 results . push ( item ) ;
139141 }
140142 }
@@ -146,19 +148,20 @@ function initSearchBar() {
146148 for ( var i = 0 , l = results . length ; i < l ; i ++ ) {
147149 var item = document . createElement ( 'div' ) ;
148150
149- item . innerText = results [ i ] [ 0 ] ;
150- item . style . backgroundImage = 'url(https://' + results [ i ] [ 0 ] . match ( / [ ^ / ] + / ) [ 0 ] + '/favicon.ico)' ;
151+ item . innerText = results [ i ] [ 2 ] ;
152+ item . dataset . url = results [ i ] [ 0 ] ;
153+ item . style . backgroundImage = 'url(chrome://favicon/' + results [ i ] [ 0 ] + ')' ;
151154
152155 item . addEventListener ( 'click' , function ( ) {
153156 search_results_element . style . display = 'none' ;
154157
155- window . open ( 'https://' + this . innerText , '_self' ) ;
158+ window . open ( this . innerText , '_self' ) ;
156159 } ) ;
157160
158161 search_results_element . appendChild ( item ) ;
159162 }
160163
161- first = results [ 0 ] [ 0 ] ;
164+ first = results [ 0 ] [ 2 ] ;
162165
163166 if ( first ) {
164167 search_results_element . children [ 0 ] . className = 'selected' ;
0 commit comments