@@ -2,41 +2,41 @@ window.onload = function() {
2
2
var s = document . getElementsByTagName ( 'div' ) , cur = 0 ;
3
3
if ( ! s ) return ;
4
4
function go ( n ) {
5
- var i = 1e3 ;
5
+ cur = n ;
6
+ var i = 1e3 , e = s [ n ] ;
6
7
for ( var k = 0 ; k < s . length ; k ++ ) s [ k ] . style . display = 'none' ;
7
- s [ n ] . style . display = 'inline' ;
8
- s [ n ] . style . fontSize = i + 'px' ;
9
- if ( s [ n ] . firstChild . nodeName === 'IMG' ) {
10
- document . body . style . backgroundImage = 'url(' + s [ n ] . firstChild . src + ')' ;
11
- s [ n ] . firstChild . style . display = 'none' ;
8
+ e . style . display = 'inline' ;
9
+ e . style . fontSize = i + 'px' ;
10
+ if ( e . firstChild . nodeName === 'IMG' ) {
11
+ document . body . style . backgroundImage = 'url(' + e . firstChild . src + ')' ;
12
+ e . firstChild . style . display = 'none' ;
12
13
} else {
13
14
document . body . style . backgroundImage = '' ;
14
15
}
15
16
while (
16
- s [ n ] . offsetWidth > window . innerWidth ||
17
- s [ n ] . offsetHeight > window . innerHeight ) {
18
- s [ n ] . style . fontSize = ( i -= 10 ) + 'px' ;
17
+ e . offsetWidth > window . innerWidth ||
18
+ e . offsetHeight > window . innerHeight ) {
19
+ e . style . fontSize = ( i -= 10 ) + 'px' ;
19
20
}
20
21
if ( window . location . hash !== n ) window . location . hash = n ;
21
22
document . title = s [ n ] . textContent || s [ n ] . innerText ;
22
23
}
23
24
document . onclick = function ( ) {
24
- cur = ++ cur % ( s . length ) ;
25
- go ( cur ) ;
25
+ go ( ++ cur % ( s . length ) ) ;
26
26
} ;
27
27
document . onkeydown = function ( e ) {
28
- ( e . which === 39 ) && go ( cur = Math . min ( s . length - 1 , ++ cur ) ) ;
29
- ( e . which === 37 ) && go ( cur = Math . max ( 0 , -- cur ) ) ;
28
+ ( e . which === 39 ) && go ( Math . min ( s . length - 1 , ++ cur ) ) ;
29
+ ( e . which === 37 ) && go ( Math . max ( 0 , -- cur ) ) ;
30
30
} ;
31
- if ( window . location . hash ) cur = Math . max (
32
- Math . min (
33
- s . length - 1 ,
34
- parseInt ( window . location . hash . substring ( 1 ) , 10 ) ) , 0 ) || cur ;
35
- window . onhashchange = function ( ) {
36
- var c = Math . max ( Math . min (
31
+ function parse_hash ( ) {
32
+ return Math . max ( Math . min (
37
33
s . length - 1 ,
38
34
parseInt ( window . location . hash . substring ( 1 ) , 10 ) ) , 0 ) ;
39
- if ( c !== cur ) go ( cur = c ) ;
35
+ } ;
36
+ if ( window . location . hash ) cur = parse_hash ( ) || cur ;
37
+ window . onhashchange = function ( ) {
38
+ var c = parse_hash ( ) ;
39
+ if ( c !== cur ) go ( c ) ;
40
40
} ;
41
41
42
42
go ( cur ) ;
0 commit comments