mirror of
				https://github.com/flynx/ImageGrid.git
				synced 2025-10-31 03:10:07 +00:00 
			
		
		
		
	started making the data merging/splitting API...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									25db2b730a
								
							
						
					
					
						commit
						9f79d00eeb
					
				
							
								
								
									
										62
									
								
								ui/data.js
									
									
									
									
									
								
							
							
						
						
									
										62
									
								
								ui/data.js
									
									
									
									
									
								
							| @ -154,6 +154,26 @@ var WORKERS = {} | |||||||
| * Helpers | * Helpers | ||||||
| */ | */ | ||||||
| 
 | 
 | ||||||
|  | // Zip concatenate lists from each argument.
 | ||||||
|  | //
 | ||||||
|  | // NOTE: this will skip null values.
 | ||||||
|  | function concatZip(){ | ||||||
|  | 	var res = [] | ||||||
|  | 	$.each(arguments, function(i, lst){ | ||||||
|  | 		$.each(lst, function(j, e){ | ||||||
|  | 			if(e != null){ | ||||||
|  | 				if(res[j] == null){ | ||||||
|  | 					res[j] = e | ||||||
|  | 				} else { | ||||||
|  | 					res[j] = res[j].concat(e) | ||||||
|  | 				} | ||||||
|  | 			} | ||||||
|  | 		}) | ||||||
|  | 	}) | ||||||
|  | 	return res | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| function makeDistanceCmp(start, get){ | function makeDistanceCmp(start, get){ | ||||||
| 	if(get == null){ | 	if(get == null){ | ||||||
| 		return function(a, b){ | 		return function(a, b){ | ||||||
| @ -392,7 +412,7 @@ Array.prototype.binSearch = function(target, cmp, get){ | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| // Orientation transaltion...
 | // Orientation translation...
 | ||||||
| function orientationExif2ImageGrid(orientation){ | function orientationExif2ImageGrid(orientation){ | ||||||
| 	return { | 	return { | ||||||
| 		orientation: { | 		orientation: { | ||||||
| @ -698,6 +718,46 @@ function dataFromImages(images){ | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | // Merge two data objects
 | ||||||
|  | //
 | ||||||
|  | //
 | ||||||
|  | //	(A)							(B)
 | ||||||
|  | //		oooooooooo		-+-
 | ||||||
|  | //	oooooooooooooooooo	 + shift
 | ||||||
|  | //	  oooooooooooooo	-+-			ooooooooooo
 | ||||||
|  | //	oooooooooooooooooo			ooooooooooooooooo
 | ||||||
|  | //								 ooooooooooooooo
 | ||||||
|  | //
 | ||||||
|  | // Negative shift moves (A) up while positive moves it down relative to (B)
 | ||||||
|  | // In the diagram above the shift is -2
 | ||||||
|  | //
 | ||||||
|  | function mergeData(data_a, data_b, shift){ | ||||||
|  | 	// pad the head of the shifted array...
 | ||||||
|  | 	var a = data_a.ribbons | ||||||
|  | 	var b = data_b.ribbons | ||||||
|  | 	if(shift > 0){ | ||||||
|  | 		a = new Array(shift).concat(a) | ||||||
|  | 	} else if(shift < 0) { | ||||||
|  | 		b = new Array(Math.abs(shift)).concat(b) | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	return { | ||||||
|  | 		version: '2.0', | ||||||
|  | 		// XXX should we set this here???
 | ||||||
|  | 		current: null, | ||||||
|  | 		ribbons: concatZip(a, b), | ||||||
|  | 		// XXX should we sort this???
 | ||||||
|  | 		order: data_a.order.concat(data_b.order), | ||||||
|  | 		image_file: null | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | function splitDataAt(gid, data){ | ||||||
|  | 	// XXX
 | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| /********************************************************************** | /********************************************************************** | ||||||
| * Format conversion | * Format conversion | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user