-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.html
73 lines (65 loc) · 1.97 KB
/
demo.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
<html>
<head></head>
<body>
<style>
#progress_bar {
margin: 10px 0;
padding: 3px;
border: 1px solid #000;
font-size: 14px;
clear: both;
-moz-transition: opacity 1s linear;
-o-transition: opacity 1s linear;
-webkit-transition: opacity 1s linear;
}
#progress_bar.loading {
opacity: 1.0;
}
#progress_bar .percent {
background-color: #99ccff;
height: auto;
width: 0;
}
</style>
<h1>SmartUpload.js DEMO</h1>
<h2>Configure upload :</h2>
<div id="smartConfig">
smartTarget : <input type="text" id="smartTarget" value="" placeholder="http://site/target/"><br />
smartSize :<input type="text" id="smartSize" value="131072" placeholder="131072"><br />
smartTimeout : <input type="text" id="smartTimeout" value="1000" placeholder="1000"><br />
<button id="change" onClick="changeConfig()">Change</button>
</div>
<br />
<h2>Choose a file to upload :</h2>
<input type="file" id="fileId" name="file" />
<br />
<div id="progress_bar"><div class="loading percent">0%</div></div>
<script src="smartupload.js"></script>
<script>
var smartUp;
function changeConfig()
{
if(smartUp) smartUp.destruct();
smartUp = new SmartUpload("fileId", document.querySelector("#smartTarget").value);
smartUp.smartSize = parseInt(document.querySelector("#smartSize").value);
smartUp.smartTimeout = parseInt(document.querySelector("#smartTimeout").value);
var progress = document.querySelector('.percent');
smartUp.onProgress = function(current, total)
{
var percentLoaded = Math.floor((current / total) * 100);
progress.style.width = percentLoaded + '%';
progress.textContent = percentLoaded + '%';
}
smartUp.onLoadStart = function()
{
progress.style.width = '0%';
progress.textContent = '0%';
};
smartUp.onDone = function()
{
alert("File upload complete !");
}
}
</script>
</body>
</html>