aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Appelman <icewind1991@gmail.com>2011-07-29 01:10:08 +0200
committerRobin Appelman <icewind1991@gmail.com>2011-07-29 01:10:08 +0200
commit82261e99073047dd72ecec927f33ff5fea3cbffd (patch)
treee1a1f9d4ce029a236dcee10129bfc47581dd8470
parentf1616b0e629ec5fd59a859748e64418862691597 (diff)
downloadnextcloud-server-82261e99073047dd72ecec927f33ff5fea3cbffd.tar.gz
nextcloud-server-82261e99073047dd72ecec927f33ff5fea3cbffd.zip
use relative times for new upload files
-rw-r--r--files/js/filelist.js16
-rw-r--r--files/js/files.js29
2 files changed, 38 insertions, 7 deletions
diff --git a/files/js/filelist.js b/files/js/filelist.js
index e4ec97e5068..252a9c95807 100644
--- a/files/js/filelist.js
+++ b/files/js/filelist.js
@@ -24,8 +24,10 @@ FileList={
simpleSize='Pending';
}
sizeColor = Math.round(200-Math.pow((size/(1024*1024)),2));
+ lastModifiedTime=Math.round(lastModified.getTime() / 1000);
+ modifiedColor=Math.round((Math.round((new Date()).getTime() / 1000)-lastModifiedTime)/60/60/24*5);
html+='<td class="filesize" title="'+humanFileSize(size)+'" style="color:rgb('+sizeColor+','+sizeColor+','+sizeColor+')">'+simpleSize+'</td>';
- html+='<td class="date">'+lastModified+'</td>';
+ html+='<td class="date" title="'+formatDate(lastModified)+'" style="color:rgb('+modifiedColor+','+modifiedColor+','+modifiedColor+')">'+relative_modified_date(lastModified.getTime() / 1000)+'</td>';
html+='</tr>';
FileList.insertElement(name,'file',$(html));
if(loading){
@@ -37,8 +39,16 @@ FileList={
addDir:function(name,size,lastModified){
var html='<tr data-file="'+name+'" data-type="dir">';
html+='<td class="filename"><input type="checkbox" /><a class="name" style="background-image:url(img/folder.png)" href="index.php?dir='+$('#dir').val()+'/'+name+'"><strong>'+name+'</strong></a></td>';
- html+='<td class="filesize">'+size+'</td>';
- html+='<td class="date">'+lastModified+'</td>';
+ if(size!='Pending'){
+ simpleSize=simpleFileSize(size);
+ }else{
+ simpleSize='Pending';
+ }
+ sizeColor = Math.round(200-Math.pow((size/(1024*1024)),2));
+ lastModifiedTime=Math.round(lastModified.getTime() / 1000);
+ modifiedColor=Math.round((Math.round((new Date()).getTime() / 1000)-lastModifiedTime)/60/60/24*5);
+ html+='<td class="filesize" title="'+humanFileSize(size)+'" style="color:rgb('+sizeColor+','+sizeColor+','+sizeColor+')">'+simpleSize+'</td>';
+ html+='<td class="date" title="'+formatDate(lastModified)+'" style="color:rgb('+modifiedColor+','+modifiedColor+','+modifiedColor+')">'+relative_modified_date(lastModified.getTime() / 1000)+'</td>';
html+='</tr>';
FileList.insertElement(name,'dir',$(html));
diff --git a/files/js/files.js b/files/js/files.js
index cd1689a2dd7..60f2b2aec87 100644
--- a/files/js/files.js
+++ b/files/js/files.js
@@ -62,8 +62,8 @@ $(document).ready(function() {
url: 'ajax/newfolder.php',
data: "dir="+$('#dir').val()+"&foldername="+$('#file_newfolder_name').val(),
complete: function(data){boolOperationFinished(data, function(){
- var date=formatDate(new Date());
- FileList.addDir($('#file_newfolder_name').val(),'0 B',date)
+ var date=new Date();
+ FileList.addDir($('#file_newfolder_name').val(),0,date)
});}
});
$('#file_newfolder_submit').fadeOut(250).trigger('vanish');
@@ -175,14 +175,13 @@ $(document).ready(function() {
});
form.submit();
var date=new Date();
- var uploadTime=formatDate(date);
for(var i=0;i<files.length;i++){
if(files[i].size>0){
var size=files[i].size;
}else{
var size='Pending';
}
- FileList.addFile(files[i].name,size,uploadTime,true);
+ FileList.addFile(files[i].name,size,date,true);
}
//clone the upload form and hide the new one to allow users to start a new upload while the old one is still uploading
@@ -416,3 +415,25 @@ function getSelectedFiles(property){
});
return files;
}
+
+function relative_modified_date(timestamp) {
+ var timediff = Math.round((new Date()).getTime() / 1000) - timestamp;
+ var diffminutes = Math.round(timediff/60);
+ var diffhours = Math.round(diffminutes/60);
+ var diffdays = Math.round(diffhours/24);
+ var diffmonths = Math.round(diffdays/31);
+ var diffyears = Math.round(diffdays/365);
+ if(timediff < 60) { return 'seconds ago'; }
+ else if(timediff < 120) { return '1 minute ago'; }
+ else if(timediff < 3600) { return diffminutes+' minutes ago'; }
+ //else if($timediff < 7200) { return '1 hour ago'; }
+ //else if($timediff < 86400) { return $diffhours.' hours ago'; }
+ else if(timediff < 86400) { return 'today'; }
+ else if(timediff < 172800) { return 'yesterday'; }
+ else if(timediff < 2678400) { return diffdays+' days ago'; }
+ else if(timediff < 5184000) { return 'last month'; }
+ //else if($timediff < 31556926) { return $diffmonths.' months ago'; }
+ else if(timediff < 31556926) { return 'months ago'; }
+ else if(timediff < 63113852) { return 'last year'; }
+ else { return diffyears+' years ago'; }
+}