Commit 536939b7252d8c5add2132eabeecb5521d7586be

Authored by ykxie
1 parent 35a69647

录制编译同步

Showing 1 changed file with 23 additions and 17 deletions
src/js/gbreplayer.js
... ... @@ -539,7 +539,6 @@ $(function(){
539 539  
540 540 // 播放录制代码过程
541 541 $('.audio-play').unbind('click').click(function(){
542   - Hourglass.init();
543 542 var resultData = {
544 543 output: '',
545 544 stderr: '',
... ... @@ -570,9 +569,9 @@ $(function(){
570 569 GBCodePlayBack.recordtimeoutcontrolls = [];
571 570 /* END 初始化播放 */
572 571  
573   -
574 572 playbtn.data('status', 0);
575 573 $('#play').trigger('click');
  574 + Hourglass.init();
576 575 });
577 576  
578 577 //setting speed in cookie
... ... @@ -990,9 +989,16 @@ $(function(){
990 989 $('#comprunbtngrp').unbind("click").on('click', '#comprun', function(event){
991 990 event.preventDefault();
992 991 var l = Ladda.create(this);
993   - $('#comprun').find('ladda-spinner').remove()
  992 + $('#comprun').find('ladda-spinner').remove();
994 993 l.start();
  994 + var runStatus = $("#comprun").data('run');
995 995  
  996 + if(runStatus == 1){
  997 + Hourglass.pauseTimer(); // 暂停计时器
  998 + recorder.pause(); // 音频暂停
  999 + }
  1000 + $("#comprun").data('run', 0);
  1001 + console.log($("#comprun").data('run'));
996 1002 // 暂停录制
997 1003 var pauseState = $('#pause').data('pause');
998 1004 if(pauseState == 1 && _role == 0){
... ... @@ -1015,10 +1021,7 @@ $(function(){
1015 1021 playTime: 0
1016 1022 };
1017 1023 GBCodePlayBack.records.push(recordobj);
1018   - console.log(GBCodePlayBack.records)
1019   -
1020   - Hourglass.pauseTimer(); // 暂停计时器
1021   - recorder.pause(); // 音频暂停
  1024 + console.log(GBCodePlayBack.records);
1022 1025  
1023 1026 $('#pause').data('status', '1');
1024 1027 $('#pause').data('pause', '0');
... ... @@ -1026,21 +1029,19 @@ $(function(){
1026 1029 $('#start-recording').hide();
1027 1030  
1028 1031 $('.pause-shodow').removeClass('hidden').addClass('show');
  1032 +
  1033 + console.log('0000---1111')
1029 1034 }
1030 1035  
1031 1036 var code = (typeof GBCodePlayBack.htmleditor !=='undefined' && GBCodePlayBack.htmleditor.getValue())
1032 1037 || (typeof GBCodePlayBack.htmlplayereditor !=='undefined' && GBCodePlayBack.htmlplayereditor.getValue());
1033   -
1034 1038 var langid = $('#htmlbutton').data("languageid");
1035   -
1036 1039 var input = $('#input').val() || '';
1037   -
1038 1040 var compileData = {
1039   - code:code,
1040   - langid:langid,
1041   - input: input
  1041 + code: code,
  1042 + langid: langid,
  1043 + input: input
1042 1044 }
1043   -
1044 1045 $.ajax({
1045 1046 type: "post",
1046 1047 url: gxb_api + "/submit/submitCode/api",
... ... @@ -1058,7 +1059,7 @@ $(function(){
1058 1059 },
1059 1060 error: function(){
1060 1061 l.stop();
1061   - alert('错误')
  1062 + alert('错误');
1062 1063 }
1063 1064 });
1064 1065 });
... ... @@ -1068,6 +1069,7 @@ $(function(){
1068 1069 $('#save_compile').unbind("click").click(function(){
1069 1070 var length = GBCodePlayBack.records.length - 1;
1070 1071 Hourglass.pauseTimer();
  1072 + $("#comprun").data('run', 1);
1071 1073 GBCodePlayBack.records[length].compile = GBCodePlayBack.compileResultData;
1072 1074  
1073 1075 GBCodePlayBack.records[length].output = GBCodePlayBack.compileResultData.output;
... ... @@ -1077,7 +1079,7 @@ $(function(){
1077 1079  
1078 1080 GBCodePlayBack.record_continue_time = new Date().getTime();
1079 1081  
1080   - contrlPause()
  1082 + contrlPause();
1081 1083  
1082 1084 })
1083 1085  
... ... @@ -1562,6 +1564,10 @@ $(function(){
1562 1564 })
1563 1565  
1564 1566 $('#re-recoding').click(function(){
  1567 + $('#audio')[0].pause();
  1568 + Hourglass.stopTimer();
  1569 + playEnd()
  1570 + $('.audio-play').attr('disabled', false);
1565 1571 $('.re-tips').show();
1566 1572 })
1567 1573  
... ... @@ -1743,7 +1749,7 @@ $(function(){
1743 1749 // $('#comprunbtngrp').html('<button id="runnow" type="button" data-style="expand-right" class="btn" title="运行代码">&nbsp; 运行</button>');
1744 1750 }else{
1745 1751 $('#fontendrun').addClass('hidden');
1746   - $('#comprunbtngrp').html('<button id="comprun" type="button" data-style="expand-right" class="btn" title="编译并运行代码">&nbsp;编译&运行</button>');
  1752 + $('#comprunbtngrp').html('<button id="comprun" type="button" data-run="1" data-style="expand-right" class="btn" title="编译并运行代码">&nbsp;编译&运行</button>');
1747 1753  
1748 1754 $('#ifrcontainer').addClass('hidden');
1749 1755 $('#cmprun-output').removeClass('hidden');
... ...