some work on loading raw directories and saving theiir state...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2013-06-13 19:42:42 +04:00
parent d629758dfe
commit fa72c0b466
5 changed files with 38 additions and 21 deletions

View File

@ -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){

View File

@ -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 = {

View File

@ -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

View File

@ -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()

View File

@ -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...
// <field-description>: <default-value>,
//
// // XXX not yet implemented outside of FIELD_TYPES...
// <field-description>: {
// type: <type-name>,
// text: <field-description>,
// default: <default-value>,
//
// // field code...
// // NOTE: class names "text" and "value" get their text
// // replaced with values set in text and default fields
// // respectively...
// html: <html>,
//
// // used on dialog creation to init default value...
// setter: <value-setter>,
//
// // used on dialog submit to get the field value...
// getter: <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