PageSourceSearch

https://novellotech.com/skin/js/banner.js

js novellotech.com collected 2026-10-05 04:47:53 UTC 2,660 bytes, 61 lines download raw bytes

1// JavaScript Document
2$(function() {
3	var sWidth = $("#focus").width(); //获取焦点图的宽度(显示面积)
4	var len = $("#focus ul li").length; //获取焦点图个数
5	var index = 0;
6	var picTimer;
7	
8	//以下代码添加数字按钮和按钮后的半透明长条
9	var btn = "<div class='btn'>";
10	for(var i=0; i < len; i++) {
11		//btn += "<span>" + (i+1) + "</span>";
12		btn += "<span>&nbsp;</span>";
13	}
14	btn += "</div>"
15	$("#focus").append(btn);
16	$("#focus .btnBg").css("opacity",0.5);
17	
18	//为数字按钮添加鼠标滑入事件,以显示相应的内容
19	$("#focus .btn span").mouseenter(function() {
20		index = $("#focus .btn span").index(this);
21		showPics(index);
22	}).eq(0).trigger("mouseenter");
23	
24	//本例为左右滚动,即所有li元素都是在同一排向左浮动,所以这里需要计算出外围ul元素的宽度
25	$("#focus ul").css("width",sWidth * (len + 1));
26	
27	
28	
29	//鼠标滑上焦点图时停止自动播放,滑出时开始自动播放
30	$("#focus").hover(function() {
31		clearInterval(picTimer);
32	},function() {
33		picTimer = setInterval(function() {
34			if(index == len) { //如果索引值等于li元素个数,说明最后一张图播放完毕,接下来要显示第一张图,即调用showFirPic(),然后将索引值清零
35				showFirPic();
36				index = 0;
37			} else { //如果索引值不等于li元素个数,按普通状态切换,调用showPics()
38				showPics(index);
39			}
40			index++;
41		},3000); //此3000代表自动播放的间隔,单位:毫秒
42	}).trigger("mouseleave");
43	
44	//显示图片函数,根据接收的index值显示相应的内容
45	function showPics(index) { //普通切换
46		var nowLeft = -index*sWidth; //根据index值计算ul元素的left值
47		$("#focus ul").stop(true,false).animate({"left":nowLeft},500); //通过animate()调整ul元素滚动到计算出的position
48		$("#focus .btn span").removeClass("on").eq(index).addClass("on"); //为当前的按钮切换到选中的效果
49	}
50	
51	function showFirPic() { //最后一张图自动切换到第一张图时专用
52		$("#focus ul").append($("#focus ul li:first").clone());
53		var nowLeft = -len*sWidth; //通过li元素个数计算ul元素的left值,也就是最后一个li元素的右边
54		$("#focus ul").stop(true,false).animate({"left":nowLeft},500,function() {
55			//通过callback,在动画结束后把ul元素重新定位到起点,然后删除最后一个复制过去的元素
56			$("#focus ul").css("left","0");
57			$("#focus ul li:last").remove();
58		}); 
59		$("#focus .btn span").removeClass("on").eq(0).addClass("on"); //为第一个按钮添加选中的效果
60	}
61});

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.