mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 18:30:09 +00:00
minor refactoring...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
1064cb79b3
commit
3523b8b61e
@ -385,21 +385,28 @@ var BaseBrowserPrototype = {
|
|||||||
opts)
|
opts)
|
||||||
: opts
|
: opts
|
||||||
|
|
||||||
// item id...
|
|
||||||
// XXX do a better id...
|
// XXX do a better id...
|
||||||
|
var makeID = function(id){
|
||||||
|
// id prefix...
|
||||||
|
return (id || '')
|
||||||
|
// separator...
|
||||||
|
+ (id && ' ')
|
||||||
|
// date...
|
||||||
|
+ Date.now() }
|
||||||
|
|
||||||
|
// item id...
|
||||||
// XXX should these include the path???
|
// XXX should these include the path???
|
||||||
var key = opts.id
|
var key = opts.id
|
||||||
// value is a browser -> generate an unique id...
|
// value is a browser -> generate an unique id...
|
||||||
// XXX identify via structure...
|
// XXX identify via structure...
|
||||||
|| (value instanceof Browser
|
|| (value instanceof Browser
|
||||||
&& Date.now())
|
&& makeID())
|
||||||
|| JSON.stringify(value)
|
|| JSON.stringify(value)
|
||||||
|
|
||||||
// handle duplicate ids -> err if found...
|
// handle duplicate ids -> err if found...
|
||||||
if(opts.id && opts.id in new_index){
|
if(opts.id && opts.id in new_index){
|
||||||
throw new Error(`make(..): duplicate id "${key}": `
|
throw new Error(`make(..): duplicate id "${key}": `
|
||||||
+`can't create multiple items with the same key.`) }
|
+`can't create multiple items with the same key.`) }
|
||||||
|
|
||||||
// handle duplicate keys...
|
// handle duplicate keys...
|
||||||
var k = key
|
var k = key
|
||||||
while(k in new_index){
|
while(k in new_index){
|
||||||
@ -407,9 +414,8 @@ var BaseBrowserPrototype = {
|
|||||||
if(options.noDuplicateValues){
|
if(options.noDuplicateValues){
|
||||||
throw new Error(`make(..): duplicate key "${key}": `
|
throw new Error(`make(..): duplicate key "${key}": `
|
||||||
+`can't create multiple items with the same key.`) }
|
+`can't create multiple items with the same key.`) }
|
||||||
|
|
||||||
// create a new key...
|
// create a new key...
|
||||||
k = key +' '+ Date.now()
|
k = makeID(key)
|
||||||
}
|
}
|
||||||
key = opts.id = k
|
key = opts.id = k
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user