mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-15 02:19:39 +01:00
Expose key splitting publicly, so other code can use it
This commit is contained in:
parent
194606b196
commit
609d1df763
@ -107,6 +107,41 @@ var et2_arrayMgr = Class.extend(
|
|||||||
return null;
|
return null;
|
||||||
},*/
|
},*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Explodes compound keys (eg IDs) into a list of namespaces
|
||||||
|
* This uses no internal values, just expands
|
||||||
|
*
|
||||||
|
* eg:
|
||||||
|
* a[b][c] => [a,b,c]
|
||||||
|
* col_filter[tr_tracker] => [col_filter, tr_tracker]
|
||||||
|
*
|
||||||
|
* @param {string} _key
|
||||||
|
*
|
||||||
|
* @return {string[]}
|
||||||
|
*/
|
||||||
|
explodeKey: function(_key)
|
||||||
|
{
|
||||||
|
// Parse the given key by removing the "]"-chars and splitting at "["
|
||||||
|
var indexes = [_key];
|
||||||
|
|
||||||
|
if(typeof _key === "string")
|
||||||
|
{
|
||||||
|
_key = _key.replace(/[/g,"[").replace(/]/g,"]");
|
||||||
|
indexes = _key.split('[');
|
||||||
|
}
|
||||||
|
if (indexes.length > 1)
|
||||||
|
{
|
||||||
|
indexes = [indexes.shift(), indexes.join('[')];
|
||||||
|
indexes[1] = indexes[1].substring(0,indexes[1].length-1);
|
||||||
|
var children = indexes[1].split('][');
|
||||||
|
if(children.length)
|
||||||
|
{
|
||||||
|
indexes = jQuery.merge([indexes[0]], children);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return indexes;
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the path to this content array manager perspective as an array
|
* Returns the path to this content array manager perspective as an array
|
||||||
* containing the key values
|
* containing the key values
|
||||||
@ -155,26 +190,7 @@ var et2_arrayMgr = Class.extend(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Parse the given key by removing the "]"-chars and splitting at "["
|
// Parse the given key by removing the "]"-chars and splitting at "["
|
||||||
var indexes = [_key];
|
var indexes = this.explodeKey(_key);
|
||||||
|
|
||||||
if (this.splitIds)
|
|
||||||
{
|
|
||||||
if(typeof _key === "string")
|
|
||||||
{
|
|
||||||
_key = _key.replace(/[/g,"[").replace(/]/g,"]");
|
|
||||||
indexes = _key.split('[');
|
|
||||||
}
|
|
||||||
if (indexes.length > 1)
|
|
||||||
{
|
|
||||||
indexes = [indexes.shift(), indexes.join('[')];
|
|
||||||
indexes[1] = indexes[1].substring(0,indexes[1].length-1);
|
|
||||||
var children = indexes[1].split('][');
|
|
||||||
if(children.length)
|
|
||||||
{
|
|
||||||
indexes = jQuery.merge([indexes[0]], children);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var entry = this.data;
|
var entry = this.data;
|
||||||
for (var i = 0; i < indexes.length; i++)
|
for (var i = 0; i < indexes.length; i++)
|
||||||
|
Loading…
Reference in New Issue
Block a user