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 | 94 | background-image: linear-gradient(to right, #1FB6FF 0%, #62DCF5 100%); |
| 95 | 95 | position: absolute; |
| 96 | 96 | top: 0; |
| 97 | - z-index: 9999; | |
| 97 | + z-index: 99; | |
| 98 | 98 | padding-left: 28px; } |
| 99 | 99 | |
| 100 | 100 | .record-wrap { |
| ... | ... | @@ -250,3 +250,30 @@ html, body { |
| 250 | 250 | position: absolute; |
| 251 | 251 | bottom: 0; |
| 252 | 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 | 16 | background-image: linear-gradient(to right, #1FB6FF 0%, #62DCF5 100%); |
| 17 | 17 | position: absolute; |
| 18 | 18 | top: 0; |
| 19 | - z-index: 9999; | |
| 19 | + z-index: 99; | |
| 20 | 20 | padding-left: 28px; } |
| 21 | 21 | |
| 22 | 22 | .record-wrap { |
| ... | ... | @@ -172,3 +172,30 @@ html, body { |
| 172 | 172 | position: absolute; |
| 173 | 173 | bottom: 0; |
| 174 | 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 | 28 | constructor: ToolBox, |
| 29 | 29 | options: { |
| 30 | 30 | el: "#toolBox", // 控制条插入位置id |
| 31 | - role: 0, // 角色 | |
| 31 | + role: null, // 角色 | |
| 32 | + userId: '', | |
| 33 | + languageId: '', | |
| 32 | 34 | startCallback: null, // 开始录制代码 |
| 33 | 35 | stopCallback: null, // 结束录制 |
| 34 | 36 | restartCallback: null, // 重新录制代码 |
| ... | ... | @@ -66,17 +68,15 @@ |
| 66 | 68 | $('#cancel').on('click', function(){ _this.cancel(); }) |
| 67 | 69 | }, |
| 68 | 70 | startRecording: function(callback){ |
| 69 | - console.log('startRecord'); | |
| 71 | + console.log(this.options.userId); | |
| 70 | 72 | $('#start-recording').hide() |
| 71 | 73 | $('#stop-recording').show() |
| 72 | - Hourglass.init() | |
| 73 | 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 | 79 | recordAudio() |
| 79 | - | |
| 80 | 80 | }, |
| 81 | 81 | stopRecording: function(){ |
| 82 | 82 | console.log('停止录制'); |
| ... | ... | @@ -92,8 +92,7 @@ |
| 92 | 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 | 98 | restartRecord: function(){ |
| ... | ... | @@ -105,8 +104,24 @@ |
| 105 | 104 | $('#recordertab a:first').tab('show'); |
| 106 | 105 | // CodingEditer.records = []; |
| 107 | 106 | _this.readOnly(0) |
| 107 | + if (typeof _this.options.restartCallback == 'function') { | |
| 108 | + console.log('restartCallback'); | |
| 109 | + _this.options.restartCallback(); | |
| 110 | + } | |
| 108 | 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 | 125 | playCode: function(){ |
| 111 | 126 | console.log('播放代码'); |
| 112 | 127 | $('#audio')[0].play(); |
| ... | ... | @@ -115,9 +130,87 @@ |
| 115 | 130 | }, |
| 116 | 131 | uploadAudio: function(){ |
| 117 | 132 | console.log('uploadAudio'); |
| 133 | + $('.upload-tip').show(); | |
| 134 | + recorder.upload(); | |
| 118 | 135 | }, |
| 119 | 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 | 215 | cancel: function(){ |
| 123 | 216 | console.log('cancel'); |
| ... | ... | @@ -141,13 +234,12 @@ |
| 141 | 234 | }; |
| 142 | 235 | |
| 143 | 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 | 65 | border: 1px solid #1FB6FF; |
| 66 | 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 | 79 | \ No newline at end of file | ... | ... |
src/js/c.js
| ... | ... | @@ -12,8 +12,19 @@ $(function(){ |
| 12 | 12 | // new一个老师录制的控制条工具 |
| 13 | 13 | var techTool = new ToolBox({ |
| 14 | 14 | el: '#toolBox', |
| 15 | + userId: _userId, | |
| 16 | + languageId: _languageid, | |
| 15 | 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 | 36 | |
| 26 | 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 | 293 | console.log(audioUrl) |
| 294 | 294 | $(".audio-url").val(audioUrl) |
| 295 | 295 | |
| 296 | - $('#savecorde').trigger('click'); | |
| 297 | - | |
| 296 | + // $('#savecorde').trigger('click'); | |
| 297 | + $('#savecode').trigger('click'); | |
| 298 | 298 | }, |
| 299 | 299 | error: function(res){ |
| 300 | 300 | $('.upload-tip').hide(); | ... | ... |
src/scss/main.scss
| ... | ... | @@ -18,7 +18,7 @@ html, body{ |
| 18 | 18 | background-image: linear-gradient(to right, #1FB6FF 0%, #62DCF5 100%); |
| 19 | 19 | position: absolute; |
| 20 | 20 | top: 0; |
| 21 | - z-index: 9999; | |
| 21 | + z-index: 99; | |
| 22 | 22 | padding-left: 28px; |
| 23 | 23 | |
| 24 | 24 | } |
| ... | ... | @@ -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 | 30 | |
| 31 | 31 | <script src="../js/util/Hourglass.js"></script> |
| 32 | 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 | 37 | <script src="../js/recorder/Myna.js"></script> |
| 35 | 38 | <script src="../gxb-ide/Dir.js"></script> |
| ... | ... | @@ -74,12 +77,7 @@ |
| 74 | 77 | |
| 75 | 78 | </head> |
| 76 | 79 | <body> |
| 77 | - <div> | |
| 78 | - | |
| 79 | - | |
| 80 | - </div> | |
| 81 | 80 | <div class="programing"> |
| 82 | - | |
| 83 | 81 | <!-- 控制条 --> |
| 84 | 82 | <div class="record-title"> |
| 85 | 83 | <ul id="recordertab" class="nav nav-tabs pull-left"> |
| ... | ... | @@ -130,8 +128,6 @@ |
| 130 | 128 | </div> |
| 131 | 129 | </div> |
| 132 | 130 | |
| 133 | - | |
| 134 | - | |
| 135 | 131 | <!-- 控录制录制 --> |
| 136 | 132 | <div class="record-toolbox"> |
| 137 | 133 | <!-- 运行结果区 --> |
| ... | ... | @@ -169,11 +165,19 @@ |
| 169 | 165 | <iframe id="resultiframe" frameBorder="0" width="100%"></iframe> |
| 170 | 166 | </div> |
| 171 | 167 | </div> |
| 172 | - | |
| 168 | + <input type="hidden" class="audio-url" value=""> | |
| 173 | 169 | <div class="" id="toolBox"> |
| 174 | 170 | |
| 175 | 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 | 181 | </div> |
| 178 | 182 | |
| 179 | 183 | </div> | ... | ... |