-
Notifications
You must be signed in to change notification settings - Fork 12
/
index.php
62 lines (52 loc) · 2.1 KB
/
index.php
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
<body>
<div>
<input type="text" placeholder="url" id="url"><br />
<input type="text" placeholder="title" id="title"><br />
<input type="text" placeholder="split size in mb" name="split"><br />
<input type="button" value="copy files" />
<br/><br/>
<div class="output"></div>
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="jquery-1.10.1.min.js"><\/script>')</script>
<script>
var progressInterval;
$('input[type=button]').on('click',function(){
var url = $('#url').val();
var title = $('#title').val();
$.ajax({
url:'copy.php',
type: 'post',
data: { "url": url, "title": title },
dataType:'json',
success: function(data) {
console.log(data);
if(progressInterval) {
clearInterval(progressInterval);
}
},
error:function(err){
console.log(err);
if(progressInterval) {
clearInterval(progressInterval);
}
}
});
progressInterval = setInterval(function(){
$.ajax({
url:'copy-progress.php',
type: 'get',
data: {"title": title},
dataType:'json',
success: function(data) {
console.log(data);
$('.output').text((parseInt(data.progress))+"%");
},
error:function(err){
console.log(err);
}
});
}, 100);
});
</script>
</body>