(node, cb)
| 99 | return onJSTreeDataComplete(); |
| 100 | |
| 101 | function getJsTreeData(node, cb) { |
| 102 | if (node.id === '#') return cb(connections.treeObjects); |
| 103 | |
| 104 | var dataUrl; |
| 105 | if (node.parent === '#') { |
| 106 | dataUrl = 'apiv2/keystree/' + encodeURIComponent(node.id) + '/'; |
| 107 | } |
| 108 | else { |
| 109 | var root = getRootConnection(node); |
| 110 | var path = getFullKeyPath(node); |
| 111 | dataUrl = 'apiv2/keystree/' + encodeURIComponent(root) + '/' + encodeURIComponent(path) + '?absolute=false'; |
| 112 | } |
| 113 | $.get({ |
| 114 | url: dataUrl, |
| 115 | dataType: 'json' |
| 116 | }).done(function(nodeData) { |
| 117 | if (Array.isArray(nodeData.data)) { |
| 118 | nodeData.data.forEach(function(elem) { |
| 119 | if (elem.rel) elem.icon = getIconForType(elem.rel); |
| 120 | }); |
| 121 | } |
| 122 | cb(nodeData.data) |
| 123 | }).fail(function(error) { |
| 124 | console.log('Error fetching data for node ' + node.id + ': ' + JSON.stringify(error)); |
| 125 | if (error.responseJSON && error.responseJSON.connectionClosed) { |
| 126 | setRootConnectionNetworkError(true, node) |
| 127 | } |
| 128 | cb('Error fetching data'); |
| 129 | }); |
| 130 | } |
| 131 | |
| 132 | function getIconForType(type) { |
| 133 | switch (type) { |
nothing calls this directly
no test coverage detected