-
Notifications
You must be signed in to change notification settings - Fork 0
/
new_wen.html
392 lines (382 loc) · 15.3 KB
/
new_wen.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
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>班级文件</title>
<link href="css/mui.min.css" rel="stylesheet" />
<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="stylesheet" href="css/mui.min.css">
<!--App自定义的css-->
<link rel="stylesheet" type="text/css" href="css/app.css"/>
<link rel="stylesheet" type="text/css" href="css/iconfont.css"/>
<script type="text/javascript" src="js/jquery-3.2.1.min.js"></script>
<script src="js/mui.min.js"></script>
<script src="js/tool.js"></script>
<style>
.mui-content{
margin-top: 5%;
}
.file {
position: relative;
height: 40px;
line-height: 40px;
}
.file label {
display: inline-block;
}
.userdefined-file {
position: absolute;
top: 0;
left: 60px;
z-index: 2;
width: 300px;
height: 40px;
line-height: 40px;
font-size: 0; /*应对子元素为 inline-block 引起的外边距*/
}
.userdefined-file input[type="text"] {
display: inline-block;
vertical-align: middle;
padding-right: 14px;
padding-left: 14px;
width: 220px;
box-sizing: border-box;
border: 1px solid #ccc;
height: 40px;
line-height: 40px;
font-size: 14px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.userdefined-file button {
display: inline-block;
vertical-align: middle;
width: 80px;
text-align: center;
height: 40px;
line-height: 40px;
font-size: 14px;
background-color: #f54;
border: none;
color: #fff;
cursor: pointer;
}
.file {
position:absolute;
top:0; right:80px;
height:24px;
filter:alpha(opacity:0);
opacity: 0;
width:260px ;
}
.mui-table-view{
margin-top: 5%;
}
#down{
margin-bottom: 10%;;
}
</style>
<script >
var userid = GetUseridCookie().get("userid");
function download(down){
// alert(down);
var classid=UrlParm.parm("classid");
// var url='127.0.0.1:8080';
mui.ajax('http://'+url+'/jizhibackend/servlet/ClassFileDownload',{
data:
{
classid:classid,
filename:down,
},
xhrFields: {
withCredentials: true
},
crossDomain: true,
dataType: 'json', //服务器返回json格式数据
type: 'post', //HTTP请求类型
timeout: 10000, //超时时间设置为10秒;
headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' },
success: function(data) {
// alert('下载成功');
downloadFile(data.path);
},
error: function(xhr, type, errorThrown) {
console.log(errorThrown);
}
});
}
function downloadFile(url){
var form=jQuery("<form>");//定义form表单,通过表单发送请求
form.attr("style","display:none");//设置为不显示
form.attr("target","");
form.attr("method","get");//设置请求类型
form.attr("action",url);//设置请求路径
jQuery("body").append(form);//添加表单到页面(body)中
form.submit();//表单提交
}
function fileload(){
var up=document.getElementById('up');
up.style.display='none';
var out=document.getElementById("out");
out.innerHTML='';
//var url='127.0.0.1:8020';
var classid=UrlParm.parm("classid");
mui.ajax('http://'+url+'/jizhibackend/servlet/GetClassFileList',{
data:
{
userid:userid,
classid:classid,
},
xhrFields: {
withCredentials: true
},
crossDomain: true,
dataType: 'json', //服务器返回json格式数据
type: 'post', //HTTP请求类型
timeout: 10000, //超时时间设置为10秒;
headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' },
success: function(data) {
var out=document.getElementById('out');
var type='';
data1=data.filelist;
jQuery.each(data1,function(index,item){
if(item.name.indexOf('.doc')>=0||item.name.indexOf('.dot')>=0)
{
type='images/word.png';
}
else if(item.name.indexOf('.txt')>=0)
{
type='images/txt.png';
}
else if(item.name.indexOf('.pdf')>=0)
{
type='images/pdf.png';
}
else if(item.name.indexOf('.ppt')>=0)
{
type='images/ppt.png';
}
else if(item.name.indexOf('.mp3')>=0||item.name.indexOf('.wmv')>=0)
{
type='images/music.png';
}
else if(item.name.indexOf('.xls')>=0||item.name.indexOf('.xlt')>=0)
{
type='images/excel.png';
}
else if(item.name.indexOf('.jpg')>=0||item.name.indexOf('.jpeg')>=0||item.name.indexOf('.png')>=0||item.name.indexOf('.gif')>=0)
{
type='images/image.png';
}
else
{
type='images/folder.png';
}
var li = document.createElement('li');
li.className="mui-table-view mui-table-view-striped mui-table-view-condensed";
li.innerHTML='<div class="mui-slider-cell">'+
'<div class="oa-contact-cell mui-table">'+
'<div class="oa-contact-avatar mui-table-cell" style="vertical-align: middle;">'+
'<img src='+type+' id="imagess" width="40px"/>'+
'</div><div class="oa-contact-content mui-table-cell" style="word-break:break-all;word-wrap:break-word;padding:10px"><div class="mui-clearfix" >'+
'<h4 class="oa-contact-name"> </h4></div>'+
'<p style="word-break:break-all;">'+item.name+
'</p></div><div class="oa-contact-content mui-table-cell" style="float: right;padding:30px">'+
'<button onclick=download(\"'+item.name+'\") id="down">下载</button>'+
'</div></div></div>';
out.appendChild(li);
});
},
error: function(xhr, type, errorThrown) {
console.log(errorThrown);
}
});
}
</script>
</head>
<body>
<header class="mui-bar mui-bar-nav">
<a class="mui-icon mui-icon-left-nav mui-pull-left" id="wenjian"></a>
<h1 class="mui-title">班级文件</h1>
<span class="mui-icon mui-icon-plus mui-pull-right" id="select" onclick="select()"></span>
<input type="file" class="file" id="file" >
</header>
<div class="mui-content" id="content">
<ul class="mui-table-view mui-table-view-striped mui-table-view-condensed" id="out">
<!--<form name="upform" action="UploadServlet" method="POST" enctype="multipart/form-data">
<div class="files">
<label for="file">文件:</label>
<div class="userdefined-file">
<input type="text" class="userdefinedFile" id="fname" value="未选择任何文件">
<button type="button" onclick="document.getElementById('file').click()">上传</button>
</div>
</div>
</form>-->
</ul>
<div class="mui-slider-cell" id="up" >
<div class="oa-contact-cell mui-table">
<div class="oa-contact-avatar mui-table-cell" style="vertical-align: middle;padding:30px" id="img">
<img id="images" width="40px"/>
</div>
<div class="oa-contact-content mui-table-cell" style="word-break:break-all;word-wrap:break-word;padding:10px">
<div class="mui-clearfix" >
<h4 class="oa-contact-name"> </h4>
</div>
<p style="word-break:break-all;" id="filename">
</p>
</div>
<div class="oa-contact-content mui-table-cell" style="float: right;padding:30px">
<button onclick="uploadFile()" style="display: none;" id="load">上传</button>
</div>
</div>
</div>
</div>
</body>
<script src="js/mui.min.js"></script>
<script src="js/app.js"></script>
<script>
document.getElementById("file").onchange = function() {
var up=document.getElementById('up').style.display='';
var file = document.getElementById("file").value;
var pos=file.lastIndexOf("\\");
document.getElementById("filename").innerHTML= file.substring(pos+1);
document.getElementById("images").src="";
if(file.indexOf('.doc')>=0||file.indexOf('.dot')>=0)
{
document.getElementById("images").src='images/word.png';
}
else if(file.indexOf('.txt')>=0)
{
document.getElementById("images").src='images/txt.png';
}
else if(file.indexOf('.pdf')>=0)
{
document.getElementById("images").src='images/pdf.png';
}
else if(file.indexOf('.ppt')>=0)
{
document.getElementById("images").src='images/ppt.png';
}
else if(file.indexOf('.mp3')>=0||file.indexOf('.wmv')>=0)
{
document.getElementById("images").src='images/music.png';
}
else if(file.indexOf('.xls')>=0||file.indexOf('.xlt')>=0)
{
document.getElementById("images").src='images/excel.png';
}
else if(file.indexOf('.jpg')>=0||file.indexOf('.jpeg')>=0||file.indexOf('.png')>=0||file.indexOf('.gif')>=0)
{
document.getElementById("images").src='images/image.png';
}
else
{
document.getElementById("images").src='images/folder.png';
}
var load=document.getElementById('load');
load.style.display='';
}
mui('body').on('tap','a',function(){document.location.href=this.href;});
var classid=UrlParm.parm("classid");
<!--alert(classid);-->
document.getElementById('wenjian').href='banjixinxi.html?classid='+classid;
//var url='127.0.0.1:8020';
mui.ajax('http://'+url+'/jizhibackend/servlet/GetClassFileList',{
data:
{
userid:userid,
classid:classid,
},
xhrFields: {
withCredentials: true
},
crossDomain: true,
dataType: 'json', //服务器返回json格式数据
type: 'post', //HTTP请求类型
timeout: 10000, //超时时间设置为10秒;
headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' },
success: function(data) {
var out=document.getElementById('out');
var type='';
data1=data.filelist;
jQuery.each(data1,function(index,item){
if(item.name.indexOf('.doc')>=0||item.name.indexOf('.dot')>=0)
{
type='images/word.png';
}
else if(item.name.indexOf('.txt')>=0)
{
type='images/txt.png';
}
else if(item.name.indexOf('.pdf')>=0)
{
type='images/pdf.png';
}
else if(item.name.indexOf('.ppt')>=0)
{
type='images/ppt.png';
}
else if(item.name.indexOf('.mp3')>=0||item.name.indexOf('.wmv')>=0)
{
type='images/music.png';
}
else if(item.name.indexOf('. xls')>=0||item.name.indexOf('. xlt')>=0)
{
type='images/excel.png';
}
else if(item.name.indexOf('.jpg')>=0||item.name.indexOf('.jpeg')>=0||item.name.indexOf('.png')>=0||item.name.indexOf('.gif')>=0)
{
type='images/image.png';
}
else
{
type='images/folder.png';
}
var li = document.createElement('li');
li.className="mui-table-view mui-table-view-striped mui-table-view-condensed";
li.innerHTML='<div class="mui-slider-cell">'+
'<div class="oa-contact-cell mui-table">'+
'<div class="oa-contact-avatar mui-table-cell" style="vertical-align: middle;">'+
'<img src='+type+' id="imagess" width="40px"/>'+
'</div><div class="oa-contact-content mui-table-cell" style="word-break:break-all;word-wrap:break-word;padding:10px"><div class="mui-clearfix" >'+
'<h4 class="oa-contact-name"> </h4></div>'+
'<p style="word-break:break-all;">'+item.name+
'</p></div><div class="oa-contact-content mui-table-cell" style="float: right;padding:30px">'+
'<button onclick=download(\"'+item.name+'\") id="down">下载</button>'+
'</div></div></div>';
out.appendChild(li);
});
},
error: function(xhr, type, errorThrown) {
console.log(xhr);
console.log(type);
console.log(errorThrown);
}
});
function select()
{
document.getElementById('file').click();
}
function uploadFile()
{
//var url='127.0.0.1:8020';
var classid=UrlParm.parm("classid");
var wenjian=document.getElementById("wenjian");
var fname=document.getElementById("file").files[0];;
wenjian.href='banjixinxi.html?classid='+classid;
var formData = new FormData();
formData.append("classid",classid);
formData.append("file",fname);
var xhr = new XMLHttpRequest();
xhr.open("post", 'http://'+url+'/jizhibackend/servlet/UploadFile', true);
xhr.onload = function () {
mui.toast("上传成功");
fileload();
};
xhr.send(formData);
}
</script>
</html>