mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-11-02 20:30:09 +00:00
added history pruning -- removal of non-existant paths, not sure if this strategy is good enough...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
c0168762ea
commit
3c7e772203
@ -58,7 +58,6 @@ if(window.CEF_dumpJSON != null){
|
|||||||
// paths to included utils...
|
// paths to included utils...
|
||||||
execPathPush('./vips/bin')
|
execPathPush('./vips/bin')
|
||||||
|
|
||||||
|
|
||||||
// Things ImageGrid needs...
|
// Things ImageGrid needs...
|
||||||
// XXX do we need assync versions??
|
// XXX do we need assync versions??
|
||||||
window.listDir = function(path){
|
window.listDir = function(path){
|
||||||
|
|||||||
@ -18,6 +18,18 @@ var BASE_URL_LIMIT = 10
|
|||||||
* URL history...
|
* URL history...
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// XXX this depends on fs.existsSync(...)
|
||||||
|
function pruneBaseURLHistory(){
|
||||||
|
if(window.fs == null){
|
||||||
|
return BASE_URL_HISTORY
|
||||||
|
}
|
||||||
|
BASE_URL_HISTORY = BASE_URL_HISTORY.filter(function(e){
|
||||||
|
return fs.existsSync(osPath(e))
|
||||||
|
})
|
||||||
|
return BASE_URL_HISTORY
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Setup history event handlers...
|
// Setup history event handlers...
|
||||||
//
|
//
|
||||||
// NOTE: this will save history state to localStorage...
|
// NOTE: this will save history state to localStorage...
|
||||||
@ -26,6 +38,8 @@ function setupBaseURLHistory(){
|
|||||||
.on('baseURLChanged', function(evt, old_url, new_url){
|
.on('baseURLChanged', function(evt, old_url, new_url){
|
||||||
var updated = false
|
var updated = false
|
||||||
|
|
||||||
|
pruneBaseURLHistory()
|
||||||
|
|
||||||
// store the old and new urls in history unless they already
|
// store the old and new urls in history unless they already
|
||||||
// exist...
|
// exist...
|
||||||
if(BASE_URL_HISTORY.indexOf(old_url) < 0){
|
if(BASE_URL_HISTORY.indexOf(old_url) < 0){
|
||||||
@ -102,6 +116,7 @@ function getURLHistoryPrev(){
|
|||||||
// NOTE: this will not affect history url order...
|
// NOTE: this will not affect history url order...
|
||||||
function makeURLHistoryLoader(get, end_msg){
|
function makeURLHistoryLoader(get, end_msg){
|
||||||
return function(){
|
return function(){
|
||||||
|
pruneBaseURLHistory()
|
||||||
var url = get()
|
var url = get()
|
||||||
if(url != BASE_URL){
|
if(url != BASE_URL){
|
||||||
statusNotify(loadDir(url))
|
statusNotify(loadDir(url))
|
||||||
@ -118,7 +133,8 @@ var loadURLHistoryPrev = makeURLHistoryLoader(getURLHistoryPrev, 'at first URL')
|
|||||||
// NOTE: this can accept either path or history index...
|
// NOTE: this can accept either path or history index...
|
||||||
// NOTE: this will not reload an already loaded url...
|
// NOTE: this will not reload an already loaded url...
|
||||||
function loadURLHistoryAt(a){
|
function loadURLHistoryAt(a){
|
||||||
a = a < 0 ? BASE_URL_HISTORY + a : a
|
pruneBaseURLHistory()
|
||||||
|
a = a < 0 ? BASE_URL_HISTORY.length + a : a
|
||||||
var url = typeof(a) == typeof(123) ? Math.min(a < 0 ? 0 : a, BASE_URL_HISTORY.length-1) : a
|
var url = typeof(a) == typeof(123) ? Math.min(a < 0 ? 0 : a, BASE_URL_HISTORY.length-1) : a
|
||||||
if(url != BASE_URL){
|
if(url != BASE_URL){
|
||||||
statusNotify(loadDir(url))
|
statusNotify(loadDir(url))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user