Commit 34312edeb4195028e4e6fe33df4c2cac5d01caba
1 parent
90dd5991
优化流程
Showing
3 changed files
with
173 additions
and
224 deletions
src/css/demo.css
| ... | ... | @@ -184,9 +184,11 @@ textarea[id^="tab"].active{ display: block; } |
| 184 | 184 | } |
| 185 | 185 | #editorwrapper .btn-group{ |
| 186 | 186 | margin: 16px 16px 14px 16px; |
| 187 | + width: 100%; | |
| 187 | 188 | } |
| 188 | 189 | #editorwrapper .btn-group .btn{ |
| 189 | 190 | border-color: transparent; |
| 191 | + color: #1FB6FF; | |
| 190 | 192 | } |
| 191 | 193 | #editorwrapper .btn-group .btn:first-child{ |
| 192 | 194 | border-top-left-radius: 5px; |
| ... | ... | @@ -204,7 +206,7 @@ textarea[id^="tab"].active{ display: block; } |
| 204 | 206 | height: 100%; |
| 205 | 207 | } |
| 206 | 208 | .editor-result .result-header{ |
| 207 | - padding: 15px; | |
| 209 | + padding: 16px 15px 13px 15px; | |
| 208 | 210 | height: 60px; |
| 209 | 211 | background-color: #F0F3F5; |
| 210 | 212 | border-radius: 0; |
| ... | ... | @@ -212,9 +214,42 @@ textarea[id^="tab"].active{ display: block; } |
| 212 | 214 | .editor-result .result-header .btn-group .btn{ |
| 213 | 215 | background-image: -webkit-linear-gradient(left, #1FB6FF 0%, #62DCF5 100%); |
| 214 | 216 | background-image: linear-gradient(to right, #1FB6FF 0%, #62DCF5 100%); |
| 215 | - border-color: #F0F3F5; | |
| 216 | - border-radius: 5px; | |
| 217 | + -webkit-transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) all !important; | |
| 218 | + transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) all !important; | |
| 219 | + /*border-color: #F0F3F5; | |
| 220 | + border-radius: 5px;*/ | |
| 221 | + border: none; | |
| 217 | 222 | color: #fff; |
| 223 | + padding-top: 5px; | |
| 224 | + padding-bottom: 5px; | |
| 225 | +} | |
| 226 | +.editor-result .result-header .btn-group .btn[data-loading] { | |
| 227 | + background-image: none; | |
| 228 | + background-image: none; | |
| 229 | + padding-right: 34px; | |
| 230 | +} | |
| 231 | +.editor-result .result-header .btn-group .ladda-spinner { | |
| 232 | + position: absolute; | |
| 233 | + z-index: 2; | |
| 234 | + display: inline-block; | |
| 235 | + width: 28px; | |
| 236 | + height: 28px; | |
| 237 | + top: 50%; | |
| 238 | + right: 3px; | |
| 239 | + margin-top: 0; | |
| 240 | + opacity: 1; | |
| 241 | + pointer-events: none; | |
| 242 | + transform: translateY(-50%); | |
| 243 | +} | |
| 244 | +.editor-result .result-header #full-screen{ | |
| 245 | + margin: 0; | |
| 246 | + background-image: linear-gradient(90deg, #1FB6FF 0%, #62DCF5 100%); | |
| 247 | + border-radius: 100px; | |
| 248 | + padding: 5px 9px; | |
| 249 | + margin-right: 15px; | |
| 250 | +} | |
| 251 | +.editor-result .result-header #full-screen .iconfont{ | |
| 252 | + font-size: 10px; | |
| 218 | 253 | } |
| 219 | 254 | .editor-result .result-tabs{ |
| 220 | 255 | height: 30px; | ... | ... |
src/index.html
| ... | ... | @@ -15,11 +15,12 @@ |
| 15 | 15 | <link href="css/layout.css" rel="stylesheet"> |
| 16 | 16 | <link href="css/main.css" rel="stylesheet"> |
| 17 | 17 | <link href="css/recording.css" rel="stylesheet"> |
| 18 | + <!-- <link href="http://lab.hakim.se/ladda/dist/ladda.min.css" rel="stylesheet"> --> | |
| 18 | 19 | <link rel="stylesheet" href="js/zTree_v3-3.5.27/css/zTreeStyle/zTreeStyle.css"> |
| 19 | 20 | |
| 20 | 21 | <script> |
| 21 | - var gxb_api = "https://restful1.gaoxiaobang.com"; | |
| 22 | - // var gxb_api = "http://192.168.80.236:8080" | |
| 22 | + // var gxb_api = "https://restful1.gaoxiaobang.com"; | |
| 23 | + var gxb_api = "http://192.168.80.140:8080" | |
| 23 | 24 | |
| 24 | 25 | </script> |
| 25 | 26 | |
| ... | ... | @@ -85,8 +86,8 @@ |
| 85 | 86 | </ul> |
| 86 | 87 | <div id="editorwrapper" class="pull-right"> |
| 87 | 88 | <div class="btn-group"> |
| 88 | - <div id="htmlbutton" class="btn btn-default btn-sm" data-editorname="html">JAVA</div> | |
| 89 | - <div class="btn btn-default btn-sm">JDK 7</div> | |
| 89 | + <div id="htmlbutton" class="btn btn-default btn-sm" data-toggle="tooltip" data-placement="bottom" data-original-title="当前课程环境:Java" data-editorname="html">JAVA</div> | |
| 90 | + <div class="btn btn-default btn-sm" data-toggle="tooltip" data-placement="bottom" data-original-title="JDK版本">JDK 7</div> | |
| 90 | 91 | </div> |
| 91 | 92 | </div> |
| 92 | 93 | </div> |
| ... | ... | @@ -100,16 +101,15 @@ |
| 100 | 101 | <div id="resultpanel" class="panel panel-default editor-result"> |
| 101 | 102 | <div class="panel-heading result-header"> |
| 102 | 103 | <div class="pull-left"> |
| 103 | - <div id="comprunbtngrp" class="btn-group"></div> | |
| 104 | + <div id="compileBtnGroup" class="btn-group"></div> | |
| 104 | 105 | </div> |
| 105 | 106 | <div class="pull-right"> |
| 106 | - <a href="javascript:;" class="btn btn-link">全屏</a> | |
| 107 | + <a id="full-screen" href="javascript:;" data-toggle="tooltip" data-placement="left" data-original-title="全屏录制" class="btn btn-link"><i class="icon iconfont icon-fangda"></i></a> | |
| 107 | 108 | </div> |
| 108 | 109 | <div class="btn-group"> |
| 109 | 110 | <button type="button" class="btn btn-success" id="play" data-status="0" title="" style="display: none;"><</button> |
| 110 | - <p id="replay">预览录制</p> | |
| 111 | + <!-- <p id="replay">预览录制</p> --> | |
| 111 | 112 | </div> |
| 112 | - <div class="btn-group pull-right" id="comprunbtngrp"></div> | |
| 113 | 113 | <!-- <div class="btn-group pull-right" id="fontendrun"> |
| 114 | 114 | <button id="autorun" type="button" class="btn" title="切换自动/手动运行代码" data-placement="bottom" data-autorun="1"></button> |
| 115 | 115 | <button id="runnow" type="button" class="btn" title="手动运行代码" data-placement="bottom" disabled="disabled"> |
| ... | ... | @@ -129,7 +129,7 @@ |
| 129 | 129 | <!-- Tab panes --> |
| 130 | 130 | <div class="tab-content"> |
| 131 | 131 | <div class="tab-pane active padall15" id="stdin"> |
| 132 | - <input type="text" class="form-control" id="input" placeholder="标准输入"> | |
| 132 | + <input type="text" class="form-control" id="runtimeArgus" placeholder="标准输入"> | |
| 133 | 133 | </div> |
| 134 | 134 | <div class="tab-pane padall15" id="cmpinfo"></div> |
| 135 | 135 | <div class="tab-pane padall15" id="stderr"></div> |
| ... | ... | @@ -199,6 +199,9 @@ |
| 199 | 199 | <script src="js/recording/recording.js"></script> |
| 200 | 200 | |
| 201 | 201 | <script> |
| 202 | + $(function () { | |
| 203 | + $('[data-toggle="tooltip"]').tooltip() | |
| 204 | + }) | |
| 202 | 205 | var recorder; |
| 203 | 206 | var _role = getQuery('role'); |
| 204 | 207 | var _chapterId = getQuery('chapterId'); | ... | ... |
src/js/gb.js
| ... | ... | @@ -24,23 +24,36 @@ $(function() { |
| 24 | 24 | |
| 25 | 25 | var ZTREE = { |
| 26 | 26 | /** |
| 27 | - * ztree 每一项点击事件 | |
| 27 | + * ztreeSetting 配置文件 | |
| 28 | 28 | * @Author syantao |
| 29 | 29 | * Created by Keystion on 2017-01-19 |
| 30 | 30 | */ |
| 31 | - beforeClick: function(treeId, treeNode){ | |
| 32 | - // 判断是否点击了文件夹 | |
| 33 | - if (treeNode.isParent) { | |
| 34 | - return false; | |
| 31 | + config: { | |
| 32 | + view: { showLine: false } | |
| 33 | + ,data: { | |
| 34 | + simpleData: { enable: true } | |
| 35 | 35 | } |
| 36 | - treeObj = $.fn.zTree.getZTreeObj("folder"); | |
| 37 | - treeObj.expandNode(treeNode); | |
| 36 | + ,callback: { | |
| 37 | + /** | |
| 38 | + * ztree 每一项点击事件 | |
| 39 | + * @Author syantao | |
| 40 | + * Created by Keystion on 2017-01-19 | |
| 41 | + */ | |
| 42 | + beforeClick: function(treeId, treeNode){ | |
| 43 | + // 判断是否点击了文件夹 | |
| 44 | + if (treeNode.isParent) { | |
| 45 | + return false; | |
| 46 | + } | |
| 47 | + treeObj = $.fn.zTree.getZTreeObj("folder"); | |
| 48 | + treeObj.expandNode(treeNode); | |
| 38 | 49 | |
| 39 | - console.info('点击了 ' + treeNode.name); | |
| 40 | - console.info(treeNode); | |
| 50 | + console.info('点击了 ' + treeNode.name); | |
| 51 | + console.info(treeNode); | |
| 41 | 52 | |
| 42 | - // 处理显示目录树对应的编辑器目录 | |
| 43 | - ZTREE.showEdite(treeNode); | |
| 53 | + // 处理显示目录树对应的编辑器目录 | |
| 54 | + ZTREE.showEdite(treeNode); | |
| 55 | + } | |
| 56 | + } | |
| 44 | 57 | }, |
| 45 | 58 | /** |
| 46 | 59 | * 通过目录树的点击来显示对应的编辑器 |
| ... | ... | @@ -50,14 +63,15 @@ $(function() { |
| 50 | 63 | * TODO treeNode放到一个变量或者隐藏域里面 |
| 51 | 64 | */ |
| 52 | 65 | showEdite: function (treeNode){ |
| 53 | - var _file, | |
| 66 | + var _this = this, | |
| 67 | + _file, | |
| 54 | 68 | _CodeMirrorRecordId, |
| 55 | 69 | _CodeMirrorReplayId, |
| 56 | 70 | _num = 0; |
| 57 | 71 | // 判断是否是初始化选时候调用 showEdite |
| 58 | 72 | if(treeNode){ |
| 59 | 73 | for (var i = 0; i < treeLinkEditor.length; i++) { |
| 60 | - if(treeLinkEditor[i].name == ZTREE.manageName(treeNode.name)){ | |
| 74 | + if(treeLinkEditor[i].name == _this.manageName(treeNode.name)){ | |
| 61 | 75 | _num = i; |
| 62 | 76 | } |
| 63 | 77 | } |
| ... | ... | @@ -69,7 +83,8 @@ $(function() { |
| 69 | 83 | mainPath = treeLinkEditor[_num].filePath; // 更新mainPath值 |
| 70 | 84 | |
| 71 | 85 | // 更新目录树选中状态 |
| 72 | - ZTREE.selectTreeItem(_file); | |
| 86 | + _this.selectTreeItem(_file); | |
| 87 | + | |
| 73 | 88 | // 显示代码编辑器 |
| 74 | 89 | $('#' + _CodeMirrorRecordId).show().parent().show().siblings().hide().find('.CodeMirror').hide(); |
| 75 | 90 | $('#' + _CodeMirrorReplayId).show().parent().show().siblings().hide().find('.CodeMirror').hide(); |
| ... | ... | @@ -120,7 +135,6 @@ $(function() { |
| 120 | 135 | * @param {[type]} id 代码编辑器的id |
| 121 | 136 | */ |
| 122 | 137 | ,getCurrentEditor: function (id){ |
| 123 | - console.log(id); | |
| 124 | 138 | var _id = id || treeLinkEditor[0].CodeMirrorRecordId, |
| 125 | 139 | _name; |
| 126 | 140 | |
| ... | ... | @@ -188,49 +202,10 @@ $(function() { |
| 188 | 202 | $(document).on('click', '#cancel', function(event) { |
| 189 | 203 | event.preventDefault(); |
| 190 | 204 | /* Act on the event */ |
| 191 | - fileList = ZTREE.getTreeData(); | |
| 192 | - if(!fileList){ | |
| 193 | - alert('请输入代码'); | |
| 194 | - return false; | |
| 195 | - } | |
| 196 | - var compileData = { | |
| 197 | - "userId": _userId, | |
| 198 | - "langId": _languageid, | |
| 199 | - "mainPath": mainPath, | |
| 200 | - "mainArgus": "", | |
| 201 | - "runtimeArgus": "", | |
| 202 | - "rand": "123456", | |
| 203 | - "fileList": fileList | |
| 204 | - } | |
| 205 | - console.log(compileData); | |
| 206 | - $.ajax({ | |
| 207 | - type: "post", | |
| 208 | - url: "http://192.168.80.140:8080/gxb-web/programmingMulti/codeRun/api", | |
| 209 | - data: JSON.stringify(compileData), | |
| 210 | - dataType: "json", | |
| 211 | - contentType: "application/json", | |
| 212 | - success: function(data) { | |
| 213 | - console.log(data); | |
| 214 | - }, | |
| 215 | - error: function() { | |
| 216 | - } | |
| 217 | - }); | |
| 218 | - }); | |
| 219 | 205 | |
| 220 | - /** | |
| 221 | - * ztreeSetting 配置文件 | |
| 222 | - * @Author syantao | |
| 223 | - * Created by Keystion on 2017-01-19 | |
| 224 | - */ | |
| 225 | - var ztreeSetting = { | |
| 226 | - view: { showLine: false } | |
| 227 | - ,data: { | |
| 228 | - simpleData: { enable: true } | |
| 229 | - } | |
| 230 | - ,callback: { | |
| 231 | - beforeClick: ZTREE.beforeClick | |
| 232 | - } | |
| 233 | - }; | |
| 206 | + ZTREE.resetCodeMirrorValue(); | |
| 207 | + | |
| 208 | + }); | |
| 234 | 209 | |
| 235 | 210 | // 根据不同的角色渲染页面 |
| 236 | 211 | if (_role == 1) { |
| ... | ... | @@ -1197,126 +1172,6 @@ $(function() { |
| 1197 | 1172 | GBCodePlayBack.replay_enhancement = !GBCodePlayBack.replay_enhancement; |
| 1198 | 1173 | }); |
| 1199 | 1174 | |
| 1200 | - $('#autorun').click(function() { | |
| 1201 | - var $this = $(this), | |
| 1202 | - autorun = $this.data('autorun'); | |
| 1203 | - | |
| 1204 | - if (autorun === 1) { | |
| 1205 | - $('#runnow').prop('disabled', false).toggleClass('btn-success').toggleClass('btn-default'); | |
| 1206 | - } else { | |
| 1207 | - $('#runnow').prop('disabled', true).toggleClass('btn-success').toggleClass('btn-default'); | |
| 1208 | - } | |
| 1209 | - | |
| 1210 | - $this.data('autorun', (autorun) ? 0 : 1); | |
| 1211 | - GBCodePlayBack.autorun = !GBCodePlayBack.autorun; | |
| 1212 | - | |
| 1213 | - $('#runnow').trigger('click'); | |
| 1214 | - }); | |
| 1215 | - | |
| 1216 | - if (GBCodePlayBack.autorun === 1) { | |
| 1217 | - $('#runnow').prop('disabled', true).removeClass('btn-success').addClass('btn-default'); | |
| 1218 | - } else { | |
| 1219 | - $('#runnow').prop('disabled', false).addClass('btn-success').removeClass('btn-default'); | |
| 1220 | - } | |
| 1221 | - | |
| 1222 | - $('#runnow').click(function() { | |
| 1223 | - if (typeof GBCodePlayBack.htmleditor !== 'undefined' && typeof GBCodePlayBack.csseditor !== 'undefined' && typeof GBCodePlayBack.jseditor !== 'undefined') { | |
| 1224 | - GBCodePlayBack.generateResult(GBCodePlayBack.htmleditor.getValue(), | |
| 1225 | - GBCodePlayBack.csseditor.getValue(), | |
| 1226 | - GBCodePlayBack.jseditor.getValue() | |
| 1227 | - ); | |
| 1228 | - | |
| 1229 | - return false; | |
| 1230 | - } | |
| 1231 | - | |
| 1232 | - if (typeof GBCodePlayBack.htmlplayereditor !== 'undefined' && typeof GBCodePlayBack.cssplayereditor !== 'undefined' && typeof GBCodePlayBack.jsplayereditor !== 'undefined') { | |
| 1233 | - GBCodePlayBack.generateResult(GBCodePlayBack.htmlplayereditor.getValue(), | |
| 1234 | - GBCodePlayBack.cssplayereditor.getValue(), | |
| 1235 | - GBCodePlayBack.jsplayereditor.getValue() | |
| 1236 | - ); | |
| 1237 | - } | |
| 1238 | - }); | |
| 1239 | - | |
| 1240 | - // 使用服务端编译语言 | |
| 1241 | - $('#comprunbtngrp').unbind("click").on('click', '#comprun', function(event) { | |
| 1242 | - event.preventDefault(); | |
| 1243 | - var l = Ladda.create(this); | |
| 1244 | - $('#comprun').find('ladda-spinner').remove() | |
| 1245 | - l.start(); | |
| 1246 | - | |
| 1247 | - // 暂停录制 | |
| 1248 | - var pauseState = $('#pause').data('pause'); | |
| 1249 | - if (pauseState == 1 && _role == 0) { | |
| 1250 | - GBCodePlayBack.record_pause_time = new Date().getTime(); // 暂停的时间 | |
| 1251 | - | |
| 1252 | - Hourglass.pauseTimer(); // 暂停计时器 | |
| 1253 | - recorder.pause(); // 音频暂停 | |
| 1254 | - | |
| 1255 | - $('#pause').data('status', '1'); | |
| 1256 | - $('#pause').data('pause', '0'); | |
| 1257 | - $('#pause').removeClass('hidden').addClass('show'); | |
| 1258 | - $('#start-recording').hide(); | |
| 1259 | - | |
| 1260 | - $('.pause-shodow').removeClass('hidden').addClass('show'); | |
| 1261 | - } | |
| 1262 | - | |
| 1263 | - var code = (typeof GBCodePlayBack.htmleditor !== 'undefined' && GBCodePlayBack.htmleditor.getValue()) || (typeof GBCodePlayBack.htmlplayereditor !== 'undefined' && GBCodePlayBack.htmlplayereditor.getValue()); | |
| 1264 | - | |
| 1265 | - var langid = $('#htmlbutton').data("languageid"); | |
| 1266 | - | |
| 1267 | - var input = $('#input').val() || ''; | |
| 1268 | - | |
| 1269 | - var compileData = { | |
| 1270 | - code: code, | |
| 1271 | - langid: langid, | |
| 1272 | - input: input | |
| 1273 | - } | |
| 1274 | - | |
| 1275 | - $.ajax({ | |
| 1276 | - type: "post", | |
| 1277 | - url: gxb_api + "/submit/submitCode/api", | |
| 1278 | - data: JSON.stringify(compileData), | |
| 1279 | - dataType: "json", | |
| 1280 | - contentType: "application/json", | |
| 1281 | - success: function(data) { | |
| 1282 | - compileResult(data) | |
| 1283 | - l.stop(); | |
| 1284 | - | |
| 1285 | - $('.compile-loading').hide(); | |
| 1286 | - $('.compile-reslut').show(); | |
| 1287 | - GBCodePlayBack.compileResultData = data; | |
| 1288 | - | |
| 1289 | - }, | |
| 1290 | - error: function() { | |
| 1291 | - l.stop(); | |
| 1292 | - alert('错误') | |
| 1293 | - } | |
| 1294 | - }); | |
| 1295 | - }); | |
| 1296 | - | |
| 1297 | - // 保存编译结果 | |
| 1298 | - $('#save_compile').unbind("click").click(function() { | |
| 1299 | - var length = GBCodePlayBack.records.length - 1; | |
| 1300 | - Hourglass.pauseTimer(); | |
| 1301 | - GBCodePlayBack.records[length].compile = GBCodePlayBack.compileResultData; | |
| 1302 | - | |
| 1303 | - GBCodePlayBack.records[length].output = GBCodePlayBack.compileResultData.output; | |
| 1304 | - GBCodePlayBack.records[length].stderr = GBCodePlayBack.compileResultData.stderr; | |
| 1305 | - GBCodePlayBack.records[length].cmpinfo = GBCodePlayBack.compileResultData.cmpinfo; | |
| 1306 | - GBCodePlayBack.records[length].result = GBCodePlayBack.compileResultData.result; | |
| 1307 | - | |
| 1308 | - GBCodePlayBack.record_continue_time = new Date().getTime(); | |
| 1309 | - | |
| 1310 | - contrlPause() | |
| 1311 | - }) | |
| 1312 | - | |
| 1313 | - // 不保存编译结果 | |
| 1314 | - $('#cancel_compile').unbind('click').click(function() { | |
| 1315 | - Hourglass.pauseTimer(); | |
| 1316 | - contrlPause() | |
| 1317 | - GBCodePlayBack.record_continue_time = new Date().getTime(); | |
| 1318 | - }) | |
| 1319 | - | |
| 1320 | 1175 | // 进度条滚动控制播放进度 |
| 1321 | 1176 | var $sliderpropress = $(".replayprogress"); |
| 1322 | 1177 | $sliderpropress.slider({}).slider("option", "disabled", true); |
| ... | ... | @@ -1487,9 +1342,9 @@ $(function() { |
| 1487 | 1342 | this.resizeWindow($('#ifrcontainer').find('#resultiframe')); |
| 1488 | 1343 | |
| 1489 | 1344 | if (document.URL.indexOf('index.htm')>=0) { |
| 1490 | - $(window).bind('beforeunload', function(){ | |
| 1491 | - return '确认立刻退出? 请确保已录制的代码回放以保存,以防回放数据丢失'; | |
| 1492 | - }); | |
| 1345 | + // $(window).bind('beforeunload', function(){ | |
| 1346 | + // return '确认立刻退出? 请确保已录制的代码回放以保存,以防回放数据丢失'; | |
| 1347 | + // }); | |
| 1493 | 1348 | } |
| 1494 | 1349 | |
| 1495 | 1350 | /* 解决Chrome浏览器非激活标签页下错乱问题 */ |
| ... | ... | @@ -1691,10 +1546,10 @@ $(function() { |
| 1691 | 1546 | playTime: 0, |
| 1692 | 1547 | currenttime: currenttime |
| 1693 | 1548 | }; |
| 1694 | - console.log('GBCodePlayBack.onChange'); | |
| 1695 | - console.log(GBCodePlayBack.records); | |
| 1696 | 1549 | GBCodePlayBack.records.push(recordobj); |
| 1697 | 1550 | GBCodePlayBack.record_startime = currenttime; //设定起始时间 |
| 1551 | + console.log('GBCodePlayBack.onChange'); | |
| 1552 | + console.log(GBCodePlayBack.records); | |
| 1698 | 1553 | }, |
| 1699 | 1554 | changeValueCallback: function(record, replay_type, offset) { |
| 1700 | 1555 | var obj = record.changeobj, |
| ... | ... | @@ -1844,6 +1699,18 @@ $(function() { |
| 1844 | 1699 | doc.open(); |
| 1845 | 1700 | doc.writeln(result); |
| 1846 | 1701 | doc.close(); |
| 1702 | + }, | |
| 1703 | + resetCodeMirrorValue: function (){ | |
| 1704 | + var _this = this; | |
| 1705 | + console.log(_this.records); | |
| 1706 | + for (var i = 0; i < treeLinkEditor.length; i++) { | |
| 1707 | + if(treeLinkEditor[i].CodeMirrorRecord.getValue() != ''){ | |
| 1708 | + treeLinkEditor[i].CodeMirrorRecord.setValue(""); | |
| 1709 | + } | |
| 1710 | + } | |
| 1711 | + | |
| 1712 | + GBCodePlayBack.records = []; | |
| 1713 | + console.log(GBCodePlayBack.records); | |
| 1847 | 1714 | } |
| 1848 | 1715 | } |
| 1849 | 1716 | |
| ... | ... | @@ -1858,7 +1725,7 @@ $(function() { |
| 1858 | 1725 | .done(function(res) { |
| 1859 | 1726 | treeData = res.tree; |
| 1860 | 1727 | |
| 1861 | - treeObj = $.fn.zTree.init($("#folder"), ztreeSetting, treeData); | |
| 1728 | + treeObj = $.fn.zTree.init($("#folder"), ZTREE.config, treeData); | |
| 1862 | 1729 | |
| 1863 | 1730 | GBCodePlayBack.recordinit(treeData); |
| 1864 | 1731 | }) |
| ... | ... | @@ -1871,7 +1738,9 @@ $(function() { |
| 1871 | 1738 | |
| 1872 | 1739 | // 开始录制 |
| 1873 | 1740 | $('#start-recording').click(function() { |
| 1741 | + // 切换到录制区域 | |
| 1874 | 1742 | $('#recordertab a:eq(0)').tab('show'); |
| 1743 | + | |
| 1875 | 1744 | // 编译状态 |
| 1876 | 1745 | var data = $(this).attr('data'); |
| 1877 | 1746 | var seconds = 0; |
| ... | ... | @@ -1941,21 +1810,21 @@ $(function() { |
| 1941 | 1810 | }); |
| 1942 | 1811 | |
| 1943 | 1812 | // 使用服务端编译语言 |
| 1944 | - $('#comprunbtngrp').unbind("click").on('click', '#comprun', function(event){ | |
| 1813 | + $('#compileBtnGroup').unbind("click").on('click', '#CompileBtn', function(event){ | |
| 1945 | 1814 | event.preventDefault(); |
| 1946 | - var l = Ladda.create(this); | |
| 1947 | - $('#comprun').find('ladda-spinner').remove(); | |
| 1948 | - l.start(); | |
| 1815 | + var ladda = Ladda.create(this); | |
| 1816 | + $('#CompileBtn').find('ladda-spinner').remove(); | |
| 1817 | + ladda.start(); | |
| 1949 | 1818 | |
| 1950 | 1819 | if (!GBCodePlayBack.isRcording) { |
| 1951 | - compileRun(l) | |
| 1820 | + compileRun(ladda) | |
| 1952 | 1821 | }else{ |
| 1953 | - var runStatus = $("#comprun").data('run'); | |
| 1822 | + var runStatus = $("#CompileBtn").data('run'); | |
| 1954 | 1823 | if (runStatus == 1) { |
| 1955 | 1824 | Hourglass.pauseTimer(); // 暂停计时器 |
| 1956 | 1825 | recorder.pause(); // 音频暂停 |
| 1957 | 1826 | } |
| 1958 | - $("#comprun").data('run', 0); | |
| 1827 | + $("#CompileBtn").data('run', 0); | |
| 1959 | 1828 | $('.compile-loading').show(); |
| 1960 | 1829 | // 暂停录制 |
| 1961 | 1830 | var pauseState = $('#pause').data('pause'); |
| ... | ... | @@ -1987,10 +1856,9 @@ $(function() { |
| 1987 | 1856 | |
| 1988 | 1857 | $('.pause-shodow').removeClass('hidden').addClass('show'); |
| 1989 | 1858 | } |
| 1990 | - compileRun(l) | |
| 1859 | + compileRun(ladda) | |
| 1991 | 1860 | } |
| 1992 | 1861 | }); |
| 1993 | - | |
| 1994 | 1862 | |
| 1995 | 1863 | // 保存编译结果 |
| 1996 | 1864 | $('#save_compile').unbind("click").click(function(){ |
| ... | ... | @@ -2016,7 +1884,7 @@ $(function() { |
| 2016 | 1884 | // 继续录制配置 |
| 2017 | 1885 | function recodingConf(){ |
| 2018 | 1886 | Hourglass.pauseTimer(); |
| 2019 | - $("#comprun").data('run', 1); | |
| 1887 | + $("#CompileBtn").data('run', 1); | |
| 2020 | 1888 | GBCodePlayBack.record_startime = new Date().getTime(); |
| 2021 | 1889 | GBCodePlayBack.record_continue_time = new Date().getTime(); |
| 2022 | 1890 | } |
| ... | ... | @@ -2042,36 +1910,78 @@ $(function() { |
| 2042 | 1910 | } |
| 2043 | 1911 | |
| 2044 | 1912 | // 云编译 |
| 2045 | - function compileRun(l){ | |
| 2046 | - var code = (typeof GBCodePlayBack.htmleditor !=='undefined' && GBCodePlayBack.htmleditor.getValue()) | |
| 2047 | - || (typeof GBCodePlayBack.htmlplayereditor !=='undefined' && GBCodePlayBack.htmlplayereditor.getValue()); | |
| 2048 | - var langid = $('#htmlbutton').data("languageid"); | |
| 2049 | - var input = $('#input').val() || ''; | |
| 1913 | + function compileRun(ladda){ | |
| 1914 | + // 获取标准输入值 | |
| 1915 | + var runtimeArgus = $('#runtimeArgus').val() || ''; | |
| 1916 | + | |
| 1917 | + fileList = ZTREE.getTreeData(); | |
| 1918 | + if(!fileList){ | |
| 1919 | + alert('请输入代码'); | |
| 1920 | + ladda.remove(); | |
| 1921 | + return false; | |
| 1922 | + } | |
| 2050 | 1923 | var compileData = { |
| 2051 | - code: code, | |
| 2052 | - langid: langid, | |
| 2053 | - input: input | |
| 1924 | + "userId": _userId, | |
| 1925 | + "langId": _languageid, | |
| 1926 | + "mainPath": mainPath, | |
| 1927 | + "mainArgus": "", | |
| 1928 | + "runtimeArgus": runtimeArgus, | |
| 1929 | + "rand": "123456", | |
| 1930 | + "fileList": fileList | |
| 2054 | 1931 | } |
| 1932 | + console.log(compileData); | |
| 2055 | 1933 | $.ajax({ |
| 2056 | - type: "post", | |
| 2057 | - url: gxb_api + "/submit/submitCode/api", | |
| 1934 | + type: "POST", | |
| 1935 | + url: gxb_api + "/gxb-web/programmingMulti/codeRun/api", | |
| 2058 | 1936 | data: JSON.stringify(compileData), |
| 2059 | 1937 | dataType: "json", |
| 2060 | 1938 | contentType: "application/json", |
| 2061 | 1939 | success: function(data) { |
| 1940 | + console.log(data); | |
| 1941 | + | |
| 2062 | 1942 | compileResult(data) |
| 2063 | - l.stop(); | |
| 1943 | + ladda.remove(); | |
| 2064 | 1944 | |
| 2065 | 1945 | $('.compile-loading').hide(); |
| 2066 | 1946 | $('.compile-reslut').show(); |
| 2067 | 1947 | GBCodePlayBack.compileResultData = data; |
| 2068 | 1948 | |
| 2069 | 1949 | }, |
| 2070 | - error: function(){ | |
| 2071 | - l.stop(); | |
| 1950 | + error: function(XMLHttpRequest, textStatus, errorThrown) { | |
| 1951 | + ladda.remove(); | |
| 2072 | 1952 | alert('错误'); |
| 1953 | + console.log(XMLHttpRequest); | |
| 2073 | 1954 | } |
| 2074 | 1955 | }); |
| 1956 | + | |
| 1957 | + // var code = (typeof GBCodePlayBack.htmleditor !=='undefined' && GBCodePlayBack.htmleditor.getValue()) | |
| 1958 | + // || (typeof GBCodePlayBack.htmlplayereditor !=='undefined' && GBCodePlayBack.htmlplayereditor.getValue()); | |
| 1959 | + // var langid = $('#htmlbutton').data("languageid"); | |
| 1960 | + // var runtimeArgus = $('#runtimeArgus').val() || ''; | |
| 1961 | + // var compileData = { | |
| 1962 | + // code: code, | |
| 1963 | + // langid: langid, | |
| 1964 | + // input: runtimeArgus | |
| 1965 | + // } | |
| 1966 | + // $.ajax({ | |
| 1967 | + // type: "post", | |
| 1968 | + // url: gxb_api + "/submit/submitCode/api", | |
| 1969 | + // data: JSON.stringify(compileData), | |
| 1970 | + // dataType: "json", | |
| 1971 | + // contentType: "application/json", | |
| 1972 | + // success: function(data) { | |
| 1973 | + // compileResult(data) | |
| 1974 | + // ladda.remove(); | |
| 1975 | + | |
| 1976 | + // $('.compile-loading').hide(); | |
| 1977 | + // $('.compile-reslut').show(); | |
| 1978 | + // GBCodePlayBack.compileResultData = data; | |
| 1979 | + // }, | |
| 1980 | + // error: function(){ | |
| 1981 | + // ladda.remove(); | |
| 1982 | + // alert('错误'); | |
| 1983 | + // } | |
| 1984 | + // }); | |
| 2075 | 1985 | } |
| 2076 | 1986 | |
| 2077 | 1987 | // 初始化页面 |
| ... | ... | @@ -2196,13 +2106,14 @@ $(function() { |
| 2196 | 2106 | for (var i = 0; i < treeLinkEditor.length; i++) { |
| 2197 | 2107 | |
| 2198 | 2108 | treeLinkEditor[i].CodeMirrorRecord = CodeMirror.fromTextArea($('#' + treeLinkEditor[i].record)[0], { |
| 2199 | - value: '输入HTML代码', | |
| 2109 | + value: '', | |
| 2200 | 2110 | mode: "text/x-java", |
| 2201 | 2111 | lineNumbers: true, |
| 2202 | 2112 | smartIndent: false, |
| 2203 | 2113 | onChange: function(em, changeobj) { |
| 2204 | 2114 | console.log('onChange'); |
| 2205 | - console.log(em, changeobj); | |
| 2115 | + console.log(em); | |
| 2116 | + console.log(changeobj); | |
| 2206 | 2117 | |
| 2207 | 2118 | if (GBCodePlayBack.recording_status) { |
| 2208 | 2119 | GBCodePlayBack.onChange(ZTREE.getCurrentEditor(em.getWrapperElement().getAttribute('id')), changeobj); |
| ... | ... | @@ -2221,7 +2132,7 @@ $(function() { |
| 2221 | 2132 | } |
| 2222 | 2133 | }); |
| 2223 | 2134 | treeLinkEditor[i].CodeMirrorReplay = CodeMirror.fromTextArea($('#' + treeLinkEditor[i].replay)[0], { |
| 2224 | - value: '输入HTML代码', | |
| 2135 | + value: '', | |
| 2225 | 2136 | mode: "text/x-java", |
| 2226 | 2137 | lineNumbers: true, |
| 2227 | 2138 | smartIndent: false, |
| ... | ... | @@ -2279,10 +2190,10 @@ $(function() { |
| 2279 | 2190 | // 判断是否需要有服务端编译 |
| 2280 | 2191 | function compileMode(langid) { |
| 2281 | 2192 | if (langid == 0 || langid == 35) { |
| 2282 | - // $('#comprunbtngrp').html('<button id="runnow" type="button" data-style="expand-right" class="btn" title="运行代码"> 运行</button>'); | |
| 2193 | + // $('#compileBtnGroup').html('<button id="runnow" type="button" data-style="expand-right" class="btn" title="运行代码"> 运行</button>'); | |
| 2283 | 2194 | } else { |
| 2284 | 2195 | $('#fontendrun').addClass('hidden'); |
| 2285 | - $('#comprunbtngrp').html('<button id="comprun" data-toggle="tooltip" data-placement="bottom" type="button" data-run="1" data-style="expand-right" class="btn comprun" title="编译并运行代码"> 编译&运行</button>'); | |
| 2196 | + $('#compileBtnGroup').html('<button id="CompileBtn" data-toggle="tooltip" data-placement="bottom" type="button" data-run="1" data-style="expand-right" class="btn" data-style="expand-right" title="编译并运行代码"> 编译&运行</button>'); | |
| 2286 | 2197 | |
| 2287 | 2198 | $('#ifrcontainer').addClass('hidden'); |
| 2288 | 2199 | $('#cmprun-output').removeClass('hidden'); |
| ... | ... | @@ -2487,7 +2398,7 @@ $(function() { |
| 2487 | 2398 | |
| 2488 | 2399 | // 缓存languageid title |
| 2489 | 2400 | function setHtmlButton(languageid, title) { |
| 2490 | - $('#htmlbutton').data('languageid', languageid).attr('data-original-title', title).html(title).trigger('click'); | |
| 2401 | + $('#htmlbutton').data('languageid', languageid).attr('data-original-title', '当前课程环境:' + title).html(title).trigger('click'); | |
| 2491 | 2402 | } |
| 2492 | 2403 | |
| 2493 | 2404 | function contrlPause() { | ... | ... |