Commit 6e5f7a7d535d80dd26e454942920fe609aaac7f4

Authored by 商艳涛
1 parent 34312ede

保存录制数据

src/index.html
... ... @@ -43,6 +43,9 @@
43 43 <script src="js/jshint-2.6.min.js"></script>
44 44 <script src="js/jstorage.js"></script>
45 45  
  46 + <script src="js/05-util.js"></script>
  47 + <script src="js/03-http.js"></script>
  48 +
46 49 <script src="js/jquery.validationEngine.js"></script>
47 50 <script src="js/jquery.validationEngine-zh.js"></script>
48 51 <script src="js/jquery.isotope.js"></script>
... ... @@ -160,9 +163,9 @@
160 163 <audio id="audio" autoplay></audio>
161 164 </div>
162 165 <div class="save-wrap">
163   - <input type="button" id="upload" class="upload-teach" disabled="disabled" value="保存">
164   - <input type="button" id="savecorde" class="upload-stud" style="display: none;" disabled="disabled" value="保存">
165   - <input type="button" id="cancel" value="关闭">
  166 + <input type="button" id="upload" class="upload-teach" disabled="disabled" value="保存 - upload">
  167 + <input type="button" id="savecorde" class="upload-stud" style="display: none;" disabled="disabled" value="保存 - savecorde">
  168 + <input type="button" id="cancel" value="关闭 - cancel">
