MCPcopy Create free account
hub / github.com/TruthHun/BookStack / parse_flat

Function parse_flat

static/jstree/3.3.4/jstree.js:1562–1648  ·  view source on GitHub ↗
(d, p, ps)

Source from the content-addressed store, hash-verified

1560 sel = data.sel,
1561 tmp, i, j, rslt,
1562 parse_flat = function (d, p, ps) {
1563 if(!ps) { ps = []; }
1564 else { ps = ps.concat(); }
1565 if(p) { ps.unshift(p); }
1566 var tid = d.id.toString(),
1567 i, j, c, e,
1568 tmp = {
1569 id : tid,
1570 text : d.text || '',
1571 icon : d.icon !== undefined ? d.icon : true,
1572 parent : p,
1573 parents : ps,
1574 children : d.children || [],
1575 children_d : d.children_d || [],
1576 data : d.data,
1577 state : { },
1578 li_attr : { id : false },
1579 a_attr : { href : '#' },
1580 original : false
1581 };
1582 for(i in df) {
1583 if(df.hasOwnProperty(i)) {
1584 tmp.state[i] = df[i];
1585 }
1586 }
1587 if(d && d.data && d.data.jstree && d.data.jstree.icon) {
1588 tmp.icon = d.data.jstree.icon;
1589 }
1590 if(tmp.icon === undefined || tmp.icon === null || tmp.icon === "") {
1591 tmp.icon = true;
1592 }
1593 if(d && d.data) {
1594 tmp.data = d.data;
1595 if(d.data.jstree) {
1596 for(i in d.data.jstree) {
1597 if(d.data.jstree.hasOwnProperty(i)) {
1598 tmp.state[i] = d.data.jstree[i];
1599 }
1600 }
1601 }
1602 }
1603 if(d && typeof d.state === 'object') {
1604 for (i in d.state) {
1605 if(d.state.hasOwnProperty(i)) {
1606 tmp.state[i] = d.state[i];
1607 }
1608 }
1609 }
1610 if(d && typeof d.li_attr === 'object') {
1611 for (i in d.li_attr) {
1612 if(d.li_attr.hasOwnProperty(i)) {
1613 tmp.li_attr[i] = d.li_attr[i];
1614 }
1615 }
1616 }
1617 if(!tmp.li_attr.id) {
1618 tmp.li_attr.id = tid;
1619 }

Callers 1

funcFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected