mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 10:20:08 +00:00
added saving state to file (at this point CEF only)...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
a3c448e2b5
commit
12aba7b102
@ -126,7 +126,6 @@ ImageGrid.GROUP('API',
|
||||
ImageGrid.GROUP('State',
|
||||
ImageGrid.ACTION({
|
||||
doc: 'Save state to local storage',
|
||||
group: 'API',
|
||||
display: false,
|
||||
},
|
||||
function save_config(name){
|
||||
@ -135,12 +134,38 @@ ImageGrid.GROUP('State',
|
||||
}
|
||||
$.jStorage.set(this.option.KEY_NAME_CONFIG+name, this.sync())
|
||||
}),
|
||||
// XXX merge this with save_localstorage...
|
||||
ImageGrid.ACTION({
|
||||
doc: 'Save state to local storage',
|
||||
group: 'API',
|
||||
doc: 'Save state to file',
|
||||
display: false,
|
||||
},
|
||||
function save(name){
|
||||
function save_file(name){
|
||||
if(dumpJSONfile == null){
|
||||
return false
|
||||
}
|
||||
if(name == null){
|
||||
name = ''
|
||||
// push the last config to a new version...
|
||||
var history = loadJSONfile(this.option.FILE_NAME_HISTORY, [])
|
||||
// XXX should we add a date?
|
||||
history.push(loadJSONfile(this.option.FILE_NAME_STATE))
|
||||
// remove versions beyond VERSIONS_TO_KEEP...
|
||||
var c = history.length - this.option.VERSIONS_TO_KEEP
|
||||
if(c > 0){
|
||||
history.splice(0, c)
|
||||
}
|
||||
dumpJSONfile(this.option.FILE_NAME_HISTORY, history)
|
||||
} else {
|
||||
name = '-' + name
|
||||
}
|
||||
this.save_config()
|
||||
dumpJSONfile(this.option.FILE_NAME_STATE+name, buildJSON())
|
||||
}),
|
||||
ImageGrid.ACTION({
|
||||
doc: 'Save state to local storage',
|
||||
display: false,
|
||||
},
|
||||
function save_localstorage(name){
|
||||
if(name == null){
|
||||
name = ''
|
||||
// push the last config to a new version...
|
||||
@ -161,7 +186,6 @@ ImageGrid.GROUP('State',
|
||||
}),
|
||||
ImageGrid.ACTION({
|
||||
doc: 'Load state from local storage',
|
||||
group: 'API',
|
||||
display: false,
|
||||
},
|
||||
function load(name, dfl_state, dfl_config){
|
||||
@ -188,7 +212,6 @@ ImageGrid.GROUP('State',
|
||||
'enabling trivial redo.\n'+
|
||||
'NOTE: if n is greater than 1 then all the skipped steps will '+
|
||||
'get dropped.',
|
||||
group: 'API',
|
||||
display: false,
|
||||
},
|
||||
function undo(n){
|
||||
@ -217,7 +240,6 @@ ImageGrid.GROUP('State',
|
||||
'NOTE: this is here because JS has no direct way to '+
|
||||
'on-demand, transparently update the value of an attr. '+
|
||||
'.valueOf() is not transparent enough.',
|
||||
group: 'API',
|
||||
display: false,
|
||||
},
|
||||
function sync(){
|
||||
@ -280,6 +302,18 @@ ImageGrid.GROUP('State',
|
||||
value: 'ImageGrid_config',
|
||||
display: false,
|
||||
}),
|
||||
ImageGrid.OPTION({
|
||||
name: 'FILE_NAME_STATE',
|
||||
title: 'File name to store state.',
|
||||
value: '.ImageGrid.state',
|
||||
display: false,
|
||||
}),
|
||||
ImageGrid.OPTION({
|
||||
name: 'FILE_NAME_HISTORY',
|
||||
title: 'File name to store state history.',
|
||||
value: '.ImageGrid.history',
|
||||
display: false,
|
||||
}),
|
||||
ImageGrid.OPTION({
|
||||
name: 'KEY_NAME_STATE',
|
||||
title: 'Name of localStorage key to store state.',
|
||||
@ -1661,7 +1695,7 @@ ImageGrid.GROUP('Mode: All',
|
||||
title: 'Save current state.',
|
||||
},
|
||||
function saveState(){
|
||||
ImageGrid.save()
|
||||
ImageGrid.save_localstorage()
|
||||
}),
|
||||
ImageGrid.ACTION({
|
||||
title: 'Get the background mode',
|
||||
|
||||
@ -9,9 +9,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
function loadJSONfile(path, escape_urls){
|
||||
function loadJSONfile(path, dfl, escape_urls){
|
||||
if(escape_urls == null){
|
||||
escape_urls = true
|
||||
escape_urls = false
|
||||
}
|
||||
// XXX CEF (file) - binding
|
||||
if(CEF_loadJSON != null){
|
||||
@ -20,6 +20,10 @@ function loadJSONfile(path, escape_urls){
|
||||
// XXX PhoneGap (file) - binding
|
||||
// XXX browser - open file dialog
|
||||
|
||||
if(data == null){
|
||||
return dfl
|
||||
}
|
||||
|
||||
// escape the URLs...
|
||||
// XXX need to make ths universal for all urls within the image object...
|
||||
if(escape_urls == true){
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user