166 169 </div>
167 170 </div>
168 171 </div>
... ... @@ -213,7 +216,8 @@
213 216  
214 217 // 结束播放事件
215 218 audio.addEventListener("ended", function() {
216   - console.log('结束播放事件');
  219 + console.info('audio.addEventListener("ended"');
  220 + console.log('audio 播放结束');
217 221 Hourglass.stopTimer();
218 222 $('.audio-play').attr('data', '1')
219 223 $('.audio-play').prop('disabled', false);
... ... @@ -224,8 +228,9 @@
224 228 })
225 229  
226 230 function uploadAudio(ob) {
227   - $('.upload-tip').show();
228   - recorder.upload();
  231 + // $('.upload-tip').show();
  232 + // recorder.upload();
  233 + $('#savecorde').trigger('click');
229 234 }
230 235 </script>
231 236 </body>
... ...
src/js/gb.js
... ... @@ -40,6 +40,9 @@ $(function() {
40 40 * Created by Keystion on 2017-01-19
41 41 */
42 42 beforeClick: function(treeId, treeNode){
  43 + console.info('ZTREE.config.callback.beforeClick');
  44 + console.log('点击了 ' + treeNode.name);
  45 + console.log(treeNode);
43 46 // 判断是否点击了文件夹
44 47 if (treeNode.isParent) {
45 48 return false;
... ... @@ -47,11 +50,8 @@ $(function() {
47 50 treeObj = $.fn.zTree.getZTreeObj("folder");
48 51 treeObj.expandNode(treeNode);
49 52  
50   - console.info('点击了 ' + treeNode.name);
51   - console.info(treeNode);
52   -
53 53 // 处理显示目录树对应的编辑器目录
54   - ZTREE.showEdite(treeNode);
  54 + ZTREE.showEdite({'treeNode': treeNode});
55 55 }
56 56 }
57 57 },
... ... @@ -62,35 +62,42 @@ $(function() {
62 62 * @param {[type]} treeNode 点击了哪一个目录
63 63 * TODO treeNode放到一个变量或者隐藏域里面
64 64 */
65   - showEdite: function (treeNode){
  65 + showEdite: function (obj){
  66 + console.info('ZTREE.showEdite');
  67 + console.log(obj);
66 68 var _this = this,
67 69 _file,
68 70 _CodeMirrorRecordId,
69 71 _CodeMirrorReplayId,
70 72 _num = 0;
71 73 // 判断是否是初始化选时候调用 showEdite
72   - if(treeNode){
  74 + if(obj){
73 75 for (var i = 0; i < treeLinkEditor.length; i++) {
74   - if(treeLinkEditor[i].name == _this.manageName(treeNode.name)){
  76 + if(treeLinkEditor[i].name == _this.manageName(obj.treeNode.name)){
75 77 _num = i;
76 78 }
77 79 }
  80 + if(typeof obj.record != 'undefined' && obj.record){
  81 + $('#recordertab a:eq(0)').tab('show');
  82 + }else if(typeof obj.replay != 'undefined'&& obj.replay){
  83 + $('#recordertab a:eq(1)').tab('show');
  84 + }
78 85 }
79 86  
80 87 _file = treeLinkEditor[_num].file;
81 88 _CodeMirrorRecordId = treeLinkEditor[_num].CodeMirrorRecordId;
82 89 _CodeMirrorReplayId = treeLinkEditor[_num].CodeMirrorReplayId;
83 90 mainPath = treeLinkEditor[_num].filePath; // 更新mainPath值
84   -
85   - // 更新目录树选中状态
86   - _this.selectTreeItem(_file);
87 91  
88 92 // 显示代码编辑器
89 93 $('#' + _CodeMirrorRecordId).show().parent().show().siblings().hide().find('.CodeMirror').hide();
90 94 $('#' + _CodeMirrorReplayId).show().parent().show().siblings().hide().find('.CodeMirror').hide();
  95 +
  96 + console.log('当前选中文件(mainPath):'+ mainPath);
  97 + console.log('当前显示代码编辑器:'+ '#' + _CodeMirrorReplayId);
91 98  
92   - console.info('当前选中文件(mainPath):'+ mainPath);
93   - console.info('当前显示代码编辑器:'+ '#' + _CodeMirrorReplayId);
  99 + // 更新目录树选中状态
  100 + _this.selectTreeItem(_file);
94 101 },
95 102 /**
96 103 * 返回目录结构路径
... ... @@ -101,6 +108,7 @@ $(function() {
101 108 */
102 109 // 根据提供的 name 获取 pId , 再根据 pId 获取 夫级 name
103 110 getTreePath: function (name){
  111 + console.info('ZTREE.getTreePath');
104 112 var _pid, _folder, _filename;
105 113 for (var i = 0; i < treeData.length; i++) {
106 114 if(treeData[i].name == name){
... ... @@ -123,6 +131,7 @@ $(function() {
123 131 * @return {[type]} Class1
124 132 */
125 133 ,manageName: function (name){
  134 + console.info('ZTREE.manageName');
126 135 if(!name){
127 136 return false;
128 137 }
... ... @@ -135,6 +144,7 @@ $(function() {
135 144 * @param {[type]} id 代码编辑器的id
136 145 */
137 146 ,getCurrentEditor: function (id){
  147 + console.info('ZTREE.getCurrentEditor');
138 148 var _id = id || treeLinkEditor[0].CodeMirrorRecordId,
139 149 _name;
140 150  
... ... @@ -155,6 +165,7 @@ $(function() {
155 165 * @return {[type]} Array/false false 每一个编辑器均无值
156 166 */
157 167 ,getTreeData: function(name){
  168 + console.info('ZTREE.getTreeData');
158 169 var _arr = [];
159 170 // 判断是否是需要返回单文件结果
160 171 if(name){
... ... @@ -191,6 +202,7 @@ $(function() {
191 202 * @param {[type]} name 例:Class1.java
192 203 */
193 204 ,selectTreeItem: function (name){
  205 + console.info('ZTREE.selectTreeItem');
194 206 var _thisName = name || treeData[1].name;
195 207 // 处理菜单选中状态
196 208 var node = treeObj.getNodeByParam("name", _thisName, null);
... ... @@ -203,7 +215,7 @@ $(function() {
203 215 event.preventDefault();
204 216 /* Act on the event */
205 217  
206   - ZTREE.resetCodeMirrorValue();
  218 + GBCodePlayBack.resetCodeMirrorValue();
207 219  
208 220 });
209 221  
... ... @@ -238,6 +250,7 @@ $(function() {
238 250 isPause: 1, // 是否暂停 1:不暂停,0:暂停
239 251 isRcording: 0, // 是否录制 1:录制中,0:暂停中
240 252 recordinit: function(codereplaytype, preload) {
  253 + console.info('GBCodePlayBack.recordinit');
241 254 /* #STRAT:生成CodeMirror Editor for JS/CSS/HTML */
242 255 if (codereplaytype) {
243 256 GBCodePlayBack.isgblibreplay = 1; // 标记GB课程库代码回放 , 1为课程库回放,否则是一般代码回放
... ... @@ -639,6 +652,9 @@ $(function() {
639 652  
640 653 /* #STRAT: 播放和暂停控制元素 */
641 654 $('#play').unbind('click').click(function() {
  655 + console.info('$(\'#play\').unbind(\'click\')');
  656 + console.log('开始播放')
  657 +
642 658 var myAudio = $('#play_audio');
643 659  
644 660 //禁用修改
... ... @@ -659,6 +675,15 @@ $(function() {
659 675 }
660 676 }
661 677 if (!playstatus) {
  678 + console.log('if (!playstatus) {');
  679 + // TOTO
  680 + // GBCodePlayBack.resetCodeMirrorValue();
  681 + // 会触发编辑器的onChange事件导致 GBCodePlayBack.records 数组会添加一个空记录
  682 + // 播放之前删除
  683 + console.log(GBCodePlayBack.records);
  684 + GBCodePlayBack.records.pop();
  685 + console.log(GBCodePlayBack.records);
  686 +
662 687 var playbackrecord = GBCodePlayBack.records,
663 688 currenteditor = '';
664 689 var starttime = playbackrecord[0].intervaltime;
... ... @@ -726,15 +751,15 @@ $(function() {
726 751  
727 752 // 播放录制代码过程
728 753 $('.audio-play').unbind('click').click(function() {
  754 + alert(1)
729 755 var resultData = {
730 756 output: '',
731 757 stderr: '',
732 758 cmpinfo: '',
733 759 result: 1
734 760 }
735   - GBCodePlayBack.htmlplayereditor.setValue('');
  761 + GBCodePlayBack.resetCodeMirrorValue();
736 762 compileResult(resultData);
737   -
738 763 var data = $(this).attr('data');
739 764 if (_role == 0) {
740 765 $('.audio-play').attr('disabled', true);
... ... @@ -1042,6 +1067,8 @@ $(function() {
1042 1067 })
1043 1068 // 保存代码
1044 1069 $('#savecorde').unbind('click').click(function() {
  1070 + console.info('$(\'#savecorde\').unbind(\'click\')');
  1071 +
1045 1072 $('#savemsg').addClass('hidden');
1046 1073 $('.upload-tip').show();
1047 1074  
... ... @@ -1056,7 +1083,13 @@ $(function() {
1056 1083 pickup = 0;
1057 1084  
1058 1085  
1059   - var replaydto = { 'replaytitle': replaytitle, 'replaydesc': replaydesc, 'pickup': pickup, 'languageid': languageid, 'saveformat': saveformat };
  1086 + var replaydto = {
  1087 + 'replaytitle': replaytitle,
  1088 + 'replaydesc': replaydesc,
  1089 + 'pickup': pickup,
  1090 + 'languageid': languageid,
  1091 + 'saveformat': saveformat
  1092 + };
1060 1093  
1061 1094 var uploadeddemoimg = $('#previewcoverimg').data('demoimg');
1062 1095  
... ... @@ -1084,86 +1117,130 @@ $(function() {
1084 1117 eventtagid = $('#eventtagid').data('tagid');
1085 1118 }
1086 1119  
1087   - replaydto.html = GBCodePlayBack.htmleditor.getValue();
1088   - replaydto.css = GBCodePlayBack.csseditor.getValue();
1089   - replaydto.javascript = GBCodePlayBack.jseditor.getValue();
1090   - replaydto.audioUrl = $('.audio-url').val();
1091   - replaydto.deleteFlag = 1
1092   -
1093   - //保存序列化录制内容
1094   - var recorddatas = [];
  1120 + // 单个文件路径及内容 数组
  1121 + var programmingFileList = ZTREE.getTreeData();
1095 1122 for (var i = 0; i < GBCodePlayBack.records.length; i++) {
1096   - var recorddata = {
1097   - intervaltime: GBCodePlayBack.records[i].intervaltime,
1098   - editor: GBCodePlayBack.records[i].editor,
1099   - changeobj: JSON.stringify(GBCodePlayBack.records[i].changeobj),
1100   - cmpinfo: GBCodePlayBack.records[i].cmpinfo,
1101   - output: GBCodePlayBack.records[i].output,
1102   - result: GBCodePlayBack.records[i].result,
1103   - stderr: GBCodePlayBack.records[i].stderr
1104   - }
1105   -
1106   - recorddatas.push(recorddata);
1107   - }
  1123 + GBCodePlayBack.records[i].changeobj = JSON.stringify(GBCodePlayBack.records[i].changeobj)
  1124 + }
  1125 + var postData = {
  1126 + "mainPath": mainPath,
  1127 + "mainArgus": "lixxx",
  1128 + "runtimeArgus": $('#runtimeArgus').val(),
  1129 + "pickup": pickup,
  1130 + "userId": _userId,
  1131 + "replaytitle": replaytitle,
  1132 + "languageid": languageid,
  1133 + "replaydesc": replaydesc,
  1134 + "image": uploadeddemoimg,
  1135 + "deleteFlag": 1,
  1136 + "viewcount": "0",
  1137 + "saveformat": saveformat,
  1138 + "audioUrl": "/uploads/programming_audio/link/17/01/24/38029c9698e144d2bd590b35eb6af56e",
  1139 + "programmingFileList": programmingFileList,
  1140 + "codeRecordMultiList": GBCodePlayBack.records
  1141 + }
  1142 +
  1143 + console.log('============');
  1144 + console.log(postData);
1108 1145  
1109   - //回放入库
1110   - recorddatas.deleteFlag = 1
  1146 + $.ajax({
  1147 + type: "post",
  1148 + url: "http://192.168.80.140:8080/gxb-web/programmingMulti/api",
  1149 + data: JSON.stringify(postData),
  1150 + dataType: "json",
  1151 + contentType: "application/json",
  1152 + success: function(data) {
  1153 + console.log(data);
  1154 + $('.upload-tip').hide();
  1155 + },
  1156 + error: function() {
  1157 + $('.upload-tip').hide();
  1158 + alert('代码保存失败重新保存')
  1159 + }
  1160 + });
1111 1161  
1112   - var keepTimer = $('.recording-time').val()
1113   - replaydto.totaltime = parseInt(keepTimer);
1114   - if (_role == 0) {
1115   - replaydto.codeRecordList = recorddatas;
1116   - $.ajax({
1117   - type: "post",
1118   - url: gxb_api + "/programming/codeReplay/api",
1119   - data: JSON.stringify(replaydto),
1120   - dataType: "json",
1121   - contentType: "application/json",
1122   - success: function(data) {
1123   - $(window).unbind('beforeunload');
1124   - var _data = {
1125   - "programId": data.codeReplayId,
1126   - "programLanguageName": data.languageName,
1127   - "programAudioLength": keepTimer
1128   - }
1129   - $('.upload-tip').hide();
  1162 + // replaydto.html = GBCodePlayBack.htmleditor.getValue();
  1163 + // replaydto.css = GBCodePlayBack.csseditor.getValue();
  1164 + // replaydto.javascript = GBCodePlayBack.jseditor.getValue();
  1165 + // // replaydto.audioUrl = $('.audio-url').val();
  1166 + // replaydto.audioUrl = '/uploads/programming_audio/link/17/01/24/38029c9698e144d2bd590b35eb6af56e';
  1167 + // replaydto.deleteFlag = 1
  1168 +
  1169 + // //保存序列化录制内容
  1170 + // var recorddatas = [];
  1171 + // for (var i = 0; i < GBCodePlayBack.records.length; i++) {
  1172 + // console.log(GBCodePlayBack.records);
  1173 + // var recorddata = {
  1174 + // intervaltime: GBCodePlayBack.records[i].intervaltime,
  1175 + // editor: GBCodePlayBack.records[i].editor,
  1176 + // changeobj: JSON.stringify(GBCodePlayBack.records[i].changeobj),
  1177 + // cmpinfo: GBCodePlayBack.records[i].cmpinfo,
  1178 + // output: GBCodePlayBack.records[i].output,
  1179 + // result: GBCodePlayBack.records[i].result,
  1180 + // stderr: GBCodePlayBack.records[i].stderr
  1181 + // }
1130 1182  
1131   - $('#cancel').prop("disabled", false);
  1183 + // recorddatas.push(recorddata);
  1184 + // }
1132 1185  
1133   - window.opener.postMessage(_data, _source);
1134   - window.close();
1135   - },
1136   - error: function() {
1137   - $('.upload-tip').hide();
1138   - alert('代码保存失败重新保存')
1139   - }
1140   - });
1141   - } else if (_role == 1) {
1142   - replaydto.studentRecordList = recorddatas;
1143   - $.ajax({
1144   - type: "post",
1145   - url: gxb_api + "/programming/student/studentReplay/api",
1146   - data: JSON.stringify(replaydto),
1147   - dataType: "json",
1148   - contentType: "application/json",
1149   - success: function(data) {
1150   - $(window).unbind('beforeunload');
1151   - var _data = {
1152   - "programId": data.studentReplayId,
1153   - "programLanguageName": data.languageName,
1154   - "programAudioLength": keepTimer
1155   - }
1156   - $('.upload-tip').hide();
1157   - $('#cancel').prop("disabled", false);
1158   - window.opener.postMessage(_data, _source);
1159   - window.close();
1160   - },
1161   - error: function() {
1162   - $('.upload-tip').hide();
1163   - alert('代码保存失败重新保存')
1164   - }
1165   - });
1166   - }
  1186 + // //回放入库
  1187 + // recorddatas.deleteFlag = 1
  1188 +
  1189 + // var keepTimer = $('.recording-time').val()
  1190 + // replaydto.totaltime = parseInt(keepTimer);
  1191 + // if (_role == 0) {
  1192 + // replaydto.codeRecordList = recorddatas;
  1193 + // $.ajax({
  1194 + // type: "post",
  1195 + // url: gxb_api + "/programming/codeReplay/api",
  1196 + // data: JSON.stringify(replaydto),
  1197 + // dataType: "json",
  1198 + // contentType: "application/json",
  1199 + // success: function(data) {
  1200 + // $(window).unbind('beforeunload');
  1201 + // var _data = {
  1202 + // "programId": data.codeReplayId,
  1203 + // "programLanguageName": data.languageName,
  1204 + // "programAudioLength": keepTimer
  1205 + // }
  1206 + // $('.upload-tip').hide();
  1207 +
  1208 + // $('#cancel').prop("disabled", false);
  1209 +
  1210 + // window.opener.postMessage(_data, _source);
  1211 + // window.close();
  1212 + // },
  1213 + // error: function() {
  1214 + // $('.upload-tip').hide();
  1215 + // alert('代码保存失败重新保存')
  1216 + // }
  1217 + // });
  1218 + // } else if (_role == 1) {
  1219 + // replaydto.studentRecordList = recorddatas;
  1220 + // $.ajax({
  1221 + // type: "post",
  1222 + // url: gxb_api + "/programming/student/studentReplay/api",
  1223 + // data: JSON.stringify(replaydto),
  1224 + // dataType: "json",
  1225 + // contentType: "application/json",
  1226 + // success: function(data) {
  1227 + // $(window).unbind('beforeunload');
  1228 + // var _data = {
  1229 + // "programId": data.studentReplayId,
  1230 + // "programLanguageName": data.languageName,
  1231 + // "programAudioLength": keepTimer
  1232 + // }
  1233 + // $('.upload-tip').hide();
  1234 + // $('#cancel').prop("disabled", false);
  1235 + // window.opener.postMessage(_data, _source);
  1236 + // window.close();
  1237 + // },
  1238 + // error: function() {
  1239 + // $('.upload-tip').hide();
  1240 + // alert('代码保存失败重新保存')
  1241 + // }
  1242 + // });
  1243 + // }
1167 1244  
1168 1245 });
1169 1246  
... ... @@ -1409,6 +1486,7 @@ $(function() {
1409 1486 }, 600);
1410 1487 },
1411 1488 resizeWindow: function(thisiframe) {
  1489 + console.info('GBCodePlayBack.resizeWindow');
1412 1490 /* #STRAT: 编辑器自适应窗口 */
1413 1491 var calcHeight = function() {
1414 1492 var app = $('#app')
... ... @@ -1522,6 +1600,7 @@ $(function() {
1522 1600 /* #END: 编辑器自适应窗口 */
1523 1601 },
1524 1602 onChange: function(editor, changeobj) { // 监听输入事件 editor: 输入语言;changeobj:输入内容{from,text,to}
  1603 + console.info('GBCodePlayBack.onChange');
1525 1604 var intervaltime = 100,
1526 1605 currenttime = new Date().getTime();
1527 1606 // if(!GBCodePlayBack.record_startime) GBCodePlayBack.record_startime = currenttime;
... ... @@ -1548,10 +1627,11 @@ $(function() {
1548 1627 };
1549 1628 GBCodePlayBack.records.push(recordobj);
1550 1629 GBCodePlayBack.record_startime = currenttime; //设定起始时间
1551   - console.log('GBCodePlayBack.onChange');
1552 1630 console.log(GBCodePlayBack.records);
1553 1631 },
1554 1632 changeValueCallback: function(record, replay_type, offset) {
  1633 + console.info('GBCodePlayBack.changeValueCallback');
  1634 + console.log(record);
1555 1635 var obj = record.changeobj,
1556 1636 editor = record.editor;
1557 1637  
... ... @@ -1562,14 +1642,20 @@ $(function() {
1562 1642 GBCodePlayBack.active_editor = editor;
1563 1643 }
1564 1644  
1565   - if (editor === 'html') {
1566   - processChangeObject(GBCodePlayBack.htmlplayereditor, obj);
1567   - } else if (editor === 'css') {
1568   - processChangeObject(GBCodePlayBack.cssplayereditor, obj);
1569   - } else if (editor === 'js') {
1570   - processChangeObject(GBCodePlayBack.jsplayereditor, obj);
  1645 + for (var i = 0; i < treeLinkEditor.length; i++) {
  1646 + if(editor == treeLinkEditor[i].name){
  1647 + processChangeObject(treeLinkEditor[i].CodeMirrorReplay, obj);
  1648 + }
1571 1649 }
1572 1650  
  1651 + // if (editor === 'html') {
  1652 + // processChangeObject(GBCodePlayBack.htmlplayereditor, obj);
  1653 + // } else if (editor === 'css') {
  1654 + // processChangeObject(GBCodePlayBack.cssplayereditor, obj);
  1655 + // } else if (editor === 'js') {
  1656 + // processChangeObject(GBCodePlayBack.jsplayereditor, obj);
  1657 + // }
  1658 +
1573 1659 record.trigger = 1; //标记已运行
1574 1660 record.playTime = new Date().getTime(); // 播放开始时间
1575 1661 GBCodePlayBack.codeTimes = 1; //
... ... @@ -1618,7 +1704,6 @@ $(function() {
1618 1704 .addClass('glyphicon-play')
1619 1705 .removeClass('glyphicon-pause');
1620 1706  
1621   -
1622 1707 $('#recordertab a:first').tab('show');
1623 1708  
1624 1709 /* 移动设备的下一节和代码编写控制 */
... ... @@ -1708,36 +1793,34 @@ $(function() {
1708 1793 treeLinkEditor[i].CodeMirrorRecord.setValue("");
1709 1794 }
1710 1795 }
1711   -
1712   - GBCodePlayBack.records = [];
1713   - console.log(GBCodePlayBack.records);
1714 1796 }
1715 1797 }
1716 1798  
1717 1799 $('.record-before').hide();
1718   -
1719 1800 // 动态获取目录结构
1720 1801 $.ajax({
1721   - url: 'js/tree.json'
1722   - ,type: 'GET'
1723   - ,dataType: 'json'
1724   - })
1725   - .done(function(res) {
1726   - treeData = res.tree;
  1802 + type: "GET",
  1803 + url: "js/tree.json",
  1804 + dataType: "json",
  1805 + contentType: "application/json",
  1806 + success: function(res) {
  1807 + console.info("Ajax tree.json success");
  1808 + treeData = res.tree;
1727 1809  
1728   - treeObj = $.fn.zTree.init($("#folder"), ZTREE.config, treeData);
  1810 + treeObj = $.fn.zTree.init($("#folder"), ZTREE.config, treeData);
1729 1811  
1730   - GBCodePlayBack.recordinit(treeData);
1731   - })
1732   - .fail(function() {
1733   - console.log("error");
1734   - })
1735   - .always(function() {
1736   - console.log("get tree.json complete");
  1812 + GBCodePlayBack.recordinit(treeData);
  1813 + },
  1814 + error: function(XMLHttpRequest, textStatus, errorThrown) {
  1815 + console.log('Ajax tree.json error');
  1816 + console.log(XMLHttpRequest);
  1817 + }
1737 1818 });
1738 1819  
1739 1820 // 开始录制
1740 1821 $('#start-recording').click(function() {
  1822 + console.info('$(\'#start-recording\').click(');
  1823 +
1741 1824 // 切换到录制区域
1742 1825 $('#recordertab a:eq(0)').tab('show');
1743 1826  
... ... @@ -1755,6 +1838,8 @@ $(function() {
1755 1838 runResult()
1756 1839  
1757 1840 if (data == 1) {
  1841 + console.log('开始录制');
  1842 +
1758 1843 GBCodePlayBack.isRcording = 1;
1759 1844 $("#countdown").find('img').attr('src', 'img/ready-go.gif');
1760 1845 $("#countdown").find('img').load(function() {
... ... @@ -1768,8 +1853,14 @@ $(function() {
1768 1853 }, 1000);
1769 1854 })
1770 1855 } else {
  1856 + console.log('结束录制');
  1857 +
1771 1858 GBCodePlayBack.isRcording = 0;
1772   - GBCodePlayBack.htmleditor.setOption('readOnly', true);
  1859 + for (var i = 0; i < treeLinkEditor.length; i++) {
  1860 + treeLinkEditor[i].CodeMirrorRecord.setOption('readOnly', true);
  1861 + treeLinkEditor[i].CodeMirrorReplay.setOption('readOnly', true);
  1862 + }
  1863 + // GBCodePlayBack.htmleditor.setOption('readOnly', true);
1773 1864 $("#countdown").hide();
1774 1865 $("#re-recoding").show();
1775 1866 $("#start-recording").hide();
... ... @@ -1811,6 +1902,7 @@ $(function() {
1811 1902  
1812 1903 // 使用服务端编译语言
1813 1904 $('#compileBtnGroup').unbind("click").on('click', '#CompileBtn', function(event){
  1905 + console.info('$(\'#compileBtnGroup\').unbind("click")')
1814 1906 event.preventDefault();
1815 1907 var ladda = Ladda.create(this);
1816 1908 $('#CompileBtn').find('ladda-spinner').remove();
... ... @@ -1862,6 +1954,7 @@ $(function() {
1862 1954  
1863 1955 // 保存编译结果
1864 1956 $('#save_compile').unbind("click").click(function(){
  1957 + console.info('$(\'#save_compile\').unbind("click")');
1865 1958 var length = GBCodePlayBack.records.length - 1;
1866 1959 recodingConf()
1867 1960  
... ... @@ -1877,12 +1970,14 @@ $(function() {
1877 1970  
1878 1971 // 不保存编译结果
1879 1972 $('#cancel_compile').unbind('click').click(function(){
1880   - recodingConf()
1881   - contrlPause()
  1973 + console.info('$(\'#cancel_compile\').unbind(\'click\')');
  1974 + recodingConf();
  1975 + contrlPause();
1882 1976 })
1883 1977  
1884 1978 // 继续录制配置
1885 1979 function recodingConf(){
  1980 + console.info('recodingConf')
1886 1981 Hourglass.pauseTimer();
1887 1982 $("#CompileBtn").data('run', 1);
1888 1983 GBCodePlayBack.record_startime = new Date().getTime();
... ... @@ -1891,6 +1986,7 @@ $(function() {
1891 1986  
1892 1987 // 切换自动/手动运行代码
1893 1988 function autoRun(autorun){
  1989 + console.info('autoRun')
1894 1990 if(autorun===1){
1895 1991 $('#runnow').prop('disabled',false).html('手动运行').attr('data-original-title', '手动运行');
1896 1992 }else{
... ... @@ -1900,6 +1996,9 @@ $(function() {
1900 1996  
1901 1997 // 编译结果
1902 1998 function runResult(){
  1999 + console.info('runResult')
  2000 + // console.log(typeof GBCodePlayBack.htmleditor);
  2001 + // console.log(typeof GBCodePlayBack.htmlplayereditor);
1903 2002 if(typeof GBCodePlayBack.htmleditor !== 'undefined'){
1904 2003 GBCodePlayBack.generateResult(GBCodePlayBack.htmleditor.getValue());
1905 2004 return false;
... ... @@ -2040,11 +2139,12 @@ $(function() {
2040 2139  
2041 2140 // 开始录制
2042 2141 function startReacoder() {
  2142 + console.info('startReacoder');
2043 2143 HZRecorder.get(function(rec) {
2044 2144 recorder = rec;
2045 2145 recorder.start();
2046 2146  
2047   - GBCodePlayBack.htmleditor.setValue('');
  2147 + GBCodePlayBack.resetCodeMirrorValue();
2048 2148 GBCodePlayBack.records = [];
2049 2149 GBCodePlayBack.record_startime = new Date().getTime();
2050 2150  
... ... @@ -2058,6 +2158,9 @@ $(function() {
2058 2158  
2059 2159 // 结束录制
2060 2160 function stopReacoder() {
  2161 + console.info('stopReacoder');
  2162 + console.log(GBCodePlayBack.records);
  2163 +
2061 2164 $('#start-recording').removeClass('recording').addClass('new-recording').attr('data', '1').attr('data-original-title', '重新录制');
2062 2165 $('.recording-time').removeClass('twinkle');
2063 2166 Hourglass.stopTimer();
... ... @@ -2076,6 +2179,7 @@ $(function() {
2076 2179 }
2077 2180  
2078 2181 function initJavaPage(treeData){
  2182 + console.info('initJavaPage');
2079 2183 var _datalist = treeData || [];
2080 2184 var recordTemplate = '';
2081 2185 var replayTemplate = '';
... ... @@ -2088,15 +2192,17 @@ $(function() {
2088 2192  
2089 2193 for (var i = 0; i < _datalist.length; i++) {
2090 2194 if(!_datalist[i].isParent){
  2195 + var _file = _datalist[i].name;
  2196 + var _name = ZTREE.manageName(_file);
2091 2197 treeLinkEditor.push({
2092   - "name": ZTREE.manageName(_datalist[i].name),
2093   - "file": _datalist[i].name,
2094   - "filePath": ZTREE.getTreePath(_datalist[i].name),
2095   - "record": ZTREE.manageName(_datalist[i].name) + 'Record',
2096   - "replay": ZTREE.manageName(_datalist[i].name) + 'Replay'
  2198 + "name": _name,
  2199 + "file": _file,
  2200 + "filePath": ZTREE.getTreePath(_file),
  2201 + "record": _name + 'Record',
  2202 + "replay": _name + 'Replay'
2097 2203 });
2098   - recordTemplate += '<div id="'+ ZTREE.manageName(_datalist[i].name) +'RecordWrap"><textarea id="'+ ZTREE.manageName(_datalist[i].name) + 'Record" title="'+ ZTREE.manageName(_datalist[i].name) +'" style="display: none;"></textarea></div>'
2099   - replayTemplate += '<div id="'+ ZTREE.manageName(_datalist[i].name) +'ReplayWrap"><textarea id="'+ ZTREE.manageName(_datalist[i].name) + 'Replay" title="'+ ZTREE.manageName(_datalist[i].name) +'" style="display: none;"></textarea></div>'
  2204 + recordTemplate += '<div id="'+ _name +'RecordWrap"><textarea id="'+ _name + 'Record" title="'+ _name +'" style="display: none;"></textarea></div>'
  2205 + replayTemplate += '<div id="'+ _name +'ReplayWrap"><textarea id="'+ _name + 'Replay" title="'+ _name +'" style="display: none;"></textarea></div>'
2100 2206 }
2101 2207 }
2102 2208  
... ... @@ -2111,16 +2217,19 @@ $(function() {
2111 2217 lineNumbers: true,
2112 2218 smartIndent: false,
2113 2219 onChange: function(em, changeobj) {
2114   - console.log('onChange');
2115   - console.log(em);
2116   - console.log(changeobj);
  2220 + // console.log('onChange');
  2221 + // console.log(em);
  2222 + // console.log(changeobj);
2117 2223  
2118   - if (GBCodePlayBack.recording_status) {
2119   - GBCodePlayBack.onChange(ZTREE.getCurrentEditor(em.getWrapperElement().getAttribute('id')), changeobj);
2120   - }
2121   - if (GBCodePlayBack.autorun) {
2122   - GBCodePlayBack.generateResult(GBCodePlayBack.htmleditor.getValue(), GBCodePlayBack.csseditor.getValue(), GBCodePlayBack.jseditor.getValue());
2123   - }
  2224 + // 是否需要在开始录制之后采取设置值
  2225 + // if(GBCodePlayBack.isRcording == 1){
  2226 + if (GBCodePlayBack.recording_status) {
  2227 + GBCodePlayBack.onChange(ZTREE.getCurrentEditor(em.getWrapperElement().getAttribute('id')), changeobj);
  2228 + }
  2229 + if (GBCodePlayBack.autorun) {
  2230 + GBCodePlayBack.generateResult(GBCodePlayBack.htmleditor.getValue(), GBCodePlayBack.csseditor.getValue(), GBCodePlayBack.jseditor.getValue());
  2231 + }
  2232 + // }
2124 2233 },
2125 2234 onFocus: function(em) {
2126 2235 // console.log('onFocus');
... ... @@ -2261,8 +2370,51 @@ $(function() {
2261 2370 GBCodePlayBack.recordtimeoutcontrolls = [];
2262 2371 GBCodePlayBack.recordtimeouts = [];
2263 2372 }
2264   -
  2373 + function getEditor(obj, key){
  2374 + var currentObj;
  2375 + for (var i = 0; i < treeLinkEditor.length; i++) {
  2376 + if(treeLinkEditor[i].CodeMirrorReplay === obj){
  2377 + currentObj = treeLinkEditor[i];
  2378 + }
  2379 + }
  2380 + console.log('getEditor');
  2381 + console.log(currentObj);
  2382 + switch (key) {
  2383 + case 'name':
  2384 + return currentObj.name;
  2385 + break;
  2386 + case 'file':
  2387 + return currentObj.file;
  2388 + break;
  2389 + case 'filePath':
  2390 + return currentObj.file;
  2391 + break;
  2392 + case 'record':
  2393 + return currentObj.record;
  2394 + break;
  2395 + case 'replay':
  2396 + return currentObj.replay;
  2397 + break;
  2398 + case 'CodeMirrorRecord':
  2399 + return currentObj.CodeMirrorRecord;
  2400 + break;
  2401 + case 'CodeMirrorReplay':
  2402 + return currentObj.CodeMirrorReplay;
  2403 + break;
  2404 + case 'CodeMirrorRecordId':
  2405 + return currentObj.CodeMirrorRecordId;
  2406 + break;
  2407 + case 'CodeMirrorReplayId':
  2408 + return currentObj.CodeMirrorReplayId;
  2409 + break;
  2410 + default:
  2411 + break;
  2412 + }
  2413 + }
2265 2414 function processChangeObject(playbackcm, obj) {
  2415 + console.log('processChangeObject');
  2416 + // 菜单选中
  2417 + ZTREE.showEdite({'treeNode': {'name': getEditor(playbackcm, 'name')},'replay': true});
2266 2418 for (var i = 0; i < obj.text.length; i++) {
2267 2419 /* 设置鼠标行标示 */
2268 2420 if (playbackcm.getTextArea().id === "HTMLplayer") {
... ... @@ -2398,6 +2550,7 @@ $(function() {
2398 2550  
2399 2551 // 缓存languageid title
2400 2552 function setHtmlButton(languageid, title) {
  2553 + console.info('setHtmlButton');
2401 2554 $('#htmlbutton').data('languageid', languageid).attr('data-original-title', '当前课程环境:' + title).html(title).trigger('click');
2402 2555 }
2403 2556  
... ...
src/js/recorder/Myna.js
... ... @@ -173,6 +173,7 @@
173 173 //上传
174 174 this.upload = function(url, callback) {
175 175 var file = audioData.encodeWAV();
  176 + var $this = $(this);
176 177 console.log(file);
177 178 var megabyte = 1024 * 1024;
178 179 var defaultChnkSize = 5 * megabyte;
... ...
src/js/treeLinkEditor.json
... ... @@ -8,4 +8,4 @@
8 8 "CodeMirrorReplay": {},
9 9 "CodeMirrorRecordId": "Class1RecordCodeMirror",
10 10 "CodeMirrorReplayId": "Class1ReplayCodeMirror"
11 11 -}]
  12 +}]
12 13 \ No newline at end of file
... ...