var channelArr = [1,2,3,4,5,6,7,8,9];
var windowArr = [1,2,3];
var time = 1;
//当逻辑通道数大于屏幕窗口数
function roundPreview(channelArr,windowArr){
var totleTime = Math.ceil(channelArr.length/windowArr.length);
var remainder = channelArr.length%windowArr.length;//取余数
if(time==totleTime){
if(remainder==0){//整除
var channelStr = "";
var windowStr = "";
for(var j=0;j<windowArr.length;j++){
channelStr+= channelArr[((time-1)*windowArr.length)+j];
windowStr +=windowArr[j];
}
alert("channelStr: "+channelStr);
alert("windowStr: "+windowStr);
}else{
var channelStr = "";
var windowStr = "";
for(var k=0;k<remainder;k++){
channelStr+= channelArr[((time-1)*windowArr.length)+k];
windowStr +=windowArr[k];
}
alert("channelStr: "+channelStr);
alert("windowStr: "+windowStr);
}
time = 1;
}else{
var channelStr = "";
var windowStr = "";
for(var i=0;i<windowArr.length;i++){
channelStr+= channelArr[((time-1)*windowArr.length)+i];
windowStr +=windowArr[i];
}
alert("channelStr:"+channelStr);
alert("windowStr:"+windowStr);
time++;
}
}
window.setInterval(roundPreview,10000,channelArr,windowArr);
轮训业务逻辑
最新推荐文章于 2022-01-17 14:25:44 发布