Rev 20 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 20 | Rev 10534 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | /* |
1 | /* |
- | 2 | ||
2 | 3 | DynAPI Distribution |
|
- | 4 | ||
3 | DynAPI Distribution |
5 | DynImage Class |
4 | 6 | ||
5 | DynImage Class |
7 | The DynAPI Distribution is distributed under the terms of the GNU LGPL license. |
- | 8 | ||
6 | 9 | */ |
|
- | 10 | ||
- | 11 | ||
7 | 12 | ||
8 | 13 | function DynImage(img,id,alt) { |
|
9 | The DynAPI Distribution is distributed under the terms of the GNU LGPL license. |
14 | this.img = img; |
10 | 15 | this.id = id; |
|
11 | */ |
16 | this.alt = alt; |
12 | 17 | }; |
|
- | 18 | ||
13 | 19 | DynImage.prototype.toString = function() { |
|
- | 20 | ||
14 | 21 | return "<img src=\""+this.img.src+"\""+ |
|
15 | function DynImage(img,id,alt) { |
22 | (this.id?" id=\""+this.id+"\"":"")+ |
16 | 23 | (this.img.width?" width=\""+this.img.width+"\"":"")+ |
|
17 | this.img = img; |
24 | (this.img.height?" height=\""+this.img.height+"\"":"")+ |
18 | 25 | (this.alt?" alt=\""+this.alt+"\"":"")+">"; |
|
19 | this.id = id; |
26 | }; |
- | 27 | ||
20 | 28 | DynImage.image = []; |
|
- | 29 | ||
21 | this.alt = alt; |
30 | DynImage.getImage = function(src,w,h) { |
- | 31 | ||
22 | 32 | for (var i=0;i<DynImage.image.length;i++) { |
|
23 | }; |
33 | if (DynImage.image[i].img.src==src) return DynImage.image[i].img; |
24 | 34 | } |
|
- | 35 | ||
25 | DynImage.prototype.toString = function() { |
36 | var index = DynImage.image.length; |
- | 37 | ||
26 | 38 | DynImage.image[index] = {}; |
|
- | 39 | ||
27 | return "<img src=\""+this.img.src+"\""+ |
40 | if (w&&h) { |
28 | 41 | DynImage.image[index].img = new Image(w,h); |
|
29 | (this.id?" id=\""+this.id+"\"":"")+ |
42 | DynImage.image[index].img.w = w; |
30 | 43 | DynImage.image[index].img.h = h; |
|
31 | (this.img.width?" width=\""+this.img.width+"\"":"")+ |
44 | } |
- | 45 | ||
32 | 46 | else DynImage.image[index].img = new Image(); |
|
- | 47 | ||
33 | (this.img.height?" height=\""+this.img.height+"\"":"")+ |
48 | DynImage.image[index].img.src = src; |
- | 49 | ||
34 | 50 | if (!DynImage.timerId) DynImage.timerId=setTimeout('DynImage.loadercheck()',50); |
|
- | 51 | ||
35 | (this.alt?" alt=\""+this.alt+"\"":"")+">"; |
52 | return DynImage.image[index].img; |
36 | 53 | }; |
|
- | 54 | ||
37 | }; |
55 | |
38 | 56 | DynImage.loadercheck=function() { |
|
- | 57 | ||
39 | DynImage.image = []; |
58 | DynImage.ItemsDone=0; |
- | 59 | ||
40 | 60 | var max = DynImage.image.length; |
|
41 | DynImage.getImage = function(src,w,h) { |
61 | var dimg = null; |
- | 62 | ||
42 | 63 | for (var i=0; i<max; i++) { |
|
- | 64 | ||
43 | for (var i=0;i<DynImage.image.length;i++) { |
65 | dimg = DynImage.image[i]; |
- | 66 | ||
44 | 67 | if (dimg.img.complete) { |
|
- | 68 | ||
45 | if (DynImage.image[i].img.src==src) return DynImage.image[i].img; |
69 | DynImage.ItemsDone+=1; |
- | 70 | ||
46 | 71 | if (dimg.img.w) dimg.img.width = dimg.img.w; |
|
47 | } |
72 | if (dimg.img.h) dimg.img.height = dimg.img.h; |
- | 73 | ||
48 | 74 | } |
|
- | 75 | ||
49 | var index = DynImage.image.length; |
76 | } |
- | 77 | ||
50 | 78 | if (DynImage.ItemsDone<max) DynImage.timerId=setTimeout('DynImage.loadercheck()',25); |
|
51 | DynImage.image[index] = {}; |
79 | else DynImage.timerId=null; |
- | 80 | ||
52 | 81 | }; |
|
53 | if (w&&h) { |
- | |
54 | 82 | ||
- | 83 | dynapi.onLoad(DynImage.loaderStart); |