c.js
5.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
$(function(){
var _languageid = getQuery('languageid'); // 返回URL中的查询部分
var _userId = getQuery('userId'); // 用户ID
var _role = getQuery('role'); // 用户角色 0:学生 1:老师
var _autoScore = getQuery('autoScore'); // 是否开启自动打分 也就是左侧是否显示目录的依据
var _questionId = getQuery('question'); // 问题ID
var flag = true;
if(_autoScore){
if(_autoScore === 'true'){
_autoScore = true;
}else{
_autoScore = false;
}
}
if(_languageid == 35){
$('.switch').show();
$("#CompileBtn .ladda-label").html("自动运行")
$('#quickTool').show();
}else{
$("#CompileBtn .ladda-label").html("编译运行")
}
// new一个基本IDE结构
var ide = new GxbIde({
el: '#folder',
isPlayPage: 0,
languageid: parseInt(_languageid),
questionId: _questionId,
autoScore: _autoScore,
role: _role
});
$('.switch').on('click', function(){
if(flag){
$("#CompileBtn .ladda-label").html("手动运行")
flag = false;
CodingEditer.isHanld = 0
}else{
$("#CompileBtn .ladda-label").html("自动运行")
flag = true;
CodingEditer.isHanld = 1
}
})
// new一个老师录制的控制条工具
var techTool = new ToolBox({
el: '#toolBox',
role: _role,
userId: _userId,
languageId: _languageid,
questionId: _questionId,
autoScore: _autoScore,
startCallback: function(){
// 禁止重命名
setTimeout(function(){
DirSetting.edit.showRenameBtn = false;
DirSetting.edit.enable = false;
$('.button.edit').hide();
}, 0)
$("#countdown").show()
.find('img').attr('src', '../img/ready-go.gif')
.load(function() {
recordReady()
})
Iterm.compileResult()
},
stopCallback: function(){
$("#countdown").find('img').attr('src', '')
},
restartCallback: function(){
}
});
// 编译控制台
// var iterm = new Iterm({
// userId: _userId,
// languageId: _languageid
// });
console.log(ide);
if (CodingEditer.recording_status) {
$('#teacherCompileBtn').show();
}else{
$('#studentCompileBtn').show();
}
$('.dropdown-menu').on('click', function(e) {
var $target = $(e.target);
$target.is('li') && $('#text').text($target.text());
var selectVal = $target.text();
if (selectVal == '图片') {
Dir.treeLinkEditor[0].CodeMirrorRecord.replaceSelection('<img src="http://www.igeekbar.com/igeekbar/laitu/300x200&text=hello world/222222/ffffff" alt="占位图片">', "end")
}else if (selectVal == 'bootstrap.css') {
Dir.treeLinkEditor[0].CodeMirrorRecord.replaceSelection('<link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">', "end")
}else if(selectVal == 'bootstrap.js'){
Dir.treeLinkEditor[0].CodeMirrorRecord.replaceSelection('<script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>', "end")
}else if (selectVal == 'jQuery') {
Dir.treeLinkEditor[0].CodeMirrorRecord.replaceSelection('<script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>', "end")
}
})
// 插入标准输入
$(document).on('focus', '#runtimeArgus', function(){
console.log('focus');
CodingEditer.input_focus_time = new Date().getTime(); // 获取焦点的时间
console.log(CodingEditer.records);
})
$(document).on('blur', '#runtimeArgus', function(){
console.log('blur');
console.log('blur');
console.log('blur');
var recordobj = {
intervaltime: CodingEditer.input_focus_time - CodingEditer.record_startime,
editor: 'runtimeArgus',
changeobj: {
from: {
ch: 0,
line: 0,
},
text: '',
to: {
ch: 0,
line: 0,
}
},
runtimeArgus: $(this).val(),
trigger: 0,
playTime: 0
};
CodingEditer.record_startime = CodingEditer.input_focus_time; // 获取焦点的时间
CodingEditer.records.push(recordobj);
console.log(CodingEditer.records);
})
// $.getScript('../js/main.js', function(){alert('../js/gbdebug/mode/xml/xml.js');});
// $.getScript('../js/gbdebug/mode/xml/xml.js')
// $.getScript('../js/gbdebug/mode/javascript/javascript.js')
// $.getScript('../js/gbdebug/mode/css/css.js')
// $.getScript('../js/gbdebug/mode/htmlmixed/htmlmixed.js')
$("#confirm").on('click', function(){
$('.confirm-tip').hide();
})
function recordReady(){
var seconds = 0;
var countdown = setInterval(function() {
seconds += 1;
if (seconds == 2) {
$("#countdown").hide();
techTool.initRecording();
Hourglass.init()
}
}, 1000);
}
$('[data-toggle="tooltip"]').tooltip()
})