Commit e81a6b61d715b91a49bee1212fb4fe64d346f7d6

Authored by ykxie
1 parent f853514a

add compile run and save

src/css/ide.css
@@ -176,7 +176,7 @@ html, body { @@ -176,7 +176,7 @@ html, body {
176 .record-toolbox #resultoutput { 176 .record-toolbox #resultoutput {
177 height: 204px; 177 height: 204px;
178 overflow: auto; } 178 overflow: auto; }
179 - .record-toolbox #compileBtn { 179 + .record-toolbox #teacherCompileBtn, .record-toolbox #studentCompileBtn {
180 background-image: -webkit-linear-gradient(left, #1FB6FF 0%, #62DCF5 100%); 180 background-image: -webkit-linear-gradient(left, #1FB6FF 0%, #62DCF5 100%);
181 background-image: linear-gradient(to right, #1FB6FF 0%, #62DCF5 100%); 181 background-image: linear-gradient(to right, #1FB6FF 0%, #62DCF5 100%);
182 -webkit-transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) all !important; 182 -webkit-transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) all !important;
@@ -215,3 +215,38 @@ html, body { @@ -215,3 +215,38 @@ html, body {
215 z-index: 99; 215 z-index: 99;
216 margin: 2px 8px; 216 margin: 2px 8px;
217 border-radius: 50%; } 217 border-radius: 50%; }
  218 +
  219 +.pause-shodow {
  220 + position: absolute;
  221 + top: 0;
  222 + z-index: 999;
  223 + width: 100%;
  224 + height: 100%;
  225 + background-color: rgba(0, 0, 0, 0.4); }
  226 + .pause-shodow img {
  227 + position: absolute;
  228 + top: 15%;
  229 + left: 50%;
  230 + transform: translate(-50%); }
  231 + .pause-shodow .compile-reslut .btn {
  232 + margin-right: 8px; }
  233 +
  234 +.compile-reslut, .re-reslut {
  235 + position: absolute;
  236 + height: 200px;
  237 + width: 400px;
  238 + background-color: #FFF;
  239 + top: 15%;
  240 + left: 50%;
  241 + transform: translate(-50%); }
  242 + .compile-reslut .tip-header, .compile-reslut .tip-footer, .re-reslut .tip-header, .re-reslut .tip-footer {
  243 + width: 100%;
  244 + padding: 8px 8px;
  245 + background-color: #F5F6FA; }
  246 + .compile-reslut .tip-content, .re-reslut .tip-content {
  247 + padding: 40px;
  248 + line-height: 1.7; }
  249 + .compile-reslut .tip-footer, .re-reslut .tip-footer {
  250 + position: absolute;
  251 + bottom: 0;
  252 + text-align: right; }
src/css/main.css
@@ -98,7 +98,7 @@ html, body { @@ -98,7 +98,7 @@ html, body {
98 .record-toolbox #resultoutput { 98 .record-toolbox #resultoutput {
99 height: 204px; 99 height: 204px;
100 overflow: auto; } 100 overflow: auto; }
101 - .record-toolbox #compileBtn { 101 + .record-toolbox #teacherCompileBtn, .record-toolbox #studentCompileBtn {
102 background-image: -webkit-linear-gradient(left, #1FB6FF 0%, #62DCF5 100%); 102 background-image: -webkit-linear-gradient(left, #1FB6FF 0%, #62DCF5 100%);
103 background-image: linear-gradient(to right, #1FB6FF 0%, #62DCF5 100%); 103 background-image: linear-gradient(to right, #1FB6FF 0%, #62DCF5 100%);
104 -webkit-transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) all !important; 104 -webkit-transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) all !important;
@@ -137,3 +137,38 @@ html, body { @@ -137,3 +137,38 @@ html, body {
137 z-index: 99; 137 z-index: 99;
138 margin: 2px 8px; 138 margin: 2px 8px;
139 border-radius: 50%; } 139 border-radius: 50%; }
  140 +
  141 +.pause-shodow {
  142 + position: absolute;
  143 + top: 0;
  144 + z-index: 999;
  145 + width: 100%;
  146 + height: 100%;
  147 + background-color: rgba(0, 0, 0, 0.4); }
  148 + .pause-shodow img {
  149 + position: absolute;
  150 + top: 15%;
  151 + left: 50%;
  152 + transform: translate(-50%); }
  153 + .pause-shodow .compile-reslut .btn {
  154 + margin-right: 8px; }
  155 +
  156 +.compile-reslut, .re-reslut {
  157 + position: absolute;
  158 + height: 200px;
  159 + width: 400px;
  160 + background-color: #FFF;
  161 + top: 15%;
  162 + left: 50%;
  163 + transform: translate(-50%); }
  164 + .compile-reslut .tip-header, .compile-reslut .tip-footer, .re-reslut .tip-header, .re-reslut .tip-footer {
  165 + width: 100%;
  166 + padding: 8px 8px;
  167 + background-color: #F5F6FA; }
  168 + .compile-reslut .tip-content, .re-reslut .tip-content {
  169 + padding: 40px;
  170 + line-height: 1.7; }
  171 + .compile-reslut .tip-footer, .re-reslut .tip-footer {
  172 + position: absolute;
  173 + bottom: 0;
  174 + text-align: right; }
src/gxb-ide/Iterm.js
1 ;(function(window){ 1 ;(function(window){
2 - var template = '<div class="upload-tip" style="display: none;"><img src="../img/upload_tip.png" alt=""></div>'  
3 2
4 function Iterm(){ 3 function Iterm(){
5 this.initIterm.apply(this, arguments); 4 this.initIterm.apply(this, arguments);
6 - } 5 + }
7 6
8 Iterm.prototype = { 7 Iterm.prototype = {
9 constructor: Iterm, 8 constructor: Iterm,
@@ -20,51 +19,106 @@ @@ -20,51 +19,106 @@
20 }, 19 },
21 events: function(){ 20 events: function(){
22 var _this = this; 21 var _this = this;
23 - $('#compileBtn').on('click', function(){ _this.compileMode(); }) 22 + $('#teacherCompileBtn').on('click', function(){ _this.teacherCompile(); })
  23 + $('#studentCompileBtn').on('click', function(){ _this.studentCompile(); })
  24 + $('#save_compile').on('click', function(){ _this.saveCompile(); })
  25 + $('#cancel_compile').on('click', function(){ _this.cancelCompile(); })
24 }, 26 },
25 - compileMode: function(){ 27 + teacherCompile: function(){
26 console.log('========================'); 28 console.log('========================');
27 - var l = Ladda.create(document.querySelector( '#compileBtn' ));  
28 - l.start(); 29 + console.log(Iterm.prototype.options);
  30 +
  31 + Hourglass.pauseTimer(); // 暂停计时器
  32 + recorder.pause(); // 音频暂停
  33 + $('.pause-shodow').show()
  34 +
  35 + // 编译时插入操作
  36 + var treeNode = null;
  37 + var check_tree_time = new Date().getTime();
  38 + CodingEditer.addRecord(treeNode, check_tree_time);
  39 +
  40 + var _this = this;
  41 + var el = document.querySelector('#teacherCompileBtn');
  42 + var userId = _this.options.userId;
  43 + var languageId = _this.options.languageId;
29 44
  45 + compileMode(el, userId, languageId)
  46 + },
  47 + studentCompile: function(){
30 var _this = this; 48 var _this = this;
31 - console.log(_this.options)  
32 - // 获取标准输入值  
33 - var runtimeArgus = $('#runtimeArgus').val() || '';  
34 - var mainPath = Dir.mainPath;  
35 - var _fileList = Dir.getTreeData(); 49 + var el = document.querySelector('#studentCompileBtn');
36 var userId = _this.options.userId; 50 var userId = _this.options.userId;
37 var languageId = _this.options.languageId; 51 var languageId = _this.options.languageId;
  52 + compileMode(el, userId, languageId)
  53 + },
  54 + saveCompile: function(){
  55 + recodingConf()
38 56
39 - var compileData = {  
40 - "userId": userId,  
41 - "langId": languageId,  
42 - "mainPath": mainPath,  
43 - "mainArgus": "",  
44 - "runtimeArgus": runtimeArgus,  
45 - "rand": "123456",  
46 - "fileList": _fileList || []  
47 - }  
48 - console.log(compileData);  
49 - $.ajax({  
50 - type: "POST",  
51 - url: gxb_api + "/gxb-web/programmingMulti/codeRun/api",  
52 - data: JSON.stringify(compileData),  
53 - dataType: "json",  
54 - contentType: "application/json",  
55 - success: function(data) {  
56 - console.log(data);  
57 - compileResult(data)  
58 - l.remove();  
59 - CodingEditer.compileResultData = data;  
60 - },  
61 - error: function(XMLHttpRequest, textStatus, errorThrown) {  
62 - l.remove();  
63 - alert('错误');  
64 - console.log(XMLHttpRequest);  
65 - },  
66 - }); 57 + var length = CodingEditer.records.length - 1;
  58 +
  59 + CodingEditer.records[length].compile = CodingEditer.compileResultData;
  60 +
  61 + CodingEditer.records[length].content = CodingEditer.compileResultData.content;
  62 + CodingEditer.records[length].error = CodingEditer.compileResultData.error;
  63 + CodingEditer.records[length].compilerInfo = CodingEditer.compileResultData.compilerInfo;
  64 + CodingEditer.records[length].code = CodingEditer.compileResultData.code;
  65 +
  66 + },
  67 + cancelCompile: function(){
  68 + recodingConf()
  69 + }
  70 + }
  71 +
  72 + // 继续录制配置
  73 + function recodingConf(){
  74 + $('.pause-shodow').hide()
  75 +
  76 + Hourglass.pauseTimer();
  77 + recorder.pause();
  78 +
  79 + CodingEditer.record_startime = new Date().getTime();
  80 + }
  81 +
  82 + // 编译
  83 + function compileMode(el, userId, languageId){
  84 + var l = Ladda.create(el);
  85 + l.start();
  86 + // 获取标准输入值
  87 + var runtimeArgus = $('#runtimeArgus').val() || '';
  88 + var mainPath = Dir.mainPath;
  89 + var _fileList = Dir.getTreeData();
  90 +
  91 + var compileData = {
  92 + "userId": userId,
  93 + "langId": languageId,
  94 + "mainPath": mainPath,
  95 + "mainArgus": "",
  96 + "runtimeArgus": runtimeArgus,
  97 + "rand": "123456",
  98 + "fileList": _fileList || []
67 } 99 }
  100 + console.log(compileData);
  101 + $.ajax({
  102 + type: "POST",
  103 + url: gxb_api + "/gxb-web/programmingMulti/codeRun/api",
  104 + data: JSON.stringify(compileData),
  105 + dataType: "json",
  106 + contentType: "application/json",
  107 + success: function(data) {
  108 + console.log(data);
  109 + $('.pause-shodow img').hide()
  110 + $('.pause-shodow .compile-reslut').show()
  111 + compileResult(data)
  112 + l.remove();
  113 + CodingEditer.compileResultData = data;
  114 + },
  115 + error: function(XMLHttpRequest, textStatus, errorThrown) {
  116 + $('.pause-shodow img').remove()
  117 + l.remove();
  118 + alert('错误');
  119 + console.log(XMLHttpRequest);
  120 + },
  121 + });
68 } 122 }
69 123
70 // 编译结果 124 // 编译结果
src/scss/main.scss
@@ -134,7 +134,7 @@ html, body{ @@ -134,7 +134,7 @@ html, body{
134 overflow: auto; 134 overflow: auto;
135 } 135 }
136 136
137 - #compileBtn{ 137 + #teacherCompileBtn, #studentCompileBtn{
138 background-image: -webkit-linear-gradient(left, #1FB6FF 0%, #62DCF5 100%); 138 background-image: -webkit-linear-gradient(left, #1FB6FF 0%, #62DCF5 100%);
139 background-image: linear-gradient(to right, #1FB6FF 0%, #62DCF5 100%); 139 background-image: linear-gradient(to right, #1FB6FF 0%, #62DCF5 100%);
140 -webkit-transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) all !important; 140 -webkit-transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) all !important;
@@ -184,6 +184,51 @@ html, body{ @@ -184,6 +184,51 @@ html, body{
184 } 184 }
185 } 185 }
186 } 186 }
  187 +.pause-shodow{
  188 + position: absolute;
  189 + top: 0;
  190 + z-index: 999;
  191 + width: 100%;
  192 + height: 100%;
  193 + background-color: rgba(0,0,0,0.4);
  194 +
  195 + img{
  196 + position: absolute;
  197 + top: 15%;
  198 + left: 50%;
  199 + transform: translate(-50%);
  200 + }
  201 + .compile-reslut{
  202 + .btn{
  203 + margin-right: 8px;
  204 + }
  205 + }
  206 +}
  207 +
  208 +.compile-reslut, .re-reslut{
  209 + position: absolute;
  210 + height: 200px;
  211 + width: 400px;
  212 + background-color: #FFF;
  213 + top: 15%;
  214 + left: 50%;
  215 + transform: translate(-50%);
  216 +
  217 + .tip-header, .tip-footer{
  218 + width: 100%;
  219 + padding: 8px 8px;
  220 + background-color: #F5F6FA;
  221 + }
  222 + .tip-content{
  223 + padding: 40px;
  224 + line-height: 1.7;
  225 + }
  226 + .tip-footer{
  227 + position: absolute;
  228 + bottom: 0;
  229 + text-align: right;
  230 + }
  231 +}
