mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 10:20:08 +00:00
minor tweaking...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
9ece16bb5b
commit
98f1f7fde2
@ -40,7 +40,7 @@ var util = require('lib/util')
|
|||||||
// .someMethod(arg, ..)
|
// .someMethod(arg, ..)
|
||||||
// .someMethod([arg, ..])
|
// .someMethod([arg, ..])
|
||||||
//
|
//
|
||||||
var splitOrList = function(args){
|
var normalizeSplit = function(args){
|
||||||
return (args.length == 1 && args[0] instanceof Array) ?
|
return (args.length == 1 && args[0] instanceof Array) ?
|
||||||
args.pop()
|
args.pop()
|
||||||
: args }
|
: args }
|
||||||
@ -78,7 +78,7 @@ var TagsClassPrototype = {
|
|||||||
: typeof(tagRemovedChars) == typeof('str') ?
|
: typeof(tagRemovedChars) == typeof('str') ?
|
||||||
new RegExp(tagRemovedChars, 'g')
|
new RegExp(tagRemovedChars, 'g')
|
||||||
: /[\s-_]/g
|
: /[\s-_]/g
|
||||||
var res = splitOrList(tags)
|
var res = normalizeSplit(tags)
|
||||||
.map(function(tag){
|
.map(function(tag){
|
||||||
return tag
|
return tag
|
||||||
.trim()
|
.trim()
|
||||||
@ -106,7 +106,7 @@ var TagsClassPrototype = {
|
|||||||
: res
|
: res
|
||||||
},
|
},
|
||||||
subTags: function(...tags){
|
subTags: function(...tags){
|
||||||
return this.normalize(splitOrList(tags))
|
return this.normalize(normalizeSplit(tags))
|
||||||
.map(function(tag){
|
.map(function(tag){
|
||||||
return tag.split(/[:\\\/]/g) })
|
return tag.split(/[:\\\/]/g) })
|
||||||
.flat()
|
.flat()
|
||||||
@ -202,6 +202,7 @@ var TagsClassPrototype = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
// XXX should we store normalized and non-normalized tags for reference???
|
// XXX should we store normalized and non-normalized tags for reference???
|
||||||
// ...there are two ways to think of this:
|
// ...there are two ways to think of this:
|
||||||
// 1) both (a-la flickr) -- keep both, use normalized internally
|
// 1) both (a-la flickr) -- keep both, use normalized internally
|
||||||
@ -235,7 +236,9 @@ var TagsPrototype = {
|
|||||||
// }
|
// }
|
||||||
__index: null,
|
__index: null,
|
||||||
|
|
||||||
// XXX
|
|
||||||
|
|
||||||
|
// XXX EXPERIMENTAL...
|
||||||
// XXX need a way to edit the compound tag...
|
// XXX need a way to edit the compound tag...
|
||||||
__special_tag_handlers__: {
|
__special_tag_handlers__: {
|
||||||
'*persistent*': function(action, tag, value){
|
'*persistent*': function(action, tag, value){
|
||||||
@ -273,6 +276,7 @@ var TagsPrototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Utils...
|
// Utils...
|
||||||
//
|
//
|
||||||
// proxies to class methods...
|
// proxies to class methods...
|
||||||
@ -603,7 +607,7 @@ var TagsPrototype = {
|
|||||||
|
|
||||||
// check if value is tagged by tags..,
|
// check if value is tagged by tags..,
|
||||||
if(value && tags.length > 0){
|
if(value && tags.length > 0){
|
||||||
tags = splitOrList(tags)
|
tags = normalizeSplit(tags)
|
||||||
var u = this.tags(value)
|
var u = this.tags(value)
|
||||||
while(tags.length > 0){
|
while(tags.length > 0){
|
||||||
if(this.match(tags.shift(), u).length == 0){
|
if(this.match(tags.shift(), u).length == 0){
|
||||||
@ -877,7 +881,7 @@ var TagsPrototype = {
|
|||||||
action = ['on', 'off', 'toggle', '?'].includes(tags[tags.length-1]) ?
|
action = ['on', 'off', 'toggle', '?'].includes(tags[tags.length-1]) ?
|
||||||
tags.pop()
|
tags.pop()
|
||||||
: 'toggle'
|
: 'toggle'
|
||||||
tags = splitOrList(tags)
|
tags = normalizeSplit(tags)
|
||||||
|
|
||||||
var persistent =
|
var persistent =
|
||||||
this.__persistent_tags =
|
this.__persistent_tags =
|
||||||
@ -935,7 +939,7 @@ var TagsPrototype = {
|
|||||||
throw new Error(
|
throw new Error(
|
||||||
`.rename(..): only support tags and tag sets as renaming target, got: "${to}"`) }
|
`.rename(..): only support tags and tag sets as renaming target, got: "${to}"`) }
|
||||||
|
|
||||||
tags = new Set(splitOrList(tags))
|
tags = new Set(normalizeSplit(tags))
|
||||||
|
|
||||||
// prepare for the replacement...
|
// prepare for the replacement...
|
||||||
var pattern = new RegExp(`(^|[:\\\\\\/])${tag}(?=$|[:\\\\\\/])`, 'g')
|
var pattern = new RegExp(`(^|[:\\\\\\/])${tag}(?=$|[:\\\\\\/])`, 'g')
|
||||||
@ -1000,7 +1004,7 @@ var TagsPrototype = {
|
|||||||
// -> this
|
// -> this
|
||||||
//
|
//
|
||||||
remove: function(...values){
|
remove: function(...values){
|
||||||
values = splitOrList(values)
|
values = normalizeSplit(values)
|
||||||
var res = this.clone()
|
var res = this.clone()
|
||||||
|
|
||||||
Object.entries(res.__index || {})
|
Object.entries(res.__index || {})
|
||||||
@ -1017,7 +1021,7 @@ var TagsPrototype = {
|
|||||||
// -> this
|
// -> this
|
||||||
//
|
//
|
||||||
keep: function(...values){
|
keep: function(...values){
|
||||||
values = splitOrList(values)
|
values = normalizeSplit(values)
|
||||||
var res = this.clone()
|
var res = this.clone()
|
||||||
|
|
||||||
Object.entries(res.__index || {})
|
Object.entries(res.__index || {})
|
||||||
@ -1027,6 +1031,9 @@ var TagsPrototype = {
|
|||||||
return res
|
return res
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
// Tags - Tags API...
|
||||||
|
//
|
||||||
// Join 1 or more Tags objects...
|
// Join 1 or more Tags objects...
|
||||||
//
|
//
|
||||||
// .join(other, ..)
|
// .join(other, ..)
|
||||||
@ -1036,7 +1043,7 @@ var TagsPrototype = {
|
|||||||
join: function(...others){
|
join: function(...others){
|
||||||
var that = this
|
var that = this
|
||||||
var index = this.__index || {}
|
var index = this.__index || {}
|
||||||
splitOrList(others)
|
normalizeSplit(others)
|
||||||
.forEach(function(other){
|
.forEach(function(other){
|
||||||
Object.entries(other.__index || {})
|
Object.entries(other.__index || {})
|
||||||
.forEach(function(e){
|
.forEach(function(e){
|
||||||
@ -1048,7 +1055,6 @@ var TagsPrototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Query API...
|
// Query API...
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
@ -1305,7 +1311,6 @@ var TagsPrototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Object utility API...
|
// Object utility API...
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
@ -1319,6 +1324,7 @@ var TagsPrototype = {
|
|||||||
clone: function(mode){
|
clone: function(mode){
|
||||||
return new this.constructor(this.json(mode)) },
|
return new this.constructor(this.json(mode)) },
|
||||||
|
|
||||||
|
|
||||||
// Serialization...
|
// Serialization...
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
@ -1391,13 +1397,13 @@ var TagsPrototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
__init__: function(json){
|
__init__: function(json){
|
||||||
json
|
json
|
||||||
&& this.load(json) },
|
&& this.load(json) },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
var Tags =
|
var Tags =
|
||||||
module.Tags =
|
module.Tags =
|
||||||
object.makeConstructor('Tags',
|
object.makeConstructor('Tags',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user