mirror of
				https://github.com/flynx/ImageGrid.git
				synced 2025-10-30 19:00:09 +00:00 
			
		
		
		
	reworking sort... (not done yet)
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									e289890eea
								
							
						
					
					
						commit
						d554876f4c
					
				| @ -116,6 +116,15 @@ module.SortActions = actions.Actions({ | |||||||
| 	// XXX add doc support -- make this an action-set???...
 | 	// XXX add doc support -- make this an action-set???...
 | ||||||
| 	// XXX add alias and string support...
 | 	// XXX add alias and string support...
 | ||||||
| 	__sort_methods__: { | 	__sort_methods__: { | ||||||
|  | 		// aliases...
 | ||||||
|  | 		'image-date': | ||||||
|  | 			'image-create-date image-modify-date', | ||||||
|  | 		'image-create-date': | ||||||
|  | 			'metadata.createDate birthtime ctime name-sequence keep-position', | ||||||
|  | 		// XXX 
 | ||||||
|  | 		'image-modify-date': | ||||||
|  | 			'metadata.createDate birthtime ctime name-sequence keep-position', | ||||||
|  | 
 | ||||||
| 		// XXX make sequence sort methods compatible with repeating numbers,
 | 		// XXX make sequence sort methods compatible with repeating numbers,
 | ||||||
| 		// 		i.e. for file names like DSC_1234 sorting more than 10K files
 | 		// 		i.e. for file names like DSC_1234 sorting more than 10K files
 | ||||||
| 		// 		should split the repeating numbers by some other means, like
 | 		// 		should split the repeating numbers by some other means, like
 | ||||||
| @ -282,20 +291,57 @@ module.SortActions = actions.Actions({ | |||||||
| 			// set sort method in data...
 | 			// set sort method in data...
 | ||||||
| 			this.data.sort_method = typeof(method) == typeof('str') ? method : method.join(' ') | 			this.data.sort_method = typeof(method) == typeof('str') ? method : method.join(' ') | ||||||
| 
 | 
 | ||||||
|  | 			var splitMethods = function(m){ | ||||||
|  | 				return m instanceof Array ? m :  | ||||||
|  | 					m | ||||||
|  | 						.split(/'([^']*)'|"([^"]*)"| +/) | ||||||
|  | 						.filter(function(e){  | ||||||
|  | 							return e && e.trim() != '' && !/['"]/.test(e) }) } | ||||||
|  | 			// XXX
 | ||||||
|  | 			var expandMethods = function(m, seen){ | ||||||
|  | 				seen = seen || new Set() | ||||||
|  | 				if(seen.has(m)){ | ||||||
|  | 					throw new Error('Sort method loop detected.') | ||||||
|  | 				} else { | ||||||
|  | 					seen.add(m) | ||||||
|  | 				} | ||||||
|  | 				return (m instanceof Array ? m : splitMethods(m)) | ||||||
|  | 					.map(function(m){  | ||||||
|  | 						var a = SortActions.__sort_methods__[m] | ||||||
|  | 							|| (that.__sort_methods__ && that.__sort_methods__[m]) | ||||||
|  | 						// expand local aliases...
 | ||||||
|  | 						return m in that.config['sort-methods'] ? | ||||||
|  | 							   expandMethods(that.config['split-methods'], seen)  | ||||||
|  | 							// expand system aliases...
 | ||||||
|  | 							: typeof(a) == typeof('str') ?  | ||||||
|  | 								expandMethods(a, seen) | ||||||
|  | 							: a instanceof Array ? | ||||||
|  | 								a | ||||||
|  | 							: m }) | ||||||
|  | 					// merge...
 | ||||||
|  | 					.reduce(function(r, e){ | ||||||
|  | 						return e instanceof Array ? r.concat(e) : r.push(e) }, []) } | ||||||
|  | 
 | ||||||
| 			// expand method names...
 | 			// expand method names...
 | ||||||
| 			// XXX should this be recursive???
 | 			// XXX should this be recursive???
 | ||||||
| 			method = typeof(method) == typeof('str') ?  | 			method = splitMethods(method) | ||||||
| 				method |  | ||||||
| 					.split(/'([^']*)'|"([^"]*)"| +/) |  | ||||||
| 						.filter(function(e){ return e && e.trim() != '' && !/['"]/.test(e) }) |  | ||||||
| 				.map(function(m){  | 				.map(function(m){  | ||||||
| 						return that.config['sort-methods'][m] || m }) | 					return m in that.config['sort-methods'] ? | ||||||
| 					.join(' ') | 					   splitMethods(that.config['split-methods']) : m }) | ||||||
| 				: method | 			// expand system aliases...
 | ||||||
| 			method = typeof(method) == typeof('str') ?  | 			/* | ||||||
| 				method.split(/'([^']*)'|"([^"]*)"| +/) | 			method = method | ||||||
| 					.filter(function(e){ return e && e.trim() != '' && !/['"]/.test(e) }) | 				.map(function(m){ | ||||||
| 				: method | 					var a = (SortActions.__sort_methods__[m] | ||||||
|  | 						|| (that.__sort_methods__ && that.__sort_methods__[m]) | ||||||
|  | 					return typeof(a) == typeof('str') ?  | ||||||
|  | 							splitMethods(a) | ||||||
|  | 						: a instanceof Array ? | ||||||
|  | 							a | ||||||
|  | 						: m }) | ||||||
|  | 				.reduce(function(r, e){ | ||||||
|  | 					return e instanceof Array ? r.concat(e) : r.push(e) }, []) | ||||||
|  | 			//*/
 | ||||||
| 
 | 
 | ||||||
| 			// get the reverse arity...
 | 			// get the reverse arity...
 | ||||||
| 			var i = method.indexOf('reverse') | 			var i = method.indexOf('reverse') | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user