Commit 92c241c576ac9cb64f1c562c15ee67eb70615f95
1 parent
982c84f7
fix bug
Showing
2 changed files
with
88 additions
and
31 deletions
src/js/gb.js
| ... | ... | @@ -144,7 +144,7 @@ $(function() { |
| 144 | 144 | * @param {[type]} id 代码编辑器的id |
| 145 | 145 | */ |
| 146 | 146 | ,getCurrentEditor: function (id){ |
| 147 | - console.info('ZTREE.getCurrentEditor'); | |
| 147 | + // console.info('ZTREE.getCurrentEditor'); | |
| 148 | 148 | var _id = id || treeLinkEditor[0].CodeMirrorRecordId, |
| 149 | 149 | _name; |
| 150 | 150 | |
| ... | ... | @@ -663,6 +663,7 @@ $(function() { |
| 663 | 663 | } |
| 664 | 664 | |
| 665 | 665 | $('#recordertab a:eq(1)').tab('show'); |
| 666 | + GBCodePlayBack.resetCodeMirrorValue(1); | |
| 666 | 667 | |
| 667 | 668 | var playstatus = $(this).data('status'); |
| 668 | 669 | |
| ... | ... | @@ -677,11 +678,11 @@ $(function() { |
| 677 | 678 | if (!playstatus) { |
| 678 | 679 | console.log('if (!playstatus) {'); |
| 679 | 680 | // TOTO |
| 680 | - // GBCodePlayBack.resetCodeMirrorValue(); | |
| 681 | + // GBCodePlayBack.resetCodeMirrorValue(1); | |
| 681 | 682 | // 会触发编辑器的onChange事件导致 GBCodePlayBack.records 数组会添加一个空记录 |
| 682 | 683 | // 播放之前删除 |
| 683 | 684 | console.log(GBCodePlayBack.records); |
| 684 | - GBCodePlayBack.records.pop(); | |
| 685 | + // GBCodePlayBack.records.pop(); | |
| 685 | 686 | console.log(GBCodePlayBack.records); |
| 686 | 687 | |
| 687 | 688 | var playbackrecord = GBCodePlayBack.records, |
| ... | ... | @@ -759,7 +760,6 @@ $(function() { |
| 759 | 760 | error: '', |
| 760 | 761 | code: '' |
| 761 | 762 | }; |
| 762 | - GBCodePlayBack.resetCodeMirrorValue(); | |
| 763 | 763 | compileResult(resultData); |
| 764 | 764 | var data = $(this).attr('data'); |
| 765 | 765 | if (_role == 0) { |
| ... | ... | @@ -1601,7 +1601,7 @@ $(function() { |
| 1601 | 1601 | /* #END: 编辑器自适应窗口 */ |
| 1602 | 1602 | }, |
| 1603 | 1603 | onChange: function(editor, changeobj) { // 监听输入事件 editor: 输入语言;changeobj:输入内容{from,text,to} |
| 1604 | - console.info('GBCodePlayBack.onChange'); | |
| 1604 | + // console.info('GBCodePlayBack.onChange'); | |
| 1605 | 1605 | var intervaltime = 100, |
| 1606 | 1606 | currenttime = new Date().getTime(); |
| 1607 | 1607 | // if(!GBCodePlayBack.record_startime) GBCodePlayBack.record_startime = currenttime; |
| ... | ... | @@ -1669,7 +1669,7 @@ $(function() { |
| 1669 | 1669 | code: record.code || '' |
| 1670 | 1670 | }; |
| 1671 | 1671 | |
| 1672 | - if (resultData.cmpinfo || resultData.result == 1) { | |
| 1672 | + if (resultData.compilerInfo) { | |
| 1673 | 1673 | compileResult(resultData); |
| 1674 | 1674 | } |
| 1675 | 1675 | |
| ... | ... | @@ -1787,15 +1787,37 @@ $(function() { |
| 1787 | 1787 | doc.writeln(result); |
| 1788 | 1788 | doc.close(); |
| 1789 | 1789 | }, |
| 1790 | - resetCodeMirrorValue: function (){ | |
| 1790 | + /** | |
| 1791 | + * 重置编辑器值 | |
| 1792 | + * @Author syantao | |
| 1793 | + * Created by Keystion on 2017-02-06 | |
| 1794 | + * @param {[type]} num 0: 重置所有录制CodeMirror的值; 0: 重置所有播放CodeMirror的值; | |
| 1795 | + * @return {[type]} [description] | |
| 1796 | + */ | |
| 1797 | + resetCodeMirrorValue: function(num) { | |
| 1798 | + console.info('GBCodePlayBack.resetCodeMirrorValue'); | |
| 1791 | 1799 | var _this = this; |
| 1800 | + var _thisNum = num || -1; | |
| 1792 | 1801 | console.log(_this.records); |
| 1793 | - for (var i = 0; i < treeLinkEditor.length; i++) { | |
| 1794 | - if(treeLinkEditor[i].CodeMirrorRecord.getValue() != ''){ | |
| 1795 | - treeLinkEditor[i].CodeMirrorRecord.setValue(""); | |
| 1802 | + if (_thisNum == 0) { | |
| 1803 | + // _this.resetRecordCodeMirrorValue(); | |
| 1804 | + for (var i = 0; i < treeLinkEditor.length; i++) { | |
| 1805 | + if (treeLinkEditor[i].CodeMirrorRecord.getValue() != undefined) { | |
| 1806 | + treeLinkEditor[i].CodeMirrorRecord.setValue(""); | |
| 1807 | + } | |
| 1796 | 1808 | } |
| 1809 | + } else if (_thisNum == 1) { | |
| 1810 | + // _this.resetReplayCodeMirrorValue(); | |
| 1811 | + for (var i = 0; i < treeLinkEditor.length; i++) { | |
| 1812 | + if (treeLinkEditor[i].CodeMirrorReplay.getValue() != undefined) { | |
| 1813 | + treeLinkEditor[i].CodeMirrorReplay.setValue(""); | |
| 1814 | + } | |
| 1815 | + } | |
| 1816 | + } else { | |
| 1817 | + return false; | |
| 1797 | 1818 | } |
| 1798 | 1819 | } |
| 1820 | + | |
| 1799 | 1821 | } |
| 1800 | 1822 | |
| 1801 | 1823 | $('.record-before').hide(); |
| ... | ... | @@ -1845,7 +1867,7 @@ $(function() { |
| 1845 | 1867 | console.log('开始录制'); |
| 1846 | 1868 | |
| 1847 | 1869 | GBCodePlayBack.isRcording = 1; |
| 1848 | - $("#countdown").find('img').attr('src', 'img/ready-go.gif'); | |
| 1870 | + $("#countdown").find('img').attr('src', '../img/ready-go.gif'); | |
| 1849 | 1871 | $("#countdown").find('img').load(function() { |
| 1850 | 1872 | var countdown = setInterval(function() { |
| 1851 | 1873 | seconds += 1; |
| ... | ... | @@ -1928,7 +1950,7 @@ $(function() { |
| 1928 | 1950 | GBCodePlayBack.record_pause_time = new Date().getTime(); // 暂停的时间 |
| 1929 | 1951 | var recordobj = { |
| 1930 | 1952 | intervaltime: GBCodePlayBack.record_pause_time - GBCodePlayBack.record_startime, |
| 1931 | - editor: 'html', | |
| 1953 | + editor: 'Class1', | |
| 1932 | 1954 | changeobj: { |
| 1933 | 1955 | from: { |
| 1934 | 1956 | ch: 0, |
| ... | ... | @@ -1958,16 +1980,17 @@ $(function() { |
| 1958 | 1980 | |
| 1959 | 1981 | // 保存编译结果 |
| 1960 | 1982 | $('#save_compile').unbind("click").click(function(){ |
| 1983 | + console.log(GBCodePlayBack.records); | |
| 1961 | 1984 | console.info('$(\'#save_compile\').unbind("click")'); |
| 1962 | 1985 | var length = GBCodePlayBack.records.length - 1; |
| 1963 | 1986 | recodingConf() |
| 1964 | 1987 | |
| 1965 | 1988 | GBCodePlayBack.records[length].compile = GBCodePlayBack.compileResultData; |
| 1966 | 1989 | |
| 1967 | - GBCodePlayBack.records[length].output = GBCodePlayBack.compileResultData.output; | |
| 1968 | - GBCodePlayBack.records[length].stderr = GBCodePlayBack.compileResultData.stderr; | |
| 1969 | - GBCodePlayBack.records[length].cmpinfo = GBCodePlayBack.compileResultData.cmpinfo; | |
| 1970 | - GBCodePlayBack.records[length].result = GBCodePlayBack.compileResultData.result; | |
| 1990 | + GBCodePlayBack.records[length].content = GBCodePlayBack.compileResultData.content; | |
| 1991 | + GBCodePlayBack.records[length].error = GBCodePlayBack.compileResultData.error; | |
| 1992 | + GBCodePlayBack.records[length].compilerInfo = GBCodePlayBack.compileResultData.compilerInfo; | |
| 1993 | + GBCodePlayBack.records[length].code = GBCodePlayBack.compileResultData.code; | |
| 1971 | 1994 | |
| 1972 | 1995 | contrlPause(); |
| 1973 | 1996 | }) |
| ... | ... | @@ -2110,22 +2133,39 @@ $(function() { |
| 2110 | 2133 | // 编译结果 |
| 2111 | 2134 | function compileResult(data) { |
| 2112 | 2135 | if (data.status == 200) { |
| 2113 | - if (data.code == 0) { | |
| 2114 | - $('#output').html('<p class="text-success">' + data.content.replace(/\n/g, "<br />") + "</p>"); | |
| 2115 | - $('#cmpinfo').prepend('<p class="alert alert-success"><i class="glyphicon glyphicon-ok-sign"></i> 编译成功 </p>'); | |
| 2116 | - $('#cmprun-tabs a[href="#output"]').tab('show'); | |
| 2117 | - } else if (data.code == 1) { | |
| 2118 | - if (data.error.length) { | |
| 2119 | - $('#cmpinfo').html('<p class="text-warning">' + data.error.replace(/\n/g, "<br />") + "</p>"); | |
| 2120 | - }else if (data.compilerInfo.length){ | |
| 2121 | - $('#cmpinfo').html('<p class="text-warning">' + data.compilerInfo.replace(/\n/g, "<br />") + "</p>"); | |
| 2122 | - }else{ | |
| 2123 | - $('#cmpinfo').html('<p class="alert alert-danger"><i class="glyphicon glyphicon-exclamation-sign"></i> 编译超时,请重新编译 </p>'); | |
| 2124 | - } | |
| 2136 | + | |
| 2137 | + $('#cmpinfo').html('<p class="text-warning">' + data.compilerInfo.replace(/\n/g, "<br />") + "</p>"); | |
| 2138 | + $('#stderr').html('<p class="text-danger">' + data.error.replace(/\n/g, "<br />") + "</p>"); | |
| 2139 | + $('#output').html('<p class="text-success">' + data.content.replace(/\n/g, "<br />") + "</p>"); | |
| 2140 | + | |
| 2141 | + if(data.compilerInfo.length){ | |
| 2125 | 2142 | $('#cmprun-tabs a[href="#cmpinfo"]').tab('show'); |
| 2126 | - }else{ | |
| 2127 | - $('#cmpinfo').prepend('<p class="alert alert-success"><i class="glyphicon glyphicon-ok-sign"></i> 等待编译 </p>'); | |
| 2143 | + }else if(data.error.length){ | |
| 2144 | + $('#cmprun-tabs a[href="#stderr"]').tab('show'); | |
| 2145 | + }else if(data.content.length){ | |
| 2146 | + $('#cmprun-tabs a[href="#output"]').tab('show'); | |
| 2128 | 2147 | } |
| 2148 | + | |
| 2149 | + if(!data.compilerInfo.length){ | |
| 2150 | + $('#cmpinfo').prepend('<p class="alert alert-success"><i class="glyphicon glyphicon-ok-sign"></i> 编译已成功</p>'); | |
| 2151 | + } | |
| 2152 | + | |
| 2153 | + // if (data.code == 0) { | |
| 2154 | + // $('#output').html('<p class="text-success">' + data.content.replace(/\n/g, "<br />") + "</p>"); | |
| 2155 | + // $('#cmpinfo').prepend('<p class="alert alert-success"><i class="glyphicon glyphicon-ok-sign"></i> 编译成功 </p>'); | |
| 2156 | + // $('#cmprun-tabs a[href="#output"]').tab('show'); | |
| 2157 | + // } else if (data.code == 1) { | |
| 2158 | + // if (data.error.length) { | |
| 2159 | + // $('#cmpinfo').html('<p class="text-warning">' + data.error.replace(/\n/g, "<br />") + "</p>"); | |
| 2160 | + // }else if (data.compilerInfo.length){ | |
| 2161 | + // $('#cmpinfo').html('<p class="text-warning">' + data.compilerInfo.replace(/\n/g, "<br />") + "</p>"); | |
| 2162 | + // }else{ | |
| 2163 | + // $('#cmpinfo').html('<p class="alert alert-danger"><i class="glyphicon glyphicon-exclamation-sign"></i> 编译超时,请重新编译 </p>'); | |
| 2164 | + // } | |
| 2165 | + // $('#cmprun-tabs a[href="#cmpinfo"]').tab('show'); | |
| 2166 | + // }else{ | |
| 2167 | + // $('#cmpinfo').prepend('<p class="alert alert-success"><i class="glyphicon glyphicon-ok-sign"></i> 等待编译 </p>'); | |
| 2168 | + // } | |
| 2129 | 2169 | }else{ |
| 2130 | 2170 | $('#cmpinfo').html('<p class="alert alert-danger"><i class="glyphicon glyphicon-exclamation-sign"></i> 请求失败 </p>'); |
| 2131 | 2171 | $('#cmprun-tabs a[href="#cmpinfo"]').tab('show'); |
| ... | ... | @@ -2139,7 +2179,7 @@ $(function() { |
| 2139 | 2179 | recorder = rec; |
| 2140 | 2180 | recorder.start(); |
| 2141 | 2181 | |
| 2142 | - GBCodePlayBack.resetCodeMirrorValue(); | |
| 2182 | + GBCodePlayBack.resetCodeMirrorValue(0); | |
| 2143 | 2183 | GBCodePlayBack.records = []; |
| 2144 | 2184 | GBCodePlayBack.record_startime = new Date().getTime(); |
| 2145 | 2185 | ... | ... |
src/v1.1/index.html
| ... | ... | @@ -99,6 +99,23 @@ |
| 99 | 99 | <div id="replayzone"></div> |
| 100 | 100 | </div> |
| 101 | 101 | <div id="handleMR"></div> |
| 102 | + <div class="pause-shodow hidden"> | |
| 103 | + <div class="compile-loading"> | |
| 104 | + <img src="../img/loading.png" alt=""> | |
| 105 | + </div> | |
| 106 | + <div class="compile-reslut" style="display: none;"> | |
| 107 | + <div class="tip-header"> | |
| 108 | + <span>成功获取编译运行结果</span> | |
| 109 | + </div> | |
| 110 | + <div class="tip-content"> | |
| 111 | + <p>保存编译结果后,播放到此处会在运行区域直接显示结果。需要保存结果后继续录制吗?</p> | |
| 112 | + </div> | |
| 113 | + <div class="tip-footer"> | |
| 114 | + <button class="btn btn-success btn-sm" id="save_compile">保存并继续录制</button> | |
| 115 | + <button class="btn btn-danger btn-sm" id="cancel_compile">不保存继续录制</button> | |
| 116 | + </div> | |
| 117 | + </div> | |
| 118 | + </div> | |
| 102 | 119 | </div> |
| 103 | 120 | <div id="appRight"> |
| 104 | 121 | <div id="resultpanel" class="panel panel-default editor-result"> | ... | ... |