timer.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. var videotimer = md5($('#time').val());
  2. var HH = 0;
  3. var mm = 0;
  4. var ss = 0;
  5. var x=1;
  6. var str = '';
  7. //var timer = setInterval(gettimer,1000);
  8. var timer;
  9. function gettimer(){
  10. str = "";
  11. if(++ss==60)
  12. {
  13. if(++mm==60)
  14. {
  15. HH++;
  16. mm=0;
  17. }
  18. ss=0;
  19. }
  20. str+=HH<10?"0"+HH:HH;
  21. str+=":";
  22. str+=mm<10?"0"+mm:mm;
  23. str+=":";
  24. str+=ss<10?"0"+ss:ss;
  25. document.getElementById("dtime").innerHTML = str;
  26. localStorage.setItem(videotimer,HH*3600+mm*60+ss);
  27. var doness = $('#doness').val();
  28. var nowss = parseInt(doness)+1;
  29. var now = Math.floor(nowss/3600*100)/100;
  30. var totalss = $('#totalss').val();
  31. var progress = Math.floor(nowss/totalss*100);
  32. $('.done_progress').text(progress);
  33. $('.done_noprogress').text(100-parseInt(progress));
  34. $('#noprogresstar').css('width',(100-parseInt(progress))+'%');
  35. $('#progresstar').css('width',progress+'%');
  36. $('.done_hh').text(now);
  37. $('#doness').val(nowss);
  38. if(nowss == totalss){
  39. $('#finishClass').show();
  40. $('#classStatus').html('已完成本课程学习');
  41. clearInterval(timer);
  42. myPlayer.pause();
  43. updatedata();
  44. }
  45. if(HH*3600+mm*60+ss == 60*5*x){
  46. updatedata();
  47. if(x%2 == 0) {
  48. clearInterval(timer);
  49. $('#videoValidate').show();
  50. $('.bodyBg').show();
  51. myPlayer.pause();
  52. }
  53. x++;
  54. }
  55. }
  56. function starttimer(){
  57. timer = setInterval(gettimer,1000);
  58. myPlayer.play();
  59. $('#videoValidate').hide();
  60. $('.bodyBg').hide();
  61. }
  62. function startclass(){
  63. $('#videoTips').hide();
  64. $('.bodyBg').hide();
  65. timer = setInterval(gettimer,1000);
  66. myPlayer.setDataSource({type: videotype, src: videosrc});
  67. myPlayer.seekTo(parseInt(videotime)*1000);
  68. myPlayer.play();
  69. }