Commit a62775a9280b440ff52eeeb86bc678a1a0ab45b1

Authored by ykxie
2 parents ad883575 a34e130f

发布线上

# Conflicts:
#	src/js/util/util.js
src/js/gb.js
... ... @@ -87,6 +87,7 @@ $(function() {
87 87 }
88 88 treeObj = $.fn.zTree.getZTreeObj("folder");
89 89 treeObj.expandNode(treeNode);
  90 + console.log(GBCodePlayBack.isRecordPlay);
90 91 if (GBCodePlayBack.isRecordPlay == 1) {
91 92 GBCodePlayBack.check_tree_time = new Date().getTime(); // 获取焦点的时间
92 93 var recordobj = {
... ... @@ -875,7 +876,8 @@ $(function() {
875 876 var data = $(this).attr('data');
876 877 if (_role == 0) {
877 878 $('.audio-play').attr('disabled', true);
878   - recorder.play(audio);
  879 + $('#audio')[0].play();
  880 + // recorder.play(audio);
879 881 }
880 882 $(this).attr('data', 0).attr('data-original-title', '播放录音');
881 883  
... ... @@ -1229,11 +1231,11 @@ $(function() {
1229 1231  
1230 1232 // 单个文件路径及内容 数组
1231 1233 var programmingFileList = ZTREE.getTreeData();
1232   - for (var i = 0; i < GBCodePlayBack.records.length; i++) {
1233   - GBCodePlayBack.records[i].changeobj = JSON.stringify(GBCodePlayBack.records[i].changeobj);
1234   - GBCodePlayBack.records[i].treefile = JSON.stringify(GBCodePlayBack.records[i].treefile) || '';
1235   - }
1236   - var keepTimer = $('.recording-time').val()
  1234 +
  1235 + var timeLength = $('#audio')[0].duration;
  1236 + var keepTimer = Math.round(timeLength);
  1237 + console.log(timeLength);
  1238 +
1237 1239 var postData = {
1238 1240 "mainPath": mainPath,
1239 1241 "mainArgus": "lixxx",
... ... @@ -1250,19 +1252,30 @@ $(function() {
1250 1252 "audioUrl": $('.audio-url').val(),
1251 1253 "programmingSource": 1,
1252 1254 "programmingFileList": programmingFileList,
1253   - "codeRecordList": GBCodePlayBack.records,
1254 1255 "totaltime": keepTimer
1255 1256 }
1256   -
1257   - console.log('============');
1258   - console.log(postData);
1259   -
  1257 + var temp_record = JSON.parse(JSON.stringify(GBCodePlayBack.records))
  1258 + var codeRecordLists = [];
  1259 + for (var i = 0; i < temp_record.length; i++) {
  1260 + var temp_record_item = temp_record[i];
  1261 + if(temp_record_item){
  1262 + temp_record_item.changeobj=JSON.stringify(temp_record_item.changeobj);
  1263 + if(temp_record_item.treefile){
  1264 + temp_record_item.treefile=JSON.stringify(temp_record_item.treefile);
  1265 + }
  1266 + }
  1267 + codeRecordLists.push(temp_record_item);
  1268 + }
1260 1269 if (_role == 0) {
  1270 + postData.codeRecordList = codeRecordLists;
1261 1271 var roleUrl = gxb_api + "/programming/codeReplay/api"
1262 1272 }else if (_role == 1) {
  1273 + postData.codeRecordList = codeRecordLists;
1263 1274 var roleUrl = gxb_api + "/programming/student/studentReplay/api"
1264 1275 }
1265   -
  1276 + console.log('============');
  1277 + console.log(postData);
  1278 + console.log(keepTimer);
1266 1279 $.ajax({
1267 1280 type: "post",
1268 1281 url: roleUrl,
... ... @@ -1698,12 +1711,14 @@ $(function() {
1698 1711 },
1699 1712 onChange: function(editor, changeobj) { // 监听输入事件 editor: 输入语言;changeobj:输入内容{from,text,to}
1700 1713 // console.info('GBCodePlayBack.onChange');
1701   - var intervaltime = 100,
  1714 + var intervaltime,
1702 1715 currenttime = new Date().getTime();
1703 1716 // if(!GBCodePlayBack.record_startime) GBCodePlayBack.record_startime = currenttime;
1704 1717 // 根据不同的身份设置录制代码的时间间隔,当学生端输入的时候,重置间隔为100毫秒
1705 1718 if (_role == 0 && GBCodePlayBack.record_startime) {
1706 1719 intervaltime = currenttime - GBCodePlayBack.record_startime;
  1720 + }else{
  1721 + intervaltime = 100;
1707 1722 }
1708 1723  
1709 1724 var pausetatus = $('#pause').data('status');
... ... @@ -1892,30 +1907,49 @@ $(function() {
1892 1907 * @return {[type]} [description]
1893 1908 */
1894 1909 resetCodeMirrorValue: function(num) {
  1910 + console.info('GBCodePlayBack.resetCodeMirrorValue');
1895 1911 var _this = this;
1896 1912 var _thisNum = num;
1897 1913 if (_thisNum == 0) {
1898 1914 for (var i = 0; i < treeLinkEditor.length; i++) {
1899   - if (treeLinkEditor[i].CodeMirrorRecord.getValue() != undefined) {
  1915 + if (treeLinkEditor[i].CodeMirrorRecord.getValue()) {
  1916 + ZTREE.showEdite({'treeNode': {'name': treeLinkEditor[i].file}});
1900 1917 treeLinkEditor[i].CodeMirrorRecord.setValue("");
1901 1918 }
1902 1919 }
1903 1920 } else if (_thisNum == 1) {
1904 1921 for (var i = 0; i < treeLinkEditor.length; i++) {
1905   - if (treeLinkEditor[i].CodeMirrorReplay.getValue() != undefined) {
1906   - treeLinkEditor[i].CodeMirrorReplay.setValue("");
1907   - }
  1922 + var _path = treeLinkEditor[i].filePath;
  1923 + var defaultValue;
  1924 + defaultValue = 'package '+ _path.split('/')[0] +';\n';
  1925 + ZTREE.showEdite({'treeNode': {'name': treeLinkEditor[i].file}});
  1926 + treeLinkEditor[i].CodeMirrorReplay.setValue(defaultValue);
  1927 + // if (treeLinkEditor[i].CodeMirrorReplay.getValue()) {
  1928 + // ZTREE.showEdite({'treeNode': {'name': treeLinkEditor[i].file}, 'replay': true});
  1929 + // treeLinkEditor[i].CodeMirrorReplay.setValue("");
  1930 + // }
1908 1931 }
1909 1932 } else {
  1933 + console.log(treeLinkEditor)
1910 1934 for (var i = 0; i < treeLinkEditor.length; i++) {
1911   - if (treeLinkEditor[i].CodeMirrorRecord.getValue() != undefined) {
1912   - treeLinkEditor[i].CodeMirrorRecord.setValue("");
1913   - }
1914   - if (treeLinkEditor[i].CodeMirrorReplay.getValue() != undefined) {
1915   - treeLinkEditor[i].CodeMirrorReplay.setValue("");
1916   - }
  1935 + var _path = treeLinkEditor[i].filePath;
  1936 + var defaultValue;
  1937 + defaultValue = 'package '+ _path.split('/')[0] +';\n';
  1938 + console.log(treeLinkEditor)
  1939 + ZTREE.showEdite({'treeNode': {'name': treeLinkEditor[i].file}});
  1940 + treeLinkEditor[i].CodeMirrorRecord.setValue(defaultValue);
  1941 + ZTREE.showEdite({'treeNode': {'name': treeLinkEditor[i].file}});
  1942 + treeLinkEditor[i].CodeMirrorReplay.setValue(defaultValue);
  1943 + // if(treeLinkEditor[i].CodeMirrorRecord){
  1944 + // ZTREE.showEdite({'treeNode': {'name': treeLinkEditor[i].file}});
  1945 + // treeLinkEditor[i].CodeMirrorRecord.setValue('');
  1946 + // }else if(treeLinkEditor[i].CodeMirrorReplay.getValue()){
  1947 + // ZTREE.showEdite({'treeNode': {'name': treeLinkEditor[i].file}, 'replay': true});
  1948 + // treeLinkEditor[i].CodeMirrorReplay.setValue("");
  1949 + // }
1917 1950 }
1918 1951 }
  1952 + ZTREE.showEdite({'treeNode': {'name': treeLinkEditor[0].file}});
1919 1953 },
1920 1954 /**
1921 1955 * 获取各个文件中的代码
... ... @@ -2005,7 +2039,7 @@ $(function() {
2005 2039 $(document).on('click', '#full-screen', function(event) {
2006 2040 event.preventDefault();
2007 2041 var fullData = $(this).data('full');
2008   - launchFullScreen(document.getElementById("app"));
  2042 + launchFullScreen(document.body);
2009 2043 $('#back-screen').show();
2010 2044 $('#full-screen').hide();
2011 2045 });
... ... @@ -2037,7 +2071,8 @@ $(function() {
2037 2071  
2038 2072 if (data == 1) {
2039 2073 console.log('开始录制');
2040   -
  2074 + GBCodePlayBack.resetCodeMirrorValue();
  2075 + compileResult(resultData);
2041 2076 GBCodePlayBack.isRcording = 1;
2042 2077 $("#countdown").find('img').attr('src', '../img/ready-go.gif');
2043 2078 $("#countdown").find('img').load(function() {
... ... @@ -2046,8 +2081,6 @@ $(function() {
2046 2081 if (seconds == 2) {
2047 2082 $("#countdown").hide();
2048 2083 startReacoder();
2049   - GBCodePlayBack.resetCodeMirrorValue(0);
2050   - compileResult(resultData);
2051 2084 }
2052 2085 }, 1000);
2053 2086 })
... ... @@ -2076,7 +2109,8 @@ $(function() {
2076 2109 })
2077 2110  
2078 2111 $('#re-sure').click(function() {
2079   - initRecoding()
  2112 + initRecoding();
  2113 + GBCodePlayBack.isRecordPlay = 1;
2080 2114 $('#start-recording').trigger('click');
2081 2115 })
2082 2116  
... ... @@ -2430,6 +2464,7 @@ $(function() {
2430 2464 $('#pause').data('pause', '0');
2431 2465 if (_role == 0) {
2432 2466 recorder.stop();
  2467 + recorder.getBlobData();
2433 2468 $('#upload').show();
2434 2469  
2435 2470 } else if (_role == 1) {
... ... @@ -2455,6 +2490,8 @@ $(function() {
2455 2490 if(!_datalist[i].isParent){
2456 2491 var _file = _datalist[i].name;
2457 2492 var _name = ZTREE.manageName(_file);
  2493 + var defaultValue;
  2494 + defaultValue = 'package '+ ZTREE.getTreePath(_file).split('/')[0] +';';
2458 2495 treeLinkEditor.push({
2459 2496 "name": _name,
2460 2497 "file": _file,
... ... @@ -2464,7 +2501,7 @@ $(function() {
2464 2501 });
2465 2502 // 判断是否是播放页面,如果是则不显示录制区相关dom
2466 2503 if(!isReplayPage){
2467   - recordTemplate += '<div id="'+ _name +'RecordWrap"><textarea id="'+ _name + 'Record" title="'+ _name +'" style="display: none;"></textarea></div>'
  2504 + recordTemplate += '<div id="'+ _name +'RecordWrap"><textarea id="'+ _name + 'Record" title="'+ _name +'" style="display: none;">'+defaultValue+'</textarea></div>'
2468 2505 }
2469 2506  
2470 2507 replayTemplate += '<div id="'+ _name +'ReplayWrap"><textarea id="'+ _name + 'Replay" title="'+ _name +'" style="display: none;"></textarea></div>'
... ...
src/js/recorder/Myna.js
... ... @@ -143,6 +143,7 @@
143 143 context.close().then(function(){
144 144 recorder.disconnect();
145 145 });
  146 +
146 147 console.log(this.getBlob);
147 148 }
148 149  
... ... @@ -154,7 +155,9 @@
154 155  
155 156 // 获取音频文件
156 157 this.getBlobData = function(){
157   - return audioData.encodeWAV();
  158 + console.log(audioData.encodeWAV());
  159 + // return audioData.encodeWAV();
  160 + $('#audio').attr('src', window.URL.createObjectURL(this.getBlob()));
158 161 }
159 162  
160 163 //回放
... ...
src/js/util/util.js
... ... @@ -41,9 +41,7 @@ getCDNFile = function (cdnUrl) {
41 41 $w.utils = $w.utils || utils;
42 42 })(window, jQuery)
43 43  
  44 +// window.console.log = function(){}
  45 +// window.console.info = function(){}
44 46  
45   -window.console.log = function(){
46   -}
47   -window.console.info = function(){
48   -}
49 47  
... ...
src/v1.1/index.html
... ... @@ -179,7 +179,7 @@
179 179 </button>
180 180 <div class="recording-time" id="timer" value="">00:00:00</div>
181 181 <div class="audio-view" style="display: none;">
182   - <audio id="audio" autoplay></audio>
  182 + <audio id="audio"></audio>
183 183 </div>
184 184 <div class="save-wrap">
185 185 <input type="button" id="upload" class="upload-teach" disabled="disabled" value="保存">
... ...