file list ui

This commit is contained in:
Daniela Arcese 2017-06-02 16:56:32 -04:00
parent cc0ece20de
commit d7e4077640
3 changed files with 143 additions and 101 deletions

View File

@ -9,6 +9,7 @@
<body background="resources/background.png"> <body background="resources/background.png">
<div class="main-window"> <div class="main-window">
<div id="page-one">
<div class="title"> <div class="title">
Share your files quickly, privately and securely. Share your files quickly, privately and securely.
</div> </div>
@ -28,12 +29,22 @@
</form> </form>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<ul id="uploaded_files"> <div id="file-list">
</ul> <table id="uploaded-files">
<tr>
<th width=30%>File</th>
<th width=45%>Copy URL</th>
<th width=20%>Expires in</th>
<th width=5%>Delete</th>
</tr>
</table>
</div>
</div>
</body> </body>
</html> </html>

View File

@ -1,4 +1,6 @@
/*** index.html ***/ /*** index.html ***/
/** page-one **/
body { body {
font-family: 'Fira Sans'; font-family: 'Fira Sans';
font-weight: 300; font-weight: 300;
@ -64,3 +66,26 @@ form{
width: 45px; width: 45px;
float: right; float: right;
} }
/** file-list **/
th{
font-size: 10px;
color: #737373;
font-weight: normal;
text-align: left;
}
td{
font-size: 12px;
vertical-align: top;
}
#uploaded-files{
width: 472px;
margin: 10px auto ;
float: top;
table-layout: fixed;
overflow-y: scroll;
}
#file-list{
overflow-y: scroll;
height: 90px;
}

View File

@ -32,20 +32,24 @@ function onChange(event) {
var hex = ivToStr(random_iv); var hex = ivToStr(random_iv);
xhr.open("post", "/upload/" + hex, true); xhr.open("post", "/upload/" + hex, true);
var li = document.createElement("li"); var row = document.createElement("tr");
var name = document.createElement("p"); var name = document.createElement("td");
name.innerHTML = file.name; var link = document.createElement("td");
li.appendChild(name); var expiry = document.createElement("td");
var link = document.createElement("a"); var cellText = document.createTextNode(file.name);
li.appendChild(link); //name.innerHTML = file.name;
name.appendChild(cellText);
var progress = document.createElement("p"); var progress = document.createElement("p");
li.appendChild(progress); //li.appendChild(progress);
document.getElementById("uploaded_files").appendChild(li); row.appendChild(name);
row.appendChild(link);
row.appendChild(expiry);
document.getElementById("uploaded-files").appendChild(row);
xhr.upload.addEventListener("progress", returnBindedLI(progress, name, link, li)); xhr.upload.addEventListener("progress", returnBindedLI(progress, name, link, row));
xhr.onreadystatechange = function() { xhr.onreadystatechange = function() {
if (xhr.readyState == XMLHttpRequest.DONE) { if (xhr.readyState == XMLHttpRequest.DONE) {
@ -106,8 +110,10 @@ function returnBindedLI(a_element, name, link, li) {
a_element.innerHTML = "Progress: " + percentComplete + "%"; a_element.innerHTML = "Progress: " + percentComplete + "%";
if (percentComplete === 100) { if (percentComplete === 100) {
var del = document.createElement("td");
var btn = document.createElement("button"); var btn = document.createElement("button");
btn.innerHTML = "Delete from server"; btn.innerHTML = "x";
btn.style = "padding: 0; border: none; background: none; cursor: pointer"
btn.addEventListener("click", function() { btn.addEventListener("click", function() {
var segments = link.innerHTML.split("/"); var segments = link.innerHTML.split("/");
var key = segments[segments.length - 2]; var key = segments[segments.length - 2];
@ -121,7 +127,7 @@ function returnBindedLI(a_element, name, link, li) {
xhr.onreadystatechange = function() { xhr.onreadystatechange = function() {
if (xhr.readyState === XMLHttpRequest.DONE) { if (xhr.readyState === XMLHttpRequest.DONE) {
document.getElementById("uploaded_files").removeChild(li); document.getElementById("uploaded-files").removeChild(li);
localStorage.removeItem(key); localStorage.removeItem(key);
} }
@ -133,9 +139,9 @@ function returnBindedLI(a_element, name, link, li) {
} }
}); });
li.appendChild(btn); del.appendChild(btn);
li.appendChild(del);
} }
} }
} }
} }