187 232
188 233
189 234
src/v1.1/c.html
@@ -111,6 +111,23 @@ @@ -111,6 +111,23 @@
111 <div id="replayzone" class="tab-pane"></div> 111 <div id="replayzone" class="tab-pane"></div>
112 </div> 112 </div>
113 </div> 113 </div>
  114 + <div class="pause-shodow" style="display: none;">
  115 + <div class="compile-loading">
  116 + <img src="../img/loading.png" alt="">
  117 + </div>
  118 + <div class="compile-reslut" style="display: none;">
  119 + <div class="tip-header">
  120 + <span>成功获取编译运行结果</span>
  121 + </div>
  122 + <div class="tip-content">
  123 + <p>保存编译结果后,播放到此处会在运行区域直接显示结果。需要保存结果后继续录制吗?</p>
  124 + </div>
  125 + <div class="tip-footer">
  126 + <button class="btn btn-success btn-sm" id="save_compile">保存并继续录制</button>
  127 + <button class="btn btn-danger btn-sm" id="cancel_compile">不保存继续录制</button>
  128 + </div>
  129 + </div>
  130 + </div>
114 </div> 131 </div>
115 132
116 133
@@ -128,7 +145,10 @@ @@ -128,7 +145,10 @@
128 <li><a href="#output" role="tab" data-toggle="tab" class="text">结果</a></li> 145 <li><a href="#output" role="tab" data-toggle="tab" class="text">结果</a></li>
129 </ul> 146 </ul>
130 <div class="pull-right func"> 147 <div class="pull-right func">
131 - <a class="btn btn-success" id="compileBtn"> 148 + <a class="btn btn-success" id="teacherCompileBtn">
  149 + <span class="ladda-label">编译运行</span>
  150 + </a>
  151 + <a class="btn btn-success" id="studentCompileBtn">
132 <span class="ladda-label">编译运行</span> 152 <span class="ladda-label">编译运行</span>
133 </a> 153 </a>
134 <a id="full-screen" class=""><i class="icon iconfont icon-quanping1"></i></a> 154 <a id="full-screen" class=""><i class="icon iconfont icon-quanping1"></i></a>