mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 18:30:09 +00:00
bugfix, doc, notes and minor refactoring...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
1667632227
commit
851dcbe1ae
@ -539,6 +539,11 @@ var BaseTagsPrototype = {
|
|||||||
|
|
||||||
// Keep only the longest matching paths...
|
// Keep only the longest matching paths...
|
||||||
//
|
//
|
||||||
|
// List all the unique paths...
|
||||||
|
// .uniquePaths()
|
||||||
|
// -> paths
|
||||||
|
//
|
||||||
|
// Return only unique paths...
|
||||||
// .uniquePaths(path, ..)
|
// .uniquePaths(path, ..)
|
||||||
// .uniquePaths([path, ..])
|
// .uniquePaths([path, ..])
|
||||||
// -> paths
|
// -> paths
|
||||||
@ -551,7 +556,9 @@ var BaseTagsPrototype = {
|
|||||||
//
|
//
|
||||||
uniquePaths: function(...list){
|
uniquePaths: function(...list){
|
||||||
var that = this
|
var that = this
|
||||||
return that.normalize(normalizeSplit(list))
|
return (list.length == 0 ?
|
||||||
|
this.paths()
|
||||||
|
: this.normalize(normalizeSplit(list)))
|
||||||
// sort by number of path elements (longest first)...
|
// sort by number of path elements (longest first)...
|
||||||
.map(function(p){ return p.split(/[\\\/]/g) })
|
.map(function(p){ return p.split(/[\\\/]/g) })
|
||||||
.sort(function(a, b){ return b.length - a.length })
|
.sort(function(a, b){ return b.length - a.length })
|
||||||
@ -565,7 +572,7 @@ var BaseTagsPrototype = {
|
|||||||
.slice(i+1)
|
.slice(i+1)
|
||||||
.forEach(function(o, j){
|
.forEach(function(o, j){
|
||||||
// skip []...
|
// skip []...
|
||||||
!(p instanceof Array)
|
!(o instanceof Array)
|
||||||
&& that.directMatch(o, p)
|
&& that.directMatch(o, p)
|
||||||
// match -> replace the matching elem with []
|
// match -> replace the matching elem with []
|
||||||
&& (list[i+j+1] = []) })
|
&& (list[i+j+1] = []) })
|
||||||
@ -1054,7 +1061,7 @@ var BaseTagsPrototype = {
|
|||||||
return res
|
return res
|
||||||
},
|
},
|
||||||
|
|
||||||
// Keep only the longest tag paths per value...
|
// Optimize tags...
|
||||||
//
|
//
|
||||||
// Optimize tags for all values...
|
// Optimize tags for all values...
|
||||||
// .optimizeTags()
|
// .optimizeTags()
|
||||||
@ -1066,14 +1073,25 @@ var BaseTagsPrototype = {
|
|||||||
// -> values
|
// -> values
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
// Optimizations:
|
||||||
|
// - Keep only the longest tag paths per value...
|
||||||
// Example:
|
// Example:
|
||||||
// var ts = new Tags()
|
// var ts = new Tags()
|
||||||
// ts.tag(['a/b/c', 'a/c'], x)
|
// ts.tag(['a/b/c', 'a/c'], x)
|
||||||
//
|
//
|
||||||
// ts.optimizeTags() // will remove 'a/c' form x as it is fully
|
// ts.optimizeTags() // will remove 'a/c' form x as it is
|
||||||
// // contained within 'a/b/c'...
|
// // fully contained within 'a/b/c'...
|
||||||
//
|
//
|
||||||
// XXX should this be done on .tag(..) and friends???
|
//
|
||||||
|
// XXX Q: should this be done on .tag(..) and friends???
|
||||||
|
// ...currently I do not think so
|
||||||
|
// + would keep the tags consistent...
|
||||||
|
// - slow things down on large numbers of tags
|
||||||
|
// - would seem inconsistent
|
||||||
|
// .tag('a/c', 'x')
|
||||||
|
// .tag('a/b/c', 'x')
|
||||||
|
// .tags(x) // -> ['a/b/c']
|
||||||
|
// might be good to add this as an option...
|
||||||
optimizeTags: function(...values){
|
optimizeTags: function(...values){
|
||||||
var that = this
|
var that = this
|
||||||
return (normalizeSplit(values) || this.values())
|
return (normalizeSplit(values) || this.values())
|
||||||
@ -1084,11 +1102,11 @@ var BaseTagsPrototype = {
|
|||||||
&& that.untag(tags, value)
|
&& that.untag(tags, value)
|
||||||
return tags.length > 0 }) },
|
return tags.length > 0 }) },
|
||||||
|
|
||||||
// Make all paths persistent...
|
// Make paths persistent...
|
||||||
//
|
//
|
||||||
// NOTE: this will add only longest unique paths (see: .uniquePaths(..))
|
// NOTE: this will touch only longest unique paths (see: .uniquePaths(..))
|
||||||
makePathsPersistent: function(){
|
makePathsPersistent: function(){
|
||||||
this.persistent = new Set(this.uniquePaths(this.paths()))
|
this.persistent = new Set(this.uniquePaths())
|
||||||
return this },
|
return this },
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user