mirror of
				https://github.com/flynx/ImageGrid.git
				synced 2025-10-31 19:30:07 +00:00 
			
		
		
		
	now history is saved in localStorage + added basic history UI -- ctrl+shift+left/right...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									41ac21f088
								
							
						
					
					
						commit
						c9d0a17f43
					
				
							
								
								
									
										19
									
								
								ui/data.js
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								ui/data.js
									
									
									
									
									
								
							| @ -1619,13 +1619,28 @@ function preCacheAllRibbons(){ | ||||
| function setupBaseURLHistory(){ | ||||
| 	$('.viewer') | ||||
| 		.on('baseURLChanged', function(evt, old_url, new_url){ | ||||
| 			var updated = false | ||||
| 
 | ||||
| 			// store the old and new urls in history unless they already
 | ||||
| 			// exist...
 | ||||
| 			if(BASE_URL_HISTORY.indexOf(old_url) < 0){ | ||||
| 				BASE_URL_HISTORY.splice(0, 0, old_url) | ||||
| 				updated = true | ||||
| 			} | ||||
| 			if(BASE_URL_HISTORY.indexOf(new_url) < 0){ | ||||
| 				BASE_URL_HISTORY.splice(0, 0, new_url) | ||||
| 				updated = true | ||||
| 			} | ||||
| 
 | ||||
| 			// truncate the history if needed...
 | ||||
| 			if(BASE_URL_HISTORY.length > BASE_URL_LIMIT){ | ||||
| 				BASE_URL_HISTORY.splice(BASE_URL_LIMIT, BASE_URL_HISTORY.length) | ||||
| 				updated = true | ||||
| 			} | ||||
| 
 | ||||
| 			// XXX is this the right place for this???
 | ||||
| 			if(updated){ | ||||
| 				saveLocalStorageBaseURLHistory()	 | ||||
| 			} | ||||
| 		}) | ||||
| } | ||||
| @ -1634,11 +1649,11 @@ function getURLHistoryPosition(){ | ||||
| 	return BASE_URL_HISTORY.indexOf(BASE_URL) | ||||
| } | ||||
| function getURLHistoryNext(){ | ||||
| 	var res = BASE_URL_HISTORY[ getURLHistoryPosition() + 1] | ||||
| 	var res = BASE_URL_HISTORY[ getURLHistoryPosition() - 1] | ||||
| 	return res == null ? BASE_URL : res | ||||
| } | ||||
| function getURLHistoryPrev(){ | ||||
| 	var res = BASE_URL_HISTORY[ getURLHistoryPosition() - 1 ] | ||||
| 	var res = BASE_URL_HISTORY[ getURLHistoryPosition() + 1 ] | ||||
| 	return res == null ? BASE_URL : res | ||||
| } | ||||
| 
 | ||||
|  | ||||
| @ -150,6 +150,8 @@ $(function(){ | ||||
| 	if((DATA_ATTR + '_BASE_URL') in localStorage | ||||
| 			&& !/^\.[\/\\]*/.test(localStorage[DATA_ATTR + '_BASE_URL'])){ | ||||
| 
 | ||||
| 		loadLocalStorageBaseURLHistory(DATA_ATTR) | ||||
| 
 | ||||
| 		BASE_URL = localStorage[DATA_ATTR + '_BASE_URL'] | ||||
| 
 | ||||
| 		var loading = statusNotify(loadDir(BASE_URL)) | ||||
|  | ||||
| @ -385,6 +385,9 @@ var KEYBOARD_CONFIG = { | ||||
| 						centerRibbons() | ||||
| 					}), | ||||
| 				ctrl: 'prev-screen', | ||||
| 
 | ||||
| 				// XXX button not final...
 | ||||
| 				'ctrl+shift': doc('Previous URL in history', loadURLHistoryPrev ), | ||||
| 			}, | ||||
| 		Right: { | ||||
| 				default: doc('Next image', | ||||
| @ -396,6 +399,9 @@ var KEYBOARD_CONFIG = { | ||||
| 						centerRibbons() | ||||
| 					}), | ||||
| 				ctrl: 'next-screen', | ||||
| 
 | ||||
| 				// XXX button not final...
 | ||||
| 				'ctrl+shift': doc('Next URL in history', loadURLHistoryNext ), | ||||
| 			}, | ||||
| 		'prev-screen': doc('Previous screen', | ||||
| 				function(){  | ||||
|  | ||||
| @ -26,6 +26,7 @@ function saveLocalStorageBaseURL(attr){ | ||||
| function loadLocalStorageBaseURLHistory(attr){ | ||||
| 	attr = attr == null ? DATA_ATTR : attr | ||||
| 	BASE_URL_HISTORY = JSON.parse(localStorage[attr + '_BASE_URL_HISTORY']) | ||||
| 	return BASE_URL_HISTORY | ||||
| } | ||||
| function saveLocalStorageBaseURLHistory(attr){ | ||||
| 	attr = attr == null ? DATA_ATTR : attr | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user