mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-12-25 12:31:58 +00:00
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:
parent
d629758dfe
commit
fa72c0b466
@ -45,6 +45,15 @@ if(window.CEF_dumpJSON != null){
|
|||||||
// XXX will this work on Mac???
|
// XXX will this work on Mac???
|
||||||
path = path.replace(fp, '')
|
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')
|
return fs.writeFileSync(path, JSON.stringify(data), encoding='utf8')
|
||||||
}
|
}
|
||||||
window.removeFile = function(path){
|
window.removeFile = function(path){
|
||||||
@ -97,6 +106,9 @@ if(window.CEF_dumpJSON != null){
|
|||||||
.appendTo($('body'))
|
.appendTo($('body'))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// PhoneGap
|
// PhoneGap
|
||||||
} else if(false){
|
} else if(false){
|
||||||
|
|
||||||
|
|||||||
@ -104,6 +104,8 @@ var IMAGES = {}
|
|||||||
// list of image GIDs that have been updated...
|
// list of image GIDs that have been updated...
|
||||||
var IMAGES_UPDATED = []
|
var IMAGES_UPDATED = []
|
||||||
|
|
||||||
|
var IMAGES_CREATED = false
|
||||||
|
|
||||||
var MARKED = []
|
var MARKED = []
|
||||||
|
|
||||||
var SETTINGS = {
|
var SETTINGS = {
|
||||||
|
|||||||
@ -498,10 +498,14 @@ function loadRawDir(path, prefix){
|
|||||||
// 3) load a directory as-is
|
// 3) load a directory as-is
|
||||||
// load fav dirs
|
// 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){
|
function loadDir(path, prefix){
|
||||||
prefix = prefix == null ? 'Data' : prefix
|
prefix = prefix == null ? 'Data' : prefix
|
||||||
prefix = prefix === false ? null : prefix
|
prefix = prefix === false ? null : prefix
|
||||||
|
|
||||||
|
IMAGES_CREATED = false
|
||||||
|
|
||||||
path = normalizePath(path)
|
path = normalizePath(path)
|
||||||
var orig_path = path
|
var orig_path = path
|
||||||
var data
|
var data
|
||||||
@ -530,6 +534,9 @@ function loadDir(path, prefix){
|
|||||||
})
|
})
|
||||||
.fail(function(){
|
.fail(function(){
|
||||||
bubbleProgress('Raw directory', loadRawDir(orig_path), res)
|
bubbleProgress('Raw directory', loadRawDir(orig_path), res)
|
||||||
|
.done(function(){
|
||||||
|
IMAGES_CREATED = true
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
return res
|
return res
|
||||||
|
|||||||
@ -465,6 +465,7 @@ var KEYBOARD_CONFIG = {
|
|||||||
function(){
|
function(){
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
//saveLocalStorage()
|
//saveLocalStorage()
|
||||||
|
|
||||||
showStatusQ('Saving: localStorage: Data.')
|
showStatusQ('Saving: localStorage: Data.')
|
||||||
saveLocalStorageData()
|
saveLocalStorageData()
|
||||||
showStatusQ('Saving: localStorage: Marks.')
|
showStatusQ('Saving: localStorage: Marks.')
|
||||||
@ -473,6 +474,12 @@ var KEYBOARD_CONFIG = {
|
|||||||
showStatusQ('Saving: localStorage: Settings.')
|
showStatusQ('Saving: localStorage: Settings.')
|
||||||
saveLocalStorageSettings()
|
saveLocalStorageSettings()
|
||||||
|
|
||||||
|
if(IMAGES_CREATED){
|
||||||
|
showStatusQ('Saving: File: Images.')
|
||||||
|
dumpJSON(normalizePath(CACHE_DIR +'/'+ IMAGES_FILE_DEFAULT), IMAGES)
|
||||||
|
//saveFileImages()
|
||||||
|
IMAGES_CREATED = false
|
||||||
|
}
|
||||||
showStatusQ('Saving: File: State.')
|
showStatusQ('Saving: File: State.')
|
||||||
saveFileState()
|
saveFileState()
|
||||||
|
|
||||||
|
|||||||
31
ui/ui.js
31
ui/ui.js
@ -420,6 +420,7 @@ var FIELD_TYPES = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// NOTE: this will not work without node-webkit...
|
||||||
dir: {
|
dir: {
|
||||||
type: 'dir',
|
type: 'dir',
|
||||||
text: null,
|
text: null,
|
||||||
@ -443,7 +444,7 @@ var FIELD_TYPES = {
|
|||||||
return f[0].path
|
return f[0].path
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
// NOTE: this will not work without node-webkit...
|
||||||
ndir: {
|
ndir: {
|
||||||
type: 'ndir',
|
type: 'ndir',
|
||||||
text: null,
|
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:
|
// config format:
|
||||||
// {
|
// {
|
||||||
// // simple field...
|
// // simple field...
|
||||||
// <field-description>: <default-value>,
|
// <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:
|
// field's default value determines it's type:
|
||||||
// bool - checkbox
|
// bool - checkbox
|
||||||
// string - textarea
|
// string - textarea
|
||||||
// array - dropdown
|
//
|
||||||
|
// see FIELD_TYPES for supported field types.
|
||||||
//
|
//
|
||||||
// XXX add form testing...
|
// XXX add form testing...
|
||||||
// XXX add undefined field handling/reporting...
|
// XXX add undefined field handling/reporting...
|
||||||
@ -606,6 +593,7 @@ function formDialog(root, message, config, btn, cls){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/************************************************ Standard dialogs ***/
|
/************************************************ Standard dialogs ***/
|
||||||
|
|
||||||
var _alert = alert
|
var _alert = alert
|
||||||
@ -632,6 +620,7 @@ function confirm(){
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
// NOTE: this will not work without node-webkit...
|
||||||
function getDir(message, dfl, btn){
|
function getDir(message, dfl, btn){
|
||||||
btn = btn == null ? 'OK' : btn
|
btn = btn == null ? 'OK' : btn
|
||||||
dfl = dfl == null ? '' : dfl
|
dfl = dfl == null ? '' : dfl
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user