teacher.html
7.04 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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
<!doctype html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>老师端</title>
<link href="../css/reset.css" rel="stylesheet">
<link rel="stylesheet" href="../css/responsive/css/bootstrap.min.css">
<link rel="stylesheet" href="../js/codemirror-5.25.0/lib/codemirror.css">
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font: 13px Helvetica, Arial;
}
.live-wrap{
position: absolute;
width: 100%;
height: 100%;
overflow: hidden;
}
.header{
text-align: center;
border-bottom: 1px solid #c1c1c1;
padding: 8px 0;
}
.header h1{
font-size: 18px;
margin: 0;
}
.live-code{
position: relative;
width: 100%;
height: 100%;
padding-bottom: 296px;
}
.live-code .CodeMirror{
height: 100%;
}
.live-console-wrap{
width: 100%;
background-color: #FFF;
height: 200px;
position: absolute;
bottom: 60px;
z-index: 999;
overflow: hidden;
}
#toolbar{
width: 100%;
height: 40px;
overflow: hidden;
background-color: #F4F6F9;
padding: 0 36px;
}
.result-tabs{
overflow: hidden;
margin: 5px 10px;
color: #fff;
}
.text{
color: #1FB6FF;
}
.result-tabs>li.active>a, .result-tabs>li.active>a:hover, .result-tabs>li>a:hover, .result-tabs>li.active>a:focus{
color: #FFF;
background-image: -webkit-linear-gradient(left, #1FB6FF 0%, #62DCF5 100%);
background-image: linear-gradient(to right, #1FB6FF 0%, #62DCF5 100%);
-webkit-transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) all !important;
transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) all !important;
box-shadow: 0px 0px 2px 0px #B3E5FF;
border: none;
}
.result-tabs>li>a, .result-tabs>li.active>a:hover{
padding: 4px 21px;
border: none;
margin: 1px;
border-radius: 15px;
font-size: 14px;
transition: all 0.1s ease;
}
.func{
height: 36px;
padding-top: 5px;
}
.stdin-wrap {
margin: 0 48px;
position: relative;
}
#stdin {
position: absolute;
width: 100%;
}
#stdin :focus{outline: none;}
#stdin input[type="text"]{font: 15px/24px "Lato", Arial, sans-serif; color: #333; width: 100%; box-sizing: border-box; letter-spacing: 1px;padding-left: 12px;}
#stdin .effect-2{border: 0; padding: 12px 0 1px; border-bottom: 1px solid #ccc;}
#stdin .effect-2 ~ .focus-border{position: absolute; bottom: 0; left: 50%; width: 0; height: 2px; background-color: #62DCF5; transition: 1s;}
#stdin .effect-2:focus ~ .focus-border{width: 100%; transition: 1s; left: 0;}
.nav-tabs {
border: none;
float: left;
border-bottom: 0;
}
.panel-body{
padding: 0;
}
.compile-btn {
background: #FFF;
border: 1px solid #3ad5f5;
color: #1FB6FF;
border-radius: 24px;
}
.btn {
padding: 3px 18px;
}
.fb {
float: right;
margin: 0 16px;
cursor: pointer;
}
.fb img {
width: 32px;
}
.live-ctrl{
width: 100%;
height: 60px;
position: absolute;
bottom: 0;
z-index: 999;
padding: 0 136px;
background-color: #23383f;
box-sizing: border-box;
}
</style>
</head>
<body>
<div class="live-wrap">
<!-- 头部信息 -->
<div class="header">
<h1>老师端</h1>
</div>
<!-- 录制区域 -->
<div class="live-code">
<textarea id="teacher" title="HTML"></textarea>
</div>
<!-- 编译操作区 -->
<!-- 运行结果区 -->
<div class="live-console-wrap">
<div id="toolbar">
<!-- Nav tabs -->
<ul class="nav nav-tabs result-tabs need-compile" role="tablist" id="cmprun-tabs">
<li class="active"><a href="#stdin" role="tab" data-toggle="tab" class="text">标准</a></li>
<li><a href="#cmpinfo" role="tab" data-toggle="tab" class="text">编译</a></li>
<li><a href="#stderr" role="tab" data-toggle="tab" class="text">错误</a></li>
<li><a href="#output" role="tab" data-toggle="tab" class="text">结果</a></li>
</ul>
<div class="pull-right func">
<button class="btn compile-btn" id="CompileBtn">
<span class="ladda-label">编译运行</span>
</button>
<a id="full-screen" class="fb">
<img src="../img/full-screen-icon.svg" alt="">
</a>
<a id="back-screen" class="fb" style="display: none;">
<img src="../img/full-screen-icon.svg" alt="">
</a>
</div>
</div>
<!-- Tab panes -->
<div id="resultoutput" class="tab-content need-compile">
<div class="tab-pane active padall15" id="stdin">
<div class="stdin-wrap">
<input class="effect-2" id="runtimeArgus" type="text" placeholder="标准输入">
<span class="focus-border"></span>
</div>
</div>
<div class="tab-pane padall15" id="cmpinfo"></div>
<div class="tab-pane padall15" id="stderr"></div>
<div class="tab-pane padall15" id="output"></div>
</div>
<div class="panel-body no-compile" id="ifrcontainer">
<iframe id="resultiframe" frameBorder="0" width="100%"></iframe>
</div>
</div>
<!-- 录制控制区 -->
<div class="live-ctrl">
</div>
</div>
<script src="https://cdn.socket.io/socket.io-1.2.0.js"></script>
<script src="https://code.jquery.com/jquery-1.11.1.js"></script>
<script src="../js/codemirror-5.25.0/lib/codemirror.js"></script>
<script src="../js/bootstrap.js"></script>
<script>
$(function() {
var teacherId = document.getElementById('teacher');
var socket = io('http://localhost:3000');
// 初始化codemirror页面
var teacher = CodeMirror.fromTextArea(teacherId, {
value: '输入HTML代码',
mode: 'text/javascript',
lineNumbers: true,
smartIndent: false
});
// 记录每次操作的变化
CodeMirror.on(teacher,"change", function(instance, changeObj) {
console.log(instance);
console.log(changeObj);
var changeObjStr = JSON.stringify(changeObj);
socket.emit('teacher.programming', changeObjStr);
socket.emit('programming.content', teacher.getValue());
});
// 链接时执行初始化代码
socket.on('programming.content', function(msg) {
console.log('programming.content ---- ' + msg);
teacher.setValue(msg);
});
});
</script>
</body>
</html>