Commit ce1fcae230e4ed1a5e3d05ca8c2f33a9f846ce85

Authored by Keystion
1 parent 89923446

合并gbreplayer.js代码到gb.js

Showing 2 changed files with 26 additions and 47 deletions
src/index.html
@@ -91,12 +91,8 @@ @@ -91,12 +91,8 @@
91 </div> 91 </div>
92 </div> 92 </div>
93 <div id="textarea"> 93 <div id="textarea">
94 - <div id="recordzone" class="active">  
95 -  
96 - </div>  
97 - <div id="replayzone">  
98 -  
99 - </div> 94 + <div id="recordzone" class="active"></div>
  95 + <div id="replayzone"></div>
100 </div> 96 </div>
101 <div id="handleMR"></div> 97 <div id="handleMR"></div>
102 </div> 98 </div>
src/js/gb.js
@@ -10,6 +10,7 @@ $(function() { @@ -10,6 +10,7 @@ $(function() {
10 _source = getQuery('source'); 10 _source = getQuery('source');
11 var $recording_time = $('.recording-time'); 11 var $recording_time = $('.recording-time');
12 var tag = 1; // 标记第一次暂停 12 var tag = 1; // 标记第一次暂停
  13 + var player = $.AudioPlayer;
13 var htmlhlLine = null, 14 var htmlhlLine = null,
14 csshlLine = null, 15 csshlLine = null,
15 jshlLine = null; 16 jshlLine = null;
@@ -246,18 +247,21 @@ $(function() { @@ -246,18 +247,21 @@ $(function() {
246 excercise_records: [], 247 excercise_records: [],
247 autorun: 1, 248 autorun: 1,
248 triggertotal: 0, 249 triggertotal: 0,
249 - firstPlay: 1, // 第一次播放  
250 - pauseValue: '', // 存储暂停时内容 250 + firstPlay: 1, // 第一次播放
  251 + pauseValue: '', // 存储暂停时内容
251 triggeroffset: 0, //判断拖动进度条的偏移量 252 triggeroffset: 0, //判断拖动进度条的偏移量
252 excercise_triggertotal: 0, 253 excercise_triggertotal: 0,
253 - replay_enhancement: 1, //是否优化播放,即匀速播放 254 + replay_enhancement:1, //是否优化播放,即匀速播放
254 replay_enhancement_value: 250, 255 replay_enhancement_value: 250,
255 speed: 1, 256 speed: 1,
256 recordtimeoutcontrolls: [], 257 recordtimeoutcontrolls: [],
257 excercise_recordtimeoutcontrolls: [], 258 excercise_recordtimeoutcontrolls: [],
258 isgblibreplay: 0, 259 isgblibreplay: 0,
259 continue_recording: 0, //是否继续自动保`存的录制 260 continue_recording: 0, //是否继续自动保`存的录制
260 - recording_status: 1, // 当前是否在录制 261 + recording_status: 1, //当前是否在录制
  262 + times: 0, // 播放次数
  263 + isPause: 1, // 是否暂停 1:不暂停,0:暂停
  264 + isRcording: 0, // 是否录制 1:录制中,0:暂停中
261 recordinit: function(codereplaytype, preload) { 265 recordinit: function(codereplaytype, preload) {
262 /* #STRAT:生成CodeMirror Editor for JS/CSS/HTML */ 266 /* #STRAT:生成CodeMirror Editor for JS/CSS/HTML */
263 if (codereplaytype) { 267 if (codereplaytype) {
@@ -605,7 +609,6 @@ $(function() { @@ -605,7 +609,6 @@ $(function() {
605 609
606 $("#play_audio").attr('src', "http://gxb-file.oss-cn-beijing.aliyuncs.com/" + coderecords.audioUrl); 610 $("#play_audio").attr('src', "http://gxb-file.oss-cn-beijing.aliyuncs.com/" + coderecords.audioUrl);
607 611
608 - var player = $.AudioPlayer;  
609 player.init({ 612 player.init({
610 container: '#audioWrap', 613 container: '#audioWrap',
611 source: "http://gxb-file.oss-cn-beijing.aliyuncs.com/" + coderecords.audioUrl, 614 source: "http://gxb-file.oss-cn-beijing.aliyuncs.com/" + coderecords.audioUrl,
@@ -613,39 +616,19 @@ $(function() { @@ -613,39 +616,19 @@ $(function() {
613 debuggers: false, 616 debuggers: false,
614 allowSeek: false, 617 allowSeek: false,
615 playCallback: function() { // 播放 618 playCallback: function() { // 播放
616 - if (GBCodePlayBack.firstPlay == 0) {  
617 - $('#readonly').trigger('click');  
618 - GBCodePlayBack.htmlplayereditor.setValue(GBCodePlayBack.pauseValue)  
619 - } else {  
620 - GBCodePlayBack.htmlplayereditor.setValue('')  
621 - var resultData = {  
622 - output: '',  
623 - stderr: '',  
624 - cmpinfo: '',  
625 - result: 1  
626 - };  
627 - compileResult(resultData);  
628 - }  
629 -  
630 - playCoder();  
631 - // $('#play').trigger('click'); 619 + playCode();
  620 + GBCodePlayBack.htmlplayereditor.setOption('readOnly', true);
632 }, 621 },
633 pauseCallback: function() { // 暂停 622 pauseCallback: function() { // 暂停
634 -  
635 - GBCodePlayBack.pauseTime = new Date().getTime(); // 暂停的时间  
636 -  
637 - $('#readonly').trigger('click');  
638 - 623 + GBCodePlayBack.audioTime = parseInt(player.elements.audioDom.currentTime*1000)
  624 + pauseCode();
639 GBCodePlayBack.firstPlay = 0; 625 GBCodePlayBack.firstPlay = 0;
640 -  
641 GBCodePlayBack.pauseValue = GBCodePlayBack.htmlplayereditor.getValue(); 626 GBCodePlayBack.pauseValue = GBCodePlayBack.htmlplayereditor.getValue();
642 -  
643 - // $('#play').trigger('click');  
644 - playCoder();  
645 - 627 + GBCodePlayBack.htmlplayereditor.setOption('readOnly', false);
646 }, 628 },
647 - seekedCallback: function() {} // 拖拽  
648 - , 629 + seekedCallback: function() { // 拖拽
  630 +
  631 + },
649 endedCallback: function() { // 结束播放 632 endedCallback: function() { // 结束播放
650 playEnd() 633 playEnd()
651 } 634 }
@@ -768,13 +751,13 @@ $(function() { @@ -768,13 +751,13 @@ $(function() {
768 751
769 // 播放录制代码过程 752 // 播放录制代码过程
770 $('.audio-play').unbind('click').click(function() { 753 $('.audio-play').unbind('click').click(function() {
771 - Hourglass.init();  
772 var resultData = { 754 var resultData = {
773 output: '', 755 output: '',
774 stderr: '', 756 stderr: '',
775 cmpinfo: '', 757 cmpinfo: '',
776 result: 1 758 result: 1
777 } 759 }
  760 + GBCodePlayBack.htmlplayereditor.setValue('');
778 compileResult(resultData); 761 compileResult(resultData);
779 762
780 var data = $(this).attr('data'); 763 var data = $(this).attr('data');
@@ -798,10 +781,10 @@ $(function() { @@ -798,10 +781,10 @@ $(function() {
798 } 781 }
799 GBCodePlayBack.recordtimeoutcontrolls = []; 782 GBCodePlayBack.recordtimeoutcontrolls = [];
800 /* END 初始化播放 */ 783 /* END 初始化播放 */
801 - GBCodePlayBack.htmlplayereditor.setValue('');  
802 784
803 playbtn.data('status', 0); 785 playbtn.data('status', 0);
804 $('#play').trigger('click'); 786 $('#play').trigger('click');
  787 + Hourglass.init();
805 }); 788 });
806 789
807 //setting speed in cookie 790 //setting speed in cookie
@@ -1503,16 +1486,16 @@ $(function() { @@ -1503,16 +1486,16 @@ $(function() {
1503 1486
1504 this.resizeWindow($('#ifrcontainer').find('#resultiframe')); 1487 this.resizeWindow($('#ifrcontainer').find('#resultiframe'));
1505 1488
1506 - // $(window).bind('beforeunload', function(){  
1507 -  
1508 - // return '确认立刻退出? 请确保已录制的代码回放以保存,以防回放数据丢失';  
1509 -  
1510 - // }); 1489 + if (document.URL.indexOf('index.htm')>=0) {
  1490 + $(window).bind('beforeunload', function(){
  1491 + return '确认立刻退出? 请确保已录制的代码回放以保存,以防回放数据丢失';
  1492 + });
  1493 + }
1511 1494
1512 /* 解决Chrome浏览器非激活标签页下错乱问题 */ 1495 /* 解决Chrome浏览器非激活标签页下错乱问题 */
1513 (function() { 1496 (function() {
1514 var hidden = "hidden"; 1497 var hidden = "hidden";
1515 - 1498 +
1516 // Standards: 1499 // Standards:
1517 if (hidden in document) 1500 if (hidden in document)
1518 document.addEventListener("visibilitychange", onchange); 1501 document.addEventListener("visibilitychange", onchange);