diff --git a/ui/compatibility.js b/ui/compatibility.js index 6f59755f..f1f7b953 100755 --- a/ui/compatibility.js +++ b/ui/compatibility.js @@ -45,6 +45,15 @@ if(window.CEF_dumpJSON != null){ // XXX will this work on Mac??? path = path.replace(fp, '') } + var dirs = path.split(/[\\\/]/) + dirs.pop() + dirs = dirs.join('/') + // build path... + if(!fs.existsSync(dirs)){ + console.log('making:', dirs, path) + // XXX NOTE: this will not make more than one dir... + fs.mkdirSync(dirs) + } return fs.writeFileSync(path, JSON.stringify(data), encoding='utf8') } window.removeFile = function(path){ @@ -97,6 +106,9 @@ if(window.CEF_dumpJSON != null){ .appendTo($('body')) }) + + + // PhoneGap } else if(false){ diff --git a/ui/data.js b/ui/data.js index 5d20e301..98366d7b 100755 --- a/ui/data.js +++ b/ui/data.js @@ -104,6 +104,8 @@ var IMAGES = {} // list of image GIDs that have been updated... var IMAGES_UPDATED = [] +var IMAGES_CREATED = false + var MARKED = [] var SETTINGS = { diff --git a/ui/files.js b/ui/files.js index 0594def4..b71793de 100755 --- a/ui/files.js +++ b/ui/files.js @@ -498,10 +498,14 @@ function loadRawDir(path, prefix){ // 3) load a directory as-is // load fav dirs // +// NOTE: this will create an images.json file in cache on opening an +// un-cached dir (XXX is this correct???) function loadDir(path, prefix){ prefix = prefix == null ? 'Data' : prefix prefix = prefix === false ? null : prefix + IMAGES_CREATED = false + path = normalizePath(path) var orig_path = path var data @@ -530,6 +534,9 @@ function loadDir(path, prefix){ }) .fail(function(){ bubbleProgress('Raw directory', loadRawDir(orig_path), res) + .done(function(){ + IMAGES_CREATED = true + }) }) return res diff --git a/ui/keybindings.js b/ui/keybindings.js index e74246ed..9715d683 100755 --- a/ui/keybindings.js +++ b/ui/keybindings.js @@ -465,6 +465,7 @@ var KEYBOARD_CONFIG = { function(){ event.preventDefault() //saveLocalStorage() + showStatusQ('Saving: localStorage: Data.') saveLocalStorageData() showStatusQ('Saving: localStorage: Marks.') @@ -473,6 +474,12 @@ var KEYBOARD_CONFIG = { showStatusQ('Saving: localStorage: Settings.') saveLocalStorageSettings() + if(IMAGES_CREATED){ + showStatusQ('Saving: File: Images.') + dumpJSON(normalizePath(CACHE_DIR +'/'+ IMAGES_FILE_DEFAULT), IMAGES) + //saveFileImages() + IMAGES_CREATED = false + } showStatusQ('Saving: File: State.') saveFileState() diff --git a/ui/ui.js b/ui/ui.js index 28288681..dd7b3c70 100755 --- a/ui/ui.js +++ b/ui/ui.js @@ -420,6 +420,7 @@ var FIELD_TYPES = { }, }, + // NOTE: this will not work without node-webkit... dir: { type: 'dir', text: null, @@ -443,7 +444,7 @@ var FIELD_TYPES = { return f[0].path }, }, - + // NOTE: this will not work without node-webkit... ndir: { type: 'ndir', text: null, @@ -489,38 +490,24 @@ var FIELD_TYPES = { }, } -// Show a complex dialog +// Show a complex form dialog +// +// This will build a form and collect it's data on "accept" specified by +// the config object... // // config format: // { // // simple field... // : , // -// // XXX not yet implemented outside of FIELD_TYPES... -// : { -// type: , -// text: , -// default: , -// -// // field code... -// // NOTE: class names "text" and "value" get their text -// // replaced with values set in text and default fields -// // respectively... -// html: , -// -// // used on dialog creation to init default value... -// setter: , -// -// // used on dialog submit to get the field value... -// getter: , -// }, // ... // } // // field's default value determines it's type: // bool - checkbox // string - textarea -// array - dropdown +// +// see FIELD_TYPES for supported field types. // // XXX add form testing... // XXX add undefined field handling/reporting... @@ -606,6 +593,7 @@ function formDialog(root, message, config, btn, cls){ } + /************************************************ Standard dialogs ***/ var _alert = alert @@ -632,6 +620,7 @@ function confirm(){ */ +// NOTE: this will not work without node-webkit... function getDir(message, dfl, btn){ btn = btn == null ? 'OK' : btn dfl = dfl == null ? '' : dfl