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