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