UNPKG

2.49 kBHTMLView Raw
1<!DOCTYPE html>
2<html xmlns="http://www.w3.org/1999/html">
3<head>
4 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
5 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6
7 <title>FileAPI :: Tests</title>
8
9 <script>
10 var FileAPI = {
11 html5: false
12 , debug: true
13 , staticPath: '../dist/'
14 };
15 </script>
16
17 <script src="../dist/FileAPI.js"></script>
18 <script src="../plugins/FileAPI.id3.js"></script>
19 <script src="../plugins/FileAPI.exif.js"></script>
20
21 <link rel="stylesheet" href="./qunit/qunit.css"/>
22</head>
23</body>
24
25 <div id="qunit"></div>
26
27 <input id="startBtn" type="button" value=" START " style="font-size: 20px;" />
28
29 <div style="margin: 30px;">
30 <div id="web-cam" style="width: 320px; height: 240px; float: right;"></div>
31
32 <div class="js-fileapi-wrapper">
33 <input id="inpEl" name="file" type="file" />
34 </div>
35
36 <pre id="logEl" style="font-size: 12px">
37 <!---->
38 </pre>
39 </div>
40
41
42 <script src="./qunit/qunit.js"></script>
43 <script>
44 (function () {
45 if (!window.console) {
46 FileAPI.log = function () {
47 logEl.insertBefore(document.createTextNode([].join.call(arguments, ' ') + '\n'), logEl.firstChild);
48 };
49 }
50
51 startBtn.onclick = function () {
52 QUnit.start();
53 };
54
55 QUnit.config.autostart = false;
56
57 asyncTest('2015', function () {
58 var opts = {
59 minSize: {width: 0, height: 0},
60 maxSize: {width: 3000, height: 2000},
61 previewSize: {width: 128, height: 128},
62 uploadUrl: '',
63 typeFilter: 'image/*'
64
65 };
66
67 var filter = function (f, i) {
68 if (/^image/.test(f.type)) {
69 if (i === false || (i.width >= opts.minSize.width && i.height >= opts.minSize.height)) {
70 return true;
71 }
72 }
73
74 return false;
75 };
76
77
78 var files = FileAPI.getFiles(inpEl);
79
80
81 FileAPI.filterFiles(files, filter, function (files, rejected) {
82 if (files.length < 1) {
83 return;
84 }
85
86
87 FileAPI.each(files, function (file) {
88 FileAPI.Image(file)
89 .resize(opts.previewSize.width, opts.previewSize.height, 'max')
90 .get(function (err, img) {
91 ok(!err, 'preview');
92 });
93 });
94
95
96 FileAPI.upload({
97 url: opts.uploadUrl,
98 files: {images: files},
99 imageTransform: {
100 maxWidth: opts.maxSize.width,
101 maxHeight: opts.maxSize.height
102 },
103 complete: function (err) {
104 ok(!/2015/.test(err), 'without 2015');
105 start();
106 }
107 });
108 });
109 });
110 })();
111 </script>
112
113</body>
114</html>