forked from snailuncle/jsTree
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser.html
327 lines (270 loc) · 9.57 KB
/
user.html
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
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>666666</title>
<link rel="stylesheet" href="https://cdn.bootcss.com/twitter-bootstrap/4.1.2/css/bootstrap.min.css" />
<script src="https://cdn.bootcss.com/jquery/3.3.0/jquery.min.js"></script>
<script src="https://cdn.bootcss.com/twitter-bootstrap/4.1.2/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="../dist/themes/default/style.min.css" />
<script src="../dist/jstree.min.js"></script>
<script src="../static/js/user.js"></script>
<style>
textarea.sansserif {
font-family: Arial, Helvetica, sans-serif;
font-size: 100%;
}
textarea.ex {
color: rgb(0, 0, 255);
}
textarea.wh {
width: 100%;
height: 888px;
outline: none !important;
border-color: #719ECE;
box-shadow: 0 0 10px #719ECE;
border: solid 1px #f00;
border-radius: 20px;
padding-top: 6px;
padding-right: 12px;
padding-bottom: 6px;
padding-left: 12px;
}
#button_edit {
width: 200px;
height: 88px;
}
#button_save {
width: 200px;
height: 88px;
}
#button_index {
width: 200px;
height: 88px;
}
#button_index_designate {
width: 200px;
height: 88px;
}
#project_list {
position: relative;
left: 20px;
top: 10px;
}
/* #codeDetail {
background-color: green;
}
#button3 {
background-color: blue;
} */
</style>
</head>
<!-- 传递给网页一个数组,数组中是文件夹和文件,用json格式存放 -->
<!-- <body onload="init();"> -->
<body>
<h1>欢迎光临{{user}}</h1>
<!-- <div class="container"> -->
<div class="container-fluid">
<div class="row clearfix">
<div class="col-md-12 column">
<h3 id="project-name" class="text-center">
这里放当前文件的路径
</h3>
</div>
</div>
<div class="row clearfix">
<!-- <div style="position:relative;left:200px;top:100px;width:400px;height:50px"> -->
<div class="col-md-2 column" id='project_list'>
<div class="list-group">
<div class="list-group-item active">项目列表</div>
<div id="jstree">
</div>
</div>
</div>
<div class="col-md-8 column" id="codeDetail">
<h3 id="script-name">
这里放选中的文件的名字
</h3>
<div>
<textarea class="sansserif ex wh" id="script-detail" readonly="readonly">
这里放具体的代码 123 123 444 555 666
</textarea>
</div>
</div>
<div class="col-md-2 column" id="button3">
<div class="btn-group btn-group-vertical btn-group-lg ">
<button type="button" class="btn btn-default btn-danger" id="button_edit">编辑</button>
<button type="button" class="btn btn-default btn-info" id="button_save">保存</button>
<button type="button" class="btn btn-default btn-success" id="button_index">运行当前项目的
<br/>入口文件index.js</button>
<button type="button" class="btn btn-default btn-info" id="button_index_designate">运行项目
<br/>指定手机</button>
</div>
<p id=connectionState></p>
<div>
<textarea class="sansserif ex wh" id="identification_code">
这里放唯一标识码,用分号隔开
</textarea>
</div>
<!-- 唯一标识码 -->
<!-- <div class="col-md-* col-sm-* col-xs-*" style="text-align:right;">
<input type="text" value="" style="box-shadow:inset 0 0 4px #eee; margin:0; padding:6px 12px; border-radius:4px; border:1px solid silver; font-size:1.1em;"
id="demo_q" placeholder="Search" />
</div> -->
</div>
</div>
</div>
<script>
//按钮点击脚本
$("#button_edit").click(function (event) {
var cObj = document.getElementById("script-detail");
cObj.removeAttribute("readonly");
})
$("#button_save").click(function (event) {
// alert($("#script-detail").val());//弹出textarea的值
var filePath = $("#project-name").text()
console.log(filePath)
filePath = filePath.replace("选中的文件的路径=", "")
var codeDetail = $("#script-detail").val()
console.log('前端向后端传送的路径和代码分别是')
console.log(filePath)
console.log(codeDetail)
// $.post("/saveCode", {
// "filePath": filePath,
// "codeDetail": codeDetail
// })
$.ajax({
url: 'saveCode',
type: 'post',
dataType: 'json',
data: {
"filePath": filePath,
"codeDetail": codeDetail
},
success: function (data) {}
});
})
$("#button_index").click(function (event) {
// alert('index.js666')
// $("#connectionState").text('正在连接手机,请稍后');
var filePath = $("#project-name").text()
console.log(filePath)
filePath = filePath.replace("选中的文件的路径=", "")
var arr = filePath.split("/");
var projectName=arr[1]
$.get("runIndex"+"/"+projectName);
var btn = document.getElementById('button_index');//首先需要获取的是哪一个按钮的id
btn.disabled = 'disabled';//只要点击就将按钮的可点击的状态更改为不可以点击的状态
setTimeout(function(){//设置时间,多久可以改变状态为可以点击
btn.disabled = '';
},8000);//6秒内不可以重复点击,一秒等于1000毫秒
})
$("#button_index_designate").click(function (event) {
// alert('指定手机')
// $("#connectionState").text('正在连接手机,请稍后');
var filePath = $("#project-name").text()
console.log(filePath)
filePath = filePath.replace("选中的文件的路径=", "")
var arr = filePath.split("/");
var projectName=arr[1]
var 手机唯一标识码=$("#identification_code").val()
// alert(手机唯一标识码)
// $.get("runIndexDesignateMobile"+"/"+projectName+"手机唯一标识码"+手机唯一标识码);
console.log("$.ajax({之前手机唯一标识码=")
console.log(手机唯一标识码);
// $.ajax({
// url: "runIndexDesignateMobile"+"/"+projectName,
// type: 'post',
// dataType: 'text',
// data: 手机唯一标识码,
// success: function (data) {}
// });
$.post("runIndexDesignateMobile"+"/"+projectName,{'code':手机唯一标识码});
var btn = document.getElementById('button_index_designate');//首先需要获取的是哪一个按钮的id
btn.disabled = 'disabled';//只要点击就将按钮的可点击的状态更改为不可以点击的状态
setTimeout(function(){//设置时间,多久可以改变状态为可以点击
btn.disabled = '';
},8000);//6秒内不可以重复点击,一秒等于1000毫秒
})
</script>
<script type="text/javascript">
var observe;
if (window.attachEvent) {
observe = function (element, event, handler) {
element.attachEvent('on' + event, handler);
};
} else {
observe = function (element, event, handler) {
element.addEventListener(event, handler, false);
};
}
function init() {
var text = document.getElementById('script-detail');
function resize() {
text.style.height = '600px';
text.style.height = text.scrollHeight + 'px';
}
/* 0-timeout to get the already changed text */
function delayedResize() {
window.setTimeout(resize, 0);
}
observe(text, 'change', resize);
observe(text, 'cut', delayedResize);
observe(text, 'paste', delayedResize);
observe(text, 'drop', delayedResize);
observe(text, 'keydown', delayedResize);
text.focus();
text.select();
resize();
}
</script>
<script>
// $(function(){
// alert($("#script-detail").val());//弹出textarea的值
// });
</script>
<!-- <script type="text/javascript">
$("#button_index").click(function (event) {
$.get("sendCommandToMobile");
})
</script> -->
<!-- <script type="text/javascript">
$("#button_index").click(function (event) {
// 很重要 必须写,判断浏览器是否支持websocket
var CreateWebSocket = (function () {
return function (urlValue) {
if (window.WebSocket) return new WebSocket(urlValue);
if (window.MozWebSocket) return new MozWebSocket(urlValue);
return false;
}
})()
// 实例化websoscket websocket有两种协议ws(不加密)和wss(加密)
var wsport = '3000'
var webSocket = null
$.get("getPort", function (result) {
console.log('从后端获取的端口信息结果=')
console.log(result)
wsport=result.httpPort
console.log('选择的ws端口=')
console.log(wsport)
webSocket = CreateWebSocket("ws://127.0.0.1:" + wsport + "/ws");
webSocket.onopen = function (evt) {
// 一旦连接成功,就发送第一条数据
webSocket.send("前端网页发送的第一条数据")
}
webSocket.onmessage = function (evt) {
// 这是服务端返回的数据
console.log("服务端说" + evt.data)
$("#connectionState").text(evt.data);
}
// 关闭连接
webSocket.onclose = function (evt) {
console.log("Connection closed.")
}
});
})
</script> -->
</body>
</html>