PageSourceSearch

https://www.rubberasia.com/system/resource/js/news/imagechangenews.js

js rubberasia.com collected 2026-10-02 19:09:54 UTC 7,889 bytes, 213 lines download raw bytes

1function getVersion()
2{
3    var browser=navigator.appName;
4    var b_version=navigator.appVersion;
5    var version=b_version.split(";");
6    var trim_Version=version[1].replace(/[ ]/g,"");
7    return (browser=="Microsoft Internet Explorer" && trim_Version=="MSIE10.0");
8}
9
10function ImageChangeNews(uid, width, height, interval, duration, btitle, bsummary, zoomtype, zoomout, isCenterCutImg, cutImgParent)
11{
12    var _this = this; //把this保存下来,以后用_this代替this,这样就不会被this弄晕了
13
14    _this.imgs = new Array(); //图片组
15    _this.urls = new Array(); //链接组
16    _this.titles = new Array(); //标题组
17    _this.summarys = new Array(); //摘要组
18    _this.tipTitles = new Array(); //鼠标提示
19    
20    _this.nextIndex=0;   //下次显示的滚动图
21    _this.currentIndex=-1;   //当前显示的滚动图
22    _this.firstFlag = 0;  //标识是否为第一次开始执行
23    _this.currentTimer = null;     //标识作用
24    
25    //图片加载完毕事件
26    _this.onimgload = function(loadIndex)
27    {
28        _this.imgs[loadIndex].setAttribute("loadedflag", true);
29        if(loadIndex == _this.currentIndex)
30        {
31            _this.constrainimg(document.getElementById(uid + "pic"), _this.imgs[loadIndex], document.getElementById(uid + "imgdiv"));
32        }
33    }   
34    
35    //添加图片
36    _this.addimg = function(img, url, title, summary,tipTitle)
37    {
38        var imgcount = _this.imgs.length;
39        _this.imgs[imgcount] = new Image();
40        
41        _this.imgs[imgcount].onload = function(){_this.onimgload(imgcount)};
42        
43        _this.imgs[imgcount].src = img;
44        
45        _this.urls[imgcount] = url;
46        _this.titles[imgcount] = title;
47        _this.summarys[imgcount] = summary;
48        if(tipTitle){
49            _this.tipTitles[imgcount] = tipTitle;
50        }
51    }
52
53    //触发图片改变
54    _this.changeimg = function (n)
55    {       
56        if(_this.imgs.length < 1)
57        {       
58            return;       
59        }       
60        
61        if(_this.currentTimer != null)
62            window.clearInterval(_this.currentTimer); //清除用于循环的currentTimer  
63        
64        _this.currentTimer = window.setInterval(_this.onchangeimg, interval * 1000);//设置循环周期为4000
65        
66        _this.nextIndex = n; //要显示的ID等于传入的N值,
67        _this.onchangeimg();
68    }
69    
70    //改变图片操作
71    _this.onchangeimg = function()       
72    {
73        try
74        {
75             if(_this.imgs.length < 1)
76             {       
77                 return;       
78             }     
79             if(_this.firstFlag == 0)
80             {
81                _this.firstFlag = 1;
82             }       
83             else if(document.all && !getVersion())
84             {
85                 var imgfilter = document.getElementById(uid + "div").filters[0];
86                 imgfilter.Apply();
87                 imgfilter.Play(duration);
88                 imgfilter.transition=23;
89             }
90             //图片未加载完毕
91             if(_this.imgs[_this.nextIndex].getAttribute("loadedflag") == null)
92             {
93                document.getElementById(uid + "pic").src = "/system/resource/images/space.gif";
94             }
95             else
96             {
97                //图片正常加载, 设置图片
98                _this.constrainimg(document.getElementById(uid + "pic"), _this.imgs[_this.nextIndex], document.getElementById(uid + "imgdiv"));
99             }
100             //设置当前图片编号
101             _this.currentIndex = _this.nextIndex;
102             
103             
104             document.getElementById(uid + "url").href = _this.urls[_this.nextIndex];
105			
106			 btitle = true;
107             if(btitle)
108             {       
109                 document.getElementById(uid + "newstitle").innerHTML = _this.titles[_this.nextIndex];
110                 
111                 document.getElementById(uid + "newstitle").href = _this.urls[_this.nextIndex];
112                 if(_this.tipTitles.length > 0){
113                     document.getElementById(uid + "newstitle").title =_this.tipTitles[_this.nextIndex];
114                 }else{
115                     document.getElementById(uid + "newstitle").title =_this.titles[_this.nextIndex];
116                 }
117
118             }       
119             if(bsummary)
120             {
121                 document.getElementById(uid + "newssummary").innerHTML = _this.summarys[_this.nextIndex];
122                 document.getElementById(uid + "newssummary").href = _this.urls[_this.nextIndex];
123             }       
124             //设置所有按钮的样式
125             for(var i = 0;i < _this.imgs.length; i++)
126             {       
127                  if(i == _this.nextIndex)
128                    document.getElementById(uid + "selectNode"+i).className='imagechangenews_fno
128de';
129                  else
130                    document.getElementById(uid + "selectNode"+i).className='imagechangenews_pnode';
131             }       
132             _this.nextIndex++;       
133             if(_this.nextIndex >= _this.imgs.length)
134             {
135                //如果ID大于总图片数量。则从头开始循环       
136                _this.nextIndex = 0;       
137             }       
138        }
139        catch(e)
140        {
141        }
142    }
143    
144    //等比例设置图片
145    _this.constrainimg = function(imgobj, imagevar, imgdiv)
146    {
147        try
148        {
149            var widthrate = imagevar.width / width;
150            var heightrate = imagevar.height / height;
151            var imgwidth = 0;
152            var imgheight = 0;
153
154            if(widthrate > 1 || heightrate > 1) //图片过大时
155            {
156                if(!isCenterCutImg) {
157                    if (zoomtype)//按比例缩小
158                    {
159                        var rate = Math.max(widthrate, heightrate);
160                        imgwidth = Math.max(1, Math.min(imagevar.width / rate, width));
161                        imgheight = Math.max(1, Math.min(imagevar.height / rate, height));
162                    }
163                    else//拉伸
164                    {
165                        imgwidth = width;
166                        imgheight = height;
167                    }
168                }
169            }
170            else if(widthrate < 1 || heightrate < 1) //图片小
171            {
172                if(!isCenterCutImg) {
173                    if (zoomout)//自动放大
174                    {
175                        if (zoomtype)//按比例放大
176                        {
177                            var rate = Math.max(widthrate, heightrate);
178                            imgwidth = Math.max(1, Math.min(imagevar.width / rate, width));
179                            imgheight = Math.max(1, Math.min(imagevar.height / rate, height));
180                        }
181                        else //拉伸
182                        {
183                            imgwidth = width;
184                            imgheight = height;
185                        }
186
187                    }
188                    else {
189                        imgwidth = imagevar.width;
190                        imgheight = imagevar.height;
191                    }
192                }
193            }
194            else //大小合适
195            {
196               imgwidth = width;
197               imgheight = height;
198            }
199
200            imgobj.src = imagevar.src;
201            if(!isCenterCutImg) {
202                imgobj.width = imgwidth;
203                imgobj.height = imgheight;
204                imgdiv.style.paddingTop = (height - imgheight) / 2+"px";
205            }else{
206                cutImg(imgobj,"autocut",cutImgParent);
207            }
208        }
209        catch(e)
210        {
211        }
212    }
213}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.