Commit 230525880752ceb924a8ff9751bb150299c9762a

Authored by ykxie
1 parent 69ae38c8

add recording pause

src/css/recording.css
@@ -52,12 +52,13 @@ button { @@ -52,12 +52,13 @@ button {
52 left: 50%; 52 left: 50%;
53 transform: translate(-50%, -50%); } 53 transform: translate(-50%, -50%); }
54 54
55 -.recording-page .col-md-8 {  
56 - padding-right: 0;  
57 - overflow: hidden; }  
58 -  
59 -.recording-page .col-md-4 {  
60 - padding-left: 0; } 55 +.recording-page {
  56 + padding-top: 16px; }
  57 + .recording-page .col-md-8 {
  58 + padding-right: 0;
  59 + overflow: hidden; }
  60 + .recording-page .col-md-4 {
  61 + padding-left: 0; }
61 62
62 .real-program-title { 63 .real-program-title {
63 width: 100%; 64 width: 100%;
src/index.html
@@ -16,7 +16,7 @@ @@ -16,7 +16,7 @@
16 <link href="css/recording.css" rel="stylesheet"> 16 <link href="css/recording.css" rel="stylesheet">
17 17
18 <script> 18 <script>
19 - var gxb_api = "https://restful.gaoxiaobang.com"; 19 + var gxb_api = "https://restful1.gaoxiaobang.com";
20 // var gxb_api = "https://restful.gaoxiaobang.cn" 20 // var gxb_api = "https://restful.gaoxiaobang.cn"
21 21
22 </script> 22 </script>
@@ -119,9 +119,9 @@ @@ -119,9 +119,9 @@
119 <div class="tab-pane active padall15" id="stdin"> 119 <div class="tab-pane active padall15" id="stdin">
120 <input type="text" class="form-control" id="input" placeholder="标准输入"> 120 <input type="text" class="form-control" id="input" placeholder="标准输入">
121 </div> 121 </div>
122 - <div class="tab-pane padall15" id="cmpinfo">...</div>  
123 - <div class="tab-pane padall15" id="stderr">...</div>  
124 - <div class="tab-pane padall15" id="output">...</div> 122 + <div class="tab-pane padall15" id="cmpinfo"></div>
  123 + <div class="tab-pane padall15" id="stderr"></div>
  124 + <div class="tab-pane padall15" id="output"></div>
125 </div> 125 </div>
126 </div> 126 </div>
127 </div> 127 </div>
@@ -243,7 +243,7 @@ @@ -243,7 +243,7 @@
243 window.location.reload(); 243 window.location.reload();
244 } 244 }
245 }) 245 })
246 - 246 +
247 // 结束播放事件 247 // 结束播放事件
248 audio.addEventListener("ended", function() { 248 audio.addEventListener("ended", function() {
249 timer.stopTimer(); 249 timer.stopTimer();
src/js/gbreplayer.js
@@ -348,47 +348,8 @@ $(function(){ @@ -348,47 +348,8 @@ $(function(){
348 }); 348 });
349 349
350 // 初始化渲染编辑页面 350 // 初始化渲染编辑页面
351 - if (document.URL.indexOf('index.htm')>=0) {  
352 - if(_languageid == 35){  
353 - // GBCodePlayBack.htmleditor.setValue(  
354 - // '<!doctype html>\n' +  
355 - // '<html>\n' +  
356 - // '<head>\n' +  
357 - // ' <meta charset="UTF-8">\n' +  
358 - // ' <title>Document</title>\n' +  
359 - // '</head>\n' +  
360 - // '<body>\n' +  
361 - // ' \n' +  
362 - // '</body>\n' +  
363 - // '</html>'  
364 - // );  
365 - $('#htmlbutton').data('languageid',35).attr('data-original-title', 'HTML/CSS/JS').html("HTML/CSS/JS").trigger('click');  
366 - }else if(_languageid == 10){  
367 - $('#htmlbutton').data('languageid',10).html("java").trigger('click');  
368 - GBCodePlayBack.htmleditor.setOption('mode','text/x-java');  
369 - }else if(_languageid == 43){  
370 - GBCodePlayBack.htmleditor.setValue('/* Objective-c基础代码 */\n');  
371 - $('#htmlbutton').data('languageid',43).attr('data-original-title', 'Objective-c').html("Objective-c").trigger('click');  
372 - GBCodePlayBack.htmleditor.setOption('mode','text/x-csrc');  
373 - }else if(_languageid == 11){  
374 - GBCodePlayBack.htmleditor.setValue('/* c基础代码 */\n');  
375 - $('#htmlbutton').data('languageid',11).attr('data-original-title', 'C').html("C").trigger('click');  
376 - GBCodePlayBack.htmleditor.setOption('mode','text/x-csrc');  
377 - }else if(_languageid == 1 || _languageid == 41 || _languageid == 82){  
378 - GBCodePlayBack.htmleditor.setValue('/* cpp基础代码 */\n');  
379 - $('#htmlbutton').data('languageid',82).attr('data-original-title', 'C++').html("C++").trigger('click');  
380 - GBCodePlayBack.htmleditor.setOption('mode','text/x-c++src');  
381 - }else if(_languageid == 4){  
382 - $('#htmlbutton').data('languageid',4).attr('data-original-title', 'Python').html("Python").trigger('click');  
383 - }else if(_languageid == 40){  
384 - $('#htmlbutton').data('languageid',40).attr('data-original-title', 'SQL').html("SQL").trigger('click');  
385 - }else if(_languageid == 117){  
386 - $('#htmlbutton').data('languageid', 117).attr('data-original-title', 'R').html("R").trigger('click');  
387 - }  
388 - } 351 + initPageLang()
389 352
390 - var langid = $('#htmlbutton').data("languageid");  
391 - $.jStorage.set("gb_autosave_langid", langid);  
392 353
393 if(document.URL.indexOf('player.htm')>=0){ 354 if(document.URL.indexOf('player.htm')>=0){
394 if (_role == 0) { 355 if (_role == 0) {
@@ -412,7 +373,6 @@ $(function(){ @@ -412,7 +373,6 @@ $(function(){
412 var langid = parseInt(coderecords.languageid); 373 var langid = parseInt(coderecords.languageid);
413 selectLang(langid); 374 selectLang(langid);
414 compileMode(langid); 375 compileMode(langid);
415 -  
416 }, 376 },
417 error: function(){ 377 error: function(){
418 alert('错误') 378 alert('错误')
@@ -420,23 +380,6 @@ $(function(){ @@ -420,23 +380,6 @@ $(function(){
420 }); 380 });
421 } 381 }
422 382
423 - // 判断是否需要有服务端编译  
424 - function compileMode(langid){  
425 - if(!(langid==='empty' || langid==0 || langid==35)){  
426 - $('#fontendrun').addClass('hidden');  
427 - $('#comprunbtngrp').html('<button id="comprun" type="button" data-style="expand-right" class="btn" title="编译并运行代码">&nbsp;编译&运行</button>');  
428 -  
429 - $('#ifrcontainer').addClass('hidden');  
430 - $('#cmprun-output').removeClass('hidden');  
431 -  
432 - $('#frontenttools').remove();  
433 - $('#allbutton').remove();  
434 - $('#cssbutton').remove();  
435 - $('#jsbutton').remove();  
436 -  
437 - GBCodePlayBack.autorun=0;  
438 - }  
439 - }  
440 // 使编辑器满屏 383 // 使编辑器满屏
441 setTimeout(function(){ 384 setTimeout(function(){
442 $("#htmlbutton").trigger('click'); 385 $("#htmlbutton").trigger('click');
@@ -560,13 +503,7 @@ $(function(){ @@ -560,13 +503,7 @@ $(function(){
560 GBCodePlayBack.jsplayereditor.setValue(''); 503 GBCodePlayBack.jsplayereditor.setValue('');
561 504
562 playbtn.data('status', 0); 505 playbtn.data('status', 0);
563 - $('#play').trigger('click');  
564 -  
565 - // if (data == 1){  
566 -  
567 - // } else if(data == 0) {  
568 - // $(this).attr('data', 1).attr('data-original-title', '预览录制');  
569 - // } 506 + $('#play').trigger('click');
570 507
571 }); 508 });
572 509
@@ -949,6 +886,8 @@ $(function(){ @@ -949,6 +886,8 @@ $(function(){
949 dataType: "json", 886 dataType: "json",
950 contentType: "application/json", 887 contentType: "application/json",
951 success: function(data){ 888 success: function(data){
  889 + console.log('-------------------');
  890 + console.log(data);
952 $(window).unbind('beforeunload'); 891 $(window).unbind('beforeunload');
953 var _data = { 892 var _data = {
954 "programId": data.codeReplayId, 893 "programId": data.codeReplayId,
@@ -976,6 +915,8 @@ $(function(){ @@ -976,6 +915,8 @@ $(function(){
976 dataType: "json", 915 dataType: "json",
977 contentType: "application/json", 916 contentType: "application/json",
978 success: function(data) { 917 success: function(data) {
  918 + console.log('++++++++++++++++++++++++');
  919 + console.log(data)
979 $(window).unbind('beforeunload'); 920 $(window).unbind('beforeunload');
980 var _data = { 921 var _data = {
981 "programId": data.studentReplayId, 922 "programId": data.studentReplayId,
@@ -1502,9 +1443,7 @@ $(function(){ @@ -1502,9 +1443,7 @@ $(function(){
1502 }else{ 1443 }else{
1503 thisiframe.height(450); 1444 thisiframe.height(450);
1504 } 1445 }
1505 -  
1506 /* end of do resize here*/ 1446 /* end of do resize here*/
1507 -  
1508 var iframe = $('#resultiframe')[0], doc; 1447 var iframe = $('#resultiframe')[0], doc;
1509 1448
1510 if(iframe.contentDocument){ 1449 if(iframe.contentDocument){
@@ -1514,7 +1453,6 @@ $(function(){ @@ -1514,7 +1453,6 @@ $(function(){
1514 }else{ 1453 }else{
1515 doc = iframe.document; 1454 doc = iframe.document;
1516 } 1455 }
1517 -  
1518 /* 判断用户输入HTML片段还是完成的HTML文档 */ 1456 /* 判断用户输入HTML片段还是完成的HTML文档 */
1519 var completedflag = 0, lowhtml = html.toLowerCase(); 1457 var completedflag = 0, lowhtml = html.toLowerCase();
1520 if(lowhtml.toLowerCase().indexOf('</body>')>=0&&lowhtml.toLowerCase().indexOf('<body>')>=0){ 1458 if(lowhtml.toLowerCase().indexOf('</body>')>=0&&lowhtml.toLowerCase().indexOf('<body>')>=0){
@@ -1533,11 +1471,10 @@ $(function(){ @@ -1533,11 +1471,10 @@ $(function(){
1533 doc.open(); 1471 doc.open();
1534 doc.writeln(result); 1472 doc.writeln(result);
1535 doc.close(); 1473 doc.close();
1536 -  
1537 } 1474 }
1538 } 1475 }
1539 1476
1540 - // // 呼气麦克风和录制代码 1477 + // 呼气麦克风和录制代码
1541 if(document.URL.indexOf('index.htm') >= 0 && _role == 0){ 1478 if(document.URL.indexOf('index.htm') >= 0 && _role == 0){
1542 HZRecorder.get(function(rec) { 1479 HZRecorder.get(function(rec) {
1543 var seconds = 0; 1480 var seconds = 0;
@@ -1570,6 +1507,58 @@ $(function(){ @@ -1570,6 +1507,58 @@ $(function(){
1570 1507
1571 1508
1572 1509
  1510 +
  1511 +
  1512 +
  1513 + // 初始化渲染编辑页面
  1514 + function initPageLang(){
  1515 + if (document.URL.indexOf('index.htm')>=0) {
  1516 + if(_languageid == 35){
  1517 + $('#htmlbutton').data('languageid',35).attr('data-original-title', 'HTML/CSS/JS').html("HTML/CSS/JS").trigger('click');
  1518 + }else if(_languageid == 10){
  1519 + $('#htmlbutton').data('languageid',10).html("java").trigger('click');
  1520 + GBCodePlayBack.htmleditor.setOption('mode','text/x-java');
  1521 + }else if(_languageid == 43){
  1522 + GBCodePlayBack.htmleditor.setValue('/* Objective-c基础代码 */\n');
  1523 + $('#htmlbutton').data('languageid',43).attr('data-original-title', 'Objective-c').html("Objective-c").trigger('click');
  1524 + GBCodePlayBack.htmleditor.setOption('mode','text/x-csrc');
  1525 + }else if(_languageid == 11){
  1526 + GBCodePlayBack.htmleditor.setValue('/* c基础代码 */\n');
  1527 + $('#htmlbutton').data('languageid',11).attr('data-original-title', 'C').html("C").trigger('click');
  1528 + GBCodePlayBack.htmleditor.setOption('mode','text/x-csrc');
  1529 + }else if(_languageid == 1 || _languageid == 41 || _languageid == 82){
  1530 + GBCodePlayBack.htmleditor.setValue('/* cpp基础代码 */\n');
  1531 + $('#htmlbutton').data('languageid',82).attr('data-original-title', 'C++').html("C++").trigger('click');
  1532 + GBCodePlayBack.htmleditor.setOption('mode','text/x-c++src');
  1533 + }else if(_languageid == 4){
  1534 + $('#htmlbutton').data('languageid',4).attr('data-original-title', 'Python').html("Python").trigger('click');
  1535 + }else if(_languageid == 40){
  1536 + $('#htmlbutton').data('languageid',40).attr('data-original-title', 'SQL').html("SQL").trigger('click');
  1537 + }else if(_languageid == 117){
  1538 + $('#htmlbutton').data('languageid', 117).attr('data-original-title', 'R').html("R").trigger('click');
  1539 + }
  1540 + }
  1541 + }
  1542 +
  1543 +
  1544 + // 判断是否需要有服务端编译
  1545 + function compileMode(langid){
  1546 + if(!(langid==0 || langid==35)){
  1547 + $('#fontendrun').addClass('hidden');
  1548 + $('#comprunbtngrp').html('<button id="comprun" type="button" data-style="expand-right" class="btn" title="编译并运行代码">&nbsp;编译&运行</button>');
  1549 +
  1550 + $('#ifrcontainer').addClass('hidden');
  1551 + $('#cmprun-output').removeClass('hidden');
  1552 +
  1553 + $('#frontenttools').remove();
  1554 + $('#allbutton').remove();
  1555 + $('#cssbutton').remove();
  1556 + $('#jsbutton').remove();
  1557 +
  1558 + GBCodePlayBack.autorun=0;
  1559 + }
  1560 + }
  1561 +
1573 1562
1574 var htmlhlLine = null, 1563 var htmlhlLine = null,
1575 csshlLine = null, 1564 csshlLine = null,
src/js/recorder/Myna.js
@@ -132,6 +132,20 @@ @@ -132,6 +132,20 @@
132 recorder.connect(context.destination); 132 recorder.connect(context.destination);
133 } 133 }
134 134
  135 + // 暂停继续
  136 + this.pause = function() {
  137 + console.log(context.state);
  138 + if (context.state === 'running') {
  139 + context.suspend().then(function() {
  140 +
  141 + });
  142 + } else if (context.state === 'suspended') {
  143 + context.resume().then(function() {
  144 +
  145 + });
  146 + }
  147 + }
  148 +
135 //停止 149 //停止
136 this.stop = function() { 150 this.stop = function() {
137 recorder.disconnect(); 151 recorder.disconnect();
src/player.html
@@ -115,9 +115,9 @@ @@ -115,9 +115,9 @@
115 <div class="tab-pane active padall15" id="stdin"> 115 <div class="tab-pane active padall15" id="stdin">
116 <input type="text" class="form-control" id="input" placeholder="标准输入"> 116 <input type="text" class="form-control" id="input" placeholder="标准输入">
117 </div> 117 </div>
118 - <div class="tab-pane padall15" id="cmpinfo">...</div>  
119 - <div class="tab-pane padall15" id="stderr">...</div>  
120 - <div class="tab-pane padall15" id="output">...</div> 118 + <div class="tab-pane padall15" id="cmpinfo"></div>
  119 + <div class="tab-pane padall15" id="stderr"></div>
  120 + <div class="tab-pane padall15" id="output"></div>
121 </div> 121 </div>
122 </div> 122 </div>
123 </div> 123 </div>
src/scss/recording.scss
@@ -79,6 +79,8 @@ button{ @@ -79,6 +79,8 @@ button{
79 } 79 }
80 80
81 .recording-page{ 81 .recording-page{
  82 + padding-top:16px;
  83 +
82 .col-md-8{ 84 .col-md-8{
83 padding-right: 0; 85 padding-right: 0;
84 overflow: hidden 86 overflow: hidden