refactoring - moving stuff to separate files

This commit is contained in:
azivner
2017-09-09 12:06:15 -04:00
parent 7c623d9a0b
commit aad90f016b
12 changed files with 478 additions and 464 deletions

27
static/js/treeutils.js Normal file
View File

@@ -0,0 +1,27 @@
function getParentKey(node) {
return (node.getParent() === null || node.getParent().key === "root_1") ? "root" : node.getParent().key;
}
function getParentEncryption(node) {
return node.getParent() === null ? 0 : node.getParent().data.encryption;
}
function getNodeByKey(noteId) {
return globalTree.fancytree('getNodeByKey', noteId);
}
function getFullName(noteId) {
let note = getNodeByKey(noteId);
const path = [];
while (note) {
path.push(note.title);
note = note.getParent();
}
// remove "root" element
path.pop();
return path.reverse().join(" > ");
}