Commit d9fdc86498b548bd45ab8345e5ae7dc04b2b33de
1 parent
cd7df55f
add test
Showing
11 changed files
with
516 additions
and
39 deletions
dist/gxb-ide/CodingEditer.js
| @@ -432,7 +432,7 @@ | @@ -432,7 +432,7 @@ | ||
| 432 | record.playTime = new Date().getTime(); // 播放开始时间 | 432 | record.playTime = new Date().getTime(); // 播放开始时间 |
| 433 | 433 | ||
| 434 | if (record.code == 0 || record.code == 1) { | 434 | if (record.code == 0 || record.code == 1) { |
| 435 | - var iterm = new Iterm(); | 435 | + // var iterm = new Iterm(); |
| 436 | var resultData = { | 436 | var resultData = { |
| 437 | status: record.status || 200, | 437 | status: record.status || 200, |
| 438 | compilerInfo: record.compilerInfo || '', | 438 | compilerInfo: record.compilerInfo || '', |
| @@ -440,10 +440,10 @@ | @@ -440,10 +440,10 @@ | ||
| 440 | error: record.error || '', | 440 | error: record.error || '', |
| 441 | code: record.code || '' | 441 | code: record.code || '' |
| 442 | }; | 442 | }; |
| 443 | - iterm.compileResult(resultData, record.runtimeArgus) | 443 | + Iterm.compileResult(resultData, record.runtimeArgus) |
| 444 | }else if (record.runtimeArgus){ | 444 | }else if (record.runtimeArgus){ |
| 445 | - var iterm = new Iterm(); | ||
| 446 | - iterm.compileResult(resultData, record.runtimeArgus) | 445 | + // var iterm = new Iterm(); |
| 446 | + Iterm.compileResult(resultData, record.runtimeArgus) | ||
| 447 | } | 447 | } |
| 448 | 448 | ||
| 449 | 449 |
dist/gxb-ide/Dir.js
| @@ -145,10 +145,9 @@ | @@ -145,10 +145,9 @@ | ||
| 145 | console.log('////---------------------------') | 145 | console.log('////---------------------------') |
| 146 | console.log(treeLinkEditor); | 146 | console.log(treeLinkEditor); |
| 147 | for (var i = 0; i < treeLinkEditor.length; i++) { | 147 | for (var i = 0; i < treeLinkEditor.length; i++) { |
| 148 | - $('.fileName').html(treeLinkEditor[i].filePath) | ||
| 149 | if(treeLinkEditor[i].name == _this.manageName(obj.treeNode.name)){ | 148 | if(treeLinkEditor[i].name == _this.manageName(obj.treeNode.name)){ |
| 150 | console.log(_this.manageName(obj.treeNode.name)); | 149 | console.log(_this.manageName(obj.treeNode.name)); |
| 151 | - | 150 | + $('.fileName').html(treeLinkEditor[i].filePath) |
| 152 | _num = i; | 151 | _num = i; |
| 153 | } | 152 | } |
| 154 | } | 153 | } |
dist/gxb-ide/Iterm.js
| 1 | ;(function(window){ | 1 | ;(function(window){ |
| 2 | - var _Iterm = window.Iterm; | ||
| 3 | - | ||
| 4 | - Iterm = function(){ | ||
| 5 | - this.initIterm.apply(this, arguments); | ||
| 6 | - } | ||
| 7 | - | ||
| 8 | var isCompile = false; | 2 | var isCompile = false; |
| 9 | var _languageid = getQuery('languageid'); | 3 | var _languageid = getQuery('languageid'); |
| 10 | var _userId = getQuery('userId'); | 4 | var _userId = getQuery('userId'); |
| 11 | 5 | ||
| 12 | - Iterm.prototype = { | 6 | + var Iterm = { |
| 13 | constructor: Iterm, | 7 | constructor: Iterm, |
| 14 | compileStatus: true, | 8 | compileStatus: true, |
| 15 | options: { | 9 | options: { |
| @@ -17,10 +11,8 @@ | @@ -17,10 +11,8 @@ | ||
| 17 | languageId: _languageid, | 11 | languageId: _languageid, |
| 18 | compileCallback: null // 编译回调 | 12 | compileCallback: null // 编译回调 |
| 19 | }, | 13 | }, |
| 20 | - initIterm: function(options){ | 14 | + init: function(options){ |
| 21 | var _this = this; | 15 | var _this = this; |
| 22 | - // _this.options = $.extend(this.options, options); | ||
| 23 | - _this.options = Object.assign(this.options, options); | ||
| 24 | _this.events(); | 16 | _this.events(); |
| 25 | }, | 17 | }, |
| 26 | events: function(){ | 18 | events: function(){ |
| @@ -120,6 +112,8 @@ | @@ -120,6 +112,8 @@ | ||
| 120 | } | 112 | } |
| 121 | } | 113 | } |
| 122 | 114 | ||
| 115 | + Iterm.init(); | ||
| 116 | + | ||
| 123 | // 继续录制配置 | 117 | // 继续录制配置 |
| 124 | function recodingConf(){ | 118 | function recodingConf(){ |
| 125 | $('.pause-shodow').hide() | 119 | $('.pause-shodow').hide() |
dist/gxb-ide/Iterm111.js
0 → 100644
| 1 | +;(function(window){ | ||
| 2 | + var _Iterm = window.Iterm; | ||
| 3 | + | ||
| 4 | + Iterm = function(){ | ||
| 5 | + this.initIterm.apply(this, arguments); | ||
| 6 | + } | ||
| 7 | + | ||
| 8 | + var isCompile = false; | ||
| 9 | + var _languageid = getQuery('languageid'); | ||
| 10 | + var _userId = getQuery('userId'); | ||
| 11 | + | ||
| 12 | + Iterm.prototype = { | ||
| 13 | + constructor: Iterm, | ||
| 14 | + compileStatus: true, | ||
| 15 | + options: { | ||
| 16 | + userId: _userId, | ||
| 17 | + languageId: _languageid, | ||
| 18 | + compileCallback: null // 编译回调 | ||
| 19 | + }, | ||
| 20 | + initIterm: function(options){ | ||
| 21 | + var _this = this; | ||
| 22 | + // _this.options = $.extend(this.options, options); | ||
| 23 | + _this.options = Object.assign(this.options, options); | ||
| 24 | + _this.events(); | ||
| 25 | + }, | ||
| 26 | + events: function(){ | ||
| 27 | + var _this = this; | ||
| 28 | + $('#CompileBtn').unbind('click').on('click', function(){ _this.compile(); }) | ||
| 29 | + $('#save_compile').on('click', function(){ _this.saveCompile(); }) | ||
| 30 | + $('#cancel_compile').on('click', function(){ _this.cancelCompile(); }) | ||
| 31 | + $('#full-screen').on('click', function(){ _this.fullScreen(); }) | ||
| 32 | + $('#back-screen').on('click', function(){ _this.exitFullscreen(); }) | ||
| 33 | + $(document).on('focus', '#runtimeArgus', function(){ }) | ||
| 34 | + }, | ||
| 35 | + compile: function(){ | ||
| 36 | + var _this = this; | ||
| 37 | + var el = document.querySelector('#CompileBtn'); | ||
| 38 | + var userId = _this.options.userId; | ||
| 39 | + // var languageId = _this.options.languageId; | ||
| 40 | + var languageId = _this.options.languageId || Dir.languageid; | ||
| 41 | + var role = getQuery('role'); | ||
| 42 | + // alert("HHHHHHH") | ||
| 43 | + | ||
| 44 | + | ||
| 45 | + // 判断是否录制走不同的逻辑 | ||
| 46 | + if (!CodingEditer.isRcording) { | ||
| 47 | + compileMode(el, userId, languageId) | ||
| 48 | + }else{ | ||
| 49 | + | ||
| 50 | + if (_this.compileStatus && !_this.isCompile) { | ||
| 51 | + $('#CompileBtn').removeClass('compile-btn').addClass('static-btn'); | ||
| 52 | + Hourglass.pauseTimer(); // 暂停计时器 | ||
| 53 | + if (role == 0) { | ||
| 54 | + recorder.pause(); // 音频暂停 | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + $('.compile-loading').show(); | ||
| 58 | + $('.pause-shodow').show() | ||
| 59 | + | ||
| 60 | + // 编译时插入操作 | ||
| 61 | + var treeNode = null; | ||
| 62 | + var check_tree_time = new Date().getTime(); | ||
| 63 | + CodingEditer.addRecord(treeNode, check_tree_time); | ||
| 64 | + | ||
| 65 | + _this.compileStatus = false; | ||
| 66 | + isCompile = true; | ||
| 67 | + | ||
| 68 | + compileMode(el, userId, languageId) | ||
| 69 | + $('.contrl-shodow').show(); | ||
| 70 | + } | ||
| 71 | + console.log('******************************' + languageId) | ||
| 72 | + | ||
| 73 | + } | ||
| 74 | + }, | ||
| 75 | + compileResult: function(data, value){ | ||
| 76 | + if (!data) { | ||
| 77 | + var data = { | ||
| 78 | + status: 200, | ||
| 79 | + compilerInfo: '', | ||
| 80 | + content: '', | ||
| 81 | + error: '', | ||
| 82 | + code: '' | ||
| 83 | + }; | ||
| 84 | + console.log('------------- compileResult --------------') | ||
| 85 | + } | ||
| 86 | + | ||
| 87 | + compileResult(data, value) | ||
| 88 | + }, | ||
| 89 | + saveCompile: function(){ | ||
| 90 | + console.log(this.compileStatus) | ||
| 91 | + this.compileStatus = true; | ||
| 92 | + console.log(this.compileStatus) | ||
| 93 | + | ||
| 94 | + recodingConf() | ||
| 95 | + | ||
| 96 | + var length = CodingEditer.records.length - 1; | ||
| 97 | + | ||
| 98 | + CodingEditer.records[length].compile = CodingEditer.compileResultData; | ||
| 99 | + | ||
| 100 | + CodingEditer.records[length].content = CodingEditer.compileResultData.content; | ||
| 101 | + CodingEditer.records[length].error = CodingEditer.compileResultData.error; | ||
| 102 | + CodingEditer.records[length].compilerInfo = CodingEditer.compileResultData.compilerInfo; | ||
| 103 | + CodingEditer.records[length].code = CodingEditer.compileResultData.code; | ||
| 104 | + }, | ||
| 105 | + cancelCompile: function(){ | ||
| 106 | + console.log(this.compileStatus) | ||
| 107 | + this.compileStatus = true; | ||
| 108 | + console.log(this.compileStatus) | ||
| 109 | + recodingConf() | ||
| 110 | + }, | ||
| 111 | + fullScreen: function(){ | ||
| 112 | + launchFullScreen(document.body); | ||
| 113 | + $('#back-screen').show(); | ||
| 114 | + $('#full-screen').hide(); | ||
| 115 | + }, | ||
| 116 | + exitFullscreen: function(){ | ||
| 117 | + exitFullscreen(); | ||
| 118 | + $('#full-screen').show(); | ||
| 119 | + $('#back-screen').hide(); | ||
| 120 | + } | ||
| 121 | + } | ||
| 122 | + | ||
| 123 | + // 继续录制配置 | ||
| 124 | + function recodingConf(){ | ||
| 125 | + $('.pause-shodow').hide() | ||
| 126 | + $('.compile-reslut').hide(); | ||
| 127 | + $('.contrl-shodow').hide(); | ||
| 128 | + $('.contrl-shodow').hide(); | ||
| 129 | + | ||
| 130 | + Hourglass.pauseTimer(); | ||
| 131 | + | ||
| 132 | + var role = getQuery('role'); | ||
| 133 | + if (role == 0) { | ||
| 134 | + recorder.pause(); | ||
| 135 | + } | ||
| 136 | + CodingEditer.record_startime = new Date().getTime(); | ||
| 137 | + | ||
| 138 | + $('#CompileBtn').addClass('compile-btn').removeClass('static-btn'); | ||
| 139 | + isCompile = false; | ||
| 140 | + } | ||
| 141 | + | ||
| 142 | + // 编译 | ||
| 143 | + function compileMode(el, userId, languageId){ | ||
| 144 | + var l = Ladda.create(el); | ||
| 145 | + l.start(); | ||
| 146 | + // 获取标准输入值 | ||
| 147 | + var runtimeArgus = $('#runtimeArgus').val() || ''; | ||
| 148 | + var mainPath = Dir.mainPath; | ||
| 149 | + var _fileList = Dir.getTreeData(); | ||
| 150 | + | ||
| 151 | + var compileData = { | ||
| 152 | + "userId": userId, | ||
| 153 | + "langId": languageId, | ||
| 154 | + "mainPath": mainPath, | ||
| 155 | + "mainArgus": "", | ||
| 156 | + "runtimeArgus": runtimeArgus, | ||
| 157 | + "rand": "123456", | ||
| 158 | + "fileList": _fileList || [] | ||
| 159 | + } | ||
| 160 | + console.log(compileData); | ||
| 161 | + $.ajax({ | ||
| 162 | + type: "POST", | ||
| 163 | + url: gxb_api + "/gxb-web/programmingMulti/codeRun/api", | ||
| 164 | + data: JSON.stringify(compileData), | ||
| 165 | + dataType: "json", | ||
| 166 | + contentType: "application/json", | ||
| 167 | + success: function(data) { | ||
| 168 | + console.log(data); | ||
| 169 | + | ||
| 170 | + $('.compile-loading').hide(); | ||
| 171 | + $('.compile-reslut').show(); | ||
| 172 | + | ||
| 173 | + compileResult(data) | ||
| 174 | + l.remove(); | ||
| 175 | + CodingEditer.compileResultData = data; | ||
| 176 | + }, | ||
| 177 | + error: function(XMLHttpRequest, textStatus, errorThrown) { | ||
| 178 | + l.remove(); | ||
| 179 | + alert('错误'); | ||
| 180 | + console.log(XMLHttpRequest); | ||
| 181 | + }, | ||
| 182 | + }); | ||
| 183 | + } | ||
| 184 | + | ||
| 185 | + // 编译结果 | ||
| 186 | + function compileResult(data, value) { | ||
| 187 | + var runtimeArgus = value || ''; | ||
| 188 | + console.info('compileResult') | ||
| 189 | + if (value != '') { | ||
| 190 | + $('#cmprun-tabs a[href="#stdin"]').tab('show'); | ||
| 191 | + $('#stdin input').val(runtimeArgus); | ||
| 192 | + }else{ | ||
| 193 | + return; | ||
| 194 | + } | ||
| 195 | + | ||
| 196 | + if (data.status == 200) { | ||
| 197 | + | ||
| 198 | + $('#cmpinfo').html('<p class="text-warning">' + data.compilerInfo.replace(/\n/g, "<br />") + "</p>"); | ||
| 199 | + $('#stderr').html('<p class="text-danger">' + data.error.replace(/\n/g, "<br />") + "</p>"); | ||
| 200 | + $('#output').html('<p class="text-success">' + data.content.replace(/\n/g, "<br />") + "</p>"); | ||
| 201 | + | ||
| 202 | + if(data.compilerInfo.length){ | ||
| 203 | + $('#cmprun-tabs a[href="#cmpinfo"]').tab('show'); | ||
| 204 | + }else if(data.error.length){ | ||
| 205 | + $('#cmprun-tabs a[href="#stderr"]').tab('show'); | ||
| 206 | + }else if(data.content.length){ | ||
| 207 | + $('#cmprun-tabs a[href="#output"]').tab('show'); | ||
| 208 | + } | ||
| 209 | + | ||
| 210 | + if(!data.compilerInfo.length){ | ||
| 211 | + $('#cmpinfo').prepend('<p class="alert alert-success"><i class="glyphicon glyphicon-ok-sign"></i> 编译已成功</p>'); | ||
| 212 | + } | ||
| 213 | + }else if(data.status == 500){ | ||
| 214 | + $('#cmprun-tabs a[href="#stderr"]').tab('show'); | ||
| 215 | + $('#stderr').html('<p class="text-danger">' + data.error.replace(/\n/g, "<br />") + "</p>"); | ||
| 216 | + }else{ | ||
| 217 | + $('#cmpinfo').html('<p class="alert alert-danger"><i class="glyphicon glyphicon-exclamation-sign"></i> 请求失败 </p>'); | ||
| 218 | + $('#cmprun-tabs a[href="#cmpinfo"]').tab('show'); | ||
| 219 | + } | ||
| 220 | + } | ||
| 221 | + | ||
| 222 | + // 找到支持的方法, 使用需要全屏的 element 调用 | ||
| 223 | + function launchFullScreen(element) { | ||
| 224 | + if (element.requestFullscreen) { | ||
| 225 | + element.requestFullscreen(); | ||
| 226 | + } else if (element.mozRequestFullScreen) { | ||
| 227 | + element.mozRequestFullScreen(); | ||
| 228 | + } else if (element.webkitRequestFullscreen) { | ||
| 229 | + element.webkitRequestFullscreen(); | ||
| 230 | + } else if (element.msRequestFullscreen) { | ||
| 231 | + element.msRequestFullscreen(); | ||
| 232 | + } | ||
| 233 | + } | ||
| 234 | + function exitFullscreen() { | ||
| 235 | + if (document.exitFullscreen) { | ||
| 236 | + document.exitFullscreen(); | ||
| 237 | + } else if (document.mozExitFullScreen) { | ||
| 238 | + document.mozExitFullScreen(); | ||
| 239 | + } else if (document.webkitExitFullscreen) { | ||
| 240 | + document.webkitExitFullscreen(); | ||
| 241 | + } | ||
| 242 | + } | ||
| 243 | + | ||
| 244 | + window.Iterm = Iterm | ||
| 245 | +})(window) | ||
| 0 | \ No newline at end of file | 246 | \ No newline at end of file |
dist/js/player.js
| @@ -19,7 +19,7 @@ $(function(){ | @@ -19,7 +19,7 @@ $(function(){ | ||
| 19 | // languageId: _languageid | 19 | // languageId: _languageid |
| 20 | // }); | 20 | // }); |
| 21 | 21 | ||
| 22 | - // alert('==============') | 22 | + // alert('============== iterm') |
| 23 | 23 | ||
| 24 | var title = decodeURIComponent(getQuery('title')); | 24 | var title = decodeURIComponent(getQuery('title')); |
| 25 | 25 |
dist/v1.1/player.html
| @@ -60,7 +60,7 @@ | @@ -60,7 +60,7 @@ | ||
| 60 | </div> | 60 | </div> |
| 61 | <div class="m-title-wrap"> | 61 | <div class="m-title-wrap"> |
| 62 | <div class="m-title"></div> | 62 | <div class="m-title"></div> |
| 63 | - <div class="m-menu"><span class="fileName"></span> <img src="../img/down.png" alt=""></div> | 63 | + <div class="m-menu"><span class="fileName">package1/default1.py</span> <img src="../img/down.png" alt=""></div> |
| 64 | </div> | 64 | </div> |
| 65 | <!-- 录制区 --> | 65 | <!-- 录制区 --> |
| 66 | <div class="record-wrap"> | 66 | <div class="record-wrap"> |
| @@ -200,8 +200,8 @@ | @@ -200,8 +200,8 @@ | ||
| 200 | 200 | ||
| 201 | <script src="../js/recorder/Myna.js"></script> | 201 | <script src="../js/recorder/Myna.js"></script> |
| 202 | <script src="../gxb-ide/Dir.js?v=0.0.6"></script> | 202 | <script src="../gxb-ide/Dir.js?v=0.0.6"></script> |
| 203 | - <script src="../gxb-ide/CodingEditer.js"></script> | ||
| 204 | <script src="../gxb-ide/Iterm.js"></script> | 203 | <script src="../gxb-ide/Iterm.js"></script> |
| 204 | + <script src="../gxb-ide/CodingEditer.js"></script> | ||
| 205 | <script src="../gxb-ide/Ide.js"></script> | 205 | <script src="../gxb-ide/Ide.js"></script> |
| 206 | <script src="../gxb-ide/ToolBox.js"></script> | 206 | <script src="../gxb-ide/ToolBox.js"></script> |
| 207 | 207 |
src/gxb-ide/CodingEditer.js
| @@ -432,7 +432,7 @@ | @@ -432,7 +432,7 @@ | ||
| 432 | record.playTime = new Date().getTime(); // 播放开始时间 | 432 | record.playTime = new Date().getTime(); // 播放开始时间 |
| 433 | 433 | ||
| 434 | if (record.code == 0 || record.code == 1) { | 434 | if (record.code == 0 || record.code == 1) { |
| 435 | - var iterm = new Iterm(); | 435 | + // var iterm = new Iterm(); |
| 436 | var resultData = { | 436 | var resultData = { |
| 437 | status: record.status || 200, | 437 | status: record.status || 200, |
| 438 | compilerInfo: record.compilerInfo || '', | 438 | compilerInfo: record.compilerInfo || '', |
| @@ -440,10 +440,10 @@ | @@ -440,10 +440,10 @@ | ||
| 440 | error: record.error || '', | 440 | error: record.error || '', |
| 441 | code: record.code || '' | 441 | code: record.code || '' |
| 442 | }; | 442 | }; |
| 443 | - iterm.compileResult(resultData, record.runtimeArgus) | 443 | + Iterm.compileResult(resultData, record.runtimeArgus) |
| 444 | }else if (record.runtimeArgus){ | 444 | }else if (record.runtimeArgus){ |
| 445 | - var iterm = new Iterm(); | ||
| 446 | - iterm.compileResult(resultData, record.runtimeArgus) | 445 | + // var iterm = new Iterm(); |
| 446 | + Iterm.compileResult(resultData, record.runtimeArgus) | ||
| 447 | } | 447 | } |
| 448 | 448 | ||
| 449 | 449 |
src/gxb-ide/Iterm.js
| 1 | ;(function(window){ | 1 | ;(function(window){ |
| 2 | - var _Iterm = window.Iterm; | ||
| 3 | - | ||
| 4 | - Iterm = function(){ | ||
| 5 | - this.initIterm.apply(this, arguments); | ||
| 6 | - } | ||
| 7 | - | ||
| 8 | var isCompile = false; | 2 | var isCompile = false; |
| 9 | var _languageid = getQuery('languageid'); | 3 | var _languageid = getQuery('languageid'); |
| 10 | var _userId = getQuery('userId'); | 4 | var _userId = getQuery('userId'); |
| 11 | 5 | ||
| 12 | - Iterm.prototype = { | 6 | + var Iterm = { |
| 13 | constructor: Iterm, | 7 | constructor: Iterm, |
| 14 | compileStatus: true, | 8 | compileStatus: true, |
| 15 | options: { | 9 | options: { |
| @@ -17,10 +11,8 @@ | @@ -17,10 +11,8 @@ | ||
| 17 | languageId: _languageid, | 11 | languageId: _languageid, |
| 18 | compileCallback: null // 编译回调 | 12 | compileCallback: null // 编译回调 |
| 19 | }, | 13 | }, |
| 20 | - initIterm: function(options){ | 14 | + init: function(options){ |
| 21 | var _this = this; | 15 | var _this = this; |
| 22 | - // _this.options = $.extend(this.options, options); | ||
| 23 | - _this.options = Object.assign(this.options, options); | ||
| 24 | _this.events(); | 16 | _this.events(); |
| 25 | }, | 17 | }, |
| 26 | events: function(){ | 18 | events: function(){ |
| @@ -120,6 +112,8 @@ | @@ -120,6 +112,8 @@ | ||
| 120 | } | 112 | } |
| 121 | } | 113 | } |
| 122 | 114 | ||
| 115 | + Iterm.init(); | ||
| 116 | + | ||
| 123 | // 继续录制配置 | 117 | // 继续录制配置 |
| 124 | function recodingConf(){ | 118 | function recodingConf(){ |
| 125 | $('.pause-shodow').hide() | 119 | $('.pause-shodow').hide() |
src/gxb-ide/Iterm111.js
0 → 100644
| 1 | +;(function(window){ | ||
| 2 | + var _Iterm = window.Iterm; | ||
| 3 | + | ||
| 4 | + Iterm = function(){ | ||
| 5 | + this.initIterm.apply(this, arguments); | ||
| 6 | + } | ||
| 7 | + | ||
| 8 | + var isCompile = false; | ||
| 9 | + var _languageid = getQuery('languageid'); | ||
| 10 | + var _userId = getQuery('userId'); | ||
| 11 | + | ||
| 12 | + Iterm.prototype = { | ||
| 13 | + constructor: Iterm, | ||
| 14 | + compileStatus: true, | ||
| 15 | + options: { | ||
| 16 | + userId: _userId, | ||
| 17 | + languageId: _languageid, | ||
| 18 | + compileCallback: null // 编译回调 | ||
| 19 | + }, | ||
| 20 | + initIterm: function(options){ | ||
| 21 | + var _this = this; | ||
| 22 | + // _this.options = $.extend(this.options, options); | ||
| 23 | + _this.options = Object.assign(this.options, options); | ||
| 24 | + _this.events(); | ||
| 25 | + }, | ||
| 26 | + events: function(){ | ||
| 27 | + var _this = this; | ||
| 28 | + $('#CompileBtn').unbind('click').on('click', function(){ _this.compile(); }) | ||
| 29 | + $('#save_compile').on('click', function(){ _this.saveCompile(); }) | ||
| 30 | + $('#cancel_compile').on('click', function(){ _this.cancelCompile(); }) | ||
| 31 | + $('#full-screen').on('click', function(){ _this.fullScreen(); }) | ||
| 32 | + $('#back-screen').on('click', function(){ _this.exitFullscreen(); }) | ||
| 33 | + $(document).on('focus', '#runtimeArgus', function(){ }) | ||
| 34 | + }, | ||
| 35 | + compile: function(){ | ||
| 36 | + var _this = this; | ||
| 37 | + var el = document.querySelector('#CompileBtn'); | ||
| 38 | + var userId = _this.options.userId; | ||
| 39 | + // var languageId = _this.options.languageId; | ||
| 40 | + var languageId = _this.options.languageId || Dir.languageid; | ||
| 41 | + var role = getQuery('role'); | ||
| 42 | + // alert("HHHHHHH") | ||
| 43 | + | ||
| 44 | + | ||
| 45 | + // 判断是否录制走不同的逻辑 | ||
| 46 | + if (!CodingEditer.isRcording) { | ||
| 47 | + compileMode(el, userId, languageId) | ||
| 48 | + }else{ | ||
| 49 | + | ||
| 50 | + if (_this.compileStatus && !_this.isCompile) { | ||
| 51 | + $('#CompileBtn').removeClass('compile-btn').addClass('static-btn'); | ||
| 52 | + Hourglass.pauseTimer(); // 暂停计时器 | ||
| 53 | + if (role == 0) { | ||
| 54 | + recorder.pause(); // 音频暂停 | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + $('.compile-loading').show(); | ||
| 58 | + $('.pause-shodow').show() | ||
| 59 | + | ||
| 60 | + // 编译时插入操作 | ||
| 61 | + var treeNode = null; | ||
| 62 | + var check_tree_time = new Date().getTime(); | ||
| 63 | + CodingEditer.addRecord(treeNode, check_tree_time); | ||
| 64 | + | ||
| 65 | + _this.compileStatus = false; | ||
| 66 | + isCompile = true; | ||
| 67 | + | ||
| 68 | + compileMode(el, userId, languageId) | ||
| 69 | + $('.contrl-shodow').show(); | ||
| 70 | + } | ||
| 71 | + console.log('******************************' + languageId) | ||
| 72 | + | ||
| 73 | + } | ||
| 74 | + }, | ||
| 75 | + compileResult: function(data, value){ | ||
| 76 | + if (!data) { | ||
| 77 | + var data = { | ||
| 78 | + status: 200, | ||
| 79 | + compilerInfo: '', | ||
| 80 | + content: '', | ||
| 81 | + error: '', | ||
| 82 | + code: '' | ||
| 83 | + }; | ||
| 84 | + console.log('------------- compileResult --------------') | ||
| 85 | + } | ||
| 86 | + | ||
| 87 | + compileResult(data, value) | ||
| 88 | + }, | ||
| 89 | + saveCompile: function(){ | ||
| 90 | + console.log(this.compileStatus) | ||
| 91 | + this.compileStatus = true; | ||
| 92 | + console.log(this.compileStatus) | ||
| 93 | + | ||
| 94 | + recodingConf() | ||
| 95 | + | ||
| 96 | + var length = CodingEditer.records.length - 1; | ||
| 97 | + | ||
| 98 | + CodingEditer.records[length].compile = CodingEditer.compileResultData; | ||
| 99 | + | ||
| 100 | + CodingEditer.records[length].content = CodingEditer.compileResultData.content; | ||
| 101 | + CodingEditer.records[length].error = CodingEditer.compileResultData.error; | ||
| 102 | + CodingEditer.records[length].compilerInfo = CodingEditer.compileResultData.compilerInfo; | ||
| 103 | + CodingEditer.records[length].code = CodingEditer.compileResultData.code; | ||
| 104 | + }, | ||
| 105 | + cancelCompile: function(){ | ||
| 106 | + console.log(this.compileStatus) | ||
| 107 | + this.compileStatus = true; | ||
| 108 | + console.log(this.compileStatus) | ||
| 109 | + recodingConf() | ||
| 110 | + }, | ||
| 111 | + fullScreen: function(){ | ||
| 112 | + launchFullScreen(document.body); | ||
| 113 | + $('#back-screen').show(); | ||
| 114 | + $('#full-screen').hide(); | ||
| 115 | + }, | ||
| 116 | + exitFullscreen: function(){ | ||
| 117 | + exitFullscreen(); | ||
| 118 | + $('#full-screen').show(); | ||
| 119 | + $('#back-screen').hide(); | ||
| 120 | + } | ||
| 121 | + } | ||
| 122 | + | ||
| 123 | + // 继续录制配置 | ||
| 124 | + function recodingConf(){ | ||
| 125 | + $('.pause-shodow').hide() | ||
| 126 | + $('.compile-reslut').hide(); | ||
| 127 | + $('.contrl-shodow').hide(); | ||
| 128 | + $('.contrl-shodow').hide(); | ||
| 129 | + | ||
| 130 | + Hourglass.pauseTimer(); | ||
| 131 | + | ||
| 132 | + var role = getQuery('role'); | ||
| 133 | + if (role == 0) { | ||
| 134 | + recorder.pause(); | ||
| 135 | + } | ||
| 136 | + CodingEditer.record_startime = new Date().getTime(); | ||
| 137 | + | ||
| 138 | + $('#CompileBtn').addClass('compile-btn').removeClass('static-btn'); | ||
| 139 | + isCompile = false; | ||
| 140 | + } | ||
| 141 | + | ||
| 142 | + // 编译 | ||
| 143 | + function compileMode(el, userId, languageId){ | ||
| 144 | + var l = Ladda.create(el); | ||
| 145 | + l.start(); | ||
| 146 | + // 获取标准输入值 | ||
| 147 | + var runtimeArgus = $('#runtimeArgus').val() || ''; | ||
| 148 | + var mainPath = Dir.mainPath; | ||
| 149 | + var _fileList = Dir.getTreeData(); | ||
| 150 | + | ||
| 151 | + var compileData = { | ||
| 152 | + "userId": userId, | ||
| 153 | + "langId": languageId, | ||
| 154 | + "mainPath": mainPath, | ||
| 155 | + "mainArgus": "", | ||
| 156 | + "runtimeArgus": runtimeArgus, | ||
| 157 | + "rand": "123456", | ||
| 158 | + "fileList": _fileList || [] | ||
| 159 | + } | ||
| 160 | + console.log(compileData); | ||
| 161 | + $.ajax({ | ||
| 162 | + type: "POST", | ||
| 163 | + url: gxb_api + "/gxb-web/programmingMulti/codeRun/api", | ||
| 164 | + data: JSON.stringify(compileData), | ||
| 165 | + dataType: "json", | ||
| 166 | + contentType: "application/json", | ||
| 167 | + success: function(data) { | ||
| 168 | + console.log(data); | ||
| 169 | + | ||
| 170 | + $('.compile-loading').hide(); | ||
| 171 | + $('.compile-reslut').show(); | ||
| 172 | + | ||
| 173 | + compileResult(data) | ||
| 174 | + l.remove(); | ||
| 175 | + CodingEditer.compileResultData = data; | ||
| 176 | + }, | ||
| 177 | + error: function(XMLHttpRequest, textStatus, errorThrown) { | ||
| 178 | + l.remove(); | ||
| 179 | + alert('错误'); | ||
| 180 | + console.log(XMLHttpRequest); | ||
| 181 | + }, | ||
| 182 | + }); | ||
| 183 | + } | ||
| 184 | + | ||
| 185 | + // 编译结果 | ||
| 186 | + function compileResult(data, value) { | ||
| 187 | + var runtimeArgus = value || ''; | ||
| 188 | + console.info('compileResult') | ||
| 189 | + if (value != '') { | ||
| 190 | + $('#cmprun-tabs a[href="#stdin"]').tab('show'); | ||
| 191 | + $('#stdin input').val(runtimeArgus); | ||
| 192 | + }else{ | ||
| 193 | + return; | ||
| 194 | + } | ||
| 195 | + | ||
| 196 | + if (data.status == 200) { | ||
| 197 | + | ||
| 198 | + $('#cmpinfo').html('<p class="text-warning">' + data.compilerInfo.replace(/\n/g, "<br />") + "</p>"); | ||
| 199 | + $('#stderr').html('<p class="text-danger">' + data.error.replace(/\n/g, "<br />") + "</p>"); | ||
| 200 | + $('#output').html('<p class="text-success">' + data.content.replace(/\n/g, "<br />") + "</p>"); | ||
| 201 | + | ||
| 202 | + if(data.compilerInfo.length){ | ||
| 203 | + $('#cmprun-tabs a[href="#cmpinfo"]').tab('show'); | ||
| 204 | + }else if(data.error.length){ | ||
| 205 | + $('#cmprun-tabs a[href="#stderr"]').tab('show'); | ||
| 206 | + }else if(data.content.length){ | ||
| 207 | + $('#cmprun-tabs a[href="#output"]').tab('show'); | ||
| 208 | + } | ||
| 209 | + | ||
| 210 | + if(!data.compilerInfo.length){ | ||
| 211 | + $('#cmpinfo').prepend('<p class="alert alert-success"><i class="glyphicon glyphicon-ok-sign"></i> 编译已成功</p>'); | ||
| 212 | + } | ||
| 213 | + }else if(data.status == 500){ | ||
| 214 | + $('#cmprun-tabs a[href="#stderr"]').tab('show'); | ||
| 215 | + $('#stderr').html('<p class="text-danger">' + data.error.replace(/\n/g, "<br />") + "</p>"); | ||
| 216 | + }else{ | ||
| 217 | + $('#cmpinfo').html('<p class="alert alert-danger"><i class="glyphicon glyphicon-exclamation-sign"></i> 请求失败 </p>'); | ||
| 218 | + $('#cmprun-tabs a[href="#cmpinfo"]').tab('show'); | ||
| 219 | + } | ||
| 220 | + } | ||
| 221 | + | ||
| 222 | + // 找到支持的方法, 使用需要全屏的 element 调用 | ||
| 223 | + function launchFullScreen(element) { | ||
| 224 | + if (element.requestFullscreen) { | ||
| 225 | + element.requestFullscreen(); | ||
| 226 | + } else if (element.mozRequestFullScreen) { | ||
| 227 | + element.mozRequestFullScreen(); | ||
| 228 | + } else if (element.webkitRequestFullscreen) { | ||
| 229 | + element.webkitRequestFullscreen(); | ||
| 230 | + } else if (element.msRequestFullscreen) { | ||
| 231 | + element.msRequestFullscreen(); | ||
| 232 | + } | ||
| 233 | + } | ||
| 234 | + function exitFullscreen() { | ||
| 235 | + if (document.exitFullscreen) { | ||
| 236 | + document.exitFullscreen(); | ||
| 237 | + } else if (document.mozExitFullScreen) { | ||
| 238 | + document.mozExitFullScreen(); | ||
| 239 | + } else if (document.webkitExitFullscreen) { | ||
| 240 | + document.webkitExitFullscreen(); | ||
| 241 | + } | ||
| 242 | + } | ||
| 243 | + | ||
| 244 | + window.Iterm = Iterm | ||
| 245 | +})(window) | ||
| 0 | \ No newline at end of file | 246 | \ No newline at end of file |
src/js/player.js
| @@ -14,12 +14,12 @@ $(function(){ | @@ -14,12 +14,12 @@ $(function(){ | ||
| 14 | }); | 14 | }); |
| 15 | 15 | ||
| 16 | // 编译控制台 | 16 | // 编译控制台 |
| 17 | - var iterm = new Iterm({ | ||
| 18 | - userId: _userId, | ||
| 19 | - languageId: _languageid | ||
| 20 | - }); | 17 | + // var iterm = new Iterm({ |
| 18 | + // userId: _userId, | ||
| 19 | + // languageId: _languageid | ||
| 20 | + // }); | ||
| 21 | 21 | ||
| 22 | - alert('============== iterm') | 22 | + // alert('============== iterm') |
| 23 | 23 | ||
| 24 | var title = decodeURIComponent(getQuery('title')); | 24 | var title = decodeURIComponent(getQuery('title')); |
| 25 | 25 |
src/v1.1/player.html
| @@ -200,8 +200,8 @@ | @@ -200,8 +200,8 @@ | ||
| 200 | 200 | ||
| 201 | <script src="../js/recorder/Myna.js"></script> | 201 | <script src="../js/recorder/Myna.js"></script> |
| 202 | <script src="../gxb-ide/Dir.js?v=0.0.6"></script> | 202 | <script src="../gxb-ide/Dir.js?v=0.0.6"></script> |
| 203 | - <script src="../gxb-ide/CodingEditer.js"></script> | ||
| 204 | <script src="../gxb-ide/Iterm.js"></script> | 203 | <script src="../gxb-ide/Iterm.js"></script> |
| 204 | + <script src="../gxb-ide/CodingEditer.js"></script> | ||
| 205 | <script src="../gxb-ide/Ide.js"></script> | 205 | <script src="../gxb-ide/Ide.js"></script> |
| 206 | <script src="../gxb-ide/ToolBox.js"></script> | 206 | <script src="../gxb-ide/ToolBox.js"></script> |
| 207 | 207 |