Commit fc00ac1aec147e04926fb9bc27b5404d8cb7b665
1 parent
e81a6b61
add save and upload tips
Showing
8 changed files
with
246 additions
and
33 deletions
src/css/ide.css
| @@ -94,7 +94,7 @@ html, body { | @@ -94,7 +94,7 @@ html, body { | ||
| 94 | background-image: linear-gradient(to right, #1FB6FF 0%, #62DCF5 100%); | 94 | background-image: linear-gradient(to right, #1FB6FF 0%, #62DCF5 100%); |
| 95 | position: absolute; | 95 | position: absolute; |
| 96 | top: 0; | 96 | top: 0; |
| 97 | - z-index: 9999; | 97 | + z-index: 99; |
| 98 | padding-left: 28px; } | 98 | padding-left: 28px; } |
| 99 | 99 | ||
| 100 | .record-wrap { | 100 | .record-wrap { |
| @@ -250,3 +250,30 @@ html, body { | @@ -250,3 +250,30 @@ html, body { | ||
| 250 | position: absolute; | 250 | position: absolute; |
| 251 | bottom: 0; | 251 | bottom: 0; |
| 252 | text-align: right; } | 252 | text-align: right; } |
| 253 | + | ||
| 254 | +#countdown { | ||
| 255 | + display: block; | ||
| 256 | + z-index: 999; | ||
| 257 | + width: 100%; | ||
| 258 | + height: 100%; | ||
| 259 | + background-color: rgba(0, 0, 0, 0.6); | ||
| 260 | + position: absolute; } | ||
| 261 | + #countdown img { | ||
| 262 | + position: absolute; | ||
| 263 | + top: 50%; | ||
| 264 | + left: 50%; | ||
| 265 | + transform: translate(-50%, -50%); } | ||
| 266 | + | ||
| 267 | +.upload-tip { | ||
| 268 | + position: absolute; | ||
| 269 | + top: 0; | ||
| 270 | + left: 0; | ||
| 271 | + width: 100%; | ||
| 272 | + height: 100%; | ||
| 273 | + background-color: rgba(0, 0, 0, 0.6); | ||
| 274 | + z-index: 9999; } | ||
| 275 | + .upload-tip img { | ||
| 276 | + position: absolute; | ||
| 277 | + top: 50%; | ||
| 278 | + left: 50%; | ||
| 279 | + transform: translate(-50%, -50%); } |
src/css/main.css
| @@ -16,7 +16,7 @@ html, body { | @@ -16,7 +16,7 @@ html, body { | ||
| 16 | background-image: linear-gradient(to right, #1FB6FF 0%, #62DCF5 100%); | 16 | background-image: linear-gradient(to right, #1FB6FF 0%, #62DCF5 100%); |
| 17 | position: absolute; | 17 | position: absolute; |
| 18 | top: 0; | 18 | top: 0; |
| 19 | - z-index: 9999; | 19 | + z-index: 99; |
| 20 | padding-left: 28px; } | 20 | padding-left: 28px; } |
| 21 | 21 | ||
| 22 | .record-wrap { | 22 | .record-wrap { |
| @@ -172,3 +172,30 @@ html, body { | @@ -172,3 +172,30 @@ html, body { | ||
| 172 | position: absolute; | 172 | position: absolute; |
| 173 | bottom: 0; | 173 | bottom: 0; |
| 174 | text-align: right; } | 174 | text-align: right; } |
| 175 | + | ||
| 176 | +#countdown { | ||
| 177 | + display: block; | ||
| 178 | + z-index: 999; | ||
| 179 | + width: 100%; | ||
| 180 | + height: 100%; | ||
| 181 | + background-color: rgba(0, 0, 0, 0.6); | ||
| 182 | + position: absolute; } | ||
| 183 | + #countdown img { | ||
| 184 | + position: absolute; | ||
| 185 | + top: 50%; | ||
| 186 | + left: 50%; | ||
| 187 | + transform: translate(-50%, -50%); } | ||
| 188 | + | ||
| 189 | +.upload-tip { | ||
| 190 | + position: absolute; | ||
| 191 | + top: 0; | ||
| 192 | + left: 0; | ||
| 193 | + width: 100%; | ||
| 194 | + height: 100%; | ||
| 195 | + background-color: rgba(0, 0, 0, 0.6); | ||
| 196 | + z-index: 9999; } | ||
| 197 | + .upload-tip img { | ||
| 198 | + position: absolute; | ||
| 199 | + top: 50%; | ||
| 200 | + left: 50%; | ||
| 201 | + transform: translate(-50%, -50%); } |
src/gxb-ide/ToolBox.js
| @@ -28,7 +28,9 @@ | @@ -28,7 +28,9 @@ | ||
| 28 | constructor: ToolBox, | 28 | constructor: ToolBox, |
| 29 | options: { | 29 | options: { |
| 30 | el: "#toolBox", // 控制条插入位置id | 30 | el: "#toolBox", // 控制条插入位置id |
| 31 | - role: 0, // 角色 | 31 | + role: null, // 角色 |
| 32 | + userId: '', | ||
| 33 | + languageId: '', | ||
| 32 | startCallback: null, // 开始录制代码 | 34 | startCallback: null, // 开始录制代码 |
| 33 | stopCallback: null, // 结束录制 | 35 | stopCallback: null, // 结束录制 |
| 34 | restartCallback: null, // 重新录制代码 | 36 | restartCallback: null, // 重新录制代码 |
| @@ -66,17 +68,15 @@ | @@ -66,17 +68,15 @@ | ||
| 66 | $('#cancel').on('click', function(){ _this.cancel(); }) | 68 | $('#cancel').on('click', function(){ _this.cancel(); }) |
| 67 | }, | 69 | }, |
| 68 | startRecording: function(callback){ | 70 | startRecording: function(callback){ |
| 69 | - console.log('startRecord'); | 71 | + console.log(this.options.userId); |
| 70 | $('#start-recording').hide() | 72 | $('#start-recording').hide() |
| 71 | $('#stop-recording').show() | 73 | $('#stop-recording').show() |
| 72 | - Hourglass.init() | ||
| 73 | var _this = this; | 74 | var _this = this; |
| 74 | - if (typeof _this.options.startRecordingCallback == 'function') { | ||
| 75 | - console.log('startRecordingCallback'); | ||
| 76 | - _this.options.startRecordingCallback(); | 75 | + if (typeof _this.options.startCallback == 'function') { |
| 76 | + console.log('startCallback'); | ||
| 77 | + _this.options.startCallback(); | ||
| 77 | } | 78 | } |
| 78 | recordAudio() | 79 | recordAudio() |
| 79 | - | ||
| 80 | }, | 80 | }, |
| 81 | stopRecording: function(){ | 81 | stopRecording: function(){ |
| 82 | console.log('停止录制'); | 82 | console.log('停止录制'); |
| @@ -92,8 +92,7 @@ | @@ -92,8 +92,7 @@ | ||
| 92 | _this.options.stopCallback(); | 92 | _this.options.stopCallback(); |
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | - recorder.stop(); | ||
| 96 | - recorder.getBlobData(); | 95 | + $('#upload').removeClass('upload-teach').addClass('recording-finish').removeAttr('disabled').prop("disabled", false); |
| 97 | 96 | ||
| 98 | }, | 97 | }, |
| 99 | restartRecord: function(){ | 98 | restartRecord: function(){ |
| @@ -105,8 +104,24 @@ | @@ -105,8 +104,24 @@ | ||
| 105 | $('#recordertab a:first').tab('show'); | 104 | $('#recordertab a:first').tab('show'); |
| 106 | // CodingEditer.records = []; | 105 | // CodingEditer.records = []; |
| 107 | _this.readOnly(0) | 106 | _this.readOnly(0) |
| 107 | + if (typeof _this.options.restartCallback == 'function') { | ||
| 108 | + console.log('restartCallback'); | ||
| 109 | + _this.options.restartCallback(); | ||
| 110 | + } | ||
| 108 | recordAudio() | 111 | recordAudio() |
| 109 | }, | 112 | }, |
| 113 | + recordAudio: function(){ | ||
| 114 | + HZRecorder.get(function(rec) { | ||
| 115 | + console.log(rec); | ||
| 116 | + recorder = rec; | ||
| 117 | + recorder.start(); | ||
| 118 | + CodingEditer.initRecodesValue() | ||
| 119 | + }); | ||
| 120 | + }, | ||
| 121 | + stopAudio: function(){ | ||
| 122 | + recorder.stop(); | ||
| 123 | + recorder.getBlobData(); | ||
| 124 | + }, | ||
| 110 | playCode: function(){ | 125 | playCode: function(){ |
| 111 | console.log('播放代码'); | 126 | console.log('播放代码'); |
| 112 | $('#audio')[0].play(); | 127 | $('#audio')[0].play(); |
| @@ -115,9 +130,87 @@ | @@ -115,9 +130,87 @@ | ||
| 115 | }, | 130 | }, |
| 116 | uploadAudio: function(){ | 131 | uploadAudio: function(){ |
| 117 | console.log('uploadAudio'); | 132 | console.log('uploadAudio'); |
| 133 | + $('.upload-tip').show(); | ||
| 134 | + recorder.upload(); | ||
| 118 | }, | 135 | }, |
| 119 | saveCode: function(){ | 136 | saveCode: function(){ |
| 120 | - console.log('saveCode'); | 137 | + var _this = this; |
| 138 | + var pickup = 0 //是否要同步录音 0:同步录音,1异步录音 | ||
| 139 | + var saveformat = $('#saveformat').find('.active').data('saveformat') || 5; | ||
| 140 | + var programmingFileList = Dir.getTreeData(); | ||
| 141 | + var keepTimer = Math.round($('#audio')[0].duration); | ||
| 142 | + | ||
| 143 | + var postData = { | ||
| 144 | + "mainPath": Dir.mainPath, | ||
| 145 | + "mainArgus": "lixxx", | ||
| 146 | + "runtimeArgus": $('#runtimeArgus').val(), | ||
| 147 | + "pickup": pickup, | ||
| 148 | + "userId": _this.options.userId, | ||
| 149 | + "replaytitle": "课程名", | ||
| 150 | + "languageid": _this.options.languageId, | ||
| 151 | + "replaydesc": "回放说明", | ||
| 152 | + "image": "placeholder.png", | ||
| 153 | + "deleteFlag": 1, | ||
| 154 | + "viewcount": "0", | ||
| 155 | + "saveformat": saveformat, | ||
| 156 | + "audioUrl": $('.audio-url').val(), | ||
| 157 | + "programmingSource": 1, | ||
| 158 | + "programmingFileList": programmingFileList, | ||
| 159 | + "totaltime": keepTimer | ||
| 160 | + } | ||
| 161 | + var temp_record = JSON.parse(JSON.stringify(CodingEditer.records)) | ||
| 162 | + var codeRecordLists = []; | ||
| 163 | + | ||
| 164 | + for (var i = 0; i < temp_record.length; i++) { | ||
| 165 | + var temp_record_item = temp_record[i]; | ||
| 166 | + if(temp_record_item){ | ||
| 167 | + temp_record_item.changeobj=JSON.stringify(temp_record_item.changeobj); | ||
| 168 | + if(temp_record_item.treefile){ | ||
| 169 | + temp_record_item.treefile=JSON.stringify(temp_record_item.treefile); | ||
| 170 | + } | ||
| 171 | + } | ||
| 172 | + codeRecordLists.push(temp_record_item); | ||
| 173 | + } | ||
| 174 | + var _role = _this.options.role; | ||
| 175 | + if (_role == 0) { | ||
| 176 | + postData.codeRecordList = codeRecordLists; | ||
| 177 | + var roleUrl = gxb_api + "/programming/codeReplay/api" | ||
| 178 | + }else if (_role == 1) { | ||
| 179 | + postData.studentRecordList = codeRecordLists; | ||
| 180 | + var roleUrl = gxb_api + "/programming/student/studentReplay/api" | ||
| 181 | + } | ||
| 182 | + console.log(postData); | ||
| 183 | + $.ajax({ | ||
| 184 | + type: "post", | ||
| 185 | + url: roleUrl, | ||
| 186 | + data: JSON.stringify(postData), | ||
| 187 | + dataType: "json", | ||
| 188 | + contentType: "application/json", | ||
| 189 | + success: function(data) { | ||
| 190 | + console.log(data); | ||
| 191 | + $('.upload-tip').hide(); | ||
| 192 | + $(window).unbind('beforeunload'); | ||
| 193 | + var _data = { | ||
| 194 | + "programId": data.codeReplayId || data.studentReplayId, | ||
| 195 | + "programLanguageName": data.languageName, | ||
| 196 | + "programLanguageId": data.languageid, | ||
| 197 | + "programmingSource": data.programmingSource, | ||
| 198 | + "programAudioLength": keepTimer || 0 | ||
| 199 | + } | ||
| 200 | + console.log(_data); | ||
| 201 | + $('.upload-tip').hide(); | ||
| 202 | + | ||
| 203 | + $('#cancel').prop("disabled", false); | ||
| 204 | + | ||
| 205 | + window.opener.postMessage(_data, _source); | ||
| 206 | + window.close(); | ||
| 207 | + }, | ||
| 208 | + error: function() { | ||
| 209 | + $('.upload-tip').hide(); | ||
| 210 | + console.log(CodingEditer.records) | ||
| 211 | + alert('代码保存失败重新保存') | ||
| 212 | + } | ||
| 213 | + }); | ||
| 121 | }, | 214 | }, |
| 122 | cancel: function(){ | 215 | cancel: function(){ |
| 123 | console.log('cancel'); | 216 | console.log('cancel'); |
| @@ -141,13 +234,12 @@ | @@ -141,13 +234,12 @@ | ||
| 141 | }; | 234 | }; |
| 142 | 235 | ||
| 143 | function recordAudio(){ | 236 | function recordAudio(){ |
| 144 | - HZRecorder.get(function(rec) { | ||
| 145 | - console.log(rec); | ||
| 146 | - recorder = rec; | ||
| 147 | - recorder.start(); | ||
| 148 | - CodingEditer.initRecodesValue() | ||
| 149 | - | ||
| 150 | - }); | 237 | + // HZRecorder.get(function(rec) { |
| 238 | + // console.log(rec); | ||
| 239 | + // recorder = rec; | ||
| 240 | + // recorder.start(); | ||
| 241 | + // CodingEditer.initRecodesValue() | ||
| 242 | + // }); | ||
| 151 | } | 243 | } |
| 152 | 244 | ||
| 153 | // 编译结果 | 245 | // 编译结果 |
src/gxb-ide/toolBox.css
| @@ -65,5 +65,14 @@ | @@ -65,5 +65,14 @@ | ||
| 65 | border: 1px solid #1FB6FF; | 65 | border: 1px solid #1FB6FF; |
| 66 | color: #1FB6FF; | 66 | color: #1FB6FF; |
| 67 | } | 67 | } |
| 68 | + | ||
| 69 | +.upload-teach, .upload-stud{ | ||
| 70 | + background: -webkit-linear-gradient(left, #505151, #939494); | ||
| 71 | + background: -moz-linear-gradient(left, #505151, #939494); | ||
| 72 | +} | ||
| 73 | +.recording-finish{ | ||
| 74 | + background: -webkit-linear-gradient(left, #1FB6FF, #62DDF5); | ||
| 75 | + background: -moz-linear-gradient(left, #1FB6FF, #62DDF5); | ||
| 76 | +} | ||
| 68 | 77 | ||
| 69 | 78 | ||
| 70 | \ No newline at end of file | 79 | \ No newline at end of file |
src/js/c.js
| @@ -12,8 +12,19 @@ $(function(){ | @@ -12,8 +12,19 @@ $(function(){ | ||
| 12 | // new一个老师录制的控制条工具 | 12 | // new一个老师录制的控制条工具 |
| 13 | var techTool = new ToolBox({ | 13 | var techTool = new ToolBox({ |
| 14 | el: '#toolBox', | 14 | el: '#toolBox', |
| 15 | + userId: _userId, | ||
| 16 | + languageId: _languageid, | ||
| 15 | startCallback: function(){ | 17 | startCallback: function(){ |
| 16 | - | 18 | + $("#countdown").show() |
| 19 | + .find('img').attr('src', '../img/ready-go.gif') | ||
| 20 | + .load(function() { | ||
| 21 | + recordReady() | ||
| 22 | + }) | ||
| 23 | + }, | ||
| 24 | + stopCallback: function(){ | ||
| 25 | + techTool.stopAudio() | ||
| 26 | + }, | ||
| 27 | + restartCallback: function(){ | ||
| 17 | } | 28 | } |
| 18 | }); | 29 | }); |
| 19 | 30 | ||
| @@ -25,6 +36,20 @@ $(function(){ | @@ -25,6 +36,20 @@ $(function(){ | ||
| 25 | 36 | ||
| 26 | console.log(ide); | 37 | console.log(ide); |
| 27 | 38 | ||
| 39 | + function recordReady(){ | ||
| 40 | + var seconds = 0; | ||
| 41 | + var countdown = setInterval(function() { | ||
| 42 | + seconds += 1; | ||
| 43 | + if (seconds == 2) { | ||
| 44 | + console.log('-============================================') | ||
| 45 | + console.log('countdown'); | ||
| 46 | + $("#countdown").hide(); | ||
| 47 | + techTool.recordAudio() | ||
| 48 | + Hourglass.init() | ||
| 49 | + } | ||
| 50 | + }, 1000); | ||
| 51 | + } | ||
| 52 | + | ||
| 28 | }) | 53 | }) |
| 29 | 54 | ||
| 30 | 55 |
src/js/recorder/Myna.js
| @@ -293,8 +293,8 @@ | @@ -293,8 +293,8 @@ | ||
| 293 | console.log(audioUrl) | 293 | console.log(audioUrl) |
| 294 | $(".audio-url").val(audioUrl) | 294 | $(".audio-url").val(audioUrl) |
| 295 | 295 | ||
| 296 | - $('#savecorde').trigger('click'); | ||
| 297 | - | 296 | + // $('#savecorde').trigger('click'); |
| 297 | + $('#savecode').trigger('click'); | ||
| 298 | }, | 298 | }, |
| 299 | error: function(res){ | 299 | error: function(res){ |
| 300 | $('.upload-tip').hide(); | 300 | $('.upload-tip').hide(); |
src/scss/main.scss
| @@ -18,7 +18,7 @@ html, body{ | @@ -18,7 +18,7 @@ html, body{ | ||
| 18 | background-image: linear-gradient(to right, #1FB6FF 0%, #62DCF5 100%); | 18 | background-image: linear-gradient(to right, #1FB6FF 0%, #62DCF5 100%); |
| 19 | position: absolute; | 19 | position: absolute; |
| 20 | top: 0; | 20 | top: 0; |
| 21 | - z-index: 9999; | 21 | + z-index: 99; |
| 22 | padding-left: 28px; | 22 | padding-left: 28px; |
| 23 | 23 | ||
| 24 | } | 24 | } |
| @@ -230,9 +230,38 @@ html, body{ | @@ -230,9 +230,38 @@ html, body{ | ||
| 230 | } | 230 | } |
| 231 | } | 231 | } |
| 232 | 232 | ||
| 233 | +// 开始录制动画 | ||
| 234 | +#countdown{ | ||
| 235 | + display: block; | ||
| 236 | + z-index: 999; | ||
| 237 | + width: 100%; | ||
| 238 | + height: 100%; | ||
| 239 | + background-color: rgba(0, 0, 0, 0.6); | ||
| 240 | + position: absolute; | ||
| 233 | 241 | ||
| 242 | + img{ | ||
| 243 | + position: absolute; | ||
| 244 | + top: 50%; | ||
| 245 | + left: 50%; | ||
| 246 | + transform: translate(-50%, -50%); | ||
| 247 | + } | ||
| 248 | +} | ||
| 249 | +.upload-tip{ | ||
| 250 | + position: absolute; | ||
| 251 | + top: 0; | ||
| 252 | + left: 0; | ||
| 253 | + width: 100%; | ||
| 254 | + height: 100%; | ||
| 255 | + background-color: rgba(0, 0, 0, 0.6); | ||
| 256 | + z-index: 9999; | ||
| 234 | 257 | ||
| 235 | - | 258 | + img{ |
| 259 | + position: absolute; | ||
| 260 | + top: 50%; | ||
| 261 | + left: 50%; | ||
| 262 | + transform: translate(-50%, -50%); | ||
| 263 | + } | ||
| 264 | +} | ||
| 236 | 265 | ||
| 237 | 266 | ||
| 238 | 267 |
src/v1.1/c.html
| @@ -30,6 +30,9 @@ | @@ -30,6 +30,9 @@ | ||
| 30 | 30 | ||
| 31 | <script src="../js/util/Hourglass.js"></script> | 31 | <script src="../js/util/Hourglass.js"></script> |
| 32 | <script src="../js/util/util.js"></script> | 32 | <script src="../js/util/util.js"></script> |
| 33 | + | ||
| 34 | + <script src="../js/05-util.js"></script> | ||
| 35 | + <script src="../js/03-http.js"></script> | ||
| 33 | 36 | ||
| 34 | <script src="../js/recorder/Myna.js"></script> | 37 | <script src="../js/recorder/Myna.js"></script> |
| 35 | <script src="../gxb-ide/Dir.js"></script> | 38 | <script src="../gxb-ide/Dir.js"></script> |
| @@ -74,12 +77,7 @@ | @@ -74,12 +77,7 @@ | ||
| 74 | 77 | ||
| 75 | </head> | 78 | </head> |
| 76 | <body> | 79 | <body> |
| 77 | - <div> | ||
| 78 | - | ||
| 79 | - | ||
| 80 | - </div> | ||
| 81 | <div class="programing"> | 80 | <div class="programing"> |
| 82 | - | ||
| 83 | <!-- 控制条 --> | 81 | <!-- 控制条 --> |
| 84 | <div class="record-title"> | 82 | <div class="record-title"> |
| 85 | <ul id="recordertab" class="nav nav-tabs pull-left"> | 83 | <ul id="recordertab" class="nav nav-tabs pull-left"> |
| @@ -130,8 +128,6 @@ | @@ -130,8 +128,6 @@ | ||
| 130 | </div> | 128 | </div> |
| 131 | </div> | 129 | </div> |
| 132 | 130 | ||
| 133 | - | ||
| 134 | - | ||
| 135 | <!-- 控录制录制 --> | 131 | <!-- 控录制录制 --> |
| 136 | <div class="record-toolbox"> | 132 | <div class="record-toolbox"> |
| 137 | <!-- 运行结果区 --> | 133 | <!-- 运行结果区 --> |
| @@ -169,11 +165,19 @@ | @@ -169,11 +165,19 @@ | ||
| 169 | <iframe id="resultiframe" frameBorder="0" width="100%"></iframe> | 165 | <iframe id="resultiframe" frameBorder="0" width="100%"></iframe> |
| 170 | </div> | 166 | </div> |
| 171 | </div> | 167 | </div> |
| 172 | - | 168 | + <input type="hidden" class="audio-url" value=""> |
| 173 | <div class="" id="toolBox"> | 169 | <div class="" id="toolBox"> |
| 174 | 170 | ||
| 175 | </div> | 171 | </div> |
| 176 | - | 172 | + </div> |
| 173 | + | ||
| 174 | + <!-- 准备开始 --> | ||
| 175 | + <div id="countdown" style="display: none;"> | ||
| 176 | + <img src="" alt=""> | ||
| 177 | + </div> | ||
| 178 | + <!-- 保存提示 --> | ||
| 179 | + <div class="upload-tip" style="display: none;"> | ||
| 180 | + <img src="../img/upload_tip.png" alt=""> | ||
| 177 | </div> | 181 | </div> |
| 178 | 182 | ||
| 179 | </div> | 183 | </div> |