add progress bars
This commit is contained in:
parent
e077160a47
commit
9e228417b4
@ -2,6 +2,7 @@ const FileReceiver = require('./fileReceiver');
|
|||||||
const $ = require('jquery');
|
const $ = require('jquery');
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
$('#download-progress').hide();
|
||||||
$('#send-file').click(() => {
|
$('#send-file').click(() => {
|
||||||
window.location.replace(`${window.location.origin}`);
|
window.location.replace(`${window.location.origin}`);
|
||||||
});
|
});
|
||||||
@ -10,16 +11,22 @@ $(document).ready(function() {
|
|||||||
|
|
||||||
let li = document.createElement('li');
|
let li = document.createElement('li');
|
||||||
let name = document.createElement('p');
|
let name = document.createElement('p');
|
||||||
let progress = document.createElement('p');
|
let $btn = $('#download-btn');
|
||||||
let btn = $('#download-btn');
|
|
||||||
|
|
||||||
fileReceiver.on('progress', percentComplete => {
|
fileReceiver.on('progress', percentComplete => {
|
||||||
progress.innerText = `Progress: ${percentComplete}%`;
|
$('#download-page-one').hide();
|
||||||
|
$('.send-new').hide();
|
||||||
|
$('#download-progress').show();
|
||||||
|
// update progress bar
|
||||||
|
document.querySelector('#progress-bar').style.setProperty('--progress', percentComplete+'%');
|
||||||
|
$('#progress-text').html(`${percentComplete}%`);
|
||||||
|
//on complete
|
||||||
if (percentComplete === 100) {
|
if (percentComplete === 100) {
|
||||||
fileReceiver.removeAllListeners('progress');
|
fileReceiver.removeAllListeners('progress');
|
||||||
btn.text('Download complete!');
|
$('#download-text').html('Download complete!');
|
||||||
btn.attr('disabled', 'true');
|
$('.send-new').show();
|
||||||
|
$btn.text('Download complete!');
|
||||||
|
$btn.attr('disabled', 'true');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -3,25 +3,32 @@ const $ = require('jquery');
|
|||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
// reset copy button
|
// reset copy button
|
||||||
let copyBtn = $('#copy-btn');
|
let $copyBtn = $('#copy-btn');
|
||||||
copyBtn.attr('disabled', false);
|
$copyBtn.attr('disabled', false);
|
||||||
copyBtn.html('Copy');
|
$copyBtn.html('Copy');
|
||||||
|
|
||||||
$('#page-one').show();
|
$('#page-one').show();
|
||||||
$('#file-list').hide();
|
$('#file-list').hide();
|
||||||
$('#upload-progress').hide();
|
$('#upload-progress').hide();
|
||||||
$('#share-link').hide();
|
$('#share-link').hide();
|
||||||
|
|
||||||
|
//load existing uploads
|
||||||
|
for (fileId in localStorage){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// copy link to clipboard
|
// copy link to clipboard
|
||||||
copyBtn.click(() => {
|
$copyBtn.click(() => {
|
||||||
var aux = document.createElement('input');
|
var aux = document.createElement('input');
|
||||||
aux.setAttribute('value', $('#link').attr('value'));
|
aux.setAttribute('value', $('#link').attr('value'));
|
||||||
document.body.appendChild(aux);
|
document.body.appendChild(aux);
|
||||||
aux.select();
|
aux.select();
|
||||||
document.execCommand('copy');
|
document.execCommand('copy');
|
||||||
document.body.removeChild(aux);
|
document.body.removeChild(aux);
|
||||||
copyBtn.attr('disabled', true);
|
//disable button for 3s
|
||||||
copyBtn.html('Copied!');
|
$copyBtn.attr('disabled', true)
|
||||||
|
$copyBtn.html('Copied!');
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// link back to home page
|
// link back to home page
|
||||||
@ -30,8 +37,8 @@ $(document).ready(function() {
|
|||||||
$('#file-list').show();
|
$('#file-list').show();
|
||||||
$('#upload-progress').hide();
|
$('#upload-progress').hide();
|
||||||
$('#share-link').hide();
|
$('#share-link').hide();
|
||||||
copyBtn.attr('disabled', false);
|
$copyBtn.attr('disabled', false);
|
||||||
copyBtn.html('Copy');
|
$copyBtn.html('Copy');
|
||||||
});
|
});
|
||||||
|
|
||||||
// on file upload by browse or drag & drop
|
// on file upload by browse or drag & drop
|
||||||
@ -49,11 +56,11 @@ $(document).ready(function() {
|
|||||||
let link = document.createElement('td');
|
let link = document.createElement('td');
|
||||||
let expiry = document.createElement('td');
|
let expiry = document.createElement('td');
|
||||||
let del = document.createElement('td');
|
let del = document.createElement('td');
|
||||||
|
del.setAttribute('align', 'center');
|
||||||
let btn = document.createElement('button');
|
let btn = document.createElement('button');
|
||||||
let popupDiv = document.createElement('div');
|
let popupDiv = document.createElement('div');
|
||||||
let $popupText = $('<span>', { 'class': 'popuptext' });
|
let $popupText = $('<span>', { 'class': 'popuptext' });
|
||||||
let cellText = document.createTextNode(file.name);
|
let cellText = document.createTextNode(file.name);
|
||||||
let progress = document.createElement('p');
|
|
||||||
|
|
||||||
name.appendChild(cellText);
|
name.appendChild(cellText);
|
||||||
|
|
||||||
@ -75,7 +82,6 @@ $(document).ready(function() {
|
|||||||
$(popupDiv).append($popupText);
|
$(popupDiv).append($popupText);
|
||||||
del.appendChild(popupDiv);
|
del.appendChild(popupDiv);
|
||||||
row.appendChild(del);
|
row.appendChild(del);
|
||||||
$fileList.append(row); //add row to table
|
|
||||||
|
|
||||||
const fileSender = new FileSender(file);
|
const fileSender = new FileSender(file);
|
||||||
fileSender.on('progress', percentComplete => {
|
fileSender.on('progress', percentComplete => {
|
||||||
@ -83,7 +89,9 @@ $(document).ready(function() {
|
|||||||
$('#file-list').hide();
|
$('#file-list').hide();
|
||||||
$('#upload-progress').show();
|
$('#upload-progress').show();
|
||||||
$('#upload-filename').innerHTML += file.name;
|
$('#upload-filename').innerHTML += file.name;
|
||||||
progress.innerText = `Progress: ${percentComplete}%`;
|
// update progress bar
|
||||||
|
document.querySelector('#progress-bar').style.setProperty('--progress', percentComplete+'%');
|
||||||
|
$('#progress-text').html(`${percentComplete}%`);
|
||||||
});
|
});
|
||||||
fileSender.upload().then(info => {
|
fileSender.upload().then(info => {
|
||||||
const url = info.url.trim() + `#${info.secretKey}`.trim();
|
const url = info.url.trim() + `#${info.secretKey}`.trim();
|
||||||
@ -97,16 +105,19 @@ $(document).ready(function() {
|
|||||||
info.fileId,
|
info.fileId,
|
||||||
localStorage.getItem(info.fileId)
|
localStorage.getItem(info.fileId)
|
||||||
).then(() => {
|
).then(() => {
|
||||||
//
|
|
||||||
$(e.target).parents('tr').remove();
|
$(e.target).parents('tr').remove();
|
||||||
localStorage.removeItem(info.fileId);
|
localStorage.removeItem(info.fileId);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// show popup
|
// show popup
|
||||||
btn.addEventListener('click', toggleShow);
|
del.addEventListener('click', toggleShow);
|
||||||
// hide popup
|
// hide popup
|
||||||
$popupText.find('.nvm').click(toggleShow);
|
$popupText.find('.nvm').click(toggleShow);
|
||||||
|
|
||||||
|
$fileList.append(row); //add row to table
|
||||||
|
$('#page-one').hide();
|
||||||
|
$('#file-list').hide();
|
||||||
$('#upload-progress').hide();
|
$('#upload-progress').hide();
|
||||||
$('#share-link').show();
|
$('#share-link').show();
|
||||||
});
|
});
|
||||||
|
@ -43,6 +43,7 @@ input, select, textarea, button {
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
#browse {
|
#browse {
|
||||||
@ -152,7 +153,13 @@ td {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** upload-progress **/
|
/** upload-progress **/
|
||||||
|
#progress-bar {
|
||||||
|
width: 300px;
|
||||||
|
height: 5px;
|
||||||
|
background: linear-gradient(90deg, #FD9800, #D73000 var(--progress), white var(--progress));
|
||||||
|
border: 0.5px solid;
|
||||||
|
border-radius: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
/** share-link **/
|
/** share-link **/
|
||||||
.share-window {
|
.share-window {
|
||||||
@ -233,10 +240,32 @@ td {
|
|||||||
cursor: auto;
|
cursor: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
#download {
|
#download-page-one {
|
||||||
|
margin: 0 auto;
|
||||||
|
width: 470px;
|
||||||
|
height: 250px;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
flex-direction: column;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
#expired-img {
|
#expired-img {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#download-progress {
|
||||||
|
margin: 0 auto;
|
||||||
|
width: 470px;
|
||||||
|
height: 250px;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
flex-direction: column;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
#download-text {
|
||||||
|
margin-bottom: 40px;
|
||||||
|
}
|
||||||
|
@ -16,15 +16,29 @@
|
|||||||
Your friend is sending you a file: <br>
|
Your friend is sending you a file: <br>
|
||||||
{{{filename}}} ({{{filesize}}})
|
{{{filename}}} ({{{filesize}}})
|
||||||
</div>
|
</div>
|
||||||
|
<div id="download-page-one">
|
||||||
<div class="share-window">
|
<div>
|
||||||
<button id="download-btn" onclick="download()">Download File</button>
|
<button id="download-btn" onclick="download()">Download File</button>
|
||||||
<img id="expired-img" src="/resources/link_expired.png"/>
|
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="download-progress">
|
||||||
|
<div id="download-text">
|
||||||
|
Downloading File...
|
||||||
|
</div>
|
||||||
|
<div class="upload">
|
||||||
|
<!-- progress bar here -->
|
||||||
|
<div id="progress-bar"></div>
|
||||||
|
<div id="progress-text"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="send-new" id="send-file">
|
<div class="send-new" id="send-file">
|
||||||
Send your own files
|
Send your own files
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{else}}
|
{{else}}
|
||||||
|
|
||||||
<div class="title">
|
<div class="title">
|
||||||
This link has expired or never existed in the first place.
|
This link has expired or never existed in the first place.
|
||||||
</div>
|
</div>
|
||||||
@ -35,6 +49,7 @@
|
|||||||
<div class="send-new" id="send-file">
|
<div class="send-new" id="send-file">
|
||||||
Send your own files
|
Send your own files
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -52,6 +52,8 @@
|
|||||||
<div id="upload-img"><img src="/resources/upload.svg"/></div>
|
<div id="upload-img"><img src="/resources/upload.svg"/></div>
|
||||||
<div class="upload">
|
<div class="upload">
|
||||||
<!-- progress bar here -->
|
<!-- progress bar here -->
|
||||||
|
<div id="progress-bar"></div>
|
||||||
|
<div id="progress-text"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user