-
Notifications
You must be signed in to change notification settings - Fork 1
/
scroll.js
65 lines (52 loc) · 2.28 KB
/
scroll.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//------------------------------------------------------------------
// sdss-main-scroll.js - javascript for the SDSS scrolling display
// written by Alex Szalay, Dec 30, 2000
// it assumes mosaic files in the path
//------------------------------------------------------------------
var p,next,status;
function nextImg() { var s = getFileName(next);
if (--next<FIELD_MIN)
resetStripe();
return s; }
function move() {
if (status) for (var i = 0; i < p.length; i++) {p[i].move();} timer = setTimeout("move()",DELTA_T);
}
function toggle() {
status = !status; }
//--------------- definition of the Scroll class --------
function Scroll(i,step) {
this.id = i;
this.step = step; this.pos = i*STRIDE;
this.setDiv(); this.nextSrc();
this.div.top = this.pos+"px";
}
Scroll.prototype.setDiv = function () {
if (is.ns4) { this.div = document["s" + this.id]; }
else if (is.ns6) { this.div = document.getElementById("s" + this.id).style; } else if (is.ie) { this.div = document.all["s" + this.id].style; }
}
Scroll.prototype.move = function () { if (this.pos < -HEIGHT) { this.pos += p.length*STRIDE;
this.nextSrc();
}
this.pos -= this.step; this.div.top = this.pos+"px";
}
Scroll.prototype.nextSrc = function () {
if (is.ns4) { document["s" + this.id].document.images["img" + this.id].src = nextImg(); } else if (is.ns6) {
document.images["img" + this.id].src = nextImg();
} else if (is.ie) { document.all["img" + this.id].src = nextImg(); }
}
//-------------------------------------------------------
function init(stepsize) {
//initialize the state variables, and the array
status = false; next = FIELD_MAX;
p = new Array(3);
for (var i = 0; i < p.length; i++) {
p[i] = new Scroll(i,stepsize);
}
status = true; move();
}
function Is() {
this.id = navigator.appVersion; this.major = parseInt(navigator.appVersion); this.agent = navigator.userAgent.toLowerCase(); this.ns = ( (this.agent.indexOf('mozilla')!=-1) &&
(this.agent.indexOf('spoofer')==-1) &&
(this.agent.indexOf('compatible')==-1) &&
(this.agent.indexOf('opera')==-1)); this.ns4 = (this.ns && (this.major==4));
this.ns6 = (this.ns && (this.major>=5)); this.ie = (this.agent.indexOf('msie')!=-1); }