From c89bd0fc5efb765166e6e7630c9c62cf917c6bda Mon Sep 17 00:00:00 2001 From: oweissbarth Date: Wed, 23 Jul 2014 09:46:07 +0200 Subject: Code Cleanup + Added filelist header --- www/static/js/dropzone.js | 84 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 59 insertions(+), 25 deletions(-) (limited to 'www/static/js/dropzone.js') diff --git a/www/static/js/dropzone.js b/www/static/js/dropzone.js index ba9b429..7accdc2 100644 --- a/www/static/js/dropzone.js +++ b/www/static/js/dropzone.js @@ -29,37 +29,71 @@ var vfs_upload_queue = []; break; } + var filelist = document.getElementById("filelist"); - var entry = document.createElement("tr"); - var filename = document.createElement("td"); - filename.appendChild(document.createTextNode(file.name)); + if(filelist.children.length==0){ + var entry = document.createElement("tr"); + var filenameCol = document.createElement("th"); + filenameCol.id="filename-head"; + filenameCol.appendChild(document.createTextNode("Name")); + + var filesizeCol = document.createElement("th"); + filesizeCol.id = "filesize-head"; + filesizeCol.appendChild(document.createTextNode("Size")); + + var publicCol = document.createElement("th"); + publicCol.id="public-head"; + var globeIcon = document.createElement("i"); + globeIcon.className="fa fa-globe"; + globeIcon.title="public"; + publicCol.appendChild(globeIcon); + + + var progressCol = document.createElement("th"); + progressCol.id="progress-head"; + progressCol.appendChild(document.createTextNode("Progress")); + + + entry.appendChild(filenameCol); + entry.appendChild(filesizeCol); + entry.appendChild(publicCol); + entry.appendChild(progressCol); + + filelist.appendChild(entry); + } + var entry = document.createElement("tr"); + var filename = document.createElement("td"); + filename.className="filenameCol"; + filename.appendChild(document.createTextNode(file.name)); - var filesize = document.createElement("td"); - filesize.appendChild(document.createTextNode(Math.floor(file.size/1024*100)/100+"KB")); - filesize.className = "filesize"; + var filesize = document.createElement("td"); + filesize.appendChild(document.createTextNode(Math.floor(file.size/1024*100)/100+"KB")); + filesize.className = "filesize"; - var progressBar = document.createElement("progress"); - progressBar.id="progressBar-"+file.name; - progressBar.className="progressBar"; - var progressCol = document.createElement("td"); - progressCol.className="progressCol"; - progressCol.appendChild(progressBar); + var progressBar = document.createElement("progress"); + progressBar.id="progressBar-"+file.name; + progressBar.className="progressBar"; + var progressCol = document.createElement("td"); + progressCol.className="progressCol"; + progressCol.appendChild(progressBar); - var publicCol = document.createElement("td"); - var public_at = document.createElement("input"); - public_at.type = "checkbox"; - public_at.id = "public-"+file.name; - publicCol.appendChild(public_at); + var publicCol = document.createElement("td"); + publicCol.className="publicCol"; + var public_at = document.createElement("input"); + public_at.type = "checkbox"; + public_at.id = "public-"+file.name; + public_at.title="public"; + publicCol.appendChild(public_at); - entry.appendChild(filename); - entry.appendChild(filesize); - entry.appendChild(publicCol); - entry.appendChild(progressCol); + entry.appendChild(filename); + entry.appendChild(filesize); + entry.appendChild(publicCol); + entry.appendChild(progressCol); - filelist.appendChild(entry); - vfs_upload_queue.push(file); - } + filelist.appendChild(entry); + vfs_upload_queue.push(file); + } } function upload(){ @@ -91,7 +125,7 @@ var vfs_upload_queue = []; xhr.upload.onprogress= function(e){ if(e.lengthComputable){ document.getElementById("progressBar-"+this.filename).value = Math.floor(e.loaded/e.total*100); - console.log(Math.floor(done/total*100)+"%"); + console.log(Math.floor(e.loaded/e.total*100)+"%"); }else{ alert("cant compute progress"); } -- cgit v1.2.3