function idx2sid(idx) {
if (idx < 10) {
return 'S00' + idx;
}
return 'S0' + idx;
}
function setS(SID) {
var iframe = document.getElementById('playframe').contentWindow;
iframe.SID = SID;
iframe.STime = 1;
iframe.lastLocation = 0;
iframe.sectionStatus = 'S';
iframe.sendServerRequest('setParam');
}
function setC(SID) {
var iframe = document.getElementById('playframe').contentWindow;
iframe.SID = SID;
iframe.STime = 1;
iframe.lastLocation = '10';
iframe.sectionStatus = 'C';
iframe.sendServerRequest('setParam');
}
function run(startIdx, endIdx) {
if (startIdx > endIdx) {
alert('课程结束');
return;
}
var SID = idx2sid(startIdx);
setS(SID);
setTimeout(function () {
setC(SID);
console.log(SID + ' ok!');
setTimeout(function () {
run(startIdx + 1, endIdx);
}, 2000);
}, 2000);
}
run(1, 17);
|