Commit 630c0bdbe8bd649d1f8f7533e2d0408b0d83c9c0
1 parent
a62775a9
增加修改文件名新功能
Showing
5 changed files
with
435 additions
and
284 deletions
src/css/demo.css
| ... | ... | @@ -114,12 +114,18 @@ ul.ztree li a{ |
| 114 | 114 | border: none; |
| 115 | 115 | opacity: 1; |
| 116 | 116 | } |
| 117 | +ul.ztree li span.node_name input{ | |
| 118 | + outline: none; | |
| 119 | +} | |
| 117 | 120 | ul.ztree li span.button.switch{ |
| 118 | 121 | display: none; |
| 119 | 122 | } |
| 120 | 123 | ul.ztree li span.button.ico_open, |
| 121 | 124 | ul.ztree li span.button.ico_close, |
| 122 | -ul.ztree li span.button.ico_docu{ | |
| 125 | +ul.ztree li span.button.ico_docu, | |
| 126 | +ul.ztree li span.button.add, | |
| 127 | +ul.ztree li span.button.edit, | |
| 128 | +ul.ztree li span.button.remove{ | |
| 123 | 129 | margin-top: 4px; |
| 124 | 130 | margin-right: 2px; |
| 125 | 131 | vertical-align: top; |
| ... | ... | @@ -131,6 +137,9 @@ ul.ztree li span.button.ico_close{ |
| 131 | 137 | ul.ztree li span.button.ico_docu{ |
| 132 | 138 | background: url(../img/icon-files-java.png) no-repeat scroll center center transparent; |
| 133 | 139 | } |
| 140 | +ul.ztree li span.button.add { | |
| 141 | + background-position:-144px 0; | |
| 142 | +} | |
| 134 | 143 | |
| 135 | 144 | textarea[id^="tab"]{ display: none; } |
| 136 | 145 | textarea[id^="tab"].active{ display: block; } | ... | ... |
src/css/recording.css
src/js/gb.js
| 1 | 1 | // 2016-11-4 By Kira |
| 2 | + | |
| 2 | 3 | $(function() { |
| 3 | 4 | /** |
| 4 | 5 | * 互动编程播放页面参数 |
| ... | ... | @@ -33,92 +34,257 @@ $(function() { |
| 33 | 34 | csshlLine = null, |
| 34 | 35 | jshlLine = null; |
| 35 | 36 | |
| 36 | - if(document.URL.indexOf('player') >= 0){ | |
| 37 | - isReplayPage = true; | |
| 38 | - // if(!_codeReplayId || !_userId || !_role || !_chapterId){ | |
| 39 | - // utils.errorVisit.template = $('<div id="tips" class="tips">' + | |
| 40 | - // '<div class="tips-inner">' + | |
| 41 | - // '访问参数出错,请联系管理人员。' + | |
| 42 | - // '</div>' + | |
| 43 | - // '</div>'); | |
| 44 | - // utils.errorVisit.show(); | |
| 45 | - // }else{ | |
| 46 | - // $('#app').show(); | |
| 47 | - // } | |
| 48 | - // }else{ | |
| 49 | - // if(!_languageid || !_userId || !_role || !_source){ | |
| 50 | - // utils.errorVisit.show(); | |
| 51 | - // }else{ | |
| 52 | - // $('#app').show(); | |
| 53 | - // } | |
| 37 | + var playUrl; | |
| 38 | + var playData; | |
| 39 | + var playTreePathData = {"tree": []}; | |
| 40 | + | |
| 41 | + var playFoo = { | |
| 42 | + showPLayError: function(){ | |
| 43 | + utils.errorVisit.template = $('<div id="tips" class="tips">' + | |
| 44 | + '<div class="tips-inner">' + | |
| 45 | + '访问参数出错,请联系管理人员。' + | |
| 46 | + '</div>' + | |
| 47 | + '</div>'); | |
| 48 | + utils.errorVisit.show(); | |
| 49 | + }, | |
| 50 | + programFileListToTreeJson: function(arr){ | |
| 51 | + var playTreeFolder = [], | |
| 52 | + playTreeFile = []; | |
| 53 | + var n = 0, | |
| 54 | + m = 0 | |
| 55 | + l = 0; | |
| 56 | + playData.programmingFileList.length = 10; | |
| 57 | + for (var i = 0; i < playData.programmingFileList.length; i++) { | |
| 58 | + var temArr = playData.programmingFileList[i].path.split('/'); | |
| 59 | + if(playTreeFolder.length > 0){ | |
| 60 | + for (var j = 0; j < playTreeFolder.length; j++) { | |
| 61 | + if(playTreeFolder[j]){ | |
| 62 | + if(playTreeFolder[j].name != temArr[0]){ | |
| 63 | + playTreeFolder[n] = {"name": temArr[0], "open": true, "isParent": true, "collapse": false }; | |
| 64 | + }else{ | |
| 65 | + // console.log('playTreeFolder[j] else'); | |
| 66 | + } | |
| 67 | + } | |
| 68 | + } | |
| 69 | + }else{ | |
| 70 | + playTreeFolder[n] = {"name": temArr[0], "open": true, "isParent": true, "collapse": false }; | |
| 71 | + n++; | |
| 72 | + } | |
| 73 | + | |
| 74 | + if(playTreeFile.length > 0){ | |
| 75 | + for (var j = 0; j < playTreeFile.length; j++) { | |
| 76 | + if(playTreeFile[j]){ | |
| 77 | + if(playTreeFile[j].name != temArr[1]){ | |
| 78 | + playTreeFile[m] = {'pName': temArr[0], "name": temArr[1], "type": "java" }; | |
| 79 | + }else{ | |
| 80 | + playTreeFile[m] = {'pName': temArr[0], "name": temArr[1], "type": "java" }; | |
| 81 | + m++; | |
| 82 | + } | |
| 83 | + } | |
| 84 | + } | |
| 85 | + }else{ | |
| 86 | + playTreeFile[m] = {'pName': temArr[0], "name": temArr[1], "type": "java" }; | |
| 87 | + m++; | |
| 88 | + } | |
| 89 | + } | |
| 90 | + for (var i = 0; i < playTreeFolder.length; i++) { | |
| 91 | + playTreeFolder[i].pId = 0; | |
| 92 | + playTreeFolder[i].id = i+1; | |
| 93 | + playTreePathData['tree'].push(playTreeFolder[i]); | |
| 94 | + } | |
| 95 | + for (var i = 0; i < playTreeFile.length; i++) { | |
| 96 | + for (var j = 0; j < playTreeFolder.length; j++) { | |
| 97 | + if(playTreeFile[i].pName == playTreeFolder[j].name){ | |
| 98 | + playTreeFile[i].id = (playTreeFolder[j].id.toString() + i.toString()) * 1; | |
| 99 | + playTreeFile[i].pId = playTreeFolder[j].id; | |
| 100 | + playTreePathData.tree.push(playTreeFile[i]); | |
| 101 | + } | |
| 102 | + } | |
| 103 | + } | |
| 104 | + return playTreePathData.tree; | |
| 105 | + } | |
| 54 | 106 | } |
| 55 | - $('#app').show(); | |
| 107 | + | |
| 56 | 108 | // 储存一个树结构和编辑器的对应关系 |
| 57 | 109 | var treeLinkEditor = [], // 缓存整个目录树结构和代码编辑器的关系 |
| 58 | 110 | treeData = {}, // 缓存目录树返回结果 |
| 59 | 111 | mainPath, // 运行编译时候需要知道当前是哪个文件 |
| 60 | 112 | fileList, // 有值的文件数据结构 |
| 61 | 113 | treeObj; // 获取ztree对象 |
| 62 | - | |
| 63 | - var ZTREE = { | |
| 64 | - /** | |
| 65 | - * ztreeSetting 配置文件 | |
| 66 | - * @Author syantao | |
| 67 | - * Created by Keystion on 2017-01-19 | |
| 68 | - */ | |
| 69 | - config: { | |
| 70 | - view: { showLine: false } | |
| 71 | - ,data: { | |
| 72 | - simpleData: { enable: true } | |
| 114 | + var treeFoo = { | |
| 115 | + beforeClick: function (treeId, treeNode){ | |
| 116 | + console.info('ZTREE.config.callback.beforeClick'); | |
| 117 | + console.log('点击了 ' + treeNode.name); | |
| 118 | + console.log(treeNode); | |
| 119 | + // 判断是否点击了文件夹 | |
| 120 | + if (treeNode.isParent) { | |
| 121 | + return false; | |
| 73 | 122 | } |
| 74 | - ,callback: { | |
| 75 | - /** | |
| 76 | - * ztree 每一项点击事件 | |
| 77 | - * @Author syantao | |
| 78 | - * Created by Keystion on 2017-01-19 | |
| 79 | - */ | |
| 80 | - beforeClick: function(treeId, treeNode){ | |
| 81 | - console.info('ZTREE.config.callback.beforeClick'); | |
| 82 | - console.log('点击了 ' + treeNode.name); | |
| 83 | - console.log(treeNode); | |
| 84 | - // 判断是否点击了文件夹 | |
| 85 | - if (treeNode.isParent) { | |
| 123 | + treeObj.expandNode(treeNode); | |
| 124 | + console.log(GBCodePlayBack.isRecordPlay); | |
| 125 | + if (GBCodePlayBack.isRecordPlay == 1) { | |
| 126 | + GBCodePlayBack.check_tree_time = new Date().getTime(); // 获取焦点的时间 | |
| 127 | + var recordobj = { | |
| 128 | + intervaltime: GBCodePlayBack.check_tree_time - GBCodePlayBack.record_startime, | |
| 129 | + editor: 'tab', | |
| 130 | + changeobj: { | |
| 131 | + from: { | |
| 132 | + ch: 0, | |
| 133 | + line: 0, | |
| 134 | + }, | |
| 135 | + text: '', | |
| 136 | + to: { | |
| 137 | + ch: 0, | |
| 138 | + line: 0, | |
| 139 | + } | |
| 140 | + }, | |
| 141 | + treefile: treeNode, | |
| 142 | + trigger: 0, | |
| 143 | + playTime: 0 | |
| 144 | + }; | |
| 145 | + GBCodePlayBack.records.push(recordobj); | |
| 146 | + console.log(GBCodePlayBack.records); | |
| 147 | + GBCodePlayBack.record_startime = GBCodePlayBack.check_tree_time; | |
| 148 | + } | |
| 149 | + | |
| 150 | + console.log(GBCodePlayBack.records); | |
| 151 | + // 处理显示目录树对应的编辑器目录 | |
| 152 | + ZTREE.showEdite({'treeNode': treeNode}); | |
| 153 | + }, | |
| 154 | + beforeDrag: function (treeId, treeNodes) { | |
| 155 | + return false; | |
| 156 | + }, | |
| 157 | + beforeEditName: function (treeId, treeNode) { | |
| 158 | + treeObj.selectNode(treeNode); | |
| 159 | + setTimeout(function() { | |
| 160 | + // if (confirm("进入节点 -- " + treeNode.name + " 的编辑状态吗?")) { | |
| 161 | + // setTimeout(function() { | |
| 162 | + treeObj.editName(treeNode); | |
| 163 | + // }, 0); | |
| 164 | + // } | |
| 165 | + }, 0); | |
| 166 | + return false; | |
| 167 | + }, | |
| 168 | + renameAlert: function (str, treeNode){ | |
| 169 | + setTimeout(function() { | |
| 170 | + // treeObj.cancelEditName(newName); | |
| 171 | + alert(str); | |
| 172 | + }, 0); | |
| 173 | + | |
| 174 | + // 优化体验再次进入编辑状态 | |
| 175 | + setTimeout(function() { | |
| 176 | + treeObj.selectNode(treeNode); | |
| 177 | + treeObj.editName(treeNode); | |
| 178 | + }, 0); | |
| 179 | + }, | |
| 180 | + beforeRename: function (treeId, treeNode, newName, isCancel) { | |
| 181 | + var _this = this; | |
| 182 | + // console.info('beforeRename'); | |
| 183 | + // console.info(treeNode); | |
| 184 | + if (newName.length == 0) { | |
| 185 | + treeFoo.renameAlert("文件名名称不能为空.", treeNode); | |
| 186 | + return false; | |
| 187 | + }else if(newName != treeNode.name){ | |
| 188 | + for (var i = 0; i < treeLinkEditor.length; i++) { | |
| 189 | + | |
| 190 | + // 判断是否重名 | |
| 191 | + if(treeLinkEditor[i].file === newName){ | |
| 192 | + treeFoo.renameAlert("文件名“" + newName + "”已被占用,请选取其他名称。", treeNode); | |
| 86 | 193 | return false; |
| 194 | + }else if(/.java$/.test(newName) && newName.split('.').length > 2){ | |
| 195 | + treeFoo.renameAlert("文件名“" + newName + "”有误,请选取其他名称。", treeNode); | |
| 196 | + return false; | |
| 197 | + }else if(!/.java$/.test(newName)){ | |
| 198 | + treeFoo.renameAlert("文件后缀名“" + newName + "”有误,请选取其他名称。", treeNode); | |
| 199 | + return false; | |
| 200 | + }else{ | |
| 201 | + console.log('else'); | |
| 202 | + // 更新 treeLinkEditor 存值 | |
| 203 | + if(treeLinkEditor[i].file === treeNode.name){ | |
| 204 | + console.log('更新前'); | |
| 205 | + console.log(treeLinkEditor[i]); | |
| 206 | + console.log(treeNode); | |
| 207 | + console.log(newName); | |
| 208 | + console.log('\n\n\n'); | |
| 209 | + var _temName = treeLinkEditor[i].name; | |
| 210 | + var _name = ZTREE.manageName(newName); | |
| 211 | + console.log(_temName); | |
| 212 | + console.log(_name); | |
| 213 | + | |
| 214 | + // 缓存值得更新 | |
| 215 | + treeLinkEditor[i].name = _name; | |
| 216 | + treeLinkEditor[i].file = newName; | |
| 217 | + treeLinkEditor[i].filePath = ZTREE.getTreePath(treeNode.name, newName); | |
| 218 | + treeLinkEditor[i].record = _name + 'Record'; | |
| 219 | + treeLinkEditor[i].replay = _name + 'Replay'; | |
| 220 | + treeLinkEditor[i].CodeMirrorRecordId = treeLinkEditor[i].record + 'CodeMirror'; | |
| 221 | + treeLinkEditor[i].CodeMirrorReplayId = treeLinkEditor[i].replay + 'CodeMirror'; | |
| 222 | + | |
| 223 | + console.log('更新后'); | |
| 224 | + console.log(treeLinkEditor[i]); | |
| 225 | + mainPath = treeLinkEditor[i].filePath; | |
| 226 | + | |
| 227 | + // 更新DOM相关 | |
| 228 | + $('#'+ _temName +'RecordWrap').attr({ | |
| 229 | + id: _name +'RecordWrap' | |
| 230 | + }); | |
| 231 | + $('#'+ _temName + 'Record').attr({ | |
| 232 | + id: _name + 'Record', | |
| 233 | + title: _name | |
| 234 | + }); | |
| 235 | + $('#'+ _temName + 'RecordCodeMirror').attr({ | |
| 236 | + id: _name + 'RecordCodeMirror' | |
| 237 | + }); | |
| 238 | + | |
| 239 | + $('#'+ _temName +'ReplayWrap').attr({ | |
| 240 | + id: _name +'ReplayWrap' | |
| 241 | + }); | |
| 242 | + $('#'+ _temName + 'Replay').attr({ | |
| 243 | + id: _name + 'Replay', | |
| 244 | + title: _name | |
| 245 | + }); | |
| 246 | + $('#'+ _temName + 'ReplayCodeMirror').attr({ | |
| 247 | + id: _name + 'ReplayCodeMirror' | |
| 248 | + }); | |
| 249 | + } | |
| 87 | 250 | } |
| 88 | - treeObj = $.fn.zTree.getZTreeObj("folder"); | |
| 89 | - treeObj.expandNode(treeNode); | |
| 90 | - console.log(GBCodePlayBack.isRecordPlay); | |
| 91 | - if (GBCodePlayBack.isRecordPlay == 1) { | |
| 92 | - GBCodePlayBack.check_tree_time = new Date().getTime(); // 获取焦点的时间 | |
| 93 | - var recordobj = { | |
| 94 | - intervaltime: GBCodePlayBack.check_tree_time - GBCodePlayBack.record_startime, | |
| 95 | - editor: 'tab', | |
| 96 | - changeobj: { | |
| 97 | - from: { | |
| 98 | - ch: 0, | |
| 99 | - line: 0, | |
| 100 | - }, | |
| 101 | - text: '', | |
| 102 | - to: { | |
| 103 | - ch: 0, | |
| 104 | - line: 0, | |
| 105 | - } | |
| 106 | - }, | |
| 107 | - treefile: treeNode, | |
| 108 | - trigger: 0, | |
| 109 | - playTime: 0 | |
| 110 | - }; | |
| 111 | - GBCodePlayBack.records.push(recordobj); | |
| 112 | - console.log(GBCodePlayBack.records); | |
| 113 | - GBCodePlayBack.record_startime = GBCodePlayBack.check_tree_time; | |
| 114 | - } | |
| 115 | - | |
| 116 | - console.log(GBCodePlayBack.records); | |
| 117 | - // 处理显示目录树对应的编辑器目录 | |
| 118 | - ZTREE.showEdite({'treeNode': treeNode}); | |
| 119 | 251 | } |
| 252 | + }else{ | |
| 253 | + isCancel = true; | |
| 120 | 254 | } |
| 255 | + return true; | |
| 121 | 256 | }, |
| 257 | + onRename: function (e, treeId, treeNode, isCancel) { | |
| 258 | + console.info('onRename'); | |
| 259 | + }, | |
| 260 | + showRemoveBtn: function (treeId, treeNode) { | |
| 261 | + return !treeNode.isFirstNode; | |
| 262 | + }, | |
| 263 | + showRenameBtn: function (treeId, treeNode) { | |
| 264 | + return !treeNode.isLastNode; | |
| 265 | + }, | |
| 266 | + addHoverDom: function (treeId, treeNode) { | |
| 267 | + // console.info('addHoverDom'); | |
| 268 | + // 修复第一个文件夹 | |
| 269 | + if(treeNode.isParent){ | |
| 270 | + $('a[title="'+ treeNode.name +'"]').find("#" + treeId + "_" + treeNode.id + "_edit").hide(); | |
| 271 | + return false; | |
| 272 | + } | |
| 273 | + | |
| 274 | + // 不知道为什么 ztree 最后一项不显示编辑按钮 | |
| 275 | + // 只能通过改变参数的值来让它显示编辑按钮 | |
| 276 | + if(treeNode.isLastNode){ | |
| 277 | + treeNode.isLastNode = false; | |
| 278 | + } | |
| 279 | + }, | |
| 280 | + removeHoverDom: function (treeId, treeNode) { | |
| 281 | + // console.info('removeHoverDom'); | |
| 282 | + if(!treeNode.isParent){ | |
| 283 | + $("#folder_" + treeNode.tId + "_edit").unbind().remove(); | |
| 284 | + } | |
| 285 | + } | |
| 286 | + } | |
| 287 | + var ZTREE = { | |
| 122 | 288 | /** |
| 123 | 289 | * 通过目录树的点击来显示对应的编辑器 |
| 124 | 290 | * @Author syantao |
| ... | ... | @@ -171,13 +337,18 @@ $(function() { |
| 171 | 337 | * TODO treeNode放到一个变量或者隐藏域里面 |
| 172 | 338 | */ |
| 173 | 339 | // 根据提供的 name 获取 pId , 再根据 pId 获取 夫级 name |
| 174 | - getTreePath: function (name){ | |
| 340 | + // newName 替换 name 更名需求 | |
| 341 | + getTreePath: function (name, newName){ | |
| 175 | 342 | console.info('ZTREE.getTreePath'); |
| 176 | 343 | var _pid, _folder, _filename; |
| 177 | 344 | for (var i = 0; i < treeData.length; i++) { |
| 178 | 345 | if(treeData[i].name == name){ |
| 179 | 346 | _pid = treeData[i].pId; |
| 180 | - _filename = treeData[i].name; | |
| 347 | + if(newName){ | |
| 348 | + _filename = newName; | |
| 349 | + }else{ | |
| 350 | + _filename = treeData[i].name; | |
| 351 | + } | |
| 181 | 352 | } |
| 182 | 353 | } |
| 183 | 354 | for (var i = 0; i < treeData.length; i++) { |
| ... | ... | @@ -295,16 +466,119 @@ $(function() { |
| 295 | 466 | var node = treeObj.getNodeByParam("name", _thisName, null); |
| 296 | 467 | |
| 297 | 468 | treeObj.selectNode(node, false, true); |
| 298 | - } | |
| 469 | + }, | |
| 470 | + /** | |
| 471 | + * ztreeSetting 配置文件 | |
| 472 | + * @Author syantao | |
| 473 | + * Created by Keystion on 2017-01-19 | |
| 474 | + */ | |
| 475 | + config: { | |
| 476 | + view: { | |
| 477 | + addHoverDom: treeFoo.addHoverDom, | |
| 478 | + removeHoverDom: treeFoo.removeHoverDom, | |
| 479 | + selectedMulti: false, | |
| 480 | + showLine: false | |
| 481 | + } | |
| 482 | + ,edit: { | |
| 483 | + enable: true, | |
| 484 | + editNameSelectAll: true, | |
| 485 | + showRemoveBtn: false, | |
| 486 | + showRenameBtn: treeFoo.showRenameBtn | |
| 487 | + } | |
| 488 | + ,data: { | |
| 489 | + simpleData: { enable: true } | |
| 490 | + } | |
| 491 | + ,callback: { | |
| 492 | + /** | |
| 493 | + * ztree 每一项点击事件 | |
| 494 | + * @Author syantao | |
| 495 | + * Created by Keystion on 2017-01-19 | |
| 496 | + */ | |
| 497 | + beforeClick: treeFoo.beforeClick, | |
| 498 | + beforeDrag: treeFoo.beforeDrag, | |
| 499 | + beforeEditName: treeFoo.beforeEditName, | |
| 500 | + beforeRename: treeFoo.beforeRename, | |
| 501 | + onRename: treeFoo.onRename | |
| 502 | + } | |
| 503 | + }, | |
| 299 | 504 | } |
| 300 | 505 | |
| 301 | - $(document).on('click', '#cancel', function(event) { | |
| 302 | - event.preventDefault(); | |
| 303 | - /* Act on the event */ | |
| 506 | + if(document.URL.indexOf('player') >= 0){ | |
| 507 | + isReplayPage = true; | |
| 508 | + if (_role == 0) { | |
| 509 | + playUrl = gxb_api + "/programming/codeReplay/" + _codeReplayId + "/api"; | |
| 510 | + } else if (_role == 1) { | |
| 511 | + playUrl = gxb_api + "/programming/student/studentReplay/" + _codeReplayId + "/api"; | |
| 512 | + } | |
| 513 | + $.ajax({ | |
| 514 | + type: "get", | |
| 515 | + url: playUrl, | |
| 516 | + dataType: "json", | |
| 517 | + contentType: "application/json", | |
| 518 | + success: function(res) { | |
| 519 | + console.info(playUrl) | |
| 520 | + console.log(res) | |
| 521 | + // 判断数据是否正常 | |
| 522 | + if(res.codeReplayId){ | |
| 523 | + playData = res; | |
| 524 | + if(playData.programmingFileList){ | |
| 525 | + | |
| 526 | + treeData = playFoo.programFileListToTreeJson(playData.programmingFileList); | |
| 304 | 527 | |
| 305 | - // GBCodePlayBack.resetCodeMirrorValue(); | |
| 528 | + console.log(treeData); | |
| 306 | 529 | |
| 307 | - }); | |
| 530 | + treeData = playTreePathData.tree; | |
| 531 | + treeObj = $.fn.zTree.init($("#folder"), ZTREE.config, treeData); | |
| 532 | + | |
| 533 | + GBCodePlayBack.recordinit(treeData); | |
| 534 | + } | |
| 535 | + $('#app').show(); | |
| 536 | + }else{ | |
| 537 | + playFoo.showPLayError(); | |
| 538 | + } | |
| 539 | + }, | |
| 540 | + error: function() { | |
| 541 | + playFoo.showPLayError(); | |
| 542 | + alert('错误') | |
| 543 | + } | |
| 544 | + }); | |
| 545 | + // if(!_codeReplayId || !_userId || !_role || !_chapterId){ | |
| 546 | + // utils.errorVisit.template = $('<div id="tips" class="tips">' + | |
| 547 | + // '<div class="tips-inner">' + | |
| 548 | + // '访问参数出错,请联系管理人员。' + | |
| 549 | + // '</div>' + | |
| 550 | + // '</div>'); | |
| 551 | + // utils.errorVisit.show(); | |
| 552 | + // }else{ | |
| 553 | + // $('#app').show(); | |
| 554 | + // } | |
| 555 | + }else{ | |
| 556 | + // 动态获取目录结构 | |
| 557 | + // if(!_languageid || !_userId || !_role || !_source){ | |
| 558 | + // utils.errorVisit.show(); | |
| 559 | + // }else{ | |
| 560 | + $.ajax({ | |
| 561 | + type: "GET", | |
| 562 | + url: "../js/tree.json", | |
| 563 | + dataType: "json", | |
| 564 | + contentType: "application/json", | |
| 565 | + success: function(res) { | |
| 566 | + console.info(); | |
| 567 | + treeData = res.tree; | |
| 568 | + | |
| 569 | + treeObj = $.fn.zTree.init($("#folder"), ZTREE.config, treeData); | |
| 570 | + | |
| 571 | + GBCodePlayBack.recordinit(treeData); | |
| 572 | + | |
| 573 | + }, | |
| 574 | + error: function(XMLHttpRequest, textStatus, errorThrown) { | |
| 575 | + console.log('Ajax tree.json error'); | |
| 576 | + console.log(XMLHttpRequest); | |
| 577 | + } | |
| 578 | + }); | |
| 579 | + $('#app').show(); | |
| 580 | + // } | |
| 581 | + } | |
| 308 | 582 | |
| 309 | 583 | // 根据不同的角色渲染页面 |
| 310 | 584 | if (_role == 1) { |
| ... | ... | @@ -661,104 +935,68 @@ $(function() { |
| 661 | 935 | |
| 662 | 936 | |
| 663 | 937 | if (document.URL.indexOf('player.htm') >= 0) { |
| 664 | - if (_role == 0) { | |
| 665 | - var apiUrl = gxb_api + "/programming/codeReplay/" + _codeReplayId + "/api"; | |
| 666 | - // var apiUrl = gxb_api + "/gxb-web/programmingMulti/" + _codeReplayId + "/api"; | |
| 667 | - // var apiUrl = "../js/codedata.json"; | |
| 668 | - | |
| 669 | - initPlayerPage(apiUrl) | |
| 670 | - | |
| 671 | - } else if (_role == 1) { | |
| 672 | - var apiUrl = gxb_api + "/programming/student/studentReplay/" + _codeReplayId + "/api"; | |
| 673 | - // var apiUrl = gxb_api + "/gxb-web/programmingMulti/" + _codeReplayId + "/api"; | |
| 674 | - // var apiUrl = "../js/codedata.json"; | |
| 675 | - | |
| 676 | - initPlayerPage(apiUrl) | |
| 677 | - } | |
| 938 | + initPlayerPage() | |
| 678 | 939 | } else { |
| 679 | 940 | compileMode(_languageid) |
| 680 | 941 | } |
| 681 | 942 | |
| 682 | 943 | // 初始化渲染页面 |
| 683 | - function initPlayerPage(apiUrl) { | |
| 684 | - initJavaPage(treeData) | |
| 685 | - $.ajax({ | |
| 686 | - type: "get", | |
| 687 | - url: apiUrl, | |
| 688 | - dataType: "json", | |
| 689 | - contentType: "application/json", | |
| 690 | - success: function(coderecords) { | |
| 691 | - console.log(coderecords); | |
| 692 | - var langid = parseInt(coderecords.languageid); | |
| 693 | - selectLang(langid); | |
| 694 | - compileMode(langid); | |
| 695 | - | |
| 696 | - // $("#play_audio").attr('src', "http://gxb-file.oss-cn-beijing.aliyuncs.com" + coderecords.audioUrl); | |
| 697 | - // $("#play_audio").attr('src', coderecords.audioUrl); | |
| 698 | - console.log("http://gxb-file.oss-cn-beijing.aliyuncs.com" + coderecords.audioUrl) | |
| 699 | - var flag = true; | |
| 700 | - player.init({ | |
| 701 | - container: '#audioWrap', | |
| 702 | - source: "http://gxb-file.oss-cn-beijing.aliyuncs.com" + coderecords.audioUrl, | |
| 703 | - imagePath: '../js/audioPlayer/image', | |
| 704 | - debuggers: false, | |
| 705 | - allowSeek: false, | |
| 706 | - playCallback: function() { // 播放 | |
| 707 | - console.log('++++++++') | |
| 708 | - if(flag){ | |
| 709 | - playCode(); | |
| 710 | - } | |
| 711 | - | |
| 712 | - // $('#play').trigger('click'); | |
| 713 | - // GBCodePlayBack.htmlplayereditor.setOption('readOnly', true); | |
| 714 | - }, | |
| 715 | - pauseCallback: function() { // 暂停 | |
| 716 | - flag = false; | |
| 717 | - player.play(); | |
| 718 | - // GBCodePlayBack.audioTime = parseInt(player.elements.audioDom.currentTime*1000) | |
| 719 | - // pauseCode(); | |
| 720 | - // GBCodePlayBack.firstPlay = 0; | |
| 721 | - // GBCodePlayBack.getCodeMirrorValue(); | |
| 722 | - | |
| 723 | - // GBCodePlayBack.pauseValue = GBCodePlayBack.htmlplayereditor.getValue(); | |
| 724 | - // GBCodePlayBack.htmlplayereditor.setOption('readOnly', false); | |
| 725 | - | |
| 726 | - console.log(GBCodePlayBack.pauseValue); | |
| 727 | - }, | |
| 728 | - seekedCallback: function() { // 拖拽 | |
| 729 | - | |
| 730 | - }, | |
| 731 | - endedCallback: function() { // 结束播放 | |
| 732 | - playEnd() | |
| 733 | - } | |
| 734 | - }); | |
| 735 | - | |
| 736 | - var coderecords = coderecords.codeRecordList; | |
| 737 | - console.log(coderecords); | |
| 738 | - // if (_role == 0) { | |
| 739 | - // var coderecords = coderecords.codeRecordList; | |
| 740 | - // } else if (_role == 1) { | |
| 741 | - // var coderecords = coderecords.studentRecordList; | |
| 742 | - // } | |
| 743 | - // GBCodePlayBack.htmlplayereditor.setValue(''); | |
| 744 | - // GBCodePlayBack.cssplayereditor.setValue(''); | |
| 745 | - // GBCodePlayBack.jsplayereditor.setValue(''); | |
| 746 | - | |
| 747 | - var starttime = 0; | |
| 748 | - for (var i = 0; i < coderecords.length; i++) { | |
| 749 | - if (!coderecords[i].trigger) coderecords[i].trigger = 0; | |
| 750 | - coderecords[i].changeobj = jQuery.parseJSON(coderecords[i].changeobj); | |
| 751 | - coderecords[i].treefile = jQuery.parseJSON(coderecords[i].treefile); | |
| 944 | + function initPlayerPage() { | |
| 945 | + console.info('initPlayerPage') | |
| 946 | + console.log(playData); | |
| 947 | + var langid = parseInt(playData.languageid); | |
| 948 | + var coderecords = playData.codeRecordList; | |
| 949 | + var flag = true; | |
| 950 | + | |
| 951 | + selectLang(langid); | |
| 952 | + compileMode(langid); | |
| 953 | + | |
| 954 | + console.log("http://gxb-file.oss-cn-beijing.aliyuncs.com" + playData.audioUrl) | |
| 955 | + player.init({ | |
| 956 | + container: '#audioWrap', | |
| 957 | + source: "http://gxb-file.oss-cn-beijing.aliyuncs.com" + playData.audioUrl, | |
| 958 | + imagePath: '../js/audioPlayer/image', | |
| 959 | + debuggers: false, | |
| 960 | + allowSeek: false, | |
| 961 | + playCallback: function() { // 播放 | |
| 962 | + console.log('++++++++') | |
| 963 | + if(flag){ | |
| 964 | + playCode(); | |
| 752 | 965 | } |
| 753 | - | |
| 754 | - GBCodePlayBack.records = coderecords; | |
| 755 | - console.log(GBCodePlayBack.records); | |
| 966 | + | |
| 967 | + // $('#play').trigger('click'); | |
| 968 | + // GBCodePlayBack.htmlplayereditor.setOption('readOnly', true); | |
| 756 | 969 | }, |
| 757 | - error: function() { | |
| 758 | - console.log('-------------------'); | |
| 759 | - alert('错误') | |
| 970 | + pauseCallback: function() { // 暂停 | |
| 971 | + flag = false; | |
| 972 | + player.play(); | |
| 973 | + // GBCodePlayBack.audioTime = parseInt(player.elements.audioDom.currentTime*1000) | |
| 974 | + // pauseCode(); | |
| 975 | + // GBCodePlayBack.firstPlay = 0; | |
| 976 | + // GBCodePlayBack.getCodeMirrorValue(); | |
| 977 | + | |
| 978 | + // GBCodePlayBack.pauseValue = GBCodePlayBack.htmlplayereditor.getValue(); | |
| 979 | + // GBCodePlayBack.htmlplayereditor.setOption('readOnly', false); | |
| 980 | + | |
| 981 | + console.log(GBCodePlayBack.pauseValue); | |
| 982 | + }, | |
| 983 | + seekedCallback: function() { // 拖拽 | |
| 984 | + | |
| 985 | + }, | |
| 986 | + endedCallback: function() { // 结束播放 | |
| 987 | + playEnd() | |
| 760 | 988 | } |
| 761 | 989 | }); |
| 990 | + | |
| 991 | + var starttime = 0; | |
| 992 | + for (var i = 0; i < coderecords.length; i++) { | |
| 993 | + if (!coderecords[i].trigger) coderecords[i].trigger = 0; | |
| 994 | + coderecords[i].changeobj = jQuery.parseJSON(coderecords[i].changeobj); | |
| 995 | + coderecords[i].treefile = jQuery.parseJSON(coderecords[i].treefile); | |
| 996 | + } | |
| 997 | + | |
| 998 | + GBCodePlayBack.records = coderecords; | |
| 999 | + console.log(GBCodePlayBack.records); | |
| 762 | 1000 | } |
| 763 | 1001 | |
| 764 | 1002 | // 使编辑器满屏 |
| ... | ... | @@ -1307,90 +1545,6 @@ $(function() { |
| 1307 | 1545 | alert('代码保存失败重新保存') |
| 1308 | 1546 | } |
| 1309 | 1547 | }); |
| 1310 | - | |
| 1311 | - // replaydto.html = GBCodePlayBack.htmleditor.getValue(); | |
| 1312 | - // replaydto.css = GBCodePlayBack.csseditor.getValue(); | |
| 1313 | - // replaydto.javascript = GBCodePlayBack.jseditor.getValue(); | |
| 1314 | - // // replaydto.audioUrl = $('.audio-url').val(); | |
| 1315 | - // replaydto.audioUrl = '/uploads/programming_audio/link/17/01/24/38029c9698e144d2bd590b35eb6af56e'; | |
| 1316 | - // replaydto.deleteFlag = 1 | |
| 1317 | - | |
| 1318 | - // //保存序列化录制内容 | |
| 1319 | - // var recorddatas = []; | |
| 1320 | - // for (var i = 0; i < GBCodePlayBack.records.length; i++) { | |
| 1321 | - // console.log(GBCodePlayBack.records); | |
| 1322 | - // var recorddata = { | |
| 1323 | - // intervaltime: GBCodePlayBack.records[i].intervaltime, | |
| 1324 | - // editor: GBCodePlayBack.records[i].editor, | |
| 1325 | - // changeobj: JSON.stringify(GBCodePlayBack.records[i].changeobj), | |
| 1326 | - // cmpinfo: GBCodePlayBack.records[i].cmpinfo, | |
| 1327 | - // output: GBCodePlayBack.records[i].output, | |
| 1328 | - // result: GBCodePlayBack.records[i].result, | |
| 1329 | - // stderr: GBCodePlayBack.records[i].stderr | |
| 1330 | - // } | |
| 1331 | - | |
| 1332 | - // recorddatas.push(recorddata); | |
| 1333 | - // } | |
| 1334 | - | |
| 1335 | - // //回放入库 | |
| 1336 | - // recorddatas.deleteFlag = 1 | |
| 1337 | - | |
| 1338 | - // var keepTimer = $('.recording-time').val() | |
| 1339 | - // replaydto.totaltime = parseInt(keepTimer); | |
| 1340 | - // if (_role == 0) { | |
| 1341 | - // replaydto.codeRecordList = recorddatas; | |
| 1342 | - // $.ajax({ | |
| 1343 | - // type: "post", | |
| 1344 | - // url: gxb_api + "/programming/codeReplay/api", | |
| 1345 | - // data: JSON.stringify(replaydto), | |
| 1346 | - // dataType: "json", | |
| 1347 | - // contentType: "application/json", | |
| 1348 | - // success: function(data) { | |
| 1349 | - // $(window).unbind('beforeunload'); | |
| 1350 | - // var _data = { | |
| 1351 | - // "programId": data.codeReplayId, | |
| 1352 | - // "programLanguageName": data.languageName, | |
| 1353 | - // "programAudioLength": keepTimer | |
| 1354 | - // } | |
| 1355 | - // $('.upload-tip').hide(); | |
| 1356 | - | |
| 1357 | - // $('#cancel').prop("disabled", false); | |
| 1358 | - | |
| 1359 | - // window.opener.postMessage(_data, _source); | |
| 1360 | - // window.close(); | |
| 1361 | - // }, | |
| 1362 | - // error: function() { | |
| 1363 | - // $('.upload-tip').hide(); | |
| 1364 | - // alert('代码保存失败重新保存') | |
| 1365 | - // } | |
| 1366 | - // }); | |
| 1367 | - // } else if (_role == 1) { | |
| 1368 | - // replaydto.studentRecordList = recorddatas; | |
| 1369 | - // $.ajax({ | |
| 1370 | - // type: "post", | |
| 1371 | - // url: gxb_api + "/programming/student/studentReplay/api", | |
| 1372 | - // data: JSON.stringify(replaydto), | |
| 1373 | - // dataType: "json", | |
| 1374 | - // contentType: "application/json", | |
| 1375 | - // success: function(data) { | |
| 1376 | - // $(window).unbind('beforeunload'); | |
| 1377 | - // var _data = { | |
| 1378 | - // "programId": data.studentReplayId, | |
| 1379 | - // "programLanguageName": data.languageName, | |
| 1380 | - // "programAudioLength": keepTimer | |
| 1381 | - // } | |
| 1382 | - // $('.upload-tip').hide(); | |
| 1383 | - // $('#cancel').prop("disabled", false); | |
| 1384 | - // window.opener.postMessage(_data, _source); | |
| 1385 | - // window.close(); | |
| 1386 | - // }, | |
| 1387 | - // error: function() { | |
| 1388 | - // $('.upload-tip').hide(); | |
| 1389 | - // alert('代码保存失败重新保存') | |
| 1390 | - // } | |
| 1391 | - // }); | |
| 1392 | - // } | |
| 1393 | - | |
| 1394 | 1548 | }); |
| 1395 | 1549 | |
| 1396 | 1550 | $('#toggle_replay_enhancement').click(function() { |
| ... | ... | @@ -1683,23 +1837,23 @@ $(function() { |
| 1683 | 1837 | var isRightResizing = false; |
| 1684 | 1838 | var _width = 0; |
| 1685 | 1839 | var _tempWidth = 0; |
| 1686 | - var appLeftRatio = 140 / appMinWidth; | |
| 1840 | + var appLeftRatio = 200 / appMinWidth; | |
| 1687 | 1841 | var appRightRatio = 320 / appMinWidth; |
| 1688 | 1842 | |
| 1689 | 1843 | if($(window).width() <= appMinWidth){ |
| 1690 | 1844 | $('body').width(appMinWidth) |
| 1691 | 1845 | app.width(appMinWidth); |
| 1692 | 1846 | appContainer.height($(window).height() - appFooter.height()); |
| 1693 | - appLeft.width(140); | |
| 1847 | + appLeft.width(200); | |
| 1694 | 1848 | appMian.width(400); |
| 1695 | 1849 | appRight.width(320); |
| 1696 | - appMainHeader.css('margin-left', -140); | |
| 1850 | + appMainHeader.css('margin-left', -200); | |
| 1697 | 1851 | $('.recording-ctrl-bar').css('padding', '0 20px'); |
| 1698 | 1852 | }else{ |
| 1699 | 1853 | $('body').width('100%'); |
| 1700 | 1854 | app.width('100%'); |
| 1701 | 1855 | appContainer.height($(window).height() - appFooter.height()); |
| 1702 | - appLeft.width(140); | |
| 1856 | + appLeft.width(200); | |
| 1703 | 1857 | appMian.width(parseInt($(window).width() - appLeft.width() - appRight.width())); |
| 1704 | 1858 | appRight.width(320); |
| 1705 | 1859 | appMainHeader.css('margin-left', -appLeft.width()); |
| ... | ... | @@ -1986,26 +2140,6 @@ $(function() { |
| 1986 | 2140 | |
| 1987 | 2141 | $('.record-before').hide(); |
| 1988 | 2142 | |
| 1989 | - // 动态获取目录结构 | |
| 1990 | - $.ajax({ | |
| 1991 | - type: "GET", | |
| 1992 | - url: "../js/tree.json", | |
| 1993 | - dataType: "json", | |
| 1994 | - contentType: "application/json", | |
| 1995 | - success: function(res) { | |
| 1996 | - console.info(); | |
| 1997 | - treeData = res.tree; | |
| 1998 | - | |
| 1999 | - treeObj = $.fn.zTree.init($("#folder"), ZTREE.config, treeData); | |
| 2000 | - | |
| 2001 | - GBCodePlayBack.recordinit(treeData); | |
| 2002 | - }, | |
| 2003 | - error: function(XMLHttpRequest, textStatus, errorThrown) { | |
| 2004 | - console.log('Ajax tree.json error'); | |
| 2005 | - console.log(XMLHttpRequest); | |
| 2006 | - } | |
| 2007 | - }); | |
| 2008 | - | |
| 2009 | 2143 | $(window).resize(function() { |
| 2010 | 2144 | setTimeout(function () { |
| 2011 | 2145 | GBCodePlayBack.resizeWindow(); |
| ... | ... | @@ -2055,6 +2189,13 @@ $(function() { |
| 2055 | 2189 | // 切换到录制区域 |
| 2056 | 2190 | $('#recordertab a:eq(0)').tab('show'); |
| 2057 | 2191 | |
| 2192 | + // 禁止重命名 | |
| 2193 | + setTimeout(function(){ | |
| 2194 | + treeObj.setting.edit.showRenameBtn = false; | |
| 2195 | + treeObj.setting.edit.enable = false; | |
| 2196 | + $('.button.edit').hide(); | |
| 2197 | + },0) | |
| 2198 | + | |
| 2058 | 2199 | // 编译状态 |
| 2059 | 2200 | var data = $(this).attr('data'); |
| 2060 | 2201 | var seconds = 0; |
| ... | ... | @@ -2321,7 +2462,7 @@ $(function() { |
| 2321 | 2462 | ladda.remove(); |
| 2322 | 2463 | alert('错误'); |
| 2323 | 2464 | console.log(XMLHttpRequest); |
| 2324 | - } | |
| 2465 | + }, | |
| 2325 | 2466 | }); |
| 2326 | 2467 | |
| 2327 | 2468 | // var code = (typeof GBCodePlayBack.htmleditor !=='undefined' && GBCodePlayBack.htmleditor.getValue()) |
| ... | ... | @@ -2378,7 +2519,7 @@ $(function() { |
| 2378 | 2519 | // 编译结果 |
| 2379 | 2520 | function compileResult(data, value) { |
| 2380 | 2521 | var runtimeArgus = value || ''; |
| 2381 | - console.log('********************************') | |
| 2522 | + console.info('compileResult') | |
| 2382 | 2523 | if (value != '') { |
| 2383 | 2524 | $('#cmprun-tabs a[href="#stdin"]').tab('show'); |
| 2384 | 2525 | $('#stdin input').val(runtimeArgus); |
| ... | ... | @@ -2721,7 +2862,7 @@ $(function() { |
| 2721 | 2862 | } |
| 2722 | 2863 | } |
| 2723 | 2864 | function processChangeObject(playbackcm, obj) { |
| 2724 | - console.log('processChangeObject'); | |
| 2865 | + console.info('processChangeObject'); | |
| 2725 | 2866 | // 菜单选中 |
| 2726 | 2867 | ZTREE.showEdite({'treeNode': {'name': getEditor(playbackcm, 'name')},'replay': true}); |
| 2727 | 2868 | for (var i = 0; i < obj.text.length; i++) { | ... | ... |
src/scss/recording.scss
src/v1.1/index.html
| ... | ... | @@ -52,6 +52,7 @@ |
| 52 | 52 | |
| 53 | 53 | <link rel="stylesheet" href="../css/demo.css"> |
| 54 | 54 | <script type="text/javascript" src="../js/zTree_v3-3.5.27/js/jquery.ztree.core.js"></script> |
| 55 | + <script type="text/javascript" src="../js/zTree_v3-3.5.27/js/jquery.ztree.exedit.js"></script> | |
| 55 | 56 | <script src="../js/gb.js"></script> |
| 56 | 57 | <!-- <script src="../js/gbreplayer.js"></script> --> |
| 57 | 58 | ... | ... |