3
3
4
4
// Local js definitions:
5
5
/* global addClass, getCurrentValue, hasClass */
6
- /* global onEach , removeClass, updateLocalStorage */
6
+ /* global onEachLazy, hasOwnProperty , removeClass, updateLocalStorage */
7
7
8
8
if ( ! String . prototype . startsWith ) {
9
9
String . prototype . startsWith = function ( searchString , position ) {
@@ -192,6 +192,7 @@ function defocusSearchBar() {
192
192
var savedHash = "" ;
193
193
194
194
function handleHashes ( ev ) {
195
+ var elem ;
195
196
var search = getSearchElement ( ) ;
196
197
if ( ev !== null && search && ! hasClass ( search , "hidden" ) && ev . newURL ) {
197
198
// This block occurs when clicking on an element in the navbar while
@@ -201,7 +202,7 @@ function defocusSearchBar() {
201
202
if ( browserSupportsHistoryApi ( ) ) {
202
203
history . replaceState ( hash , "" , "?search=#" + hash ) ;
203
204
}
204
- var elem = document . getElementById ( hash ) ;
205
+ elem = document . getElementById ( hash ) ;
205
206
if ( elem ) {
206
207
elem . scrollIntoView ( ) ;
207
208
}
@@ -212,7 +213,7 @@ function defocusSearchBar() {
212
213
if ( savedHash . length === 0 ) {
213
214
return ;
214
215
}
215
- var elem = document . getElementById ( savedHash . slice ( 1 ) ) ; // we remove the '#'
216
+ elem = document . getElementById ( savedHash . slice ( 1 ) ) ; // we remove the '#'
216
217
if ( ! elem || ! isHidden ( elem ) ) {
217
218
return ;
218
219
}
@@ -335,7 +336,7 @@ function defocusSearchBar() {
335
336
}
336
337
337
338
function displayHelp ( display , ev , help ) {
338
- var help = help ? help : getHelpElement ( ) ;
339
+ help = help ? help : getHelpElement ( ) ;
339
340
if ( display === true ) {
340
341
if ( hasClass ( help , "hidden" ) ) {
341
342
ev . preventDefault ( ) ;
@@ -449,7 +450,7 @@ function defocusSearchBar() {
449
450
450
451
set_fragment ( cur_line_id ) ;
451
452
}
452
- }
453
+ } ;
453
454
} ( ) ) ;
454
455
455
456
document . addEventListener ( "click" , function ( ev ) {
@@ -615,7 +616,7 @@ function defocusSearchBar() {
615
616
function sortResults ( results , isType ) {
616
617
var ar = [ ] ;
617
618
for ( var entry in results ) {
618
- if ( results . hasOwnProperty ( entry ) ) {
619
+ if ( hasOwnProperty ( results , entry ) ) {
619
620
ar . push ( results [ entry ] ) ;
620
621
}
621
622
}
@@ -1113,8 +1114,6 @@ function defocusSearchBar() {
1113
1114
}
1114
1115
fullId = generateId ( ty ) ;
1115
1116
1116
- // allow searching for void (no output) functions as well
1117
- var typeOutput = type . length > OUTPUT_DATA ? type [ OUTPUT_DATA ] . name : "" ;
1118
1117
returned = checkReturned ( ty , output , true , NO_TYPE_FILTER ) ;
1119
1118
if ( output . name === "*" || returned === true ) {
1120
1119
in_args = false ;
@@ -1177,7 +1176,6 @@ function defocusSearchBar() {
1177
1176
var contains = paths . slice ( 0 , paths . length > 1 ? paths . length - 1 : 1 ) ;
1178
1177
1179
1178
var lev ;
1180
- var lev_distance ;
1181
1179
for ( j = 0 ; j < nSearchWords ; ++ j ) {
1182
1180
ty = searchIndex [ j ] ;
1183
1181
if ( ! ty || ( filterCrates !== undefined && ty . crate !== filterCrates ) ) {
@@ -1674,7 +1672,7 @@ function defocusSearchBar() {
1674
1672
function getFilterCrates ( ) {
1675
1673
var elem = document . getElementById ( "crate-search" ) ;
1676
1674
1677
- if ( elem && elem . value !== "All crates" && rawSearchIndex . hasOwnProperty ( elem . value ) ) {
1675
+ if ( elem && elem . value !== "All crates" && hasOwnProperty ( rawSearchIndex , elem . value ) ) {
1678
1676
return elem . value ;
1679
1677
}
1680
1678
return undefined ;
@@ -1722,7 +1720,7 @@ function defocusSearchBar() {
1722
1720
var currentIndex = 0 ;
1723
1721
1724
1722
for ( var crate in rawSearchIndex ) {
1725
- if ( ! rawSearchIndex . hasOwnProperty ( crate ) ) { continue ; }
1723
+ if ( ! hasOwnProperty ( rawSearchIndex , crate ) ) { continue ; }
1726
1724
1727
1725
var crateSize = 0 ;
1728
1726
@@ -1906,7 +1904,7 @@ function defocusSearchBar() {
1906
1904
1907
1905
var crates = [ ] ;
1908
1906
for ( var crate in rawSearchIndex ) {
1909
- if ( ! rawSearchIndex . hasOwnProperty ( crate ) ) {
1907
+ if ( ! hasOwnProperty ( rawSearchIndex , crate ) ) {
1910
1908
continue ;
1911
1909
}
1912
1910
crates . push ( crate ) ;
@@ -2173,19 +2171,13 @@ function defocusSearchBar() {
2173
2171
}
2174
2172
}
2175
2173
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" ) ;
2187
2179
}
2188
- break ;
2180
+ ns = ns . nextElementSibling ;
2189
2181
}
2190
2182
}
2191
2183
} ;
@@ -2482,7 +2474,7 @@ function defocusSearchBar() {
2482
2474
onEachLazy ( inner_toggle . getElementsByClassName ( "toggle-label" ) , function ( e ) {
2483
2475
e . style . display = "inline-block" ;
2484
2476
if ( extra === true ) {
2485
- i_e . innerHTML = " Show " + e . childNodes [ 0 ] . innerHTML ;
2477
+ e . innerHTML = " Show " + e . childNodes [ 0 ] . innerHTML ;
2486
2478
}
2487
2479
} ) ;
2488
2480
}
@@ -2587,17 +2579,17 @@ function defocusSearchBar() {
2587
2579
}
2588
2580
onEachLazy ( document . getElementsByClassName ( "rust-example-rendered" ) , function ( e ) {
2589
2581
if ( hasClass ( e , "compile_fail" ) ) {
2590
- e . addEventListener ( "mouseover" , function ( event ) {
2582
+ e . addEventListener ( "mouseover" , function ( ) {
2591
2583
this . parentElement . previousElementSibling . childNodes [ 0 ] . style . color = "#f00" ;
2592
2584
} ) ;
2593
- e . addEventListener ( "mouseout" , function ( event ) {
2585
+ e . addEventListener ( "mouseout" , function ( ) {
2594
2586
this . parentElement . previousElementSibling . childNodes [ 0 ] . style . color = "" ;
2595
2587
} ) ;
2596
2588
} else if ( hasClass ( e , "ignore" ) ) {
2597
- e . addEventListener ( "mouseover" , function ( event ) {
2589
+ e . addEventListener ( "mouseover" , function ( ) {
2598
2590
this . parentElement . previousElementSibling . childNodes [ 0 ] . style . color = "#ff9200" ;
2599
2591
} ) ;
2600
- e . addEventListener ( "mouseout" , function ( event ) {
2592
+ e . addEventListener ( "mouseout" , function ( ) {
2601
2593
this . parentElement . previousElementSibling . childNodes [ 0 ] . style . color = "" ;
2602
2594
} ) ;
2603
2595
}
@@ -2705,7 +2697,7 @@ function defocusSearchBar() {
2705
2697
var crates_text = [ ] ;
2706
2698
if ( Object . keys ( crates ) . length > 1 ) {
2707
2699
for ( var crate in crates ) {
2708
- if ( crates . hasOwnProperty ( crate ) ) {
2700
+ if ( hasOwnProperty ( crates , crate ) ) {
2709
2701
crates_text . push ( crate ) ;
2710
2702
}
2711
2703
}
@@ -2740,7 +2732,7 @@ function defocusSearchBar() {
2740
2732
2741
2733
if ( search_input ) {
2742
2734
search_input . removeAttribute ( 'disabled' ) ;
2743
- } ;
2735
+ }
2744
2736
} ;
2745
2737
2746
2738
function buildHelperPopup ( ) {
0 commit comments