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,16 +78,16 @@ $(function() {
78 * Created by Keystion on 2017-01-19 78 * Created by Keystion on 2017-01-19
79 */ 79 */
80 beforeClick: function(treeId, treeNode){ 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 if (treeNode.isParent) { 85 if (treeNode.isParent) {
86 return false; 86 return false;
87 } 87 }
88 treeObj = $.fn.zTree.getZTreeObj("folder"); 88 treeObj = $.fn.zTree.getZTreeObj("folder");
89 treeObj.expandNode(treeNode); 89 treeObj.expandNode(treeNode);
90 - console.log(GBCodePlayBack.isRecordPlay); 90 + // console.log(GBCodePlayBack.isRecordPlay);
91 if (GBCodePlayBack.isRecordPlay == 1) { 91 if (GBCodePlayBack.isRecordPlay == 1) {
92 GBCodePlayBack.check_tree_time = new Date().getTime(); // 获取焦点的时间 92 GBCodePlayBack.check_tree_time = new Date().getTime(); // 获取焦点的时间
93 var recordobj = { 93 var recordobj = {
@@ -109,11 +109,11 @@ $(function() { @@ -109,11 +109,11 @@ $(function() {
109 playTime: 0 109 playTime: 0
110 }; 110 };
111 GBCodePlayBack.records.push(recordobj); 111 GBCodePlayBack.records.push(recordobj);
112 - console.log(GBCodePlayBack.records); 112 + // console.log(GBCodePlayBack.records);
113 GBCodePlayBack.record_startime = GBCodePlayBack.check_tree_time; 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 ZTREE.showEdite({'treeNode': treeNode}); 118 ZTREE.showEdite({'treeNode': treeNode});
119 } 119 }
@@ -127,8 +127,8 @@ $(function() { @@ -127,8 +127,8 @@ $(function() {
127 * TODO treeNode放到一个变量或者隐藏域里面 127 * TODO treeNode放到一个变量或者隐藏域里面
128 */ 128 */
129 showEdite: function (obj){ 129 showEdite: function (obj){
130 - console.info('ZTREE.showEdite');  
131 - console.log(obj); 130 + // console.info('ZTREE.showEdite');
  131 + // console.log(obj);
132 var _this = this, 132 var _this = this,
133 _file, 133 _file,
134 _CodeMirrorRecordId, 134 _CodeMirrorRecordId,
@@ -157,8 +157,8 @@ $(function() { @@ -157,8 +157,8 @@ $(function() {
157 $('#' + _CodeMirrorRecordId).show().parent().show().siblings().hide().find('.CodeMirror').hide(); 157 $('#' + _CodeMirrorRecordId).show().parent().show().siblings().hide().find('.CodeMirror').hide();
158 $('#' + _CodeMirrorReplayId).show().parent().show().siblings().hide().find('.CodeMirror').hide(); 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 _this.selectTreeItem(_file); 164 _this.selectTreeItem(_file);
@@ -172,7 +172,7 @@ $(function() { @@ -172,7 +172,7 @@ $(function() {
172 */ 172 */
173 // 根据提供的 name 获取 pId , 再根据 pId 获取 夫级 name 173 // 根据提供的 name 获取 pId , 再根据 pId 获取 夫级 name
174 getTreePath: function (name){ 174 getTreePath: function (name){
175 - console.info('ZTREE.getTreePath'); 175 + // console.info('ZTREE.getTreePath');
176 var _pid, _folder, _filename; 176 var _pid, _folder, _filename;
177 for (var i = 0; i < treeData.length; i++) { 177 for (var i = 0; i < treeData.length; i++) {
178 if(treeData[i].name == name){ 178 if(treeData[i].name == name){
@@ -195,7 +195,7 @@ $(function() { @@ -195,7 +195,7 @@ $(function() {
195 * @return {[type]} Class1 195 * @return {[type]} Class1
196 */ 196 */
197 ,manageName: function (name){ 197 ,manageName: function (name){
198 - console.info('ZTREE.manageName'); 198 + // console.info('ZTREE.manageName');
199 if(!name){ 199 if(!name){
200 return false; 200 return false;
201 } 201 }
@@ -214,7 +214,7 @@ $(function() { @@ -214,7 +214,7 @@ $(function() {
214 214
215 for (var i = 0; i < treeLinkEditor.length; i++) { 215 for (var i = 0; i < treeLinkEditor.length; i++) {
216 if(treeLinkEditor[i].CodeMirrorRecordId == _id){ 216 if(treeLinkEditor[i].CodeMirrorRecordId == _id){
217 - // console.log(treeLinkEditor[i]); 217 + console.log(treeLinkEditor[i]);
218 _name = treeLinkEditor[i].name; 218 _name = treeLinkEditor[i].name;
219 } 219 }
220 } 220 }
@@ -289,7 +289,7 @@ $(function() { @@ -289,7 +289,7 @@ $(function() {
289 * @param {[type]} name 例:Class1.java 289 * @param {[type]} name 例:Class1.java
290 */ 290 */
291 ,selectTreeItem: function (name){ 291 ,selectTreeItem: function (name){
292 - console.info('ZTREE.selectTreeItem'); 292 + // console.info('ZTREE.selectTreeItem');
293 var _thisName = name || treeData[1].name; 293 var _thisName = name || treeData[1].name;
294 // 处理菜单选中状态 294 // 处理菜单选中状态
295 var node = treeObj.getNodeByParam("name", _thisName, null); 295 var node = treeObj.getNodeByParam("name", _thisName, null);
@@ -338,7 +338,7 @@ $(function() { @@ -338,7 +338,7 @@ $(function() {
338 isPause: 1, // 是否暂停 1:不暂停,0:暂停 338 isPause: 1, // 是否暂停 1:不暂停,0:暂停
339 isRcording: 0, // 是否录制 1:录制中,0:暂停中 339 isRcording: 0, // 是否录制 1:录制中,0:暂停中
340 recordinit: function(codereplaytype, preload) { 340 recordinit: function(codereplaytype, preload) {
341 - console.info('GBCodePlayBack.recordinit'); 341 + // console.info('GBCodePlayBack.recordinit');
342 /* #STRAT:生成CodeMirror Editor for JS/CSS/HTML */ 342 /* #STRAT:生成CodeMirror Editor for JS/CSS/HTML */
343 if (codereplaytype) { 343 if (codereplaytype) {
344 GBCodePlayBack.isgblibreplay = 1; // 标记GB课程库代码回放 , 1为课程库回放,否则是一般代码回放 344 GBCodePlayBack.isgblibreplay = 1; // 标记GB课程库代码回放 , 1为课程库回放,否则是一般代码回放
@@ -705,25 +705,30 @@ $(function() { @@ -705,25 +705,30 @@ $(function() {
705 allowSeek: false, 705 allowSeek: false,
706 playCallback: function() { // 播放 706 playCallback: function() { // 播放
707 console.log('++++++++') 707 console.log('++++++++')
708 - if(flag){  
709 - playCode();  
710 - } 708 + playCode();
  709 + // if(flag){
  710 + // playCode();
  711 + // }
711 712
712 // $('#play').trigger('click'); 713 // $('#play').trigger('click');
713 // GBCodePlayBack.htmlplayereditor.setOption('readOnly', true); 714 // GBCodePlayBack.htmlplayereditor.setOption('readOnly', true);
714 }, 715 },
715 pauseCallback: function() { // 暂停 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 console.log(GBCodePlayBack.pauseValue); 727 console.log(GBCodePlayBack.pauseValue);
  728 + console.log('---------------------------------------');
  729 +
  730 + // GBCodePlayBack.pauseValue = GBCodePlayBack.htmlplayereditor.getValue();
  731 + // GBCodePlayBack.htmlplayereditor.setOption('readOnly', false);
727 }, 732 },
728 seekedCallback: function() { // 拖拽 733 seekedCallback: function() { // 拖拽
729 734
@@ -1956,14 +1961,20 @@ $(function() { @@ -1956,14 +1961,20 @@ $(function() {
1956 * Created by Kira on 2017-02-08 1961 * Created by Kira on 2017-02-08
1957 */ 1962 */
1958 getCodeMirrorValue: function(){ 1963 getCodeMirrorValue: function(){
  1964 + GBCodePlayBack.pauseValue = [];
1959 for (var i = 0; i < treeLinkEditor.length; i++) { 1965 for (var i = 0; i < treeLinkEditor.length; i++) {
1960 console.log(treeLinkEditor[i].CodeMirrorReplay.getValue()) 1966 console.log(treeLinkEditor[i].CodeMirrorReplay.getValue())
  1967 + // ZTREE.showEdite({'treeNode': {'name': treeLinkEditor[i].file}});
1961 GBCodePlayBack.pauseValue.push(treeLinkEditor[i].CodeMirrorReplay.getValue()); 1968 GBCodePlayBack.pauseValue.push(treeLinkEditor[i].CodeMirrorReplay.getValue());
1962 } 1969 }
1963 }, 1970 },
1964 setCodeMirrorValue: function(){ 1971 setCodeMirrorValue: function(){
  1972 + GBCodePlayBack.resetCodeMirrorValue(1);
  1973 + var codeLength = GBCodePlayBack.pauseValue;
  1974 + console.log(treeLinkEditor);
1965 for (var i = 0; i < treeLinkEditor.length; i++) { 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,11 +1985,11 @@ $(function() {
1974 editable: function(status){ 1985 editable: function(status){
1975 if (status == 1) { 1986 if (status == 1) {
1976 for (var i = 0; i < treeLinkEditor.length; i++) { 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 }else{ 1990 }else{
1980 for (var i = 0; i < treeLinkEditor.length; i++) { 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,6 +2296,7 @@ $(function() {
2285 var runtimeArgus = $('#runtimeArgus').val() || ''; 2296 var runtimeArgus = $('#runtimeArgus').val() || '';
2286 2297
2287 fileList = ZTREE.getTreeData(); 2298 fileList = ZTREE.getTreeData();
  2299 + console.log(fileList);
2288 if(!fileList){ 2300 if(!fileList){
2289 alert('请输入代码'); 2301 alert('请输入代码');
2290 ladda.remove(); 2302 ladda.remove();
@@ -2628,6 +2640,8 @@ $(function() { @@ -2628,6 +2640,8 @@ $(function() {
2628 if (GBCodePlayBack.firstPlay == 0) { 2640 if (GBCodePlayBack.firstPlay == 0) {
2629 $('#readonly').trigger('click'); 2641 $('#readonly').trigger('click');
2630 // GBCodePlayBack.htmlplayereditor.setValue(GBCodePlayBack.pauseValue) 2642 // GBCodePlayBack.htmlplayereditor.setValue(GBCodePlayBack.pauseValue)
  2643 + GBCodePlayBack.setCodeMirrorValue();
  2644 +
2631 }else{ 2645 }else{
2632 // GBCodePlayBack.htmlplayereditor.setValue('') 2646 // GBCodePlayBack.htmlplayereditor.setValue('')
2633 var resultData = { 2647 var resultData = {
@@ -2686,8 +2700,8 @@ $(function() { @@ -2686,8 +2700,8 @@ $(function() {
2686 currentObj = treeLinkEditor[i]; 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 switch (key) { 2705 switch (key) {
2692 case 'name': 2706 case 'name':
2693 return currentObj.name; 2707 return currentObj.name;