mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-12-20 18:21:40 +00:00
fixed a couple of bugs in the fs listers...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
320444e107
commit
9f2d4971a8
@ -55,13 +55,14 @@ function(path, make){
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX mostly works, this has trouble with drives...
|
|
||||||
var listDirfs =
|
var listDirfs =
|
||||||
module.listDirfs =
|
module.listDirfs =
|
||||||
function(path, make){
|
function(path, make){
|
||||||
path = path.constructor == Array ? path.join('/') : path
|
path = path.constructor == Array ? path.join('/') : path
|
||||||
path = /^[a-zA-Z]:/.test(path.trim()) ? path : '/'+path
|
path = /^[a-zA-Z]:/.test(path.trim()) ? path : '/'+path
|
||||||
|
// XXX the windows root path must have a trailing '/'
|
||||||
|
path = /^[a-zA-Z]:$/.test(path.trim()) ? path+'/' : path
|
||||||
|
|
||||||
var fullpath = false
|
var fullpath = false
|
||||||
|
|
||||||
fs.readdir(path, function(err, files){
|
fs.readdir(path, function(err, files){
|
||||||
@ -88,42 +89,46 @@ function(path, make){
|
|||||||
|
|
||||||
// NOTE: this should work from a chrome app and does not require anything
|
// NOTE: this should work from a chrome app and does not require anything
|
||||||
// but fs access...
|
// but fs access...
|
||||||
// XXX for some reason this breaks with a 404...
|
// XXX need a default for '/' on windows...
|
||||||
var listDirBrowser =
|
var listDirBrowser =
|
||||||
module.listDirBrowser =
|
module.listDirBrowser =
|
||||||
function(path, make){
|
function(path, make){
|
||||||
path = path.constructor == Array ? path.join('/') : path
|
path = path.constructor == Array ? path.join('/') : path
|
||||||
path = /^[a-zA-Z]:/.test(path.trim()) ? path : '/'+path
|
path = /^[a-zA-Z]:/.test(path.trim()) ? path : '/'+path
|
||||||
path = /^file:\/\//.test(path.trim()) ? path : 'file://'+path
|
// XXX this is a bit fragile...
|
||||||
|
path = /^file:\/\//.test(path.trim()) ? path : 'file:///'+path
|
||||||
|
|
||||||
var fullpath = false
|
var fullpath = false
|
||||||
|
|
||||||
$.get(path)
|
$.get(path)
|
||||||
// XXX
|
// XXX
|
||||||
.fail(function(err){
|
.fail(function(err){
|
||||||
|
console.log('!!!', arguments)
|
||||||
})
|
})
|
||||||
.done(function(data){
|
.done(function(data){
|
||||||
|
// XXX this is very chrome specific...
|
||||||
// XXX this is chrome specific...
|
|
||||||
// look for: addRow(name, url, isdir, size, date_modified)
|
// look for: addRow(name, url, isdir, size, date_modified)
|
||||||
data
|
$(data)
|
||||||
.split(/.*addRow\(([^)]+)\)/g)
|
.filter('script')
|
||||||
// skip odd sections...
|
.toArray()
|
||||||
.filter(function(e, i){ return i % 2 })
|
.forEach(function(e){
|
||||||
// skip the columns...
|
e = e.innerHTML.split(/.*addRow\((.*)\);/g)
|
||||||
.slice(1)
|
if(e.length > 1){
|
||||||
.forEach(function(elem){
|
e.filter(function(e, i){ return i % 2 })
|
||||||
// get the data...
|
.forEach(function(elem){
|
||||||
elem = elem.split(',')
|
elem = JSON.parse('['+elem+']')
|
||||||
var file = elem[0]
|
var file = elem[0]
|
||||||
// remove quotes...
|
|
||||||
.replace(/.*(['"])([^\1]*)\1.*/, '$2')
|
|
||||||
//.replace(/"([^"]+)"/, '$1')
|
|
||||||
|
|
||||||
// do the build...
|
if(file == '..' || file == '.'){
|
||||||
make(fullpath
|
return
|
||||||
? path +'/'+ file
|
}
|
||||||
: file + (elem[2]*1 ? '/' : ''))
|
|
||||||
|
// do the build...
|
||||||
|
make(fullpath
|
||||||
|
? path +'/'+ file
|
||||||
|
: file + (elem[2] ? '/' : ''))
|
||||||
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -136,6 +141,8 @@ var listDir = module.listDir = listDirfs
|
|||||||
|
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
|
|
||||||
|
// XXX for some reason pop does not focus the container dir correctly...
|
||||||
|
// ...this is potentially due to the list not being ready yet...
|
||||||
var WalkPrototype = Object.create(browse.Browser.prototype)
|
var WalkPrototype = Object.create(browse.Browser.prototype)
|
||||||
WalkPrototype.options = {
|
WalkPrototype.options = {
|
||||||
|
|
||||||
|
|||||||
@ -22,7 +22,7 @@ var walk = require('lib/widget/browse-walk')
|
|||||||
|
|
||||||
//var data = require('data')
|
//var data = require('data')
|
||||||
|
|
||||||
window.dirLister = walk.listDir
|
window.listDirBrowser = walk.listDirBrowser
|
||||||
|
|
||||||
window.toggleFullscreenMode =
|
window.toggleFullscreenMode =
|
||||||
module.toggleFullscreenMode = CSSClassToggler(
|
module.toggleFullscreenMode = CSSClassToggler(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user