mirror of
				https://github.com/flynx/ImageGrid.git
				synced 2025-10-30 19:00:09 +00:00 
			
		
		
		
	made sure everything is compatible, moved to $.getJSON(...) for reading json files instead of a CEF extension...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									c8cd7d1bf0
								
							
						
					
					
						commit
						04e4e6ccb8
					
				| @ -1,7 +1,7 @@ | ||||
| #======================================================================= | ||||
| 
 | ||||
| __version__ = '''0.0.01''' | ||||
| __sub_version__ = '''20130522014220''' | ||||
| __sub_version__ = '''20130522020247''' | ||||
| __copyright__ = '''(c) Alex A. Naanou 2011''' | ||||
| 
 | ||||
| 
 | ||||
| @ -12,6 +12,7 @@ import Image | ||||
| import json | ||||
| import sha | ||||
| import urllib2 | ||||
| import time | ||||
| 
 | ||||
| from pli.logictypes import OR | ||||
| 
 | ||||
| @ -72,7 +73,6 @@ TARGET: %(target-file)s | ||||
| 
 | ||||
| #----------------------------------------------------------------------- | ||||
| # Helpers... | ||||
| 
 | ||||
| #------------------------------------------------------------pathjoin--- | ||||
| def pathjoin(*p): | ||||
| 	''' | ||||
| @ -87,7 +87,7 @@ def getpath(root, path, absolute=False): | ||||
| 	if absolute == True: | ||||
| 		return 'file:///' + urllib2.quote(pathjoin(root, path), safe='/:') | ||||
| 	else: | ||||
| 		return urllib2.quote(path, safe='/') | ||||
| 		return urllib2.quote(pathjoin(path), safe='/:') | ||||
| 
 | ||||
| 
 | ||||
| #-------------------------------------------------------------log_err--- | ||||
| @ -139,11 +139,15 @@ def report_progress(img, status): | ||||
| def make_inline_report_progress(state=None): | ||||
| 	if state == None: | ||||
| 		state = {} | ||||
| 	if 'started at' not in state: | ||||
| 		state['started at'] = time.time() | ||||
| 
 | ||||
| 	def _inline_report_progress(img, status): | ||||
| 		created = state.get('created', 0) | ||||
| 		skipped = state.get('skipped', 0) | ||||
| 		partial = state.get('partial', 0) | ||||
| 
 | ||||
| 
 | ||||
| 		# created all previews... | ||||
| 		if False not in status: | ||||
| 			created += 1 | ||||
| @ -159,6 +163,8 @@ def make_inline_report_progress(state=None): | ||||
| 			partial += 1 | ||||
| 			state['partial'] = partial | ||||
| 
 | ||||
| 		state['done at'] = time.time() | ||||
| 
 | ||||
| 		print 'Previews created: %s partial: %s skipped: %s...\r' % (created, partial, skipped), | ||||
| 
 | ||||
| 		return img | ||||
| @ -168,7 +174,6 @@ def make_inline_report_progress(state=None): | ||||
| 
 | ||||
| #----------------------------------------------------------------------- | ||||
| # API... | ||||
| 
 | ||||
| #----------------------------------------------------build_cache_dirs--- | ||||
| def build_cache_dirs(path, config=CONFIG): | ||||
| 	''' | ||||
| @ -306,7 +311,6 @@ def build_data(images, path, config=CONFIG): | ||||
| 
 | ||||
| #----------------------------------------------------------------------- | ||||
| # High-level API... | ||||
| 
 | ||||
