From 3523b8b61e884e9f354499e0287fba7fb255dbed Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Fri, 1 Mar 2019 00:40:16 +0300 Subject: [PATCH] minor refactoring... Signed-off-by: Alex A. Naanou --- ui (gen4)/lib/widget/browse2.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/ui (gen4)/lib/widget/browse2.js b/ui (gen4)/lib/widget/browse2.js index ce0cccb8..5d71cb7a 100755 --- a/ui (gen4)/lib/widget/browse2.js +++ b/ui (gen4)/lib/widget/browse2.js @@ -385,21 +385,28 @@ var BaseBrowserPrototype = { opts) : opts - // item 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??? var key = opts.id // value is a browser -> generate an unique id... // XXX identify via structure... || (value instanceof Browser - && Date.now()) + && makeID()) || JSON.stringify(value) // handle duplicate ids -> err if found... if(opts.id && opts.id in new_index){ throw new Error(`make(..): duplicate id "${key}": ` +`can't create multiple items with the same key.`) } - // handle duplicate keys... var k = key while(k in new_index){ @@ -407,9 +414,8 @@ var BaseBrowserPrototype = { if(options.noDuplicateValues){ throw new Error(`make(..): duplicate key "${key}": ` +`can't create multiple items with the same key.`) } - // create a new key... - k = key +' '+ Date.now() + k = makeID(key) } key = opts.id = k