Commit 40c822623ed3bb37f69f9d0549c1cc2d84edeeb8

Authored by ykxie
1 parent 5bc76a25

修改播放暂停

kkb@192.168.30.25 0 → 100644
No preview for this file type
src/js/gb.js
... ... @@ -82,6 +82,11 @@ $(function() {
82 82 // console.log('点击了 ' + treeNode.name);
83 83 // console.log(treeNode);
84 84 // 判断是否点击了文件夹
  85 +
  86 + console.log('==========================================')
  87 + console.log(treeNode)
  88 + console.log('==========================================')
  89 +
85 90 if (treeNode.isParent) {
86 91 return false;
87 92 }
... ... @@ -214,7 +219,7 @@ $(function() {
214 219  
215 220 for (var i = 0; i < treeLinkEditor.length; i++) {
216 221 if(treeLinkEditor[i].CodeMirrorRecordId == _id){
217   - console.log(treeLinkEditor[i]);
  222 + // console.log(treeLinkEditor[i]);
218 223 _name = treeLinkEditor[i].name;
219 224 }
220 225 }
... ... @@ -318,6 +323,7 @@ $(function() {
318 323  
319 324 var GBCodePlayBack = {
320 325 records: [],
  326 + initRecodes: [],
321 327 excercise_records: [],
322 328 autorun: 1,
323 329 triggertotal: 0,
... ... @@ -689,7 +695,8 @@ $(function() {
689 695 contentType: "application/json",
690 696 success: function(coderecords) {
691 697 console.log(coderecords);
692   - var langid = parseInt(coderecords.languageid);
  698 + GBCodePlayBack.langid = parseInt(coderecords.languageid);
  699 + var langid = GBCodePlayBack.langid;
693 700 selectLang(langid);
694 701 compileMode(langid);
695 702  
... ... @@ -704,8 +711,9 @@ $(function() {
704 711 debuggers: false,
705 712 allowSeek: false,
706 713 playCallback: function() { // 播放
707   - console.log('++++++++')
  714 + console.log('++++++++');
708 715 playCode();
  716 +
709 717 // if(flag){
710 718 // playCode();
711 719 // }
... ... @@ -718,15 +726,11 @@ $(function() {
718 726 // player.play();
719 727  
720 728 GBCodePlayBack.audioTime = parseInt(player.elements.audioDom.currentTime*1000)
721   -
  729 + GBCodePlayBack.treeSelectNode = treeObj.getSelectedNodes()[0];
722 730 pauseCode();
723 731 GBCodePlayBack.firstPlay = 0;
724 732 GBCodePlayBack.getCodeMirrorValue();
725 733  
726   - console.log('---------------------------------------');
727   - console.log(GBCodePlayBack.pauseValue);
728   - console.log('---------------------------------------');
729   -
730 734 // GBCodePlayBack.pauseValue = GBCodePlayBack.htmlplayereditor.getValue();
731 735 // GBCodePlayBack.htmlplayereditor.setOption('readOnly', false);
732 736 },
... ... @@ -1722,8 +1726,10 @@ $(function() {
1722 1726 // 根据不同的身份设置录制代码的时间间隔,当学生端输入的时候,重置间隔为100毫秒
1723 1727 if (_role == 0 && GBCodePlayBack.record_startime) {
1724 1728 intervaltime = currenttime - GBCodePlayBack.record_startime;
1725   - }else{
  1729 + }else if (_role == 1){
1726 1730 intervaltime = 100;
  1731 + }else{
  1732 + intervaltime = 0;
1727 1733 }
1728 1734  
1729 1735 var pausetatus = $('#pause').data('status');
... ... @@ -1917,41 +1923,39 @@ $(function() {
1917 1923 var _thisNum = num;
1918 1924 if (_thisNum == 0) {
1919 1925 for (var i = 0; i < treeLinkEditor.length; i++) {
1920   - if (treeLinkEditor[i].CodeMirrorRecord.getValue()) {
1921   - ZTREE.showEdite({'treeNode': {'name': treeLinkEditor[i].file}});
1922   - treeLinkEditor[i].CodeMirrorRecord.setValue("");
1923   - }
1924   - }
1925   - } else if (_thisNum == 1) {
1926   - for (var i = 0; i < treeLinkEditor.length; i++) {
  1926 + // if (treeLinkEditor[i].CodeMirrorRecord.getValue()) {
  1927 + // ZTREE.showEdite({'treeNode': {'name': treeLinkEditor[i].file}});
  1928 + // treeLinkEditor[i].CodeMirrorRecord.setValue("");
  1929 + // }
1927 1930 var _path = treeLinkEditor[i].filePath;
1928 1931 var defaultValue;
1929 1932 defaultValue = 'package '+ _path.split('/')[0] +';\n';
  1933 + console.log(treeLinkEditor)
1930 1934 ZTREE.showEdite({'treeNode': {'name': treeLinkEditor[i].file}});
1931   - treeLinkEditor[i].CodeMirrorReplay.setValue(defaultValue);
1932   - // if (treeLinkEditor[i].CodeMirrorReplay.getValue()) {
1933   - // ZTREE.showEdite({'treeNode': {'name': treeLinkEditor[i].file}, 'replay': true});
1934   - // treeLinkEditor[i].CodeMirrorReplay.setValue("");
1935   - // }
  1935 + treeLinkEditor[i].CodeMirrorRecord.setValue(defaultValue);
  1936 + }
  1937 + } else if (_thisNum == 1) {
  1938 + for (var i = 0; i < treeLinkEditor.length; i++) {
  1939 + // var _path = treeLinkEditor[i].filePath;
  1940 + // var defaultValue;
  1941 + // defaultValue = 'package '+ _path.split('/')[0] +';\n';
  1942 + // ZTREE.showEdite({'treeNode': {'name': treeLinkEditor[i].file}});
  1943 + // treeLinkEditor[i].CodeMirrorReplay.setValue(defaultValue);
  1944 + if (treeLinkEditor[i].CodeMirrorReplay.getValue()) {
  1945 + ZTREE.showEdite({'treeNode': {'name': treeLinkEditor[i].file}, 'replay': true});
  1946 + treeLinkEditor[i].CodeMirrorReplay.setValue("");
  1947 + }
1936 1948 }
1937 1949 } else {
1938 1950 console.log(treeLinkEditor)
1939 1951 for (var i = 0; i < treeLinkEditor.length; i++) {
1940   - var _path = treeLinkEditor[i].filePath;
1941   - var defaultValue;
1942   - defaultValue = 'package '+ _path.split('/')[0] +';\n';
1943   - console.log(treeLinkEditor)
1944   - ZTREE.showEdite({'treeNode': {'name': treeLinkEditor[i].file}});
1945   - treeLinkEditor[i].CodeMirrorRecord.setValue(defaultValue);
1946   - ZTREE.showEdite({'treeNode': {'name': treeLinkEditor[i].file}});
1947   - treeLinkEditor[i].CodeMirrorReplay.setValue(defaultValue);
1948   - // if(treeLinkEditor[i].CodeMirrorRecord){
1949   - // ZTREE.showEdite({'treeNode': {'name': treeLinkEditor[i].file}});
1950   - // treeLinkEditor[i].CodeMirrorRecord.setValue('');
1951   - // }else if(treeLinkEditor[i].CodeMirrorReplay.getValue()){
1952   - // ZTREE.showEdite({'treeNode': {'name': treeLinkEditor[i].file}, 'replay': true});
1953   - // treeLinkEditor[i].CodeMirrorReplay.setValue("");
1954   - // }
  1952 + if(treeLinkEditor[i].CodeMirrorRecord){
  1953 + ZTREE.showEdite({'treeNode': {'name': treeLinkEditor[i].file}});
  1954 + treeLinkEditor[i].CodeMirrorRecord.setValue('');
  1955 + }else if(treeLinkEditor[i].CodeMirrorReplay.getValue()){
  1956 + ZTREE.showEdite({'treeNode': {'name': treeLinkEditor[i].file}, 'replay': true});
  1957 + treeLinkEditor[i].CodeMirrorReplay.setValue("");
  1958 + }
1955 1959 }
1956 1960 }
1957 1961 ZTREE.showEdite({'treeNode': {'name': treeLinkEditor[0].file}});
... ... @@ -1962,12 +1966,38 @@ $(function() {
1962 1966 */
1963 1967 getCodeMirrorValue: function(){
1964 1968 GBCodePlayBack.pauseValue = [];
  1969 +
1965 1970 for (var i = 0; i < treeLinkEditor.length; i++) {
1966 1971 console.log(treeLinkEditor[i].CodeMirrorReplay.getValue())
1967 1972 // ZTREE.showEdite({'treeNode': {'name': treeLinkEditor[i].file}});
1968 1973 GBCodePlayBack.pauseValue.push(treeLinkEditor[i].CodeMirrorReplay.getValue());
1969 1974 }
1970 1975 },
  1976 + initRecodesValue: function(){
  1977 + GBCodePlayBack.records = [];
  1978 + for (var i = treeLinkEditor.length-1; i >= 0; i--) {
  1979 + console.log(treeLinkEditor[i].CodeMirrorRecord.getValue());
  1980 + var recordobj = {
  1981 + intervaltime: 0,
  1982 + editor: treeLinkEditor[i].name,
  1983 + changeobj: {
  1984 + from: {
  1985 + ch: 0,
  1986 + line: 0,
  1987 + },
  1988 + text: [treeLinkEditor[i].CodeMirrorRecord.getValue()],
  1989 + to: {
  1990 + ch: 0,
  1991 + line: 0,
  1992 + }
  1993 + },
  1994 + trigger: 0,
  1995 + playTime: 0
  1996 + };
  1997 + GBCodePlayBack.records.push(recordobj);
  1998 + }
  1999 + console.log(GBCodePlayBack.records);
  2000 + },
1971 2001 setCodeMirrorValue: function(){
1972 2002 GBCodePlayBack.resetCodeMirrorValue(1);
1973 2003 var codeLength = GBCodePlayBack.pauseValue;
... ... @@ -2062,7 +2092,7 @@ $(function() {
2062 2092  
2063 2093 // 开始录制
2064 2094 $('#start-recording').click(function() {
2065   - console.log('-=======------------log');
  2095 + console.log('-=======------------log')
2066 2096 // 切换到录制区域
2067 2097 $('#recordertab a:eq(0)').tab('show');
2068 2098  
... ... @@ -2082,7 +2112,7 @@ $(function() {
2082 2112  
2083 2113 if (data == 1) {
2084 2114 console.log('开始录制');
2085   - GBCodePlayBack.resetCodeMirrorValue();
  2115 + GBCodePlayBack.resetCodeMirrorValue(0);
2086 2116 compileResult(resultData);
2087 2117 GBCodePlayBack.isRcording = 1;
2088 2118 $("#countdown").find('img').attr('src', '../img/ready-go.gif');
... ... @@ -2092,6 +2122,11 @@ $(function() {
2092 2122 if (seconds == 2) {
2093 2123 $("#countdown").hide();
2094 2124 startReacoder();
  2125 + console.log('-============================================')
  2126 + // GBCodePlayBack.records.push(GBCodePlayBack.getCodeMirrorValue);
  2127 + GBCodePlayBack.initRecodesValue();
  2128 + console.log(GBCodePlayBack.records);
  2129 + console.log('-============================================')
2095 2130 }
2096 2131 }, 1000);
2097 2132 })
... ... @@ -2304,7 +2339,7 @@ $(function() {
2304 2339 }
2305 2340 var compileData = {
2306 2341 "userId": _userId,
2307   - "langId": _languageid,
  2342 + "langId": GBCodePlayBack.langid,
2308 2343 "mainPath": mainPath,
2309 2344 "mainArgus": "",
2310 2345 "runtimeArgus": runtimeArgus,
... ... @@ -2449,7 +2484,7 @@ $(function() {
2449 2484 recorder.start();
2450 2485  
2451 2486 // GBCodePlayBack.resetCodeMirrorValue(0);
2452   - GBCodePlayBack.records = [];
  2487 + // GBCodePlayBack.records = [];
2453 2488 GBCodePlayBack.record_startime = new Date().getTime();
2454 2489  
2455 2490 $('#start-recording').removeClass('new-recording').addClass('recording').attr('data', '0').attr('data-original-title', '结束录制');
... ... @@ -2503,7 +2538,7 @@ $(function() {
2503 2538 var _file = _datalist[i].name;
2504 2539 var _name = ZTREE.manageName(_file);
2505 2540 var defaultValue;
2506   - defaultValue = 'package '+ ZTREE.getTreePath(_file).split('/')[0] +';';
  2541 + defaultValue = 'package '+ ZTREE.getTreePath(_file).split('/')[0] +';\n';
2507 2542 treeLinkEditor.push({
2508 2543 "name": _name,
2509 2544 "file": _file,
... ... @@ -2635,15 +2670,17 @@ $(function() {
2635 2670 }
2636 2671  
2637 2672 // 播发代码
2638   - function playCode(){
2639   - GBCodePlayBack.resetCodeMirrorValue(1);
  2673 + function playCode(){
2640 2674 if (GBCodePlayBack.firstPlay == 0) {
2641 2675 $('#readonly').trigger('click');
2642   - // GBCodePlayBack.htmlplayereditor.setValue(GBCodePlayBack.pauseValue)
2643 2676 GBCodePlayBack.setCodeMirrorValue();
  2677 + console.log('---------------------------------------');
  2678 + console.log(GBCodePlayBack.treeSelectNode);
  2679 + console.log('---------------------------------------');
  2680 + ZTREE.showEdite({'treeNode': GBCodePlayBack.treeSelectNode});
2644 2681  
2645 2682 }else{
2646   - // GBCodePlayBack.htmlplayereditor.setValue('')
  2683 + GBCodePlayBack.resetCodeMirrorValue(1);
2647 2684 var resultData = {
2648 2685 status: 200,
2649 2686 compilerInfo: '',
... ...