mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 18:30:09 +00:00
added marked data loading and some tweaks...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
e46e656417
commit
296bfdf02e
90
ui/data.js
90
ui/data.js
@ -1170,6 +1170,7 @@ function saveLocalStorage(attr){
|
|||||||
* File storage (Extension API -- CEF/PhoneGap/...)
|
* File storage (Extension API -- CEF/PhoneGap/...)
|
||||||
*
|
*
|
||||||
* XXX need to cleanup this section...
|
* XXX need to cleanup this section...
|
||||||
|
* XXX do a generic find latest and load it function....
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// load the target-specific handlers...
|
// load the target-specific handlers...
|
||||||
@ -1197,7 +1198,7 @@ function loadFileImages(path, no_load_diffs, callback){
|
|||||||
}).sort().reverse()[0]
|
}).sort().reverse()[0]
|
||||||
path = path == null ? 'images.json' : path
|
path = path == null ? 'images.json' : path
|
||||||
|
|
||||||
updateStatus('Loading:', path)
|
showStatus('Loading:', path)
|
||||||
|
|
||||||
path = base +'/'+ path
|
path = base +'/'+ path
|
||||||
|
|
||||||
@ -1226,7 +1227,7 @@ function loadFileImages(path, no_load_diffs, callback){
|
|||||||
// whether we have one or more deffereds here...
|
// whether we have one or more deffereds here...
|
||||||
.done(function(data){
|
.done(function(data){
|
||||||
diff_data[i+1] = data
|
diff_data[i+1] = data
|
||||||
updateStatus('Loaded:', e)
|
showStatus('Loaded:', e)
|
||||||
})
|
})
|
||||||
}))
|
}))
|
||||||
.then(function(){
|
.then(function(){
|
||||||
@ -1239,10 +1240,15 @@ function loadFileImages(path, no_load_diffs, callback){
|
|||||||
return $.when(diff, $.getJSON(path))
|
return $.when(diff, $.getJSON(path))
|
||||||
.done(function(_, json){
|
.done(function(_, json){
|
||||||
json = json[0]
|
json = json[0]
|
||||||
$.extend(json, diff_data)
|
|
||||||
IMAGES = json
|
|
||||||
|
|
||||||
updateStatus('Loaded images...')
|
// merge diffs...
|
||||||
|
if(Object.keys(diff_data).length != 0){
|
||||||
|
$.extend(json, diff_data)
|
||||||
|
showStatus('Merged images diffs...')
|
||||||
|
}
|
||||||
|
|
||||||
|
IMAGES = json
|
||||||
|
showStatus('Loaded images...')
|
||||||
|
|
||||||
callback != null && callback()
|
callback != null && callback()
|
||||||
})
|
})
|
||||||
@ -1272,7 +1278,7 @@ function saveFileImages(name){
|
|||||||
$.each($.map(listDir(normalizePath(CACHE_DIR)), function(e){
|
$.each($.map(listDir(normalizePath(CACHE_DIR)), function(e){
|
||||||
return /.*-images-diff.json$/.test(e) ? e : null
|
return /.*-images-diff.json$/.test(e) ? e : null
|
||||||
}), function(i, e){
|
}), function(i, e){
|
||||||
updateStatus('removeing:', e)
|
showStatus('removeing:', e)
|
||||||
removeFile(normalizePath(CACHE_DIR +'/'+ e))
|
removeFile(normalizePath(CACHE_DIR +'/'+ e))
|
||||||
})
|
})
|
||||||
IMAGES_UPDATED = []
|
IMAGES_UPDATED = []
|
||||||
@ -1283,6 +1289,50 @@ function saveFileImages(name){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function loadFileMarks(path, callback){
|
||||||
|
// default locations...
|
||||||
|
if(path == null){
|
||||||
|
var base = normalizePath(CACHE_DIR)
|
||||||
|
// find the latest images file...
|
||||||
|
var files = listDir(base)
|
||||||
|
var path = $.map(files, function(e){
|
||||||
|
return /.*-marked.json$/.test(e) ? e : null
|
||||||
|
}).sort().reverse()[0]
|
||||||
|
path = path == null ? 'marked.json' : path
|
||||||
|
|
||||||
|
if(files.indexOf(path) < 0){
|
||||||
|
showStatus('No marks found...')
|
||||||
|
return $.Deferred().resolve()
|
||||||
|
}
|
||||||
|
|
||||||
|
showStatus('Loading:', path)
|
||||||
|
|
||||||
|
path = base +'/'+ path
|
||||||
|
|
||||||
|
// explicit path...
|
||||||
|
// XXX need to account for paths without a CACHE_DIR
|
||||||
|
} else {
|
||||||
|
path = normalizePath(path)
|
||||||
|
var base = path.split(CACHE_DIR)[0]
|
||||||
|
base += '/'+ CACHE_DIR
|
||||||
|
}
|
||||||
|
|
||||||
|
// load the main image file and merge the diff with it...
|
||||||
|
return $.getJSON(path)
|
||||||
|
.done(function(json){
|
||||||
|
MARKED = json
|
||||||
|
|
||||||
|
showStatus('Loaded marks...')
|
||||||
|
|
||||||
|
callback != null && callback()
|
||||||
|
})
|
||||||
|
.fail(function(){
|
||||||
|
showErrorStatus('Loading: ' + path)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// XXX save marks...
|
||||||
|
|
||||||
|
|
||||||
function loadFileState(data_path, callback){
|
function loadFileState(data_path, callback){
|
||||||
var base = data_path.split(CACHE_DIR)[0]
|
var base = data_path.split(CACHE_DIR)[0]
|
||||||
base = base == data_path ? '.' : base
|
base = base == data_path ? '.' : base
|
||||||
@ -1303,18 +1353,23 @@ function loadFileState(data_path, callback){
|
|||||||
// version 2.0
|
// version 2.0
|
||||||
} else if(json.version == '2.0') {
|
} else if(json.version == '2.0') {
|
||||||
DATA = json
|
DATA = json
|
||||||
loadFileImages(DATA.image_file == null ?
|
$.when(
|
||||||
|
// load images...
|
||||||
|
loadFileImages(DATA.image_file == null ?
|
||||||
normalizePath(DATA.image_file, base)
|
normalizePath(DATA.image_file, base)
|
||||||
: null)
|
: null),
|
||||||
.done(function(){
|
// load marks if available...
|
||||||
reloadViewer()
|
// XXX do we need to do this???
|
||||||
callback != null && callback()
|
loadFileMarks())
|
||||||
res.resolve()
|
.done(function(){
|
||||||
})
|
reloadViewer()
|
||||||
|
callback != null && callback()
|
||||||
|
res.resolve()
|
||||||
|
})
|
||||||
|
|
||||||
// unknown format...
|
// unknown format...
|
||||||
} else {
|
} else {
|
||||||
updateStatus('Unknown format.')
|
showStatus('Unknown format.')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -1341,6 +1396,7 @@ function saveFileState(name, no_normalize_path){
|
|||||||
}
|
}
|
||||||
|
|
||||||
dumpJSON(name + '-data.json', DATA)
|
dumpJSON(name + '-data.json', DATA)
|
||||||
|
// XXX do we need to do this???
|
||||||
dumpJSON(name + '-marked.json', MARKED)
|
dumpJSON(name + '-marked.json', MARKED)
|
||||||
|
|
||||||
// save the updated images...
|
// save the updated images...
|
||||||
@ -1364,12 +1420,13 @@ function saveFileState(name, no_normalize_path){
|
|||||||
//
|
//
|
||||||
// XXX this will not load the marks file...
|
// XXX this will not load the marks file...
|
||||||
// XXX make sure that save works...
|
// XXX make sure that save works...
|
||||||
|
// XXX might be good to split this into loadFileData and loadDir...
|
||||||
function loadDir(path, raw_load){
|
function loadDir(path, raw_load){
|
||||||
path = normalizePath(path)
|
path = normalizePath(path)
|
||||||
var orig_path = path
|
var orig_path = path
|
||||||
var data
|
var data
|
||||||
|
|
||||||
updateStatus('Loading...').show()
|
showStatus('Loading:', path)
|
||||||
|
|
||||||
var files = listDir(path)
|
var files = listDir(path)
|
||||||
|
|
||||||
@ -1400,7 +1457,7 @@ function loadDir(path, raw_load){
|
|||||||
|
|
||||||
// load the found data file...
|
// load the found data file...
|
||||||
if(data != null){
|
if(data != null){
|
||||||
updateStatus('Loading:', data)
|
showStatus('Loading:', data)
|
||||||
|
|
||||||
data = path + '/' + data
|
data = path + '/' + data
|
||||||
|
|
||||||
@ -1437,6 +1494,7 @@ function loadDir(path, raw_load){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// XXX loads duplicate images....
|
||||||
function updateRibbonsFromFavDirs(){
|
function updateRibbonsFromFavDirs(){
|
||||||
DATA.ribbons = ribbonsFromFavDirs(null, null, imageOrderCmp)
|
DATA.ribbons = ribbonsFromFavDirs(null, null, imageOrderCmp)
|
||||||
reloadViewer()
|
reloadViewer()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user