-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
11,156 additions
and
41 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
function addToTree(path, fullPath) { | ||
|
||
var pathSegments = path.split("/"); | ||
var currentNode = $("#js-tree").jstree("get_node", "#"); | ||
|
||
for (var i = 0; i < pathSegments.length; i++) { | ||
|
||
//try to find node and use that if found | ||
let node = findNode(currentNode, pathSegments[i]) | ||
if (node != null) { | ||
currentNode = node; | ||
} | ||
else { | ||
//set properties for node | ||
var node_data = "_"; | ||
var icon_path = "icons/opened-folder-24.png"; | ||
if(endsWith(pathSegments[i], "?")) icon_path = "icons/block-chain-24.png"; | ||
if(i == pathSegments.length - 1){ | ||
icon_path = "icons/document-24.png"; | ||
node_data = fullPath; | ||
} | ||
|
||
//define and add node | ||
var newNode = { | ||
id: CreateGuid(), | ||
data: node_data, | ||
text: pathSegments[i], | ||
type: "file", | ||
state: "open", | ||
icon: icon_path | ||
}; | ||
$("#js-tree").jstree('create_node', currentNode.id, newNode); | ||
currentNode = newNode; | ||
} | ||
}; | ||
}; | ||
|
||
function findNode(root, search_string) { | ||
|
||
if (root != null) { | ||
let children = root.children; | ||
|
||
if (children) { | ||
for (let i = 0; i < children.length; i++) { | ||
let node = $("#js-tree").jstree("get_node", children[i]); | ||
if (node.text == search_string) { | ||
return node; | ||
} | ||
else { | ||
let nextNode = $("#js-tree").jstree("get_node", node.id); | ||
findNode(nextNode, search_string); | ||
} | ||
} | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
//checks if string endsWith a given substring | ||
function endsWith(str, suffix) { | ||
return str.indexOf(suffix, str.length - suffix.length) !== -1; | ||
} | ||
|
||
//creates a random Guid string | ||
function CreateGuid() { | ||
function _p8(s) { | ||
var p = (Math.random().toString(16) + "000000000").substr(2, 8); | ||
return s ? "-" + p.substr(0, 4) + "-" + p.substr(4, 4) : p; | ||
} | ||
return _p8() + _p8(true) + _p8(true) + _p8(); | ||
} |