Commit a62775a9280b440ff52eeeb86bc678a1a0ab45b1
发布线上
# Conflicts: # src/js/util/util.js
Showing
4 changed files
with
73 additions
and
35 deletions
src/js/gb.js
| @@ -87,6 +87,7 @@ $(function() { | @@ -87,6 +87,7 @@ $(function() { | ||
| 87 | } | 87 | } |
| 88 | treeObj = $.fn.zTree.getZTreeObj("folder"); | 88 | treeObj = $.fn.zTree.getZTreeObj("folder"); |
| 89 | treeObj.expandNode(treeNode); | 89 | treeObj.expandNode(treeNode); |
| 90 | + console.log(GBCodePlayBack.isRecordPlay); | ||
| 90 | if (GBCodePlayBack.isRecordPlay == 1) { | 91 | if (GBCodePlayBack.isRecordPlay == 1) { |
| 91 | GBCodePlayBack.check_tree_time = new Date().getTime(); // 获取焦点的时间 | 92 | GBCodePlayBack.check_tree_time = new Date().getTime(); // 获取焦点的时间 |
| 92 | var recordobj = { | 93 | var recordobj = { |
| @@ -875,7 +876,8 @@ $(function() { | @@ -875,7 +876,8 @@ $(function() { | ||
| 875 | var data = $(this).attr('data'); | 876 | var data = $(this).attr('data'); |
| 876 | if (_role == 0) { | 877 | if (_role == 0) { |
| 877 | $('.audio-play').attr('disabled', true); | 878 | $('.audio-play').attr('disabled', true); |
| 878 | - recorder.play(audio); | 879 | + $('#audio')[0].play(); |
| 880 | + // recorder.play(audio); | ||
| 879 | } | 881 | } |
| 880 | $(this).attr('data', 0).attr('data-original-title', '播放录音'); | 882 | $(this).attr('data', 0).attr('data-original-title', '播放录音'); |
| 881 | 883 | ||
| @@ -1229,11 +1231,11 @@ $(function() { | @@ -1229,11 +1231,11 @@ $(function() { | ||
| 1229 | 1231 | ||
| 1230 | // 单个文件路径及内容 数组 | 1232 | // 单个文件路径及内容 数组 |
| 1231 | var programmingFileList = ZTREE.getTreeData(); | 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 | var postData = { | 1239 | var postData = { |
| 1238 | "mainPath": mainPath, | 1240 | "mainPath": mainPath, |
| 1239 | "mainArgus": "lixxx", | 1241 | "mainArgus": "lixxx", |
| @@ -1250,19 +1252,30 @@ $(function() { | @@ -1250,19 +1252,30 @@ $(function() { | ||
| 1250 | "audioUrl": $('.audio-url').val(), | 1252 | "audioUrl": $('.audio-url').val(), |
| 1251 | "programmingSource": 1, | 1253 | "programmingSource": 1, |
| 1252 | "programmingFileList": programmingFileList, | 1254 | "programmingFileList": programmingFileList, |
| 1253 | - "codeRecordList": GBCodePlayBack.records, | ||
| 1254 | "totaltime": keepTimer | 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 | if (_role == 0) { | 1269 | if (_role == 0) { |
| 1270 | + postData.codeRecordList = codeRecordLists; | ||
| 1261 | var roleUrl = gxb_api + "/programming/codeReplay/api" | 1271 | var roleUrl = gxb_api + "/programming/codeReplay/api" |
| 1262 | }else if (_role == 1) { | 1272 | }else if (_role == 1) { |
| 1273 | + postData.codeRecordList = codeRecordLists; | ||
| 1263 | var roleUrl = gxb_api + "/programming/student/studentReplay/api" | 1274 | var roleUrl = gxb_api + "/programming/student/studentReplay/api" |
| 1264 | } | 1275 | } |
| 1265 | - | 1276 | + console.log('============'); |
| 1277 | + console.log(postData); | ||
| 1278 | + console.log(keepTimer); | ||
| 1266 | $.ajax({ | 1279 | $.ajax({ |
| 1267 | type: "post", | 1280 | type: "post", |
| 1268 | url: roleUrl, | 1281 | url: roleUrl, |
| @@ -1698,12 +1711,14 @@ $(function() { | @@ -1698,12 +1711,14 @@ $(function() { | ||
| 1698 | }, | 1711 | }, |
| 1699 | onChange: function(editor, changeobj) { // 监听输入事件 editor: 输入语言;changeobj:输入内容{from,text,to} | 1712 | onChange: function(editor, changeobj) { // 监听输入事件 editor: 输入语言;changeobj:输入内容{from,text,to} |
| 1700 | // console.info('GBCodePlayBack.onChange'); | 1713 | // console.info('GBCodePlayBack.onChange'); |
| 1701 | - var intervaltime = 100, | 1714 | + var intervaltime, |
| 1702 | currenttime = new Date().getTime(); | 1715 | currenttime = new Date().getTime(); |
| 1703 | // if(!GBCodePlayBack.record_startime) GBCodePlayBack.record_startime = currenttime; | 1716 | // if(!GBCodePlayBack.record_startime) GBCodePlayBack.record_startime = currenttime; |
| 1704 | // 根据不同的身份设置录制代码的时间间隔,当学生端输入的时候,重置间隔为100毫秒 | 1717 | // 根据不同的身份设置录制代码的时间间隔,当学生端输入的时候,重置间隔为100毫秒 |
| 1705 | if (_role == 0 && GBCodePlayBack.record_startime) { | 1718 | if (_role == 0 && GBCodePlayBack.record_startime) { |
| 1706 | intervaltime = currenttime - GBCodePlayBack.record_startime; | 1719 | intervaltime = currenttime - GBCodePlayBack.record_startime; |
| 1720 | + }else{ | ||
| 1721 | + intervaltime = 100; | ||
| 1707 | } | 1722 | } |
| 1708 | 1723 | ||
| 1709 | var pausetatus = $('#pause').data('status'); | 1724 | var pausetatus = $('#pause').data('status'); |
| @@ -1892,30 +1907,49 @@ $(function() { | @@ -1892,30 +1907,49 @@ $(function() { | ||
| 1892 | * @return {[type]} [description] | 1907 | * @return {[type]} [description] |
| 1893 | */ | 1908 | */ |
| 1894 | resetCodeMirrorValue: function(num) { | 1909 | resetCodeMirrorValue: function(num) { |
| 1910 | + console.info('GBCodePlayBack.resetCodeMirrorValue'); | ||
| 1895 | var _this = this; | 1911 | var _this = this; |
| 1896 | var _thisNum = num; | 1912 | var _thisNum = num; |
| 1897 | if (_thisNum == 0) { | 1913 | if (_thisNum == 0) { |
| 1898 | for (var i = 0; i < treeLinkEditor.length; i++) { | 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 | treeLinkEditor[i].CodeMirrorRecord.setValue(""); | 1917 | treeLinkEditor[i].CodeMirrorRecord.setValue(""); |
| 1901 | } | 1918 | } |
| 1902 | } | 1919 | } |
| 1903 | } else if (_thisNum == 1) { | 1920 | } else if (_thisNum == 1) { |
| 1904 | for (var i = 0; i < treeLinkEditor.length; i++) { | 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 | } else { | 1932 | } else { |
| 1933 | + console.log(treeLinkEditor) | ||
| 1910 | for (var i = 0; i < treeLinkEditor.length; i++) { | 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,7 +2039,7 @@ $(function() { | ||
| 2005 | $(document).on('click', '#full-screen', function(event) { | 2039 | $(document).on('click', '#full-screen', function(event) { |
| 2006 | event.preventDefault(); | 2040 | event.preventDefault(); |
| 2007 | var fullData = $(this).data('full'); | 2041 | var fullData = $(this).data('full'); |
| 2008 | - launchFullScreen(document.getElementById("app")); | 2042 | + launchFullScreen(document.body); |
| 2009 | $('#back-screen').show(); | 2043 | $('#back-screen').show(); |
| 2010 | $('#full-screen').hide(); | 2044 | $('#full-screen').hide(); |
| 2011 | }); | 2045 | }); |
| @@ -2037,7 +2071,8 @@ $(function() { | @@ -2037,7 +2071,8 @@ $(function() { | ||
| 2037 | 2071 | ||
| 2038 | if (data == 1) { | 2072 | if (data == 1) { |
| 2039 | console.log('开始录制'); | 2073 | console.log('开始录制'); |
| 2040 | - | 2074 | + GBCodePlayBack.resetCodeMirrorValue(); |
| 2075 | + compileResult(resultData); | ||
| 2041 | GBCodePlayBack.isRcording = 1; | 2076 | GBCodePlayBack.isRcording = 1; |
| 2042 | $("#countdown").find('img').attr('src', '../img/ready-go.gif'); | 2077 | $("#countdown").find('img').attr('src', '../img/ready-go.gif'); |
| 2043 | $("#countdown").find('img').load(function() { | 2078 | $("#countdown").find('img').load(function() { |
| @@ -2046,8 +2081,6 @@ $(function() { | @@ -2046,8 +2081,6 @@ $(function() { | ||
| 2046 | if (seconds == 2) { | 2081 | if (seconds == 2) { |
| 2047 | $("#countdown").hide(); | 2082 | $("#countdown").hide(); |
| 2048 | startReacoder(); | 2083 | startReacoder(); |
| 2049 | - GBCodePlayBack.resetCodeMirrorValue(0); | ||
| 2050 | - compileResult(resultData); | ||
| 2051 | } | 2084 | } |
| 2052 | }, 1000); | 2085 | }, 1000); |
| 2053 | }) | 2086 | }) |
| @@ -2076,7 +2109,8 @@ $(function() { | @@ -2076,7 +2109,8 @@ $(function() { | ||
| 2076 | }) | 2109 | }) |
| 2077 | 2110 | ||
| 2078 | $('#re-sure').click(function() { | 2111 | $('#re-sure').click(function() { |
| 2079 | - initRecoding() | 2112 | + initRecoding(); |
| 2113 | + GBCodePlayBack.isRecordPlay = 1; | ||
| 2080 | $('#start-recording').trigger('click'); | 2114 | $('#start-recording').trigger('click'); |
| 2081 | }) | 2115 | }) |
| 2082 | 2116 | ||
| @@ -2430,6 +2464,7 @@ $(function() { | @@ -2430,6 +2464,7 @@ $(function() { | ||
| 2430 | $('#pause').data('pause', '0'); | 2464 | $('#pause').data('pause', '0'); |
| 2431 | if (_role == 0) { | 2465 | if (_role == 0) { |
| 2432 | recorder.stop(); | 2466 | recorder.stop(); |
| 2467 | + recorder.getBlobData(); | ||
| 2433 | $('#upload').show(); | 2468 | $('#upload').show(); |
| 2434 | 2469 | ||
| 2435 | } else if (_role == 1) { | 2470 | } else if (_role == 1) { |
| @@ -2455,6 +2490,8 @@ $(function() { | @@ -2455,6 +2490,8 @@ $(function() { | ||
| 2455 | if(!_datalist[i].isParent){ | 2490 | if(!_datalist[i].isParent){ |
| 2456 | var _file = _datalist[i].name; | 2491 | var _file = _datalist[i].name; |
| 2457 | var _name = ZTREE.manageName(_file); | 2492 | var _name = ZTREE.manageName(_file); |
| 2493 | + var defaultValue; | ||
| 2494 | + defaultValue = 'package '+ ZTREE.getTreePath(_file).split('/')[0] +';'; | ||
| 2458 | treeLinkEditor.push({ | 2495 | treeLinkEditor.push({ |
| 2459 | "name": _name, | 2496 | "name": _name, |
| 2460 | "file": _file, | 2497 | "file": _file, |
| @@ -2464,7 +2501,7 @@ $(function() { | @@ -2464,7 +2501,7 @@ $(function() { | ||
| 2464 | }); | 2501 | }); |
| 2465 | // 判断是否是播放页面,如果是则不显示录制区相关dom | 2502 | // 判断是否是播放页面,如果是则不显示录制区相关dom |
| 2466 | if(!isReplayPage){ | 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 | replayTemplate += '<div id="'+ _name +'ReplayWrap"><textarea id="'+ _name + 'Replay" title="'+ _name +'" style="display: none;"></textarea></div>' | 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,6 +143,7 @@ | ||
| 143 | context.close().then(function(){ | 143 | context.close().then(function(){ |
| 144 | recorder.disconnect(); | 144 | recorder.disconnect(); |
| 145 | }); | 145 | }); |
| 146 | + | ||
| 146 | console.log(this.getBlob); | 147 | console.log(this.getBlob); |
| 147 | } | 148 | } |
| 148 | 149 | ||
| @@ -154,7 +155,9 @@ | @@ -154,7 +155,9 @@ | ||
| 154 | 155 | ||
| 155 | // 获取音频文件 | 156 | // 获取音频文件 |
| 156 | this.getBlobData = function(){ | 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,9 +41,7 @@ getCDNFile = function (cdnUrl) { | ||
| 41 | $w.utils = $w.utils || utils; | 41 | $w.utils = $w.utils || utils; |
| 42 | })(window, jQuery) | 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,7 +179,7 @@ | ||
| 179 | </button> | 179 | </button> |
| 180 | <div class="recording-time" id="timer" value="">00:00:00</div> | 180 | <div class="recording-time" id="timer" value="">00:00:00</div> |
| 181 | <div class="audio-view" style="display: none;"> | 181 | <div class="audio-view" style="display: none;"> |
| 182 | - <audio id="audio" autoplay></audio> | 182 | + <audio id="audio"></audio> |
| 183 | </div> | 183 | </div> |
| 184 | <div class="save-wrap"> | 184 | <div class="save-wrap"> |
| 185 | <input type="button" id="upload" class="upload-teach" disabled="disabled" value="保存"> | 185 | <input type="button" id="upload" class="upload-teach" disabled="disabled" value="保存"> |