2017-11-04 19:38:50 -04:00
|
|
|
"use strict";
|
|
|
|
|
2017-11-04 22:18:36 -04:00
|
|
|
const treeUtils = (function() {
|
2018-02-14 23:31:20 -05:00
|
|
|
const $tree = $("#tree");
|
2017-11-04 19:28:49 -04:00
|
|
|
|
2017-11-14 23:01:23 -05:00
|
|
|
function getParentProtectedStatus(node) {
|
2018-03-24 23:37:55 -04:00
|
|
|
return utils.isTopLevelNode(node) ? 0 : node.getParent().data.isProtected;
|
2017-11-04 22:18:36 -04:00
|
|
|
}
|
2017-09-09 12:06:15 -04:00
|
|
|
|
2017-11-18 17:05:50 -05:00
|
|
|
function getNodeByKey(key) {
|
2018-02-14 23:31:20 -05:00
|
|
|
return $tree.fancytree('getNodeByKey', key);
|
2017-10-01 23:07:32 -04:00
|
|
|
}
|
|
|
|
|
2017-11-19 12:06:48 -05:00
|
|
|
function getNoteIdFromNotePath(notePath) {
|
|
|
|
const path = notePath.split("/");
|
2017-10-01 23:07:32 -04:00
|
|
|
|
2017-11-19 12:06:48 -05:00
|
|
|
return path[path.length - 1];
|
|
|
|
}
|
2017-09-18 20:48:02 -04:00
|
|
|
|
2017-11-19 08:47:22 -05:00
|
|
|
function getNotePath(node) {
|
|
|
|
const path = [];
|
|
|
|
|
2018-03-24 23:37:55 -04:00
|
|
|
while (node && !utils.isRootNode(node)) {
|
2018-01-28 19:30:14 -05:00
|
|
|
if (node.data.noteId) {
|
|
|
|
path.push(node.data.noteId);
|
2017-11-19 08:47:22 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
node = node.getParent();
|
|
|
|
}
|
|
|
|
|
|
|
|
return path.reverse().join("/");
|
|
|
|
}
|
|
|
|
|
2017-11-04 22:18:36 -04:00
|
|
|
return {
|
2017-11-14 23:01:23 -05:00
|
|
|
getParentProtectedStatus,
|
2017-11-04 22:18:36 -04:00
|
|
|
getNodeByKey,
|
2017-11-19 12:06:48 -05:00
|
|
|
getNotePath,
|
2017-11-28 10:17:30 -05:00
|
|
|
getNoteIdFromNotePath,
|
2017-11-04 22:18:36 -04:00
|
|
|
};
|
|
|
|
})();
|