mirror of
				https://github.com/flynx/ImageGrid.git
				synced 2025-11-03 21:00:14 +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
 | 
					// 	- queued <path>			- json file path queued for loading
 | 
				
			||||||
// 	- loaded <path>			- done loading json file path
 | 
					// 	- loaded <path>			- done loading json file path
 | 
				
			||||||
// 	- index <path> <data>	- done loding index at 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:
 | 
					// XXX test with:
 | 
				
			||||||
// 		requirejs(['file'], 
 | 
					// 		requirejs(['file'], 
 | 
				
			||||||
@ -97,6 +98,8 @@ function loadJSON(path){
 | 
				
			|||||||
// 				f = m.loadIndex("L:/mnt/hdd15 (photo)/NTFS1/media/img/others") })
 | 
					// 				f = m.loadIndex("L:/mnt/hdd15 (photo)/NTFS1/media/img/others") })
 | 
				
			||||||
// 			.done(function(d){ console.log(d) })
 | 
					// 			.done(function(d){ console.log(d) })
 | 
				
			||||||
// XXX need to do better error handling...
 | 
					// XXX need to do better error handling...
 | 
				
			||||||
 | 
					// XXX a bit overcomplicated, see if this can be split into more generic 
 | 
				
			||||||
 | 
					// 		sections...
 | 
				
			||||||
var loadIndex =
 | 
					var loadIndex =
 | 
				
			||||||
module.loadIndex = 
 | 
					module.loadIndex = 
 | 
				
			||||||
function(path, logger){
 | 
					function(path, logger){
 | 
				
			||||||
@ -212,23 +215,16 @@ function(path, logger){
 | 
				
			|||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			var res = {}
 | 
								var res = {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								// XXX handle 'error' event...
 | 
				
			||||||
			listIndexes(path)
 | 
								listIndexes(path)
 | 
				
			||||||
				.on('end', function(indexes){
 | 
					 | 
				
			||||||
					var i = indexes.length
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
					indexes.forEach(function(path){ 
 | 
					 | 
				
			||||||
						loadIndex(path, logger) 
 | 
					 | 
				
			||||||
				// collect the found indexes...
 | 
									// collect the found indexes...
 | 
				
			||||||
							.done(function(obj){
 | 
									.on('match', function(path){
 | 
				
			||||||
								i -= 1
 | 
										loadIndex(path, logger) 
 | 
				
			||||||
								res[path] = obj[path]
 | 
											.done(function(obj){ res[path] = obj[path] })
 | 
				
			||||||
 | 
									})
 | 
				
			||||||
								// call this when the load is done...
 | 
									// done...
 | 
				
			||||||
								if(i <= 0){
 | 
									.on('end', function(paths){
 | 
				
			||||||
					resolve(res)
 | 
										resolve(res)
 | 
				
			||||||
								}
 | 
					 | 
				
			||||||
							})
 | 
					 | 
				
			||||||
					})
 | 
					 | 
				
			||||||
				})
 | 
									})
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user