Add link in progress div
This commit is contained in:
parent
4ab7aa7e1c
commit
9e0bb0963f
10
js/script.js
10
js/script.js
@ -190,7 +190,7 @@ function downloadFile(event) {
|
|||||||
xhr.addEventListener("loadstart", function(e){
|
xhr.addEventListener("loadstart", function(e){
|
||||||
this.progressId = progressId;
|
this.progressId = progressId;
|
||||||
this.name = title;
|
this.name = title;
|
||||||
$("#transProgress").append('<div class="progress" id="' + this.progressId + '" ><i class="fa fa-download"></i><span class="name"></span><progress value="0" max="100"></progress><span class="speed"></span></div>');
|
$("#transProgress").append('<div class="progress" id="' + this.progressId + '" ><i class="fa fa-download"></i><a class="name"></a><progress value="0" max="100"></progress><span class="speed"></span></div>');
|
||||||
});
|
});
|
||||||
xhr.addEventListener("progress", function(evt) {
|
xhr.addEventListener("progress", function(evt) {
|
||||||
if (evt.lengthComputable) {
|
if (evt.lengthComputable) {
|
||||||
@ -221,12 +221,16 @@ function downloadFile(event) {
|
|||||||
success: function(data){
|
success: function(data){
|
||||||
lock = 0;
|
lock = 0;
|
||||||
var blob = data;
|
var blob = data;
|
||||||
var a = document.createElement("a");
|
|
||||||
var blobUrl = window.URL.createObjectURL(new Blob([blob], {type: blob.type}));
|
var blobUrl = window.URL.createObjectURL(new Blob([blob], {type: blob.type}));
|
||||||
|
console.log(blobUrl);
|
||||||
|
|
||||||
|
$('#' + progressId + ' > .name').attr("href", blobUrl);
|
||||||
|
$('#' + progressId + ' > .name').attr("download", title);
|
||||||
|
|
||||||
|
var a = document.createElement("a");
|
||||||
document.body.appendChild(a);
|
document.body.appendChild(a);
|
||||||
a.style = "display: none";
|
a.style = "display: none";
|
||||||
a.href = blobUrl;
|
a.href = blobUrl;
|
||||||
console.log(blobUrl);
|
|
||||||
a.download = title;
|
a.download = title;
|
||||||
a.click();
|
a.click();
|
||||||
a.remove();
|
a.remove();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user