mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-12-17 08:41:40 +00:00
added fav dir loading (wo. index)...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
92f8c6ea86
commit
96c71629f3
@ -74,8 +74,8 @@ Roadmap
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
[_] 21% Gen 3 current todo
|
[_] 22% Gen 3 current todo
|
||||||
[_] 43% High priority
|
[_] 45% High priority
|
||||||
[_] BUG: aligning still sometimes gets off...
|
[_] BUG: aligning still sometimes gets off...
|
||||||
| ...after rotating a number of images
|
| ...after rotating a number of images
|
||||||
|
|
|
|
||||||
@ -109,7 +109,6 @@ Roadmap
|
|||||||
[_] BUG: jumping screen images does not load the adjacent ribbons...
|
[_] BUG: jumping screen images does not load the adjacent ribbons...
|
||||||
| positioning is OK but ribbons are not fully visible...
|
| positioning is OK but ribbons are not fully visible...
|
||||||
[_] ASAP: test on Android...
|
[_] ASAP: test on Android...
|
||||||
[_] import fav dirs (wo. index)...
|
|
||||||
[_] slideshow mode...
|
[_] slideshow mode...
|
||||||
[_] single ribbon mode
|
[_] single ribbon mode
|
||||||
| should this have up/down navigation?
|
| should this have up/down navigation?
|
||||||
@ -166,6 +165,7 @@ Roadmap
|
|||||||
[_] thresholds and frame size
|
[_] thresholds and frame size
|
||||||
[_] remove extra and repetitive actions
|
[_] remove extra and repetitive actions
|
||||||
[_] caching config
|
[_] caching config
|
||||||
|
[X] import fav dirs (wo. index)...
|
||||||
[X] ASAP: load/view un-cached directories...
|
[X] ASAP: load/view un-cached directories...
|
||||||
[X] ASAP: support relative paths in cache...
|
[X] ASAP: support relative paths in cache...
|
||||||
[X] ASAP: account for image rotation with screen proportions while positioning
|
[X] ASAP: account for image rotation with screen proportions while positioning
|
||||||
|
|||||||
63
ui/data.js
63
ui/data.js
@ -377,11 +377,22 @@ function getBestPreview(gid, size){
|
|||||||
* Constructors
|
* Constructors
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// NOTE: this depends on that the base dir contains ALL the images...
|
||||||
function imagesFromUrls(lst){
|
function imagesFromUrls(lst){
|
||||||
var res = {}
|
var res = {}
|
||||||
|
|
||||||
$.each(lst, function(i, e){
|
$.each(lst, function(i, e){
|
||||||
var gid = 'image-' + i
|
|
||||||
|
// this is ugly but I'm bored so this pretty...
|
||||||
|
var ii = i < 10 ? '0000000' + i
|
||||||
|
: i < 100 ? '000000' + i
|
||||||
|
: i < 1000 ? '00000' + i
|
||||||
|
: i < 10000 ? '0000' + i
|
||||||
|
: i < 100000 ? '000' + i
|
||||||
|
: i < 1000000 ? '00' + i
|
||||||
|
: i < 10000000 ? '0' + i
|
||||||
|
: i
|
||||||
|
var gid = 'image-' + ii
|
||||||
res[gid] = {
|
res[gid] = {
|
||||||
id: gid,
|
id: gid,
|
||||||
type: 'image',
|
type: 'image',
|
||||||
@ -413,6 +424,53 @@ function dataFromImages(images){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// NOTE: this depends on listDir(...)
|
||||||
|
// NOTE: this assumes that images contain ALL the images...
|
||||||
|
function ribbonsFromFavDirs(path, images){
|
||||||
|
path = path == null ? BASE_URL : path
|
||||||
|
images = images == null ? IMAGES : images
|
||||||
|
|
||||||
|
// build a reverse name-gid index for fast access...
|
||||||
|
var index = {}
|
||||||
|
var name
|
||||||
|
for(var gid in images){
|
||||||
|
name = images[gid].path.split('/').pop()
|
||||||
|
// XXX we assume that names are unique...
|
||||||
|
index[name] = gid
|
||||||
|
}
|
||||||
|
|
||||||
|
var ribbons = []
|
||||||
|
// add the base row...
|
||||||
|
var base = Object.keys(images)
|
||||||
|
ribbons.push(base)
|
||||||
|
|
||||||
|
var files = listDir(path)
|
||||||
|
var cur_path = path
|
||||||
|
while(files.indexOf('fav') >= 0){
|
||||||
|
cur_path += '/fav'
|
||||||
|
files = listDir(cur_path)
|
||||||
|
ribbon = []
|
||||||
|
// collect the images...
|
||||||
|
$.each(files, function(i, e){
|
||||||
|
var _gid = index[e]
|
||||||
|
var found = /.*\.(jpg|jpeg)$/i.test(e) ? ribbon.push(_gid) : false
|
||||||
|
// remove the found item from each of the below ribbons...
|
||||||
|
if(found !== false){
|
||||||
|
$.each(ribbons, function(i ,e){
|
||||||
|
e.splice(e.indexOf(_gid), 1)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
ribbons.push(ribbon)
|
||||||
|
}
|
||||||
|
|
||||||
|
// remove empty ribbons...
|
||||||
|
ribbons = $.map(ribbons, function(e){ return e.length > 0 ? [e] : null })
|
||||||
|
|
||||||
|
return ribbons.reverse()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* Format conversion
|
* Format conversion
|
||||||
@ -1097,8 +1155,9 @@ function loadDir(path, raw_load){
|
|||||||
|
|
||||||
IMAGES = imagesFromUrls(image_paths)
|
IMAGES = imagesFromUrls(image_paths)
|
||||||
DATA = dataFromImages(IMAGES)
|
DATA = dataFromImages(IMAGES)
|
||||||
MARKED = []
|
|
||||||
BASE_URL = orig_path
|
BASE_URL = orig_path
|
||||||
|
DATA.ribbons = ribbonsFromFavDirs()
|
||||||
|
MARKED = []
|
||||||
|
|
||||||
loadData()
|
loadData()
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user