plugin/plugin copy.js
// Loads children of a supplied node
Loads children of a supplied node
Loads children of a supplied node
function loadData(node, callback) {
    if(!node.loadedChildren) {
        const state = node.data.state;
        getChildStates(state)
        .then(data => {
            for (let i = 0; i < data['states'].length; i++) {
                if(node.data.children) {
                    const newName = "State " + stateCounter;
                    stateCounter += 1;
                    const newState = {"name":newName, "children":[], "state":data.states[i], "strState":data.stringStates[i], "precondition":data.actions[i].toString(), "loadedChildren":false};
                    node.data.children.push(newState);
                }
            }
            node.loadedChildren = true;
            callback(node);
        });
    }
}
function loadData ( node , callback ) { if ( ! node . loadedChildren ) { const state = node . data . state ; getChildStates ( state ) . then ( data => { for ( let i = 0 ; i < data [ 'states' ] . length ; i ++ ) { if ( node . data . children ) { const newName = "State " + stateCounter ; stateCounter += 1 ; const newState = { "name" : newName , "children" : [ ] , "state" : data . states [ i ] , "strState" : data . stringStates [ i ] , "precondition" : data . actions [ i ] . toString ( ) , "loadedChildren" : false } ; node . data . children . push ( newState ) ; } } node . loadedChildren = true ; callback ( node ) ; } ) ; } }
Loads children of a supplied node
Loads children of a supplied node
// Create data // Call the callback function with the node that contains // the newly loaded children