mirror of
				https://github.com/flynx/ImageGrid.git
				synced 2025-10-31 11:20:09 +00:00 
			
		
		
		
	started work on sorting...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									2f024149a9
								
							
						
					
					
						commit
						0c3b584ca8
					
				
							
								
								
									
										39
									
								
								ui/data.js
									
									
									
									
									
								
							
							
						
						
									
										39
									
								
								ui/data.js
									
									
									
									
									
								
							| @ -38,6 +38,7 @@ var DATA = { | |||||||
| 	order: $(new Array(100)).map(function(i){return i}).toArray(), | 	order: $(new Array(100)).map(function(i){return i}).toArray(), | ||||||
| 	// the images object, this is indexed by image GID and contains all 
 | 	// the images object, this is indexed by image GID and contains all 
 | ||||||
| 	// the needed data...
 | 	// the needed data...
 | ||||||
|  | 	// XXX should we split this out?
 | ||||||
| 	images: {} | 	images: {} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -51,6 +52,26 @@ var IMAGE_CACHE = [] | |||||||
| * Helpers | * Helpers | ||||||
| */ | */ | ||||||
| 
 | 
 | ||||||
|  | // NOTE: this expects gids...
 | ||||||
|  | function imageDateCmp(a, b){ | ||||||
|  | 	return DATA.images[b].ctime - DATA.images[a].ctime | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | // NOTE: this expects gids...
 | ||||||
|  | function imageNameCmp(a, b){ | ||||||
|  | 	a = DATA.images[b].path.split('/')[-1] | ||||||
|  | 	b = DATA.images[a].path.split('/')[-1] | ||||||
|  | 	if(a == b){ | ||||||
|  | 		return 0 | ||||||
|  | 	} else if(a < b){ | ||||||
|  | 		return -1 | ||||||
|  | 	} else { | ||||||
|  | 		return +1 | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| // A predicate returning:
 | // A predicate returning:
 | ||||||
| // 	- 0 if a is equal at position i in lst or is between i and i+1
 | // 	- 0 if a is equal at position i in lst or is between i and i+1
 | ||||||
| // 	- -1 if a is "below" position i
 | // 	- -1 if a is "below" position i
 | ||||||
| @ -460,13 +481,8 @@ function loadData(data, images_per_screen){ | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| // NOTE: this compares two images by gid...
 | function convertDataGen1(data, cmp){ | ||||||
| function imageDateCmp(a, b){ | 	cmp = cmp == null ? imageDateCmp : cmp | ||||||
| 	return DATA.images[b].ctime - DATA.images[a].ctime |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| function convertDataGen1(data){ |  | ||||||
| 	var res = { | 	var res = { | ||||||
| 		varsion: '2.0', | 		varsion: '2.0', | ||||||
| 		current: null, | 		current: null, | ||||||
| @ -490,11 +506,11 @@ function convertDataGen1(data){ | |||||||
| 			order.push(id) | 			order.push(id) | ||||||
| 			images[id] = image | 			images[id] = image | ||||||
| 		} | 		} | ||||||
| 		ribbon.sort(imageDateCmp) | 		ribbon.sort(cmp) | ||||||
| 	}) | 	}) | ||||||
| 
 | 
 | ||||||
| 	// order...
 | 	// order...
 | ||||||
| 	order.sort(imageDateCmp) | 	order.sort(cmp) | ||||||
| 
 | 
 | ||||||
| 	// XXX STUB
 | 	// XXX STUB
 | ||||||
| 	res.current = order[0] | 	res.current = order[0] | ||||||
| @ -578,9 +594,10 @@ function preCacheAllRibbons(){ | |||||||
| * Marking | * Marking | ||||||
| */ | */ | ||||||
| 
 | 
 | ||||||
| function loadMarkedOnlyData(){ | function loadMarkedOnlyData(cmp){ | ||||||
|  | 	cmp = cmp == null ? imageDateCmp : cmp | ||||||
| 	var cur = DATA.current | 	var cur = DATA.current | ||||||
| 	var marked = MARKED.slice().sort(imageDateCmp) | 	var marked = MARKED.slice().sort(cmp) | ||||||
| 	ALL_DATA = DATA | 	ALL_DATA = DATA | ||||||
| 	DATA = { | 	DATA = { | ||||||
| 		varsion: '2.0', | 		varsion: '2.0', | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user