33
44// Local js definitions:
55/* global addClass, getCurrentValue, hasClass */
6- /* global onEach , removeClass, updateLocalStorage */
6+ /* global onEachLazy, hasOwnProperty , removeClass, updateLocalStorage */
77
88if ( ! String . prototype . startsWith ) {
99 String . prototype . startsWith = function ( searchString , position ) {
@@ -192,6 +192,7 @@ function defocusSearchBar() {
192192 var savedHash = "" ;
193193
194194 function handleHashes ( ev ) {
195+ var elem ;
195196 var search = getSearchElement ( ) ;
196197 if ( ev !== null && search && ! hasClass ( search , "hidden" ) && ev . newURL ) {
197198 // This block occurs when clicking on an element in the navbar while
@@ -201,7 +202,7 @@ function defocusSearchBar() {
201202 if ( browserSupportsHistoryApi ( ) ) {
202203 history . replaceState ( hash , "" , "?search=#" + hash ) ;
203204 }
204- var elem = document . getElementById ( hash ) ;
205+ elem = document . getElementById ( hash ) ;
205206 if ( elem ) {
206207 elem . scrollIntoView ( ) ;
207208 }
@@ -212,7 +213,7 @@ function defocusSearchBar() {
212213 if ( savedHash . length === 0 ) {
213214 return ;
214215 }
215- var elem = document . getElementById ( savedHash . slice ( 1 ) ) ; // we remove the '#'
216+ elem = document . getElementById ( savedHash . slice ( 1 ) ) ; // we remove the '#'
216217 if ( ! elem || ! isHidden ( elem ) ) {
217218 return ;
218219 }
@@ -335,7 +336,7 @@ function defocusSearchBar() {
335336 }
336337
337338 function displayHelp ( display , ev , help ) {
338- var help = help ? help : getHelpElement ( ) ;
339+ help = help ? help : getHelpElement ( ) ;
339340 if ( display === true ) {
340341 if ( hasClass ( help , "hidden" ) ) {
341342 ev . preventDefault ( ) ;
@@ -449,7 +450,7 @@ function defocusSearchBar() {
449450
450451 set_fragment ( cur_line_id ) ;
451452 }
452- }
453+ } ;
453454 } ( ) ) ;
454455
455456 document . addEventListener ( "click" , function ( ev ) {
@@ -615,7 +616,7 @@ function defocusSearchBar() {
615616 function sortResults ( results , isType ) {
616617 var ar = [ ] ;
617618 for ( var entry in results ) {
618- if ( results . hasOwnProperty ( entry ) ) {
619+ if ( hasOwnProperty ( results , entry ) ) {
619620 ar . push ( results [ entry ] ) ;
620621 }
621622 }
@@ -1113,8 +1114,6 @@ function defocusSearchBar() {
11131114 }
11141115 fullId = generateId ( ty ) ;
11151116
1116- // allow searching for void (no output) functions as well
1117- var typeOutput = type . length > OUTPUT_DATA ? type [ OUTPUT_DATA ] . name : "" ;
11181117 returned = checkReturned ( ty , output , true , NO_TYPE_FILTER ) ;
11191118 if ( output . name === "*" || returned === true ) {
11201119 in_args = false ;
@@ -1177,7 +1176,6 @@ function defocusSearchBar() {
11771176 var contains = paths . slice ( 0 , paths . length > 1 ? paths . length - 1 : 1 ) ;
11781177
11791178 var lev ;
1180- var lev_distance ;
11811179 for ( j = 0 ; j < nSearchWords ; ++ j ) {
11821180 ty = searchIndex [ j ] ;
11831181 if ( ! ty || ( filterCrates !== undefined && ty . crate !== filterCrates ) ) {
@@ -1674,7 +1672,7 @@ function defocusSearchBar() {
16741672 function getFilterCrates ( ) {
16751673 var elem = document . getElementById ( "crate-search" ) ;
16761674
1677- if ( elem && elem . value !== "All crates" && rawSearchIndex . hasOwnProperty ( elem . value ) ) {
1675+ if ( elem && elem . value !== "All crates" && hasOwnProperty ( rawSearchIndex , elem . value ) ) {
16781676 return elem . value ;
16791677 }
16801678 return undefined ;
@@ -1722,7 +1720,7 @@ function defocusSearchBar() {
17221720 var currentIndex = 0 ;
17231721
17241722 for ( var crate in rawSearchIndex ) {
1725- if ( ! rawSearchIndex . hasOwnProperty ( crate ) ) { continue ; }
1723+ if ( ! hasOwnProperty ( rawSearchIndex , crate ) ) { continue ; }
17261724
17271725 var crateSize = 0 ;
17281726
@@ -1906,7 +1904,7 @@ function defocusSearchBar() {
19061904
19071905 var crates = [ ] ;
19081906 for ( var crate in rawSearchIndex ) {
1909- if ( ! rawSearchIndex . hasOwnProperty ( crate ) ) {
1907+ if ( ! hasOwnProperty ( rawSearchIndex , crate ) ) {
19101908 continue ;
19111909 }
19121910 crates . push ( crate ) ;
@@ -2173,19 +2171,13 @@ function defocusSearchBar() {
21732171 }
21742172 }
21752173 var ns = n . nextElementSibling ;
2176- while ( true ) {
2177- if ( ns && (
2178- hasClass ( ns , "docblock" ) ||
2179- hasClass ( ns , "stability" ) ) ) {
2180- if ( addOrRemove ) {
2181- addClass ( ns , "hidden-by-impl-hider" ) ;
2182- } else {
2183- removeClass ( ns , "hidden-by-impl-hider" ) ;
2184- }
2185- ns = ns . nextElementSibling ;
2186- continue ;
2174+ while ( ns && ( hasClass ( ns , "docblock" ) || hasClass ( ns , "stability" ) ) ) {
2175+ if ( addOrRemove ) {
2176+ addClass ( ns , "hidden-by-impl-hider" ) ;
2177+ } else {
2178+ removeClass ( ns , "hidden-by-impl-hider" ) ;
21872179 }
2188- break ;
2180+ ns = ns . nextElementSibling ;
21892181 }
21902182 }
21912183 } ;
@@ -2482,7 +2474,7 @@ function defocusSearchBar() {
24822474 onEachLazy ( inner_toggle . getElementsByClassName ( "toggle-label" ) , function ( e ) {
24832475 e . style . display = "inline-block" ;
24842476 if ( extra === true ) {
2485- i_e . innerHTML = " Show " + e . childNodes [ 0 ] . innerHTML ;
2477+ e . innerHTML = " Show " + e . childNodes [ 0 ] . innerHTML ;
24862478 }
24872479 } ) ;
24882480 }
@@ -2587,17 +2579,17 @@ function defocusSearchBar() {
25872579 }
25882580 onEachLazy ( document . getElementsByClassName ( "rust-example-rendered" ) , function ( e ) {
25892581 if ( hasClass ( e , "compile_fail" ) ) {
2590- e . addEventListener ( "mouseover" , function ( event ) {
2582+ e . addEventListener ( "mouseover" , function ( ) {
25912583 this . parentElement . previousElementSibling . childNodes [ 0 ] . style . color = "#f00" ;
25922584 } ) ;
2593- e . addEventListener ( "mouseout" , function ( event ) {
2585+ e . addEventListener ( "mouseout" , function ( ) {
25942586 this . parentElement . previousElementSibling . childNodes [ 0 ] . style . color = "" ;
25952587 } ) ;
25962588 } else if ( hasClass ( e , "ignore" ) ) {
2597- e . addEventListener ( "mouseover" , function ( event ) {
2589+ e . addEventListener ( "mouseover" , function ( ) {
25982590 this . parentElement . previousElementSibling . childNodes [ 0 ] . style . color = "#ff9200" ;
25992591 } ) ;
2600- e . addEventListener ( "mouseout" , function ( event ) {
2592+ e . addEventListener ( "mouseout" , function ( ) {
26012593 this . parentElement . previousElementSibling . childNodes [ 0 ] . style . color = "" ;
26022594 } ) ;
26032595 }
@@ -2705,7 +2697,7 @@ function defocusSearchBar() {
27052697 var crates_text = [ ] ;
27062698 if ( Object . keys ( crates ) . length > 1 ) {
27072699 for ( var crate in crates ) {
2708- if ( crates . hasOwnProperty ( crate ) ) {
2700+ if ( hasOwnProperty ( crates , crate ) ) {
27092701 crates_text . push ( crate ) ;
27102702 }
27112703 }
@@ -2740,7 +2732,7 @@ function defocusSearchBar() {
27402732
27412733 if ( search_input ) {
27422734 search_input . removeAttribute ( 'disabled' ) ;
2743- } ;
2735+ }
27442736 } ;
27452737
27462738 function buildHelperPopup ( ) {
0 commit comments