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 91 </div>
92 92 </div>
93 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 96 </div>
101 97 <div id="handleMR"></div>
102 98 </div>
... ...
src/js/gb.js
... ... @@ -10,6 +10,7 @@ $(function() {
10 10 _source = getQuery('source');
11 11 var $recording_time = $('.recording-time');
12 12 var tag = 1; // 标记第一次暂停
  13 + var player = $.AudioPlayer;
13 14 var htmlhlLine = null,
14 15 csshlLine = null,
15 16 jshlLine = null;
... ... @@ -246,18 +247,21 @@ $(function() {
246 247 excercise_records: [],
247 248 autorun: 1,
248 249 triggertotal: 0,
249   - firstPlay: 1, // 第一次播放
250   - pauseValue: '', // 存储暂停时内容
  250 + firstPlay: 1, // 第一次播放
  251 + pauseValue: '', // 存储暂停时内容
251 252 triggeroffset: 0, //判断拖动进度条的偏移量
252 253 excercise_triggertotal: 0,
253   - replay_enhancement: 1, //是否优化播放,即匀速播放
  254 + replay_enhancement:1, //是否优化播放,即匀速播放
254 255 replay_enhancement_value: 250,
255 256 speed: 1,
256 257 recordtimeoutcontrolls: [],
257 258 excercise_recordtimeoutcontrolls: [],
258 259 isgblibreplay: 0,
259 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 265 recordinit: function(codereplaytype, preload) {
262 266 /* #STRAT:生成CodeMirror Editor for JS/CSS/HTML */
263 267 if (codereplaytype) {
... ... @@ -605,7 +609,6 @@ $(function() {
605 609  
606 610 $("#play_audio").attr('src', "http://gxb-file.oss-cn-beijing.aliyuncs.com/" + coderecords.audioUrl);
607 611  
608   - var player = $.AudioPlayer;
609 612 player.init({
610 613 container: '#audioWrap',
611 614 source: "http://gxb-file.oss-cn-beijing.aliyuncs.com/" + coderecords.audioUrl,
... ... @@ -613,39 +616,19 @@ $(function() {
613 616 debuggers: false,
614 617 allowSeek: false,
615 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 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 625 GBCodePlayBack.firstPlay = 0;
640   -
641 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 632 endedCallback: function() { // 结束播放
650 633 playEnd()
651 634 }
... ... @@ -768,13 +751,13 @@ $(function() {
768 751  
769 752 // 播放录制代码过程
770 753 $('.audio-play').unbind('click').click(function() {
771   - Hourglass.init();
772 754 var resultData = {
773 755 output: '',
774 756 stderr: '',
775 757 cmpinfo: '',
776 758 result: 1
777 759 }
  760 + GBCodePlayBack.htmlplayereditor.setValue('');
778 761 compileResult(resultData);
779 762  
780 763 var data = $(this).attr('data');
... ... @@ -798,10 +781,10 @@ $(function() {
798 781 }
799 782 GBCodePlayBack.recordtimeoutcontrolls = [];
800 783 /* END 初始化播放 */
801   - GBCodePlayBack.htmlplayereditor.setValue('');
802 784  
803 785 playbtn.data('status', 0);
804 786 $('#play').trigger('click');
  787 + Hourglass.init();
805 788 });
806 789  
807 790 //setting speed in cookie
... ... @@ -1503,16 +1486,16 @@ $(function() {
1503 1486  
1504 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 1495 /* 解决Chrome浏览器非激活标签页下错乱问题 */
1513 1496 (function() {
1514 1497 var hidden = "hidden";
1515   -
  1498 +
1516 1499 // Standards:
1517 1500 if (hidden in document)
1518 1501 document.addEventListener("visibilitychange", onchange);
... ...