Commit b108971a57792dc56ebdbd06e99aef8b523894a1
1 parent
1ddd2900
fix bug
Showing
8 changed files
with
110 additions
and
124 deletions
src/gxb-ide/CodingEditer.js
| ... | ... | @@ -13,6 +13,7 @@ |
| 13 | 13 | firstPlay: 1, // 第一次播放 |
| 14 | 14 | pauseValue: [], |
| 15 | 15 | isRecordPage: 1, |
| 16 | + flag: true, // 解决多次点击 | |
| 16 | 17 | init: function(){ |
| 17 | 18 | console.log('CodingEditer'); |
| 18 | 19 | }, |
| ... | ... | @@ -95,7 +96,7 @@ |
| 95 | 96 | */ |
| 96 | 97 | playCoding: function(){ |
| 97 | 98 | CodingEditer.editable(1); |
| 98 | - | |
| 99 | + CodingEditer.flag = false; | |
| 99 | 100 | if (CodingEditer.firstPlay == 0) { |
| 100 | 101 | CodingEditer.setCodeMirrorValue(); |
| 101 | 102 | Dir.showEdite({'treeNode': CodingEditer.treeSelectNode}); |
| ... | ... | @@ -360,7 +361,7 @@ |
| 360 | 361 | }; |
| 361 | 362 | |
| 362 | 363 | CodingEditer.records.push(recordobj); // 添加每次输入对象 |
| 363 | - | |
| 364 | + console.log(CodingEditer.records) | |
| 364 | 365 | CodingEditer.record_startime = currenttime; //设定起始时间 |
| 365 | 366 | } |
| 366 | 367 | |
| ... | ... | @@ -384,7 +385,7 @@ |
| 384 | 385 | record.playTime = new Date().getTime(); // 播放开始时间 |
| 385 | 386 | |
| 386 | 387 | console.log("==================++======================"); |
| 387 | - console.log(record); | |
| 388 | + console.log(record.runtimeArgus); | |
| 388 | 389 | |
| 389 | 390 | if (record.code == 0 || record.code == 1) { |
| 390 | 391 | var iterm = new Iterm(); |
| ... | ... | @@ -395,13 +396,20 @@ |
| 395 | 396 | error: record.error || '', |
| 396 | 397 | code: record.code || '' |
| 397 | 398 | }; |
| 398 | - iterm.compileResult(resultData) | |
| 399 | + iterm.compileResult(resultData, record.runtimeArgus) | |
| 400 | + }else if (record.runtimeArgus){ | |
| 401 | + var iterm = new Iterm(); | |
| 402 | + iterm.compileResult(resultData, record.runtimeArgus) | |
| 399 | 403 | } |
| 400 | 404 | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 401 | 408 | CodingEditer.triggertotal += 1; |
| 402 | 409 | |
| 403 | 410 | if (CodingEditer.triggertotal === CodingEditer.records.length && !replay_type) { |
| 404 | 411 | CodingEditer.editable(0); |
| 412 | + CodingEditer.flag = true | |
| 405 | 413 | if (CodingEditer.isRecordPage) { |
| 406 | 414 | $('#recordertab a:first').tab('show'); |
| 407 | 415 | } | ... | ... |
src/gxb-ide/Dir.js
| ... | ... | @@ -55,7 +55,7 @@ |
| 55 | 55 | }, |
| 56 | 56 | initIdePage: function(el, id, isPlayPage, role){ |
| 57 | 57 | var _url = "../data/" + id + ".json"; |
| 58 | - var _lang = getLangName(id); | |
| 58 | + var _lang = Dir.getLangName(id); | |
| 59 | 59 | |
| 60 | 60 | console.log('======================='); |
| 61 | 61 | console.log('isPlayPage ----- ' + isPlayPage); |
| ... | ... | @@ -69,6 +69,7 @@ |
| 69 | 69 | contentType: "application/json", |
| 70 | 70 | success: function(res) { |
| 71 | 71 | console.log(res); |
| 72 | + setTitle(res.languageid); | |
| 72 | 73 | Dir.treeData = res[_lang]; |
| 73 | 74 | Dir.treeObj = $.fn.zTree.init($(el), setting, Dir.treeData); |
| 74 | 75 | addTextareaPage(Dir.treeData); |
| ... | ... | @@ -293,10 +294,43 @@ |
| 293 | 294 | // $('.CodeMirror').height(recordHeight); |
| 294 | 295 | // $('.CodeMirror-lines').height(recordHeight); |
| 295 | 296 | // $('.CodeMirror-gutter').height(recordHeight); |
| 297 | + }, | |
| 298 | + getLangName: function(langid){ | |
| 299 | + var langid = parseInt(langid); | |
| 300 | + var _langName; | |
| 301 | + switch (langid) { | |
| 302 | + case 10: | |
| 303 | + _langName = "java"; | |
| 304 | + break; | |
| 305 | + case 35: | |
| 306 | + _langName = "html"; | |
| 307 | + break; | |
| 308 | + case 43: | |
| 309 | + _langName = "Objective-C"; | |
| 310 | + break; | |
| 311 | + case 11: | |
| 312 | + _langName = "C"; | |
| 313 | + break; | |
| 314 | + case 82: | |
| 315 | + _langName = "C++"; | |
| 316 | + break; | |
| 317 | + case 29: | |
| 318 | + _langName = "php"; | |
| 319 | + break; | |
| 320 | + case 4: | |
| 321 | + _langName = "python"; | |
| 322 | + break; | |
| 323 | + case 40: | |
| 324 | + _langName = "SQL"; | |
| 325 | + break; | |
| 326 | + case 117: | |
| 327 | + _langName = "R"; | |
| 328 | + break; | |
| 329 | + default: | |
| 330 | + break; | |
| 331 | + } | |
| 296 | 332 | |
| 297 | - | |
| 298 | - | |
| 299 | - | |
| 333 | + return _langName; | |
| 300 | 334 | } |
| 301 | 335 | } |
| 302 | 336 | |
| ... | ... | @@ -468,43 +502,7 @@ |
| 468 | 502 | |
| 469 | 503 | } |
| 470 | 504 | |
| 471 | - // 获取编程语言 | |
| 472 | - function getLangName(langid){ | |
| 473 | - var _langName; | |
| 474 | - switch (langid) { | |
| 475 | - case 10: | |
| 476 | - _langName = "java"; | |
| 477 | - break; | |
| 478 | - case 35: | |
| 479 | - _langName = "html"; | |
| 480 | - break; | |
| 481 | - case 43: | |
| 482 | - _langName = "Objective-C"; | |
| 483 | - break; | |
| 484 | - case 11: | |
| 485 | - _langName = "C"; | |
| 486 | - break; | |
| 487 | - case 82: | |
| 488 | - _langName = "C++"; | |
| 489 | - break; | |
| 490 | - case 29: | |
| 491 | - _langName = "php"; | |
| 492 | - break; | |
| 493 | - case 4: | |
| 494 | - _langName = "python"; | |
| 495 | - break; | |
| 496 | - case 40: | |
| 497 | - _langName = "SQL"; | |
| 498 | - break; | |
| 499 | - case 117: | |
| 500 | - _langName = "R"; | |
| 501 | - break; | |
| 502 | - default: | |
| 503 | - break; | |
| 504 | - } | |
| 505 | 505 | |
| 506 | - return _langName; | |
| 507 | - } | |
| 508 | 506 | |
| 509 | 507 | var isPlayDataError = false; |
| 510 | 508 | function programFileListToTreeJson(arr, lang){ |
| ... | ... | @@ -587,8 +585,8 @@ |
| 587 | 585 | dataType: "json", |
| 588 | 586 | contentType: "application/json", |
| 589 | 587 | success: function(res) { |
| 590 | - console.log('++++++++--------'); | |
| 591 | 588 | console.log(res) |
| 589 | + setTitle(res.languageid); | |
| 592 | 590 | |
| 593 | 591 | var coderecords = res.codeRecordList |
| 594 | 592 | var audioUrl = res.audioUrl; |
| ... | ... | @@ -645,6 +643,12 @@ |
| 645 | 643 | }); |
| 646 | 644 | } |
| 647 | 645 | |
| 646 | + // 设置 title | |
| 647 | + function setTitle(languageid){ | |
| 648 | + var languageName = Dir.getLangName(languageid); | |
| 649 | + $("title").html(languageName); | |
| 650 | + } | |
| 651 | + | |
| 648 | 652 | |
| 649 | 653 | $(window).resize(function() { |
| 650 | 654 | console.log('重置屏幕') | ... | ... |
src/gxb-ide/Iterm.js
| ... | ... | @@ -25,6 +25,7 @@ |
| 25 | 25 | $('#cancel_compile').on('click', function(){ _this.cancelCompile(); }) |
| 26 | 26 | $('#full-screen').on('click', function(){ _this.fullScreen(); }) |
| 27 | 27 | $('#back-screen').on('click', function(){ _this.exitFullscreen(); }) |
| 28 | + $(document).on('focus', '#runtimeArgus', function(){ }) | |
| 28 | 29 | }, |
| 29 | 30 | compile: function(){ |
| 30 | 31 | var _this = this; |
| ... | ... | @@ -68,7 +69,6 @@ |
| 68 | 69 | } |
| 69 | 70 | |
| 70 | 71 | compileResult(data, value) |
| 71 | - | |
| 72 | 72 | }, |
| 73 | 73 | saveCompile: function(){ |
| 74 | 74 | console.log(this.compileStatus) |
| ... | ... | @@ -85,7 +85,6 @@ |
| 85 | 85 | CodingEditer.records[length].error = CodingEditer.compileResultData.error; |
| 86 | 86 | CodingEditer.records[length].compilerInfo = CodingEditer.compileResultData.compilerInfo; |
| 87 | 87 | CodingEditer.records[length].code = CodingEditer.compileResultData.code; |
| 88 | - | |
| 89 | 88 | }, |
| 90 | 89 | cancelCompile: function(){ |
| 91 | 90 | console.log(this.compileStatus) |
| ... | ... | @@ -110,6 +109,7 @@ |
| 110 | 109 | $('.pause-shodow').hide() |
| 111 | 110 | $('.compile-reslut').hide(); |
| 112 | 111 | $('.contrl-shodow').hide(); |
| 112 | + $('.contrl-shodow').hide(); | |
| 113 | 113 | |
| 114 | 114 | Hourglass.pauseTimer(); |
| 115 | 115 | recorder.pause(); | ... | ... |
src/gxb-ide/ToolBox.js
| ... | ... | @@ -75,7 +75,7 @@ |
| 75 | 75 | $('#stop-recording').show() |
| 76 | 76 | var _this = this; |
| 77 | 77 | _this.readOnly(0) |
| 78 | - | |
| 78 | + | |
| 79 | 79 | setTimeout(function(){ |
| 80 | 80 | Dir.treeObj.setting.edit.showRenameBtn = false; |
| 81 | 81 | Dir.treeObj.setting.edit.enable = false; |
| ... | ... | @@ -166,10 +166,14 @@ |
| 166 | 166 | }, |
| 167 | 167 | playCode: function(){ |
| 168 | 168 | console.log('播放代码=-------------------------'); |
| 169 | - $('#audio')[0].play(); | |
| 170 | - Hourglass.init() | |
| 171 | - CodingEditer.playCoding() | |
| 172 | - console.log('播放代码=-------------------------'); | |
| 169 | + if (CodingEditer.flag) { | |
| 170 | + $('#audio')[0].play(); | |
| 171 | + Hourglass.init() | |
| 172 | + CodingEditer.playCoding() | |
| 173 | + }else{ | |
| 174 | + console.log('播放代码=-------------------------'); | |
| 175 | + return false; | |
| 176 | + } | |
| 173 | 177 | }, |
| 174 | 178 | uploadAudio: function(){ |
| 175 | 179 | console.log('uploadAudio'); | ... | ... |
src/js/c.js
| ... | ... | @@ -5,8 +5,6 @@ $(function(){ |
| 5 | 5 | var _languageid = getQuery('languageid'); |
| 6 | 6 | var _userId = getQuery('userId'); |
| 7 | 7 | var _role = getQuery('role'); |
| 8 | - | |
| 9 | - // $("title").html("C 语言"); | |
| 10 | 8 | |
| 11 | 9 | // new一个基本IDE结构 |
| 12 | 10 | var ide = new GxbIde({ |
| ... | ... | @@ -58,6 +56,42 @@ $(function(){ |
| 58 | 56 | $('#studentCompileBtn').show(); |
| 59 | 57 | } |
| 60 | 58 | |
| 59 | + | |
| 60 | + // 插入标准输入 | |
| 61 | + $(document).on('focus', '#runtimeArgus', function(){ | |
| 62 | + console.log('focus'); | |
| 63 | + CodingEditer.input_focus_time = new Date().getTime(); // 获取焦点的时间 | |
| 64 | + console.log(CodingEditer.records); | |
| 65 | + }) | |
| 66 | + $(document).on('blur', '#runtimeArgus', function(){ | |
| 67 | + console.log('blur'); | |
| 68 | + console.log('blur'); | |
| 69 | + console.log('blur'); | |
| 70 | + var recordobj = { | |
| 71 | + intervaltime: CodingEditer.input_focus_time - CodingEditer.record_startime, | |
| 72 | + editor: 'runtimeArgus', | |
| 73 | + changeobj: { | |
| 74 | + from: { | |
| 75 | + ch: 0, | |
| 76 | + line: 0, | |
| 77 | + }, | |
| 78 | + text: '', | |
| 79 | + to: { | |
| 80 | + ch: 0, | |
| 81 | + line: 0, | |
| 82 | + } | |
| 83 | + }, | |
| 84 | + runtimeArgus: $(this).val(), | |
| 85 | + trigger: 0, | |
| 86 | + playTime: 0 | |
| 87 | + }; | |
| 88 | + | |
| 89 | + CodingEditer.record_startime = CodingEditer.input_focus_time; // 获取焦点的时间 | |
| 90 | + CodingEditer.records.push(recordobj); | |
| 91 | + console.log(CodingEditer.records); | |
| 92 | + }) | |
| 93 | + | |
| 94 | + | |
| 61 | 95 | function recordReady(){ |
| 62 | 96 | var seconds = 0; |
| 63 | 97 | var countdown = setInterval(function() { | ... | ... |
src/js/player.js
| ... | ... | @@ -5,7 +5,9 @@ $(function(){ |
| 5 | 5 | var _codeReplayId = getQuery('codeReplayId'); |
| 6 | 6 | var player = $.AudioPlayer; |
| 7 | 7 | |
| 8 | - $("title").html("C 语言"); | |
| 8 | + var languageName = Dir.getLangName(_languageid); | |
| 9 | + $("title").html(languageName); | |
| 10 | + | |
| 9 | 11 | // new一个基本IDE结构 |
| 10 | 12 | var ide = new GxbIde({ |
| 11 | 13 | el: '#folder', |
| ... | ... | @@ -21,73 +23,9 @@ $(function(){ |
| 21 | 23 | }); |
| 22 | 24 | |
| 23 | 25 | console.log(_role) |
| 24 | - // if (_role == 0) { | |
| 25 | - // playUrl = gxb_api + "/programming/codeReplay/" + _codeReplayId + "/api"; | |
| 26 | - // getCodeData(playUrl) | |
| 27 | - // } else if (_role == 1) { | |
| 28 | - // playUrl = gxb_api + "/programming/student/studentReplay/" + _codeReplayId + "/api"; | |
| 29 | - // getCodeData(playUrl) | |
| 30 | - // } | |
| 31 | - | |
| 32 | - CodingEditer.isRecordPage = 0; | |
| 33 | - | |
| 34 | - // // 获取code | |
| 35 | - // function getCodeData(url){ | |
| 36 | - // console.log(url) | |
| 37 | - // $.ajax({ | |
| 38 | - // type: "get", | |
| 39 | - // url: url, | |
| 40 | - // dataType: "json", | |
| 41 | - // contentType: "application/json", | |
| 42 | - // success: function(res) { | |
| 43 | - // console.log('++++++++--------'); | |
| 44 | - // console.log(res) | |
| 45 | - // var coderecords = res.codeRecordList | |
| 46 | - // var audioUrl = res.audioUrl; | |
| 47 | 26 | |
| 48 | - // initTrigger(coderecords) | |
| 49 | - // AudioPlayer(audioUrl) | |
| 50 | - // }, | |
| 51 | - // error: function(error) { | |
| 52 | - // console.log(error) | |
| 53 | - // } | |
| 54 | - // }); | |
| 55 | - // } | |
| 56 | - | |
| 57 | - // // 初始化tigger | |
| 58 | - // function initTrigger(records){ | |
| 59 | - // var records = records | |
| 60 | - // for (var i = 0, leg = records.length; i < leg; i++) { | |
| 61 | - // if (!records[i].trigger) records[i].trigger = 0; | |
| 62 | - // records[i].changeobj = jQuery.parseJSON(records[i].changeobj); | |
| 63 | - // records[i].treefile = jQuery.parseJSON(records[i].treefile); | |
| 64 | - // } | |
| 65 | - // CodingEditer.records = records; | |
| 66 | - // } | |
| 27 | + CodingEditer.isRecordPage = 0; | |
| 67 | 28 | |
| 68 | - // // 初始化播放音频控制条 | |
| 69 | - // function AudioPlayer(audioUrl){ | |
| 70 | - // player.init({ | |
| 71 | - // container: '#audioWrap', | |
| 72 | - // source: "https://gxb-file.oss-cn-beijing.aliyuncs.com" + audioUrl, | |
| 73 | - // imagePath: '../js/audioPlayer/image', | |
| 74 | - // debuggers: false, | |
| 75 | - // allowSeek: false, | |
| 76 | - // playCallback: function() { // 播放 | |
| 77 | - // console.log('++++++++'); | |
| 78 | - // CodingEditer.playCoding(); | |
| 79 | - // }, | |
| 80 | - // pauseCallback: function() { // 暂停 | |
| 81 | - // CodingEditer.audioTime = parseInt(player.elements.audioDom.currentTime*1000); | |
| 82 | - // CodingEditer.pauseCode(); | |
| 83 | - // }, | |
| 84 | - // seekedCallback: function() { // 拖拽 | |
| 85 | - // }, | |
| 86 | - // endedCallback: function() { // 结束播放 | |
| 87 | - // playEnd() | |
| 88 | - // } | |
| 89 | - // }); | |
| 90 | - // } | |
| 91 | 29 | |
| 92 | 30 | |
| 93 | 31 | }) |
| 94 | 32 | \ No newline at end of file | ... | ... |
src/v1.1/index.html
| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | <html lang="en"> |
| 3 | 3 | <head> |
| 4 | 4 | <meta charset="UTF-8"> |
| 5 | - <title>JAVA</title> | |
| 5 | + <title></title> | |
| 6 | 6 | <link rel="stylesheet" href="../css/responsive/css/bootstrap.min.css"> |
| 7 | 7 | <link href="../css/codemirror.css" rel="stylesheet"> |
| 8 | 8 | <link href="../css/reset.css" rel="stylesheet"> |
| ... | ... | @@ -25,9 +25,7 @@ |
| 25 | 25 | // $('.my-button').click(function(){ |
| 26 | 26 | // var l = Ladda.create(this); |
| 27 | 27 | // l.start(); |
| 28 | - | |
| 29 | 28 | // }) |
| 30 | - | |
| 31 | 29 | // }) |
| 32 | 30 | </script> |
| 33 | 31 | ... | ... |
src/v1.1/player.html
| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | <html lang="en"> |
| 3 | 3 | <head> |
| 4 | 4 | <meta charset="UTF-8"> |
| 5 | - <title>JAVA</title> | |
| 5 | + <title></title> | |
| 6 | 6 | <link rel="stylesheet" href="../css/responsive/css/bootstrap.min.css"> |
| 7 | 7 | <link href="../css/codemirror.css" rel="stylesheet"> |
| 8 | 8 | <link href="../css/reset.css" rel="stylesheet"> | ... | ... |