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

Function parse_nest

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

Source from the content-addressed store, hash-verified

1647 return tmp.id;
1648 },
1649 parse_nest = function (d, p, ps) {
1650 if(!ps) { ps = []; }
1651 else { ps = ps.concat(); }
1652 if(p) { ps.unshift(p); }
1653 var tid = false, i, j, c, e, tmp;
1654 do {
1655 tid = 'j' + t_id + '_' + (++t_cnt);
1656 } while(m[tid]);
1657
1658 tmp = {
1659 id : false,
1660 text : typeof d === 'string' ? d : '',
1661 icon : typeof d === 'object' && d.icon !== undefined ? d.icon : true,
1662 parent : p,
1663 parents : ps,
1664 children : [],
1665 children_d : [],
1666 data : null,
1667 state : { },
1668 li_attr : { id : false },
1669 a_attr : { href : '#' },
1670 original : false
1671 };
1672 for(i in df) {
1673 if(df.hasOwnProperty(i)) {
1674 tmp.state[i] = df[i];
1675 }
1676 }
1677 if(d && d.id) { tmp.id = d.id.toString(); }
1678 if(d && d.text) { tmp.text = d.text; }
1679 if(d && d.data && d.data.jstree && d.data.jstree.icon) {
1680 tmp.icon = d.data.jstree.icon;
1681 }
1682 if(tmp.icon === undefined || tmp.icon === null || tmp.icon === "") {
1683 tmp.icon = true;
1684 }
1685 if(d && d.data) {
1686 tmp.data = d.data;
1687 if(d.data.jstree) {
1688 for(i in d.data.jstree) {
1689 if(d.data.jstree.hasOwnProperty(i)) {
1690 tmp.state[i] = d.data.jstree[i];
1691 }
1692 }
1693 }
1694 }
1695 if(d && typeof d.state === 'object') {
1696 for (i in d.state) {
1697 if(d.state.hasOwnProperty(i)) {
1698 tmp.state[i] = d.state[i];
1699 }
1700 }
1701 }
1702 if(d && typeof d.li_attr === 'object') {
1703 for (i in d.li_attr) {
1704 if(d.li_attr.hasOwnProperty(i)) {
1705 tmp.li_attr[i] = d.li_attr[i];
1706 }

Callers 1

funcFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected