forked from revolunet/cordova-download-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
70 lines (57 loc) · 3.01 KB
/
index.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
<!DOCTYPE html>
<html>
<head>
<title>Cordova Download plugin demo</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no;" />
<meta charset="utf-8">
<link href="http://lea.verou.me/polyfills/progress/progress-polyfill.css" rel="stylesheet" />
<script type="text/javascript" charset="utf-8" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" charset="utf-8" src="cordova-1.7.0.js"></script>
<script type="text/javascript" charset="utf-8" src="cordova-download.js"></script>
<script type="text/javascript" charset="utf-8" src="http://lea.verou.me/polyfills/progress/progress-polyfill.js"></script>
<script type="text/javascript">
var callbacks = {};
function onBodyLoad()
{
document.addEventListener("deviceready", onDeviceReady, false);
// some sample files to play with
var files = [
'https://github.com/apache/incubator-cordova-js/zipball/master',
'https://github.com/phonegap/phonegap-plugins/zipball/master',
'http://substack.net/images/npmdep/npm-twopi.png',
'http://fc05.deviantart.net/fs70/f/2012/125/0/a/lol_cats_me_by_kittenknowskungfu-d4yo4xm.jpg'
];
for (var i = 0; i < files.length ; i++) {
var file = files[i];
$('#downloads').append(' \
<b>' + file + '</b><br><br> \
<button id="download'+ i +'" data-url="' + file + '">START DOWNLOAD </button> \
<div id="status' + i +'" style="width:100px;text-align:center;display:inline-block">IDLE</div> \
<progress id="progress' + i +'" style="width:300px;" value=0 max=1 /> \
<hr/> \
');
$('#download' + i).on('click', null, { index: i }, function(event) {
window.plugins.Download.start(
$(this).data('url'),
function() {$('#status' + event.data.index).html('SUCCESS'); },
function() {$('#status' + event.data.index).html('FAILURE'); },
function(info) {
$('#status' + event.data.index).html(window.plugins.Download.status[info.status]);
$('#progress' + event.data.index).attr('value', info.progress);
}
);
})
};
}
function onDeviceReady() {}
</script>
</head>
<body onload="onBodyLoad()">
<h1>Cordova Download plugin test</h1>
<i>Some example files.</i>
<br><br>
<div id="downloads"></div>
<br><br><br><br>
Proudly made by <a href='http://revolunet.com'>revolunet team</a>
</body>
</html>