Skip to content
Snippets Groups Projects
Select Git revision
  • 9805336c0aae4bbbce9ea52f36770d399aea89a4
  • master default protected
2 results

lib_files.js

Blame
  • lib_files.js 12.57 KiB
    /**
    * ownCloud - ajax frontend
    *
    * @author Robin Appelman
    * @copyright 2010 Robin Appelman icewind1991@gmail.com
    * 
    * This library is free software; you can redistribute it and/or
    * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
    * License as published by the Free Software Foundation; either 
    * version 3 of the License, or any later version.
    * 
    * This library is distributed in the hope that it will be useful,
    * but WITHOUT ANY WARRANTY; without even the implied warranty of
    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
    *  
    * You should have received a copy of the GNU Lesser General Public 
    * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
    * 
    */
    
    OC_FILES=new Object();
    
    OC_FILES.cache=new Object();
    
    OC_FILES.cache.files=Array();
    OC_FILES.cache.incomplete=Array();
    OC_FILES.cache.actions=new Object();
    
    OC_FILES.cache.actions.move=Array();
    OC_FILES.cache.actions.rename=Array();
    OC_FILES.cache.actions['new']=Array();
    OC_FILES.cache.actions['delete']=Array();
    OC_FILES.cache.actions.upload=Array();
    
    OC_FILES.cache.refresh=function(){
    	OC_FILES.getdirectorycontent(OC_FILES.dir,false,true);
    }
    
    OC_FILES.xmlloader=new OCXMLLoader();
    
    OC_FILES.getdirectorycontent_parse=function(req){
    	var files=new Array();
    	var json=eval('('+req.responseText+')');
    	OC_FILES.cache.files=Array();
    	if(json){
    		for(var name in json){
    			if(name!='__max_upload'){
    				var file=new Array();
    				var attributes=Array('size','name','type','directory','date','mime');
    				for(var i in attributes){
    					var attributeName=attributes[i];
    					file[attributeName]=json[name][attributeName];
    				}
    				files[file.name]=file;
    			}
    		}
    		OC_FILES.cache.files=files;
    		if(OC_FILES.cache.incomplete[OC_FILES.dir]){
    			files=arrayMerge(files,OC_FILES.cache.incomplete[OC_FILES.dir]);
    		}
    		files['max_upload']=json['__max_upload'];
    		if(OC_FILES.getdirectorycontent_callback){
    			OC_FILES.getdirectorycontent_callback(files);
    		}
    	}
    }
    
    OC_FILES.getdirectorycontent=function(dir,callback,refresh){
    	if(refresh || OC_FILES.dir!=dir){