2012-08-31 03:11:19 +04:00
|
|
|
/*
|
|
|
|
|
* Here we will need several levels of storage:
|
|
|
|
|
* - state
|
|
|
|
|
* this can be anything including file or localstorage.
|
|
|
|
|
* this is stored in a unified location.
|
|
|
|
|
* global per user/instance
|
|
|
|
|
* - progress
|
|
|
|
|
* this is stored in file location as local config file.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2012-09-05 00:04:07 +04:00
|
|
|
function loadJSONfile(path, escape_urls){
|
|
|
|
|
if(escape_urls == null){
|
|
|
|
|
escape_urls = true
|
|
|
|
|
}
|
2012-08-31 03:11:19 +04:00
|
|
|
// XXX CEF (file) - binding
|
|
|
|
|
if(CEF_loadJSON != null){
|
2012-09-05 00:04:07 +04:00
|
|
|
var data = CEF_loadJSON(path)
|
2012-08-31 03:11:19 +04:00
|
|
|
}
|
|
|
|
|
// XXX PhoneGap (file) - binding
|
|
|
|
|
// XXX browser - open file dialog
|
2012-09-05 00:04:07 +04:00
|
|
|
|
|
|
|
|
// escape the URLs...
|
2012-09-05 00:41:59 +04:00
|
|
|
if(escape_urls == true){
|
|
|
|
|
var ribbons = data.ribbons
|
|
|
|
|
for(var i=0; i<ribbons.length; i++){
|
|
|
|
|
var images = ribbons[i]
|
|
|
|
|
for(var id in images){
|
|
|
|
|
var image = images[id]
|
2012-09-05 00:04:07 +04:00
|
|
|
// escape the url ...
|
|
|
|
|
var o = /([a-zA-Z0-9]*:)(.*)/.exec(image.url)
|
|
|
|
|
if(o.length == 3){
|
|
|
|
|
image.url = o[1] + escape(o[2])
|
|
|
|
|
} else {
|
|
|
|
|
console.log('no schema...')
|
|
|
|
|
image.url = escape(image.url)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return data
|
2012-08-31 03:11:19 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function dumpJSONfile(path, value){
|
|
|
|
|
// XXX CEF (file) - binding
|
|
|
|
|
if(CEF_dumpJSON != null){
|
|
|
|
|
return CEF_dumpJSON(path, value)
|
|
|
|
|
}
|
|
|
|
|
// XXX PhoneGap (file) - binding
|
|
|
|
|
// XXX browser - download file dialog
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|