一段图片切换的js,调用的prototype,现须要把其转换成用jquery,谢谢帮助.图片切换代码效果演示:http://movie.xunlei.com/topic/gougou_vid/gougou_picnews.html
须要转换的js文件:effect_switcher_1104.jsif (!window.Switcher)
var Switcher = new Object();
Switcher = {
autoSwitchTimer: null,
CurTab:1,
autoSwitchTimeIntval:3000,
showTab: function(args) {
if (!args.CurElm) { return false ;}
if (!args.Total) { return false ;}
if (!args.TabupStyle) { return false ;}
if (!args.ListupStyle) { return false ;}
if (!args.Symbol) { return false ;}
for (j=1;j<=args.Total;j++ ) {
if (j==args.CurElm) {
//alert(args.TabupStyle) ;
$(args.Symbol+"_tab_"+args.CurElm).addClassName(args.TabupStyle) ;
$(args.Symbol+"_list_"+args.CurElm).addClassName(args.ListupStyle) ;
}
else {
$(args.Symbol+"_tab_"+j).removeClassName(args.TabupStyle) ;
$(args.Symbol+"_list_"+j).removeClassName(args.ListupStyle) ;
}
}
if (args.autoSwitch) {
var argsstr = 'Total:'+args.Total+','+
'TabupStyle:"'+args.TabupStyle+'",'+
'ListupStyle:"'+args.ListupStyle+'",'+
'Symbol:"'+args.Symbol+'",'+
'autoSwitch:true';
$(args.Symbol+"_list_"+args.CurElm).onmouseover = new Function("Switcher.pauseSwitch();") ;
$(args.Symbol+"_list_"+args.CurElm).onmouseout = new Function("Switcher.goonSwitch({"+argsstr+"});") ;
this.autoSwitch(args) ;
}
},
initTab: function(args) {
//if (!args.CurElm) { return false ;}
if (!args.Total) { return false ;}
if (!args.TabupStyle) { return false ;}
if (!args.ListupStyle) { return false ;}
if (!args.Symbol) { return false ;}
if (args.TimeIntval){
this.autoSwitchTimeIntval = args.TimeIntval ;
}
this.CurTab = 1 ;
for (i=1;i<=args.Total;i++ ) {
var MyCurElm = i ;
FunctionStr = "Switcher.showTab({ "+
"CurElm:'"+MyCurElm+"',"+
"Total:'"+args.Total+"',"+
"TabupStyle:'"+args.TabupStyle+"',"+
"ListupStyle:'"+args.ListupStyle+"',"+
"Symbol:'"+args.Symbol+"'} );" ;
$(args.Symbol+"_tab_"+i).onmouseover = new Function(FunctionStr) ;
}
if (args.autoSwitch) {
this.autoSwitch(args) ;
}
},
autoSwitch: function(args) {
this.CurTab ++ ;
if (this.CurTab > args.Total) {
this.CurTab = 1 ;
}
var argsstr = 'Total:'+args.Total+','+
'CurElm:'+this.CurTab+','+
'TabupStyle:"'+args.TabupStyle+'",'+
'ListupStyle:"'+args.ListupStyle+'",'+
'Symbol:"'+args.Symbol+'",'+
'autoSwitch:true';
//alert(argsstr) ;
this.autoSwitchTimer = setTimeout("Switcher.showTab({"+argsstr+"});", this.autoSwitchTimeIntval);
},
pauseSwitch: function(args) {
clearTimeout(this.autoSwitchTimer);
},
goonSwitch: function(args) {
clearTimeout(this.autoSwitchTimer);
this.autoSwitch(args) ;
}
}
if (!window.MyFlashSwitch)
var FlashSwitch = new Object();
FlashSwitch = {
AutoFlashTimer: null ,
CurScreen: 0,
MaxScreen:0,
TimeIntval:3000,
SwitchImage:{},
SwitchData:{},
SwitchTitleContainers:{},
PageNavContainer:{},
init: function(args) {
var SwitchContainer = $(args.Container) ;
if (args.TimeIntval) {
this.TimeIntval = args.TimeIntval ;
}
this.SwitchData = args.Data ;
for (i=0;i<this.SwitchData.length ;i++ ) {
var MyImgContainer = document.createElement("a") ;
MyImgContainer.href = this.SwitchData[i]["link"] ;
MyImgContainer.title = this.SwitchData[i]["title"] ;
MyImgContainer.blockid = this.SwitchData[i]["blockid"] ;
MyImgContainer.innerHTML = '<img src="'+this.SwitchData[i]["img"]+'">' ;
SwitchContainer.appendChild(MyImgContainer) ;
}
SwitchContainer.onmouseover = function() {FlashSwitch.pauseSwitch();}
SwitchContainer.onmouseout = function() {FlashSwitch.goonSwitch();}
this.SwitchImage = SwitchContainer.getElementsByTagName("img") ;
this.SwitchTitleContainers = args.Titles ;
this.MaxScreen = this.SwitchImage.length ;
this.PageNavContainer = $(args.PageNav) ;
this.goSwitch(this.CurScreen) ;
this.AutoFlashTimer = setTimeout('FlashSwitch.goAutoSwitch();', this.TimeIntval);
},
goSwitch: function(screen) {
if (screen >= this.MaxScreen) {
screen = 0 ;
}
//alert(screen) ;
var ImageTmp = this.SwitchImage ;
for (i=0;i<this.MaxScreen;i++) {
ImageTmp[i].style.display = "none" ;
}
ImageTmp[screen].style.display = "block" ;
this.showSwitchNav(screen) ;
if (this.SwitchTitleContainers) {
this.showSwitchTitles(screen) ;
}
this.CurScreen = screen ; },
goAutoSwitch: function() {
this.goSwitch(this.CurScreen+1);
this.AutoFlashTimer = setTimeout('FlashSwitch.goAutoSwitch();', this.TimeIntval);
},
showSwitchNav: function(screen) {
this.PageNavContainer.innerHTML ="" ;
var PageNavInnerHTML = "" ;
for (i=1;i<=this.MaxScreen ;i++ ) {
if ((i - 1) == screen ) {
PageNavInnerHTML += "<a href='javascript://' class='currA' target='_self'>"+i+"</a>" ;
}else {
PageNavInnerHTML += "<a href='javascript://' target='_self' onclick='FlashSwitch.goManSwitch("+(i-1)+")'>"+i+"</a>" ;
}
}
this.PageNavContainer.onmouseover = function() {FlashSwitch.pauseSwitch();}
this.PageNavContainer.onmouseout = function() {FlashSwitch.goonSwitch();}
this.PageNavContainer.innerHTML =PageNavInnerHTML ;
},
showSwitchTitles: function(screen) {
for (i=0;i<this.SwitchTitleContainers.length ;i++ ) {
$("SwitchTitle_"+this.SwitchTitleContainers[i]).onmouseover = function() {FlashSwitch.pauseSwitch();}
$("SwitchTitle_"+this.SwitchTitleContainers[i]).onmouseout = function() {FlashSwitch.goonSwitch();}
$("SwitchTitle_"+this.SwitchTitleContainers[i]).innerHTML = '<a href="'+this.SwitchData[screen]['link']+'" title="'+
this.SwitchData[screen][this.SwitchTitleContainers[i]]+'" target="_blank">'+
this.SwitchData[screen][this.SwitchTitleContainers[i]]+
'</a>' ;
}
},
pauseSwitch: function() {
clearTimeout(this.AutoFlashTimer);
},
goonSwitch: function() {
clearTimeout(this.AutoFlashTimer);
this.AutoFlashTimer = setTimeout('FlashSwitch.goAutoSwitch();', this.TimeIntval);
},
goManSwitch: function(screen) {
clearTimeout(this.AutoFlashTimer);
this.CurScreen = screen - 1 ;
this.goAutoSwitch();
}
}
if (!window.XLEffect)
var XLEffect = new Object();XLEffect.randomStyles = function(args) {
if (!args.Container) { return false ;}
if (!args.Styles) { return false ;}
if (!args.Elm) { return false ;}
var MyElms = $(args.Container).getElementsByTagName(args.Elm) ;
for (i=0;i<MyElms.length ;i++ ) {
var myrand = parseInt(Math.random() * (args.Styles.length + 1) + 1 ) - 1 ;
if (myrand > 0) {
MyElms[i].className = args.Styles[(myrand-1)] ;
}
}
}具体说明见此:http://bbs.kesion.com/dispbbs.asp?BoardID=41&ID=62665
须要转换的js文件:effect_switcher_1104.jsif (!window.Switcher)
var Switcher = new Object();
Switcher = {
autoSwitchTimer: null,
CurTab:1,
autoSwitchTimeIntval:3000,
showTab: function(args) {
if (!args.CurElm) { return false ;}
if (!args.Total) { return false ;}
if (!args.TabupStyle) { return false ;}
if (!args.ListupStyle) { return false ;}
if (!args.Symbol) { return false ;}
for (j=1;j<=args.Total;j++ ) {
if (j==args.CurElm) {
//alert(args.TabupStyle) ;
$(args.Symbol+"_tab_"+args.CurElm).addClassName(args.TabupStyle) ;
$(args.Symbol+"_list_"+args.CurElm).addClassName(args.ListupStyle) ;
}
else {
$(args.Symbol+"_tab_"+j).removeClassName(args.TabupStyle) ;
$(args.Symbol+"_list_"+j).removeClassName(args.ListupStyle) ;
}
}
if (args.autoSwitch) {
var argsstr = 'Total:'+args.Total+','+
'TabupStyle:"'+args.TabupStyle+'",'+
'ListupStyle:"'+args.ListupStyle+'",'+
'Symbol:"'+args.Symbol+'",'+
'autoSwitch:true';
$(args.Symbol+"_list_"+args.CurElm).onmouseover = new Function("Switcher.pauseSwitch();") ;
$(args.Symbol+"_list_"+args.CurElm).onmouseout = new Function("Switcher.goonSwitch({"+argsstr+"});") ;
this.autoSwitch(args) ;
}
},
initTab: function(args) {
//if (!args.CurElm) { return false ;}
if (!args.Total) { return false ;}
if (!args.TabupStyle) { return false ;}
if (!args.ListupStyle) { return false ;}
if (!args.Symbol) { return false ;}
if (args.TimeIntval){
this.autoSwitchTimeIntval = args.TimeIntval ;
}
this.CurTab = 1 ;
for (i=1;i<=args.Total;i++ ) {
var MyCurElm = i ;
FunctionStr = "Switcher.showTab({ "+
"CurElm:'"+MyCurElm+"',"+
"Total:'"+args.Total+"',"+
"TabupStyle:'"+args.TabupStyle+"',"+
"ListupStyle:'"+args.ListupStyle+"',"+
"Symbol:'"+args.Symbol+"'} );" ;
$(args.Symbol+"_tab_"+i).onmouseover = new Function(FunctionStr) ;
}
if (args.autoSwitch) {
this.autoSwitch(args) ;
}
},
autoSwitch: function(args) {
this.CurTab ++ ;
if (this.CurTab > args.Total) {
this.CurTab = 1 ;
}
var argsstr = 'Total:'+args.Total+','+
'CurElm:'+this.CurTab+','+
'TabupStyle:"'+args.TabupStyle+'",'+
'ListupStyle:"'+args.ListupStyle+'",'+
'Symbol:"'+args.Symbol+'",'+
'autoSwitch:true';
//alert(argsstr) ;
this.autoSwitchTimer = setTimeout("Switcher.showTab({"+argsstr+"});", this.autoSwitchTimeIntval);
},
pauseSwitch: function(args) {
clearTimeout(this.autoSwitchTimer);
},
goonSwitch: function(args) {
clearTimeout(this.autoSwitchTimer);
this.autoSwitch(args) ;
}
}
if (!window.MyFlashSwitch)
var FlashSwitch = new Object();
FlashSwitch = {
AutoFlashTimer: null ,
CurScreen: 0,
MaxScreen:0,
TimeIntval:3000,
SwitchImage:{},
SwitchData:{},
SwitchTitleContainers:{},
PageNavContainer:{},
init: function(args) {
var SwitchContainer = $(args.Container) ;
if (args.TimeIntval) {
this.TimeIntval = args.TimeIntval ;
}
this.SwitchData = args.Data ;
for (i=0;i<this.SwitchData.length ;i++ ) {
var MyImgContainer = document.createElement("a") ;
MyImgContainer.href = this.SwitchData[i]["link"] ;
MyImgContainer.title = this.SwitchData[i]["title"] ;
MyImgContainer.blockid = this.SwitchData[i]["blockid"] ;
MyImgContainer.innerHTML = '<img src="'+this.SwitchData[i]["img"]+'">' ;
SwitchContainer.appendChild(MyImgContainer) ;
}
SwitchContainer.onmouseover = function() {FlashSwitch.pauseSwitch();}
SwitchContainer.onmouseout = function() {FlashSwitch.goonSwitch();}
this.SwitchImage = SwitchContainer.getElementsByTagName("img") ;
this.SwitchTitleContainers = args.Titles ;
this.MaxScreen = this.SwitchImage.length ;
this.PageNavContainer = $(args.PageNav) ;
this.goSwitch(this.CurScreen) ;
this.AutoFlashTimer = setTimeout('FlashSwitch.goAutoSwitch();', this.TimeIntval);
},
goSwitch: function(screen) {
if (screen >= this.MaxScreen) {
screen = 0 ;
}
//alert(screen) ;
var ImageTmp = this.SwitchImage ;
for (i=0;i<this.MaxScreen;i++) {
ImageTmp[i].style.display = "none" ;
}
ImageTmp[screen].style.display = "block" ;
this.showSwitchNav(screen) ;
if (this.SwitchTitleContainers) {
this.showSwitchTitles(screen) ;
}
this.CurScreen = screen ; },
goAutoSwitch: function() {
this.goSwitch(this.CurScreen+1);
this.AutoFlashTimer = setTimeout('FlashSwitch.goAutoSwitch();', this.TimeIntval);
},
showSwitchNav: function(screen) {
this.PageNavContainer.innerHTML ="" ;
var PageNavInnerHTML = "" ;
for (i=1;i<=this.MaxScreen ;i++ ) {
if ((i - 1) == screen ) {
PageNavInnerHTML += "<a href='javascript://' class='currA' target='_self'>"+i+"</a>" ;
}else {
PageNavInnerHTML += "<a href='javascript://' target='_self' onclick='FlashSwitch.goManSwitch("+(i-1)+")'>"+i+"</a>" ;
}
}
this.PageNavContainer.onmouseover = function() {FlashSwitch.pauseSwitch();}
this.PageNavContainer.onmouseout = function() {FlashSwitch.goonSwitch();}
this.PageNavContainer.innerHTML =PageNavInnerHTML ;
},
showSwitchTitles: function(screen) {
for (i=0;i<this.SwitchTitleContainers.length ;i++ ) {
$("SwitchTitle_"+this.SwitchTitleContainers[i]).onmouseover = function() {FlashSwitch.pauseSwitch();}
$("SwitchTitle_"+this.SwitchTitleContainers[i]).onmouseout = function() {FlashSwitch.goonSwitch();}
$("SwitchTitle_"+this.SwitchTitleContainers[i]).innerHTML = '<a href="'+this.SwitchData[screen]['link']+'" title="'+
this.SwitchData[screen][this.SwitchTitleContainers[i]]+'" target="_blank">'+
this.SwitchData[screen][this.SwitchTitleContainers[i]]+
'</a>' ;
}
},
pauseSwitch: function() {
clearTimeout(this.AutoFlashTimer);
},
goonSwitch: function() {
clearTimeout(this.AutoFlashTimer);
this.AutoFlashTimer = setTimeout('FlashSwitch.goAutoSwitch();', this.TimeIntval);
},
goManSwitch: function(screen) {
clearTimeout(this.AutoFlashTimer);
this.CurScreen = screen - 1 ;
this.goAutoSwitch();
}
}
if (!window.XLEffect)
var XLEffect = new Object();XLEffect.randomStyles = function(args) {
if (!args.Container) { return false ;}
if (!args.Styles) { return false ;}
if (!args.Elm) { return false ;}
var MyElms = $(args.Container).getElementsByTagName(args.Elm) ;
for (i=0;i<MyElms.length ;i++ ) {
var myrand = parseInt(Math.random() * (args.Styles.length + 1) + 1 ) - 1 ;
if (myrand > 0) {
MyElms[i].className = args.Styles[(myrand-1)] ;
}
}
}具体说明见此:http://bbs.kesion.com/dispbbs.asp?BoardID=41&ID=62665
解决方案 »
- Jquery等比缩放图片问题
- 层的隐藏和显示问题?
- 请问一下javascript如何调用ocx控件?
- 求一简单(与fromCharCode相关)的编码函数
- 如何判断一个字符串是有效的时间串(hh:mm:ss)以及是有效的日期时间串(yyyy-mm-dd hh:mm:ss)?
- 后台Action处理完后 jqgrid接收完数据怎样同时调用一个function
- 对于一个字符串,里面包含了一些分号,可能是中文,也可能是英文,我怎么用js实现把所有的分号转换为英文分号
- javascript能实现如下功能吗?
- 在JavaScript中怎么样忽略小错误--不要弹出错误提示?
- My97DatePicker选择时间控件问题
- 请问js的对象的问题
- JavaScript如何向HTML中输出自定义函数
Switcher = {
autoSwitchTimer: null,
CurTab: 1,
autoSwitchTimeIntval: 3000,
showTab: function(args){
if (!args.CurElm || !args.Total || !args.TabupStyle || !args.ListupStyle || !args.Symbol) {
return false;
}
for (j = 1; j <= args.Total; j++) {
if (j == args.CurElm) {
//alert(args.TabupStyle) ;
$("#" + args.Symbol + "_tab_" + args.CurElm).addClass(args.TabupStyle);
$("#" + args.Symbol + "_list_" + args.CurElm).addClass(args.ListupStyle);
} else {
$("#" + args.Symbol + "_tab_" + j).removeClass(args.TabupStyle);
$("#" + args.Symbol + "_list_" + j).removeClass(args.ListupStyle);
}
}
if (args.autoSwitch) {
var argsstr = 'Total:' + args.Total + ',' +
'TabupStyle:"' +
args.TabupStyle +
'",' +
'ListupStyle:"' +
args.ListupStyle +
'",' +
'Symbol:"' +
args.Symbol +
'",' +
'autoSwitch:true';
$("#" + args.Symbol + "_list_" + args.CurElm).mouseover(new Function("Switcher.pauseSwitch();"));
$("#" + args.Symbol + "_list_" + args.CurElm).mouseout(new Function("Switcher.goonSwitch({" + argsstr + "});"));
this.autoSwitch(args);
}
},
initTab: function(args){
//if (!args.CurElm) { return false ;}
if (!args.Total || !args.TabupStyle || !args.ListupStyle || !args.Symbol) {
return false;
}
if (args.TimeIntval) {
this.autoSwitchTimeIntval = args.TimeIntval;
}
this.CurTab = 1;
for (i = 1; i <= args.Total; i++) {
var MyCurElm = i;
FunctionStr = "Switcher.showTab({" +
"CurElm:'" +
MyCurElm +
"'," +
"Total:'" +
args.Total +
"'," +
"TabupStyle:'" +
args.TabupStyle +
"'," +
"ListupStyle:'" +
args.ListupStyle +
"'," +
"Symbol:'" +
args.Symbol +
"'});";
$("#" + args.Symbol + "_tab_" + i).mouseover(new Function(FunctionStr));
}
if (args.autoSwitch) {
this.autoSwitch(args);
}
},
autoSwitch: function(args){
this.CurTab++;
if (this.CurTab > args.Total) {
this.CurTab = 1;
}
var argsstr = 'Total:' + args.Total + ',' +
'CurElm:' +
this.CurTab +
',' +
'TabupStyle:"' +
args.TabupStyle +
'",' +
'ListupStyle:"' +
args.ListupStyle +
'",' +
'Symbol:"' +
args.Symbol +
'",' +
'autoSwitch:true';
//alert(argsstr) ;
this.autoSwitchTimer = setTimeout("Switcher.showTab({" + argsstr + "});", this.autoSwitchTimeIntval);
},
pauseSwitch: function(args){
clearTimeout(this.autoSwitchTimer);
},
goonSwitch: function(args){
clearTimeout(this.autoSwitchTimer);
this.autoSwitch(args);
}
}
if (!window.MyFlashSwitch) var FlashSwitch = new Object();
FlashSwitch = {
AutoFlashTimer: null,
CurScreen: 0,
MaxScreen: 0,
TimeIntval: 3000,
SwitchImage: {},
SwitchData: {},
SwitchTitleContainers: {},
PageNavContainer: {},
init: function(args){
var SwitchContainer = $(args.Container);
if (args.TimeIntval) {
this.TimeIntval = args.TimeIntval;
}
this.SwitchData = args.Data;
for (i = 0; i < this.SwitchData.length; i++) {
var MyImgContainer = document.createElement("a");
MyImgContainer.href = this.SwitchData[i]["link"];
MyImgContainer.title = this.SwitchData[i]["title"];
MyImgContainer.blockid = this.SwitchData[i]["blockid"];
MyImgContainer.innerHTML = '<img src="' + this.SwitchData[i]["img"] + '">';
SwitchContainer.appen(MyImgContainer);
}
SwitchContainer.mouseover(function(){
FlashSwitch.pauseSwitch();
});
SwitchContainer.mouseout(function(){
FlashSwitch.goonSwitch();
});
this.SwitchImage = SwitchContainer.children("img");
this.SwitchTitleContainers = args.Titles;
this.MaxScreen = this.SwitchImage.length;
this.PageNavContainer = $(args.PageNav);
this.goSwitch(this.CurScreen);
this.AutoFlashTimer = setTimeout('FlashSwitch.goAutoSwitch();', this.TimeIntval);
},
goSwitch: function(screen){
if (screen >= this.MaxScreen) {
screen = 0;
}
//alert(screen) ;
var ImageTmp = this.SwitchImage;
ImageTmp.hide();
ImageTmp[screen].style.display = "block";
this.showSwitchNav(screen);
if (this.SwitchTitleContainers) {
this.showSwitchTitles(screen);
}
this.CurScreen = screen;
},
goAutoSwitch: function(){
this.goSwitch(this.CurScreen + 1);
this.AutoFlashTimer = setTimeout('FlashSwitch.goAutoSwitch();', this.TimeIntval);
},
showSwitchNav: function(screen){
this.PageNavContainer.html("");
var PageNavInnerHTML = "";
for (i = 1; i <= this.MaxScreen; i++) {
if ((i - 1) == screen) {
PageNavInnerHTML += "<a href='javascript://' class='currA' target='_self'>" + i + "</a>";
} else {
PageNavInnerHTML += "<a href='javascript://' target='_self' onclick='FlashSwitch.goManSwitch(" + (i - 1) + ")'>" + i + "</a>";
}
}
this.PageNavContainer.mouseover(function(){
FlashSwitch.pauseSwitch();
});
this.PageNavContainer.mouseout(function(){
FlashSwitch.goonSwitch();
});
this.PageNavContainer.html(PageNavInnerHTML);
},
showSwitchTitles: function(screen){
for (i = 0; i < this.SwitchTitleContainers.length; i++) {
$("#SwitchTitle_" + this.SwitchTitleContainers[i]).mouseover(function(){
FlashSwitch.pauseSwitch();
});
$("#SwitchTitle_" + this.SwitchTitleContainers[i]).mouseout(function(){
FlashSwitch.goonSwitch();
});
$("#SwitchTitle_" + this.SwitchTitleContainers[i]).html('<a href="' + this.SwitchData[screen]['link'] + '" title="' +
this.SwitchData[screen][this.SwitchTitleContainers[i]] +
'" target="_blank">' +
this.SwitchData[screen][this.SwitchTitleContainers[i]] +
'</a>');
}
},
pauseSwitch: function(){
clearTimeout(this.AutoFlashTimer);
},
goonSwitch: function(){
clearTimeout(this.AutoFlashTimer);
this.AutoFlashTimer = setTimeout('FlashSwitch.goAutoSwitch();', this.TimeIntval);
},
goManSwitch: function(screen){
clearTimeout(this.AutoFlashTimer);
this.CurScreen = screen - 1;
this.goAutoSwitch();
}
}
if (!window.XLEffect) var XLEffect = new Object();XLEffect.randomStyles = function(args){
if (!args.Container || !args.Styles || !args.Elm) {
return false;
}
var MyElms = $(args.Container).children(args.Elm);
MyElms.each(function(){
var myrand = parseInt(Math.random() * (args.Styles.length + 1) + 1) - 1;
if (myrand > 0) {
this.className = args.Styles[(myrand - 1)];
}
});
}