use relative times for new upload files
This commit is contained in:
parent
f1616b0e62
commit
82261e9907
2 changed files with 38 additions and 7 deletions
|
@ -24,8 +24,10 @@ FileList={
|
||||||
simpleSize='Pending';
|
simpleSize='Pending';
|
||||||
}
|
}
|
||||||
sizeColor = Math.round(200-Math.pow((size/(1024*1024)),2));
|
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="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>';
|
html+='</tr>';
|
||||||
FileList.insertElement(name,'file',$(html));
|
FileList.insertElement(name,'file',$(html));
|
||||||
if(loading){
|
if(loading){
|
||||||
|
@ -37,8 +39,16 @@ FileList={
|
||||||
addDir:function(name,size,lastModified){
|
addDir:function(name,size,lastModified){
|
||||||
var html='<tr data-file="'+name+'" data-type="dir">';
|
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="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>';
|
if(size!='Pending'){
|
||||||
html+='<td class="date">'+lastModified+'</td>';
|
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>';
|
html+='</tr>';
|
||||||
|
|
||||||
FileList.insertElement(name,'dir',$(html));
|
FileList.insertElement(name,'dir',$(html));
|
||||||
|
|
|
@ -62,8 +62,8 @@ $(document).ready(function() {
|
||||||
url: 'ajax/newfolder.php',
|
url: 'ajax/newfolder.php',
|
||||||
data: "dir="+$('#dir').val()+"&foldername="+$('#file_newfolder_name').val(),
|
data: "dir="+$('#dir').val()+"&foldername="+$('#file_newfolder_name').val(),
|
||||||
complete: function(data){boolOperationFinished(data, function(){
|
complete: function(data){boolOperationFinished(data, function(){
|
||||||
var date=formatDate(new Date());
|
var date=new Date();
|
||||||
FileList.addDir($('#file_newfolder_name').val(),'0 B',date)
|
FileList.addDir($('#file_newfolder_name').val(),0,date)
|
||||||
});}
|
});}
|
||||||
});
|
});
|
||||||
$('#file_newfolder_submit').fadeOut(250).trigger('vanish');
|
$('#file_newfolder_submit').fadeOut(250).trigger('vanish');
|
||||||
|
@ -175,14 +175,13 @@ $(document).ready(function() {
|
||||||
});
|
});
|
||||||
form.submit();
|
form.submit();
|
||||||
var date=new Date();
|
var date=new Date();
|
||||||
var uploadTime=formatDate(date);
|
|
||||||
for(var i=0;i<files.length;i++){
|
for(var i=0;i<files.length;i++){
|
||||||
if(files[i].size>0){
|
if(files[i].size>0){
|
||||||
var size=files[i].size;
|
var size=files[i].size;
|
||||||
}else{
|
}else{
|
||||||
var size='Pending';
|
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
|
//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;
|
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'; }
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue