Commit 5bc76a255e128ab0395c9c26c769241262c8fc49

Authored by ykxie
1 parent a62775a9

修改播放暂停

Showing 1 changed file with 45 additions and 31 deletions
src/js/gb.js
... ... @@ -78,16 +78,16 @@ $(function() {
78 78 * Created by Keystion on 2017-01-19
79 79 */
80 80 beforeClick: function(treeId, treeNode){
81   - console.info('ZTREE.config.callback.beforeClick');
82   - console.log('点击了 ' + treeNode.name);
83   - console.log(treeNode);
  81 + // console.info('ZTREE.config.callback.beforeClick');
  82 + // console.log('点击了 ' + treeNode.name);
  83 + // console.log(treeNode);
84 84 // 判断是否点击了文件夹
85 85 if (treeNode.isParent) {
86 86 return false;
87 87 }
88 88 treeObj = $.fn.zTree.getZTreeObj("folder");
89 89 treeObj.expandNode(treeNode);
90   - console.log(GBCodePlayBack.isRecordPlay);
  90 + // console.log(GBCodePlayBack.isRecordPlay);
91 91 if (GBCodePlayBack.isRecordPlay == 1) {
92 92 GBCodePlayBack.check_tree_time = new Date().getTime(); // 获取焦点的时间
93 93 var recordobj = {
... ... @@ -109,11 +109,11 @@ $(function() {
109 109 playTime: 0
110 110 };
111 111 GBCodePlayBack.records.push(recordobj);
112   - console.log(GBCodePlayBack.records);
  112 + // console.log(GBCodePlayBack.records);
113 113 GBCodePlayBack.record_startime = GBCodePlayBack.check_tree_time;
114 114 }
115 115  
116   - console.log(GBCodePlayBack.records);
  116 + // console.log(GBCodePlayBack.records);
117 117 // 处理显示目录树对应的编辑器目录
118 118 ZTREE.showEdite({'treeNode': treeNode});
119 119 }
... ... @@ -127,8 +127,8 @@ $(function() {
127 127 * TODO treeNode放到一个变量或者隐藏域里面
128 128 */
129 129 showEdite: function (obj){
130   - console.info('ZTREE.showEdite');
131   - console.log(obj);
  130 + // console.info('ZTREE.showEdite');
  131 + // console.log(obj);
132 132 var _this = this,
133 133 _file,
134 134 _CodeMirrorRecordId,
... ... @@ -157,8 +157,8 @@ $(function() {
157 157 $('#' + _CodeMirrorRecordId).show().parent().show().siblings().hide().find('.CodeMirror').hide();
158 158 $('#' + _CodeMirrorReplayId).show().parent().show().siblings().hide().find('.CodeMirror').hide();
159 159  
160   - console.log('当前选中文件(mainPath):'+ mainPath);
161   - console.log('当前显示代码编辑器:'+ '#' + _CodeMirrorReplayId);
  160 + // console.log('当前选中文件(mainPath):'+ mainPath);
  161 + // console.log('当前显示代码编辑器:'+ '#' + _CodeMirrorReplayId);
162 162  
163 163 // 更新目录树选中状态
164 164 _this.selectTreeItem(_file);
... ... @@ -172,7 +172,7 @@ $(function() {
172 172 */
173 173 // 根据提供的 name 获取 pId , 再根据 pId 获取 夫级 name
174 174 getTreePath: function (name){
175   - console.info('ZTREE.getTreePath');
  175 + // console.info('ZTREE.getTreePath');
176 176 var _pid, _folder, _filename;
177 177 for (var i = 0; i < treeData.length; i++) {
178 178 if(treeData[i].name == name){
... ... @@ -195,7 +195,7 @@ $(function() {
195 195 * @return {[type]} Class1
196 196 */
197 197 ,manageName: function (name){
198   - console.info('ZTREE.manageName');
  198 + // console.info('ZTREE.manageName');
199 199 if(!name){
200 200 return false;
201 201 }
... ... @@ -214,7 +214,7 @@ $(function() {
214 214  
215 215 for (var i = 0; i < treeLinkEditor.length; i++) {
216 216 if(treeLinkEditor[i].CodeMirrorRecordId == _id){
217   - // console.log(treeLinkEditor[i]);
  217 + console.log(treeLinkEditor[i]);
218 218 _name = treeLinkEditor[i].name;
219 219 }
220 220 }
... ... @@ -289,7 +289,7 @@ $(function() {
289 289 * @param {[type]} name 例:Class1.java
290 290 */
291 291 ,selectTreeItem: function (name){
292   - console.info('ZTREE.selectTreeItem');
  292 + // console.info('ZTREE.selectTreeItem');
293 293 var _thisName = name || treeData[1].name;
294 294 // 处理菜单选中状态
295 295 var node = treeObj.getNodeByParam("name", _thisName, null);
... ... @@ -338,7 +338,7 @@ $(function() {
338 338 isPause: 1, // 是否暂停 1:不暂停,0:暂停
339 339 isRcording: 0, // 是否录制 1:录制中,0:暂停中
340 340 recordinit: function(codereplaytype, preload) {
341   - console.info('GBCodePlayBack.recordinit');
  341 + // console.info('GBCodePlayBack.recordinit');
342 342 /* #STRAT:生成CodeMirror Editor for JS/CSS/HTML */
343 343 if (codereplaytype) {
344 344 GBCodePlayBack.isgblibreplay = 1; // 标记GB课程库代码回放 , 1为课程库回放,否则是一般代码回放
... ... @@ -705,25 +705,30 @@ $(function() {
705 705 allowSeek: false,
706 706 playCallback: function() { // 播放
707 707 console.log('++++++++')
708   - if(flag){
709   - playCode();
710   - }
  708 + playCode();
  709 + // if(flag){
  710 + // playCode();
  711 + // }
711 712  
712 713 // $('#play').trigger('click');
713 714 // GBCodePlayBack.htmlplayereditor.setOption('readOnly', true);
714 715 },
715 716 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();
  717 + // flag = false;
  718 + // player.play();
722 719  
723   - // GBCodePlayBack.pauseValue = GBCodePlayBack.htmlplayereditor.getValue();
724   - // GBCodePlayBack.htmlplayereditor.setOption('readOnly', false);
  720 + GBCodePlayBack.audioTime = parseInt(player.elements.audioDom.currentTime*1000)
  721 +
  722 + pauseCode();
  723 + GBCodePlayBack.firstPlay = 0;
  724 + GBCodePlayBack.getCodeMirrorValue();
725 725  
  726 + console.log('---------------------------------------');
726 727 console.log(GBCodePlayBack.pauseValue);
  728 + console.log('---------------------------------------');
  729 +
  730 + // GBCodePlayBack.pauseValue = GBCodePlayBack.htmlplayereditor.getValue();
  731 + // GBCodePlayBack.htmlplayereditor.setOption('readOnly', false);
727 732 },
728 733 seekedCallback: function() { // 拖拽
729 734  
... ... @@ -1956,14 +1961,20 @@ $(function() {
1956 1961 * Created by Kira on 2017-02-08
1957 1962 */
1958 1963 getCodeMirrorValue: function(){
  1964 + GBCodePlayBack.pauseValue = [];
1959 1965 for (var i = 0; i < treeLinkEditor.length; i++) {
1960 1966 console.log(treeLinkEditor[i].CodeMirrorReplay.getValue())
  1967 + // ZTREE.showEdite({'treeNode': {'name': treeLinkEditor[i].file}});
1961 1968 GBCodePlayBack.pauseValue.push(treeLinkEditor[i].CodeMirrorReplay.getValue());
1962 1969 }
1963 1970 },
1964 1971 setCodeMirrorValue: function(){
  1972 + GBCodePlayBack.resetCodeMirrorValue(1);
  1973 + var codeLength = GBCodePlayBack.pauseValue;
  1974 + console.log(treeLinkEditor);
1965 1975 for (var i = 0; i < treeLinkEditor.length; i++) {
1966   - reeLinkEditor[i].CodeMirrorReplay.setValue(GBCodePlayBack.pauseValue[i]);
  1976 + ZTREE.showEdite({'treeNode': {'name': treeLinkEditor[i].file}});
  1977 + treeLinkEditor[i].CodeMirrorReplay.setValue(codeLength[i]);
1967 1978 }
1968 1979 },
1969 1980 /**
... ... @@ -1974,11 +1985,11 @@ $(function() {
1974 1985 editable: function(status){
1975 1986 if (status == 1) {
1976 1987 for (var i = 0; i < treeLinkEditor.length; i++) {
1977   - reeLinkEditor[i].CodeMirrorReplay.setOption('readOnly', false);
  1988 + treeLinkEditor[i].CodeMirrorReplay.setOption('readOnly', false);
1978 1989 }
1979 1990 }else{
1980 1991 for (var i = 0; i < treeLinkEditor.length; i++) {
1981   - reeLinkEditor[i].CodeMirrorReplay.setOption('readOnly', true);
  1992 + treeLinkEditor[i].CodeMirrorReplay.setOption('readOnly', true);
1982 1993 }
1983 1994 }
1984 1995 }
... ... @@ -2285,6 +2296,7 @@ $(function() {
2285 2296 var runtimeArgus = $('#runtimeArgus').val() || '';
2286 2297  
2287 2298 fileList = ZTREE.getTreeData();
  2299 + console.log(fileList);
2288 2300 if(!fileList){
2289 2301 alert('请输入代码');
2290 2302 ladda.remove();
... ... @@ -2628,6 +2640,8 @@ $(function() {
2628 2640 if (GBCodePlayBack.firstPlay == 0) {
2629 2641 $('#readonly').trigger('click');
2630 2642 // GBCodePlayBack.htmlplayereditor.setValue(GBCodePlayBack.pauseValue)
  2643 + GBCodePlayBack.setCodeMirrorValue();
  2644 +
2631 2645 }else{
2632 2646 // GBCodePlayBack.htmlplayereditor.setValue('')
2633 2647 var resultData = {
... ... @@ -2686,8 +2700,8 @@ $(function() {
2686 2700 currentObj = treeLinkEditor[i];
2687 2701 }
2688 2702 }
2689   - console.log('getEditor');
2690   - console.log(currentObj);
  2703 + // console.log('getEditor');
  2704 + // console.log(currentObj);
2691 2705 switch (key) {
2692 2706 case 'name':
2693 2707 return currentObj.name;
... ...