-
Notifications
You must be signed in to change notification settings - Fork 36
/
test.html
47 lines (46 loc) · 1.33 KB
/
test.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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="x-UA-Compatible" content="Edge">
<meta http-equiv="ContentType" content="text/html;charset=utf-8">
<title>Preview by fsjohnhuang</title>
<style type="text/css">
.preview{
width: 100px;
height: 100px;
}
</style>
</head>
<body>
<input type="file" id="icon1" accept="image/x-png"/> <button onclick="pv1.reset()">重置</button>
<div class="preview" id="pv1">
</div>
<input type="file" id="icon2" accept="image/jpeg"/> <button onclick="pv2.reset()">重置</button>
<div class="preview" id="pv2">
</div>
<script type="text/javascript">
var $ = function(id){
return document.getElementById(id.substring(1));
};
</script>
<script type="text/javascript" src="./preview.js"></script>
<script type="text/javascript">
var get = function(id){
return document.getElementById(id);
};
Preview.defaults.onlegal = false;
Preview.defaults.onillegal = true;
var pv1 = new Preview(get('icon1'), get('pv1'), {
onlegal: function(path, ext, accept){
alert(this === pv1);
alert('path:' + path);
alert('extension:' + ext);
alert('accept:' + accept);
return true;
},
onillegal: false
});
var pv2 = Preview(get('pv2'), get('icon2'));
</script>
</body>
</html>