mirror of
https://github.com/zadam/trilium.git
synced 2025-11-01 19:05:59 +01:00
moved all sources to src directory
This commit is contained in:
50
src/public/javascripts/tree_utils.js
Normal file
50
src/public/javascripts/tree_utils.js
Normal file
@@ -0,0 +1,50 @@
|
||||
"use strict";
|
||||
|
||||
const treeUtils = (function() {
|
||||
const treeEl = $("#tree");
|
||||
|
||||
function getParentProtectedStatus(node) {
|
||||
return isTopLevelNode(node) ? 0 : node.getParent().data.isProtected;
|
||||
}
|
||||
|
||||
function getNodeByKey(key) {
|
||||
return treeEl.fancytree('getNodeByKey', key);
|
||||
}
|
||||
|
||||
function getNoteIdFromNotePath(notePath) {
|
||||
const path = notePath.split("/");
|
||||
|
||||
return path[path.length - 1];
|
||||
}
|
||||
|
||||
function getNotePath(node) {
|
||||
const path = [];
|
||||
|
||||
while (node && !isRootNode(node)) {
|
||||
if (node.data.noteId) {
|
||||
path.push(node.data.noteId);
|
||||
}
|
||||
|
||||
node = node.getParent();
|
||||
}
|
||||
|
||||
return path.reverse().join("/");
|
||||
}
|
||||
|
||||
function setNodeTitleWithPrefix(node) {
|
||||
const noteTitle = noteTree.getNoteTitle(node.data.noteId);
|
||||
const prefix = node.data.prefix;
|
||||
|
||||
const title = (prefix ? (prefix + " - ") : "") + noteTitle;
|
||||
|
||||
node.setTitle(escapeHtml(title));
|
||||
}
|
||||
|
||||
return {
|
||||
getParentProtectedStatus,
|
||||
getNodeByKey,
|
||||
getNotePath,
|
||||
getNoteIdFromNotePath,
|
||||
setNodeTitleWithPrefix
|
||||
};
|
||||
})();
|
||||
Reference in New Issue
Block a user