Skip to content

Commit c8a589e

Browse files
committed
Merge branch 'cleanup'
2 parents 1b039a6 + 546df40 commit c8a589e

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

big.js

+20-20
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,41 @@ window.onload = function() {
22
var s = document.getElementsByTagName('div'), cur = 0;
33
if (!s) return;
44
function go(n) {
5-
var i = 1e3;
5+
cur = n;
6+
var i = 1e3, e = s[n];
67
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';
1213
} else {
1314
document.body.style.backgroundImage = '';
1415
}
1516
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';
1920
}
2021
if (window.location.hash !== n) window.location.hash = n;
2122
document.title = s[n].textContent || s[n].innerText;
2223
}
2324
document.onclick = function() {
24-
cur = ++cur % (s.length);
25-
go(cur);
25+
go(++cur % (s.length));
2626
};
2727
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));
3030
};
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(
3733
s.length - 1,
3834
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);
4040
};
4141

4242
go(cur);

0 commit comments

Comments
 (0)