mirror of
				https://github.com/flynx/ImageGrid.git
				synced 2025-11-04 13:20:10 +00:00 
			
		
		
		
	minor refactoring...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									c5a8e28f33
								
							
						
					
					
						commit
						004d574c14
					
				@ -89,7 +89,8 @@ function loadJSON(path){
 | 
			
		||||
// 	- queued <path>			- json file path queued for loading
 | 
			
		||||
// 	- loaded <path>			- done loading json file path
 | 
			
		||||
// 	- index <path> <data>	- done loding index at path
 | 
			
		||||
// 	- end <indexes>			- done loading all indexes
 | 
			
		||||
//
 | 
			
		||||
// NOTE: logger must be an event emitter...
 | 
			
		||||
//
 | 
			
		||||
// XXX test with:
 | 
			
		||||
// 		requirejs(['file'], 
 | 
			
		||||
@ -97,6 +98,8 @@ function loadJSON(path){
 | 
			
		||||
// 				f = m.loadIndex("L:/mnt/hdd15 (photo)/NTFS1/media/img/others") })
 | 
			
		||||
// 			.done(function(d){ console.log(d) })
 | 
			
		||||
// XXX need to do better error handling...
 | 
			
		||||
// XXX a bit overcomplicated, see if this can be split into more generic 
 | 
			
		||||
// 		sections...
 | 
			
		||||
var loadIndex =
 | 
			
		||||
module.loadIndex = 
 | 
			
		||||
function(path, logger){
 | 
			
		||||
@ -212,23 +215,16 @@ function(path, logger){
 | 
			
		||||
		} else {
 | 
			
		||||
			var res = {}
 | 
			
		||||
 | 
			
		||||
			// XXX handle 'error' event...
 | 
			
		||||
			listIndexes(path)
 | 
			
		||||
				.on('end', function(indexes){
 | 
			
		||||
					var i = indexes.length
 | 
			
		||||
 | 
			
		||||
					indexes.forEach(function(path){ 
 | 
			
		||||
						loadIndex(path, logger) 
 | 
			
		||||
				// collect the found indexes...
 | 
			
		||||
							.done(function(obj){
 | 
			
		||||
								i -= 1
 | 
			
		||||
								res[path] = obj[path]
 | 
			
		||||
 | 
			
		||||
								// call this when the load is done...
 | 
			
		||||
								if(i <= 0){
 | 
			
		||||
				.on('match', function(path){
 | 
			
		||||
					loadIndex(path, logger) 
 | 
			
		||||
						.done(function(obj){ res[path] = obj[path] })
 | 
			
		||||
				})
 | 
			
		||||
				// done...
 | 
			
		||||
				.on('end', function(paths){
 | 
			
		||||
					resolve(res)
 | 
			
		||||
								}
 | 
			
		||||
							})
 | 
			
		||||
					})
 | 
			
		||||
				})
 | 
			
		||||
		}
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user