var AutoPlay = function (id) { this.initialize(id) }; AutoPlay.prototype = { initialize: function (id) { var oThis = this; this.oBox = document.getElementById(id); this.creatPic(); this.oUl = (this.oBox || document).getElementsByTagName("ul")[0]; this.aImg = (this.oBox || document).getElementsByTagName("img"); this.timer = null; this.autoTimer = null; this.iNow = 0; this.creatBtn(); this.aBtn = (this.oCount || document).getElementsByTagName("li"); this.toggle(); this.autoTimer = setInterval(function () { oThis.next() }, 3000); this.oBox.onmouseover = function () { clearInterval(oThis.autoTimer) }; this.oBox.onmouseout = function () { oThis.autoTimer = setInterval(function () { oThis.next() }, 3000) }; for (var i = 0; i < this.aBtn.length; i++) { this.aBtn[i].index = i; this.aBtn[i].onmouseover = function () { oThis.iNow = this.index; oThis.toggle() } } }, creatPic: function () { var links = "#|#|#|/userfiles/images/2021041210185111297.jpg|#".split("|"); var pics = "/userfiles/images/hf2.jpg|/userfiles/images/hf3.jpg|/userfiles/images/2022110710223348dad.jpg|/userfiles/images/2021041210185111297.jpg|/userfiles/images/202211070936017b0f9.jpg".split("|"); var adsIDs = "2|3|5|7|11".split("|"); var oPicDiv = document.createElement("div"); oPicDiv.className = "rotation_box_list_2"; var oPics = document.createElement("ul"); var oFrag = document.createDocumentFragment(); for (var i = 0; i < links.length; i++) { var oLi = document.createElement("li"); oLi.id = "rotation_box_li_" + adsIDs[i]; oLi.innerHTML = ''; oFrag.appendChild(oLi); } oPics.appendChild(oFrag); oPicDiv.appendChild(oPics); this.oBox.appendChild(oPicDiv) }, creatBtn: function () { this.oCount = document.createElement("ul"); var oFrag = document.createDocumentFragment(); this.oCount.className = "rotation_box_count_2"; for (var i = 0; i < this.aImg.length; i++) { var oLi = document.createElement("li"); oLi.innerHTML = i + 1; oFrag.appendChild(oLi) } this.oCount.appendChild(oFrag); this.oBox.appendChild(this.oCount) }, toggle: function () { for (var i = 0; i < this.aBtn.length; i++) this.aBtn[i].className = ""; this.aBtn[this.iNow].className = "current"; this.doMove(-(this.iNow * this.aImg[0].offsetHeight)) }, next: function () { this.iNow++; this.iNow == this.aBtn.length && (this.iNow = 0); this.toggle() }, doMove: function (iTarget) { var oThis = this; clearInterval(oThis.timer); oThis.timer = setInterval(function () { var iSpeed = (iTarget - oThis.oUl.offsetTop) / parseInt("5"); iSpeed = iSpeed > 0 ? Math.ceil(iSpeed) : Math.floor(iSpeed); oThis.oUl.offsetTop == iTarget ? clearInterval(oThis.timer) : (oThis.oUl.style.top = oThis.oUl.offsetTop + iSpeed + "px") }, 30) } }; document.writeln(''); document.writeln('
'); new AutoPlay("rotation_box_2"); document.close();