Commit 07f513d48841e44a34e11f844db418398c4e06e9
1 parent
8f8a761d
修复编译异常操作bug
Showing
3 changed files
with
127 additions
and
106 deletions
src/css/recording.css
| ... | ... | @@ -502,7 +502,8 @@ button { |
| 502 | 502 | position: absolute; |
| 503 | 503 | top: 50%; |
| 504 | 504 | left: 50%; |
| 505 | - transform: translate(-50%, -50%); } | |
| 505 | + transform: translate(-50%, -50%); | |
| 506 | + z-index: 999; } | |
| 506 | 507 | |
| 507 | 508 | .re-tips .btn-success, .pause-shodow .btn-success { |
| 508 | 509 | background-color: #1FB6FF; | ... | ... |
src/js/gbreplayer.js
| ... | ... | @@ -40,6 +40,7 @@ $(function(){ |
| 40 | 40 | recording_status: 1, //当前是否在录制 |
| 41 | 41 | times: 0, // 播放次数 |
| 42 | 42 | isPause: 1, // 是否暂停 1:不暂停,0:暂停 |
| 43 | + isRcording: 0, // 是否录制 1:录制中,0:暂停中 | |
| 43 | 44 | recordinit: function(codereplaytype, preload) { |
| 44 | 45 | /* #STRAT:生成CodeMirror Editor for JS/CSS/HTML */ |
| 45 | 46 | var htmlid = document.getElementById('HTMLeditor'), |
| ... | ... | @@ -966,111 +967,6 @@ $(function(){ |
| 966 | 967 | $(this).toggleClass('btn-primary').toggleClass('btn-default'); |
| 967 | 968 | GBCodePlayBack.replay_enhancement = !GBCodePlayBack.replay_enhancement; |
| 968 | 969 | }); |
| 969 | - | |
| 970 | - // 使用服务端编译语言 | |
| 971 | - $('#comprunbtngrp').unbind("click").on('click', '#comprun', function(event){ | |
| 972 | - event.preventDefault(); | |
| 973 | - var l = Ladda.create(this); | |
| 974 | - $('#comprun').find('ladda-spinner').remove(); | |
| 975 | - l.start(); | |
| 976 | - | |
| 977 | - var runStatus = $("#comprun").data('run'); | |
| 978 | - if(runStatus == 1){ | |
| 979 | - Hourglass.pauseTimer(); // 暂停计时器 | |
| 980 | - recorder.pause(); // 音频暂停 | |
| 981 | - } | |
| 982 | - $("#comprun").data('run', 0); | |
| 983 | - console.log($("#comprun").data('run')); | |
| 984 | - // 暂停录制 | |
| 985 | - var pauseState = $('#pause').data('pause'); | |
| 986 | - if(pauseState == 1 && _role == 0){ | |
| 987 | - GBCodePlayBack.record_pause_time = new Date().getTime(); // 暂停的时间 | |
| 988 | - var recordobj = { | |
| 989 | - intervaltime: GBCodePlayBack.record_pause_time - GBCodePlayBack.record_startime, | |
| 990 | - editor: 'html', | |
| 991 | - changeobj: { | |
| 992 | - from:{ | |
| 993 | - ch: 0, | |
| 994 | - line: 0, | |
| 995 | - }, | |
| 996 | - text: '', | |
| 997 | - to:{ | |
| 998 | - ch: 0, | |
| 999 | - line: 0, | |
| 1000 | - } | |
| 1001 | - }, | |
| 1002 | - trigger: 0, | |
| 1003 | - playTime: 0 | |
| 1004 | - }; | |
| 1005 | - GBCodePlayBack.records.push(recordobj); | |
| 1006 | - console.log(GBCodePlayBack.records); | |
| 1007 | - | |
| 1008 | - $('#pause').data('status', '1'); | |
| 1009 | - $('#pause').data('pause', '0'); | |
| 1010 | - $('#pause').removeClass('hidden').addClass('show'); | |
| 1011 | - $('#start-recording').hide(); | |
| 1012 | - | |
| 1013 | - $('.pause-shodow').removeClass('hidden').addClass('show'); | |
| 1014 | - | |
| 1015 | - console.log('0000---1111') | |
| 1016 | - } | |
| 1017 | - | |
| 1018 | - var code = (typeof GBCodePlayBack.htmleditor !=='undefined' && GBCodePlayBack.htmleditor.getValue()) | |
| 1019 | - || (typeof GBCodePlayBack.htmlplayereditor !=='undefined' && GBCodePlayBack.htmlplayereditor.getValue()); | |
| 1020 | - var langid = $('#htmlbutton').data("languageid"); | |
| 1021 | - var input = $('#input').val() || ''; | |
| 1022 | - var compileData = { | |
| 1023 | - code: code, | |
| 1024 | - langid: langid, | |
| 1025 | - input: input | |
| 1026 | - } | |
| 1027 | - $.ajax({ | |
| 1028 | - type: "post", | |
| 1029 | - url: gxb_api + "/submit/submitCode/api", | |
| 1030 | - data: JSON.stringify(compileData), | |
| 1031 | - dataType: "json", | |
| 1032 | - contentType: "application/json", | |
| 1033 | - success: function(data) { | |
| 1034 | - compileResult(data) | |
| 1035 | - l.stop(); | |
| 1036 | - | |
| 1037 | - $('.compile-loading').hide(); | |
| 1038 | - $('.compile-reslut').show(); | |
| 1039 | - GBCodePlayBack.compileResultData = data; | |
| 1040 | - | |
| 1041 | - }, | |
| 1042 | - error: function(){ | |
| 1043 | - l.stop(); | |
| 1044 | - alert('错误'); | |
| 1045 | - } | |
| 1046 | - }); | |
| 1047 | - }); | |
| 1048 | - | |
| 1049 | - | |
| 1050 | - // 保存编译结果 | |
| 1051 | - $('#save_compile').unbind("click").click(function(){ | |
| 1052 | - var length = GBCodePlayBack.records.length - 1; | |
| 1053 | - Hourglass.pauseTimer(); | |
| 1054 | - $("#comprun").data('run', 1); | |
| 1055 | - GBCodePlayBack.records[length].compile = GBCodePlayBack.compileResultData; | |
| 1056 | - | |
| 1057 | - GBCodePlayBack.records[length].output = GBCodePlayBack.compileResultData.output; | |
| 1058 | - GBCodePlayBack.records[length].stderr = GBCodePlayBack.compileResultData.stderr; | |
| 1059 | - GBCodePlayBack.records[length].cmpinfo = GBCodePlayBack.compileResultData.cmpinfo; | |
| 1060 | - GBCodePlayBack.records[length].result = GBCodePlayBack.compileResultData.result; | |
| 1061 | - | |
| 1062 | - GBCodePlayBack.record_continue_time = new Date().getTime(); | |
| 1063 | - | |
| 1064 | - contrlPause(); | |
| 1065 | - | |
| 1066 | - }) | |
| 1067 | - | |
| 1068 | - // 不保存编译结果 | |
| 1069 | - $('#cancel_compile').unbind('click').click(function(){ | |
| 1070 | - Hourglass.pauseTimer(); | |
| 1071 | - contrlPause() | |
| 1072 | - GBCodePlayBack.record_continue_time = new Date().getTime(); | |
| 1073 | - }) | |
| 1074 | 970 | |
| 1075 | 971 | // 进度条滚动控制播放进度 |
| 1076 | 972 | var $sliderpropress = $(".replayprogress"); |
| ... | ... | @@ -1515,6 +1411,7 @@ $(function(){ |
| 1515 | 1411 | |
| 1516 | 1412 | // 开始录制 |
| 1517 | 1413 | $('#start-recording').click(function(){ |
| 1414 | + $('#recordertab a:eq(0)').tab('show'); | |
| 1518 | 1415 | // 编译状态 |
| 1519 | 1416 | var data = $(this).attr('data'); |
| 1520 | 1417 | var seconds = 0; |
| ... | ... | @@ -1527,6 +1424,7 @@ $(function(){ |
| 1527 | 1424 | }; |
| 1528 | 1425 | runResult() |
| 1529 | 1426 | if(data == 1){ |
| 1427 | + GBCodePlayBack.isRcording = 1; | |
| 1530 | 1428 | $("#countdown").find('img').attr('src', 'img/ready-go.gif'); |
| 1531 | 1429 | $("#countdown").find('img').load(function(){ |
| 1532 | 1430 | var countdown = setInterval(function(){ |
| ... | ... | @@ -1539,6 +1437,7 @@ $(function(){ |
| 1539 | 1437 | },1000); |
| 1540 | 1438 | }) |
| 1541 | 1439 | }else{ |
| 1440 | + GBCodePlayBack.isRcording = 0; | |
| 1542 | 1441 | $("#countdown").hide(); |
| 1543 | 1442 | $("#re-recoding").show(); |
| 1544 | 1443 | $("#start-recording").hide(); |
| ... | ... | @@ -1579,6 +1478,93 @@ $(function(){ |
| 1579 | 1478 | }); |
| 1580 | 1479 | |
| 1581 | 1480 | |
| 1481 | + // 使用服务端编译语言 | |
| 1482 | + $('#comprunbtngrp').unbind("click").on('click', '#comprun', function(event){ | |
| 1483 | + event.preventDefault(); | |
| 1484 | + var l = Ladda.create(this); | |
| 1485 | + $('#comprun').find('ladda-spinner').remove(); | |
| 1486 | + l.start(); | |
| 1487 | + | |
| 1488 | + if (!GBCodePlayBack.isRcording) { | |
| 1489 | + compileRun(l) | |
| 1490 | + }else{ | |
| 1491 | + var runStatus = $("#comprun").data('run'); | |
| 1492 | + if (runStatus == 1) { | |
| 1493 | + Hourglass.pauseTimer(); // 暂停计时器 | |
| 1494 | + recorder.pause(); // 音频暂停 | |
| 1495 | + } | |
| 1496 | + $("#comprun").data('run', 0); | |
| 1497 | + $('.compile-loading').show(); | |
| 1498 | + console.log($("#comprun").data('run')); | |
| 1499 | + // 暂停录制 | |
| 1500 | + var pauseState = $('#pause').data('pause'); | |
| 1501 | + if (pauseState == 1 && _role == 0) { | |
| 1502 | + GBCodePlayBack.record_pause_time = new Date().getTime(); // 暂停的时间 | |
| 1503 | + var recordobj = { | |
| 1504 | + intervaltime: GBCodePlayBack.record_pause_time - GBCodePlayBack.record_startime, | |
| 1505 | + editor: 'html', | |
| 1506 | + changeobj: { | |
| 1507 | + from: { | |
| 1508 | + ch: 0, | |
| 1509 | + line: 0, | |
| 1510 | + }, | |
| 1511 | + text: '', | |
| 1512 | + to: { | |
| 1513 | + ch: 0, | |
| 1514 | + line: 0, | |
| 1515 | + } | |
| 1516 | + }, | |
| 1517 | + trigger: 0, | |
| 1518 | + playTime: 0 | |
| 1519 | + }; | |
| 1520 | + GBCodePlayBack.records.push(recordobj); | |
| 1521 | + console.log(GBCodePlayBack.records); | |
| 1522 | + | |
| 1523 | + $('#pause').data('status', '1'); | |
| 1524 | + $('#pause').data('pause', '0'); | |
| 1525 | + $('#pause').removeClass('hidden').addClass('show'); | |
| 1526 | + $('#start-recording').hide(); | |
| 1527 | + | |
| 1528 | + $('.pause-shodow').removeClass('hidden').addClass('show'); | |
| 1529 | + console.log('0000---1111') | |
| 1530 | + } | |
| 1531 | + | |
| 1532 | + compileRun(l) | |
| 1533 | + } | |
| 1534 | + | |
| 1535 | + }); | |
| 1536 | + | |
| 1537 | + | |
| 1538 | + // 保存编译结果 | |
| 1539 | + $('#save_compile').unbind("click").click(function(){ | |
| 1540 | + var length = GBCodePlayBack.records.length - 1; | |
| 1541 | + recodingConf() | |
| 1542 | + | |
| 1543 | + GBCodePlayBack.records[length].compile = GBCodePlayBack.compileResultData; | |
| 1544 | + | |
| 1545 | + GBCodePlayBack.records[length].output = GBCodePlayBack.compileResultData.output; | |
| 1546 | + GBCodePlayBack.records[length].stderr = GBCodePlayBack.compileResultData.stderr; | |
| 1547 | + GBCodePlayBack.records[length].cmpinfo = GBCodePlayBack.compileResultData.cmpinfo; | |
| 1548 | + GBCodePlayBack.records[length].result = GBCodePlayBack.compileResultData.result; | |
| 1549 | + | |
| 1550 | + contrlPause(); | |
| 1551 | + }) | |
| 1552 | + | |
| 1553 | + // 不保存编译结果 | |
| 1554 | + $('#cancel_compile').unbind('click').click(function(){ | |
| 1555 | + recodingConf() | |
| 1556 | + contrlPause() | |
| 1557 | + }) | |
| 1558 | + | |
| 1559 | + // 继续录制配置 | |
| 1560 | + function recodingConf(){ | |
| 1561 | + Hourglass.pauseTimer(); | |
| 1562 | + $("#comprun").data('run', 1); | |
| 1563 | + GBCodePlayBack.record_startime = new Date().getTime(); | |
| 1564 | + GBCodePlayBack.record_continue_time = new Date().getTime(); | |
| 1565 | + } | |
| 1566 | + | |
| 1567 | + | |
| 1582 | 1568 | // 切换自动/手动运行代码 |
| 1583 | 1569 | function autoRun(autorun){ |
| 1584 | 1570 | if(autorun===1){ |
| ... | ... | @@ -1600,6 +1586,39 @@ $(function(){ |
| 1600 | 1586 | } |
| 1601 | 1587 | |
| 1602 | 1588 | |
| 1589 | + // 云编译 | |
| 1590 | + function compileRun(l){ | |
| 1591 | + var code = (typeof GBCodePlayBack.htmleditor !=='undefined' && GBCodePlayBack.htmleditor.getValue()) | |
| 1592 | + || (typeof GBCodePlayBack.htmlplayereditor !=='undefined' && GBCodePlayBack.htmlplayereditor.getValue()); | |
| 1593 | + var langid = $('#htmlbutton').data("languageid"); | |
| 1594 | + var input = $('#input').val() || ''; | |
| 1595 | + var compileData = { | |
| 1596 | + code: code, | |
| 1597 | + langid: langid, | |
| 1598 | + input: input | |
| 1599 | + } | |
| 1600 | + $.ajax({ | |
| 1601 | + type: "post", | |
| 1602 | + url: gxb_api + "/submit/submitCode/api", | |
| 1603 | + data: JSON.stringify(compileData), | |
| 1604 | + dataType: "json", | |
| 1605 | + contentType: "application/json", | |
| 1606 | + success: function(data) { | |
| 1607 | + compileResult(data) | |
| 1608 | + l.stop(); | |
| 1609 | + | |
| 1610 | + $('.compile-loading').hide(); | |
| 1611 | + $('.compile-reslut').show(); | |
| 1612 | + GBCodePlayBack.compileResultData = data; | |
| 1613 | + | |
| 1614 | + }, | |
| 1615 | + error: function(){ | |
| 1616 | + l.stop(); | |
| 1617 | + alert('错误'); | |
| 1618 | + } | |
| 1619 | + }); | |
| 1620 | + } | |
| 1621 | + | |
| 1603 | 1622 | // 初始化页面 |
| 1604 | 1623 | function initRecoding(){ |
| 1605 | 1624 | GBCodePlayBack.recordinit(); | ... | ... |