mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-12-17 00:31:40 +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.GROUP('State',
|
||||||
ImageGrid.ACTION({
|
ImageGrid.ACTION({
|
||||||
doc: 'Save state to local storage',
|
doc: 'Save state to local storage',
|
||||||
group: 'API',
|
|
||||||
display: false,
|
display: false,
|
||||||
},
|
},
|
||||||
function save_config(name){
|
function save_config(name){
|
||||||
@ -135,12 +134,38 @@ ImageGrid.GROUP('State',
|
|||||||
}
|
}
|
||||||
$.jStorage.set(this.option.KEY_NAME_CONFIG+name, this.sync())
|
$.jStorage.set(this.option.KEY_NAME_CONFIG+name, this.sync())
|
||||||
}),
|
}),
|
||||||
|
// XXX merge this with save_localstorage...
|
||||||
ImageGrid.ACTION({
|
ImageGrid.ACTION({
|
||||||
doc: 'Save state to local storage',
|
doc: 'Save state to file',
|
||||||
group: 'API',
|
|
||||||
display: false,
|
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){
|
if(name == null){
|
||||||
name = ''
|
name = ''
|
||||||
// push the last config to a new version...
|
// push the last config to a new version...
|
||||||
@ -161,7 +186,6 @@ ImageGrid.GROUP('State',
|
|||||||
}),
|
}),
|
||||||
ImageGrid.ACTION({
|
ImageGrid.ACTION({
|
||||||
doc: 'Load state from local storage',
|
doc: 'Load state from local storage',
|
||||||
group: 'API',
|
|
||||||
display: false,
|
display: false,
|
||||||
},
|
},
|
||||||
function load(name, dfl_state, dfl_config){
|
function load(name, dfl_state, dfl_config){
|
||||||
@ -188,7 +212,6 @@ ImageGrid.GROUP('State',
|
|||||||
'enabling trivial redo.\n'+
|
'enabling trivial redo.\n'+
|
||||||
'NOTE: if n is greater than 1 then all the skipped steps will '+
|
'NOTE: if n is greater than 1 then all the skipped steps will '+
|
||||||
'get dropped.',
|
'get dropped.',
|
||||||
group: 'API',
|
|
||||||
display: false,
|
display: false,
|
||||||
},
|
},
|
||||||
function undo(n){
|
function undo(n){
|
||||||
@ -217,7 +240,6 @@ ImageGrid.GROUP('State',
|
|||||||
'NOTE: this is here because JS has no direct way to '+
|
'NOTE: this is here because JS has no direct way to '+
|
||||||
'on-demand, transparently update the value of an attr. '+
|
'on-demand, transparently update the value of an attr. '+
|
||||||
'.valueOf() is not transparent enough.',
|
'.valueOf() is not transparent enough.',
|
||||||
group: 'API',
|
|
||||||
display: false,
|
display: false,
|
||||||
},
|
},
|
||||||
function sync(){
|
function sync(){
|
||||||
@ -280,6 +302,18 @@ ImageGrid.GROUP('State',
|
|||||||
value: 'ImageGrid_config',
|
value: 'ImageGrid_config',
|
||||||
display: false,
|
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({
|
ImageGrid.OPTION({
|
||||||
name: 'KEY_NAME_STATE',
|
name: 'KEY_NAME_STATE',
|
||||||
title: 'Name of localStorage key to store state.',
|
title: 'Name of localStorage key to store state.',
|
||||||
@ -1661,7 +1695,7 @@ ImageGrid.GROUP('Mode: All',
|
|||||||
title: 'Save current state.',
|
title: 'Save current state.',
|
||||||
},
|
},
|
||||||
function saveState(){
|
function saveState(){
|
||||||
ImageGrid.save()
|
ImageGrid.save_localstorage()
|
||||||
}),
|
}),
|
||||||
ImageGrid.ACTION({
|
ImageGrid.ACTION({
|
||||||
title: 'Get the background mode',
|
title: 'Get the background mode',
|
||||||
|
|||||||
@ -9,9 +9,9 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function loadJSONfile(path, escape_urls){
|
function loadJSONfile(path, dfl, escape_urls){
|
||||||
if(escape_urls == null){
|
if(escape_urls == null){
|
||||||
escape_urls = true
|
escape_urls = false
|
||||||
}
|
}
|
||||||
// XXX CEF (file) - binding
|
// XXX CEF (file) - binding
|
||||||
if(CEF_loadJSON != null){
|
if(CEF_loadJSON != null){
|
||||||
@ -20,6 +20,10 @@ function loadJSONfile(path, escape_urls){
|
|||||||
// XXX PhoneGap (file) - binding
|
// XXX PhoneGap (file) - binding
|
||||||
// XXX browser - open file dialog
|
// XXX browser - open file dialog
|
||||||
|
|
||||||
|
if(data == null){
|
||||||
|
return dfl
|
||||||
|
}
|
||||||
|
|
||||||
// escape the URLs...
|
// escape the URLs...
|
||||||
// XXX need to make ths universal for all urls within the image object...
|
// XXX need to make ths universal for all urls within the image object...
|
||||||
if(escape_urls == true){
|
if(escape_urls == true){
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user