summaryrefslogtreecommitdiffstats
path: root/js
diff options
context:
space:
mode:
authorRobin <robin@Amaya.(none)>2010-04-25 15:04:13 +0200
committerRobin <robin@Amaya.(none)>2010-04-25 15:04:13 +0200
commitafc0ef420b58b92e38ea600c2eac972ed132fbac (patch)
tree3ced70c323eb110da0738b75556783953cf85322 /js
parentc2bdd6134be53dcf822632192af10cf3cf80be1e (diff)
downloadnextcloud-server-afc0ef420b58b92e38ea600c2eac972ed132fbac.tar.gz
nextcloud-server-afc0ef420b58b92e38ea600c2eac972ed132fbac.zip
bug fix when starting multiply uploads while the old ones arent finsihed, detect file actions on mimetype not on extention
Diffstat (limited to 'js')
-rw-r--r--js/filebrowser.js6
-rw-r--r--js/lib_files.js48
2 files changed, 34 insertions, 20 deletions
diff --git a/js/filebrowser.js b/js/filebrowser.js
index f12cec44143..cc03fe33156 100644
--- a/js/filebrowser.js
+++ b/js/filebrowser.js
@@ -129,16 +129,16 @@ OC_FILES.browser.files.show=function(parent,fileList){
for(name in fileList){
file=fileList[name];
if(!OC_FILES.browser.files.fileNodes[file.name]){
- OC_FILES.browser.files.add(file.name,file.type,file.size,file.date);
+ OC_FILES.browser.files.add(file.name,file.type,file.size,file.date,file.mime);
}
}
}
}
-OC_FILES.browser.files.add=function(name,type,size,date){
+OC_FILES.browser.files.add=function(name,type,size,date,mime){
if(name){
if(!size) size=0;
if(!date) date=getTimeString();
- OC_FILES.files[name]=new OC_FILES.file(OC_FILES.dir,name,type);
+ OC_FILES.files[name]=new OC_FILES.file(OC_FILES.dir,name,type,mime);
tr=document.createElement('tr');
OC_FILES.browser.files.fileNodes[name]=tr;
OC_FILES.browser.files.tbody.appendChild(tr);
diff --git a/js/lib_files.js b/js/lib_files.js
index 7c23ee16a9d..f60b399746d 100644
--- a/js/lib_files.js
+++ b/js/lib_files.js
@@ -49,7 +49,7 @@ OC_FILES.getdirectorycontent_parse=function(req){
if(fileElements.length>0){
for(index=0;index<fileElements.length;index++){
var file=new Array();
- var attributes=Array('size','name','type','directory','date');
+ var attributes=Array('size','name','type','directory','date','mime');
for(i in attributes){
var name=attributes[i];
file[name]=fileElements.item(index).getAttribute(name);
@@ -106,6 +106,11 @@ OC_FILES.upload=function(dir,iframeId){
return false;
}
}
+ var mime='';
+ if(fileSelector.files && fileSelector.files[0].type){
+ var mime=fileSelector.files[0].type;
+ }
+ file.dir=dir;
file.dir=dir;
file.name=name;
file.type='file';
@@ -118,9 +123,10 @@ OC_FILES.upload=function(dir,iframeId){
OC_FILES.cache.incomplete[dir][name]['name']=name;
OC_FILES.cache.incomplete[dir][name]['type']='incomplete';
OC_FILES.cache.incomplete[dir][name]['size']=size;
+ OC_FILES.cache.incomplete[dir][name]['mime']=mime;
OC_FILES.uploadIFrames[iframeId].file=file;
OC_FILES.uploadIFrames[iframeId].addEvent('onload',new callBack(OC_FILES.upload_callback,OC_FILES.uploadIFrames[iframeId]));
- OC_FILES.browser.files.add(name,'incomplete',size);
+ OC_FILES.browser.files.add(name,'incomplete',size,null,mime);
OC_FILES.uploadForm.submit();
if(OC_FILES.uploadForm.parentElement){
OC_FILES.uploadForm.className='hidden';
@@ -137,11 +143,11 @@ OC_FILES.upload_callback=function(iframeId){
if(OC_FILES.cache.incomplete[file.dir][file.name]){
OC_FILES.browser.files.remove(file.name);
OC_FILES.cache.files[file.name]=OC_FILES.cache.incomplete[file.dir][file.name]
- OC_FILES.cache.incomplete[file.dir][file.name]=null;
+ delete OC_FILES.cache.incomplete[file.dir][file.name];
OC_FILES.cache.files[file.name]['type']=file.type;
this.uploadForm.parentNode.removeChild(this.uploadForm);
this.parentNode.removeChild(this);
- delete OC_FILES.uploadIFrames[file.iframeId];
+ OC_FILES.uploadIFrames[file.iframeId]=null;
OC_FILES.browser.show(file.dir);
}
}
@@ -305,11 +311,17 @@ OC_FILES.actions_selected['delete']=function(){
OC_FILES.files=Array();
-OC_FILES.file=function(dir,file,type){
+OC_FILES.file=function(dir,file,type,mime){
if(file){
this.type=type;
this.file=file;
this.dir=dir;
+ this.mime=mime;
+ if(mime){
+ var mimeParts=mime.split('/');
+ this.mime1=mimeParts[0];
+ this.mime2=mimeParts[1];
+ }
this.actions=new Object();
if(file.lastIndexOf('.')){
this.extention=file.substr(file.lastIndexOf('.')+1);
@@ -328,10 +340,17 @@ OC_FILES.file=function(dir,file,type){
}
}
}
- if(OC_FILES.fileActions[this.extention]){
- for(index in OC_FILES.fileActions[this.extention]){
- if(OC_FILES.fileActions[this.extention][index].call){
- this.actions[index]=OC_FILES.fileActions[this.extention][index];
+ if(OC_FILES.fileActions[this.mime1]){
+ for(index in OC_FILES.fileActions[this.mime1]){
+ if(OC_FILES.fileActions[this.mime1][index].call){
+ this.actions[index]=OC_FILES.fileActions[this.mime1][index];
+ }
+ }
+ }
+ if(OC_FILES.fileActions[this.mime]){
+ for(index in OC_FILES.fileActions[this.mime]){
+ if(OC_FILES.fileActions[this.mime][index].call){
+ this.actions[index]=OC_FILES.fileActions[this.mime][index];
}
}
}
@@ -372,15 +391,10 @@ OC_FILES.fileActions.dir.dropOn=function(file){
OC_FILES.move(file.file,file.file,file.dir,this.dir+'/'+this.file);
}
-OC_FILES.fileActions.jpg=new Object()
+OC_FILES.fileActions.image=new Object()
-OC_FILES.fileActions.jpg.show=function(){
+OC_FILES.fileActions.image.show=function(){
OC_FILES.browser.showImage(this.dir,this.file);
}
-OC_FILES.fileActions.jpg['default']=OC_FILES.fileActions.jpg.show;
-
-OC_FILES.fileActions.jpeg=OC_FILES.fileActions.jpg
-OC_FILES.fileActions.png=OC_FILES.fileActions.jpg
-OC_FILES.fileActions.gif=OC_FILES.fileActions.jpg
-OC_FILES.fileActions.bmp=OC_FILES.fileActions.jpg \ No newline at end of file
+OC_FILES.fileActions.image['default']=OC_FILES.fileActions.image.show; \ No newline at end of file