var vfs_upload_queue = []; function dragover(e){ e.preventDefault(); var dropzone = document.getElementById("dropzone"); dropzone.style.backgroundColor = "#E6E6FF"; } function dragout(e){ var dropzone = document.getElementById("dropzone"); dropzone.style.backgroundColor = "white"; } function drop(e){ e.preventDefault(); var dropzone = document.getElementById("dropzone"); dropzone.style.backgroundColor = "white"; addToUploadQueue(e.dataTransfer.files); } function addToUploadQueue(files){ for(file of files){ try { reader = new FileReader(); reader.readAsBinaryString(file); } catch (NS_ERROR_FILE_ACCESS_DENIED) { //file is a directory. Dropping of directories is only implemented in chrome > v21. alert("file is a directory. Dropping of directories is only implemented in chrome > v21."); break; } var filelist = document.getElementById("filelist"); 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 = "filesizeCol"; var progressBar = document.createElement("progress"); progressBar.id="progressBar-"+file.name; progressBar.className="progressBar"; progressBar.style.display="none"; var progressPending = document.createElement("p"); progressPending.id="progressPending-"+file.name; progressPending.appendChild(document.createTextNode("pending")); var progressCol = document.createElement("td"); progressCol.className="progressCol"; progressCol.appendChild(progressBar); progressCol.appendChild(progressPending); 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); filelist.appendChild(entry); vfs_upload_queue.push(file); } } function upload(){ for(i = 0; i