Skip to content

Commit

Permalink
handle history list files
Browse files Browse the repository at this point in the history
  • Loading branch information
vubui committed Nov 9, 2013
1 parent abb85b3 commit 38cfc9d
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 9 deletions.
2 changes: 1 addition & 1 deletion app/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ hr {
display:inline-block;
vertical-align:top;
color:#30693D;
width:100px;
width:200px;
margin-left:10px;
margin-right:5px;
padding-top: 5px;
Expand Down
5 changes: 3 additions & 2 deletions app/history.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<link href="css/bootstrap.min.css" rel="stylesheet">

<script src="https://www.dropbox.com/static/api/dropbox-datastores-1.0-latest.js"></script>
<script src="js/dropbox.js"></script>
<script src="js/history.js"></script>

</head>
<body>
Expand All @@ -33,7 +33,8 @@
<hr>

<h2 >File History</h2>
<div> </div>
<div class="statusbar"><div class="filename">FILE NAME</div><div class="filesize">DELETION TIME</div></div>
<div class="history"> </div>

</div>

Expand Down
39 changes: 33 additions & 6 deletions app/js/history.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ function createStatusbar(obj)
this.statusbar = $("<div class='statusbar "+row+"'></div>");
this.filename = $("<div class='filename'></div>").appendTo(this.statusbar);
this.size = $("<div class='filesize'></div>").appendTo(this.statusbar);
/*this.progressBar = $("<div class='progressBar'><div></div></div>").appendTo(this.statusbar);
*/

obj.after(this.statusbar);

this.setFileNameSize = function(name,size)
{
var sizeStr="";
/* var sizeStr="";
var sizeKB = size/1024;
if(parseInt(sizeKB) > 1024)
{
Expand All @@ -24,8 +23,36 @@ function createStatusbar(obj)
{
sizeStr = sizeKB.toFixed(2)+" KB";
}

*/
this.filename.html(name);
this.size.html(sizeStr);
this.size.html(size);
}
}
}

function updateHistory(files,obj)
{
for (var i = 0; i < files.length; i++)
{
var status = new createStatusbar(obj); //Using this we can set progress.
status.setFileNameSize(files[i].file_name,files[i].deletion_date.$date);
}
}

files = {};

// ajax
$.ajax({
type: "GET",
dataType: "json",
url: "https://api.mongolab.com/api/1/databases/snapbox/collections/schedule?apiKey=YUKjYvofAmJT5vdbqQOs6uerLIkbeV7v",
success: function(response) {
files = response;
console.log(response);
},
error: function(error) {
console.log(error);
}
}).done(function() {
var obj = $(".history");
updateHistory(files, obj);
});

0 comments on commit 38cfc9d

Please sign in to comment.