| #---------------------------------------------------------build_cache--- | ||||
| ##!!! DO NOT OVERWRITE EXISTING DATA... | ||||
| def build_cache(path, config=CONFIG, gid_generator=hash_gid,  | ||||
|  | ||||
							
								
								
									
										40
									
								
								ui/data.js
									
									
									
									
									
								
							
							
						
						
									
										40
									
								
								ui/data.js
									
									
									
									
									
								
							| @ -647,51 +647,49 @@ function saveLocalStorageMarks(attr){ | ||||
| * Extension API (CEF/PhoneGap/...) | ||||
| */ | ||||
| 
 | ||||
| function loadFileImages(path){ | ||||
| 	if(window.CEF_loadJSON != null){ | ||||
| 		IMAGES = CEF_loadJSON(path) | ||||
| function loadFileImages(path, callback){ | ||||
| 	return $.getJSON(path, function(json){ | ||||
| 		IMAGES = json | ||||
| 		localStorage[DATA_ATTR + '_IMAGES_FILE'] = path | ||||
| 		console.log('Loaded IMAGES...') | ||||
| 		return IMAGES | ||||
| 
 | ||||
| 	} else { | ||||
| 		// XXX
 | ||||
| 	} | ||||
| 		callback != null && callback() | ||||
| 	}) | ||||
| } | ||||
| 
 | ||||
| function loadFile(data_path, image_path){ | ||||
| function loadFile(data_path, image_path, callback){ | ||||
| 	// CEF
 | ||||
| 	if(window.CEF_loadJSON != null){ | ||||
| 		var json = CEF_loadJSON(data_path) | ||||
| 		console.log('Loaded DATA...') | ||||
| 
 | ||||
| 	return $.getJSON(data_path, function(json){ | ||||
| 		// legacy format...
 | ||||
| 		if(json.version == null){ | ||||
| 			json = convertDataGen1(json) | ||||
| 			DATA = json.data | ||||
| 			IMAGES = json.images | ||||
| 			return loadData() | ||||
| 			loadData() | ||||
| 
 | ||||
| 		// version 2.0
 | ||||
| 		// XXX needs a more flexible protocol...
 | ||||
| 		} else if(json.version == '2.0') { | ||||
| 			DATA = json | ||||
| 			if(image_path != null){ | ||||
| 				loadFileImages(image_path) | ||||
| 				loadFileImages(image_path, function(){ | ||||
| 					loadData() | ||||
| 
 | ||||
| 					callback != null && callback() | ||||
| 				}) | ||||
| 			} else if(DATA.image_file != null) { | ||||
| 				loadFileImages(DATA.image_file) | ||||
| 				loadFileImages(DATA.image_file, function(){ | ||||
| 					loadData() | ||||
| 
 | ||||
| 					callback != null && callback() | ||||
| 				}) | ||||
| 			} | ||||
| 			return loadData() | ||||
| 
 | ||||
| 		} else { | ||||
| 			console.error('unknown format.') | ||||
| 			return | ||||
| 		} | ||||
| 
 | ||||
| 	// PhoneGap
 | ||||
| 	} else if(false) { | ||||
| 		// XXX
 | ||||
| 	} | ||||
| 	}) | ||||
| } | ||||
| 
 | ||||
| function saveFile(name){ | ||||
|  | ||||
| @ -316,32 +316,6 @@ $(function(){ | ||||
| 
 | ||||
| 	toggleTheme('gray') | ||||
| 
 | ||||
| 	//setElementOrigin($('.ribbon-set'), 'top', 'left') | ||||
| 
 | ||||
| 	// we have an image file... | ||||
| 	if((DATA_ATTR + '_IMAGES_FILE') in localStorage){ | ||||
| 		loadFileImages(localStorage[DATA_ATTR + '_IMAGES_FILE']) | ||||
| 		DATA = loadLocalStorageData() | ||||
| 		loadData() | ||||
| 
 | ||||
| 	// everything is in localStorage... | ||||
| 	} else if('DATA' in localStorage){ | ||||
| 		loadLocalStorage() | ||||
| 
 | ||||
| 	// legacy default data... | ||||
| 	} else { | ||||
| 		DATA = convertDataGen1(image_list) | ||||
| 		DATA = DATA.data | ||||
| 		IMAGES = DATA.images | ||||
| 		loadData() | ||||
| 	} | ||||
| 
 | ||||
| 	// XXX this will reload everything... | ||||
| 	if('MARKED' in localStorage){ | ||||
| 		loadLocalStorageMarks() | ||||
| 	} | ||||
| 
 | ||||
| 
 | ||||
| 	// NOTE: this is global so as to not to add any extra complexity to  | ||||
| 	//		the internal workings... | ||||
| 	$('.viewer') | ||||
| @ -364,9 +338,50 @@ $(function(){ | ||||
| 
 | ||||
| 	setupDataBindings() | ||||
| 
 | ||||
| 	// XXX stub... | ||||
| 	//centerView(focusImage($('.image').first()), 'css') | ||||
| 	updateImages() | ||||
| 
 | ||||
| 	//setElementOrigin($('.ribbon-set'), 'top', 'left') | ||||
| 
 | ||||
| 	// we have an image file... | ||||
| 	if((DATA_ATTR + '_IMAGES_FILE') in localStorage){ | ||||
| 		loadFileImages(localStorage[DATA_ATTR + '_IMAGES_FILE']) | ||||
| 			.done(function(){ | ||||
| 				DATA = loadLocalStorageData() | ||||
| 				loadData() | ||||
| 
 | ||||
| 				// XXX this will reload everything... | ||||
| 				if('MARKED' in localStorage){ | ||||
| 					loadLocalStorageMarks() | ||||
| 				} | ||||
| 
 | ||||
| 				// XXX stub... | ||||
| 				//centerView(focusImage($('.image').first()), 'css') | ||||
| 				updateImages() | ||||
| 			}) | ||||
| 
 | ||||
| 	} else { | ||||
| 		// everything is in localStorage... | ||||
| 		if('DATA' in localStorage){ | ||||
| 			loadLocalStorage() | ||||
| 
 | ||||
| 		// legacy default data... | ||||
| 		} else { | ||||
| 			DATA = convertDataGen1(image_list) | ||||
| 			DATA = DATA.data | ||||
| 			IMAGES = DATA.images | ||||
| 			loadData() | ||||
| 		} | ||||
| 
 | ||||
| 		// XXX this will reload everything... | ||||
| 		if('MARKED' in localStorage){ | ||||
| 			loadLocalStorageMarks() | ||||
| 		} | ||||
| 
 | ||||
| 		// XXX stub... | ||||
| 		//centerView(focusImage($('.image').first()), 'css') | ||||
| 		updateImages() | ||||
| 	} | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| }) | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user