more refactoring

This commit is contained in:
azivner 2017-09-09 12:34:20 -04:00
parent aad90f016b
commit 42c21afa62
10 changed files with 102 additions and 93 deletions

View file

@ -38,7 +38,7 @@
</div>
</div>
<div id="noteDetailWrapper" style="width: 750px; float: left; margin-left: 30px;">
<div id="noteDetailWrapper">
<div style="float: left; margin: 0 5px 5px 5px;" class="hide-toggle">
<button class="btn btn-sm"
onclick="encryptNoteAndSendToServer();"
@ -153,19 +153,23 @@
<script src="stat/js/init.js"></script>
<!-- Tree scripts -->
<script src="stat/js/tree.js"></script>
<script src="stat/js/treeutils.js"></script>
<script src="stat/js/draganddrop.js"></script>
<script src="stat/js/contextmenu.js"></script>
<script src="stat/js/tree_mutations.js"></script>
<script src="stat/js/tree_utils.js"></script>
<script src="stat/js/drag_and_drop.js"></script>
<script src="stat/js/context_menu.js"></script>
<!-- Note detail -->
<script src="stat/js/note.js"></script>
<script src="stat/js/notecase2html.js"></script>
<script src="stat/js/html2notecase.js"></script>
<script src="stat/js/encryption.js"></script>
<script src="stat/js/recentnotes.js"></script>
<script src="stat/js/addlink.js"></script>
<script src="stat/js/jumptonote.js"></script>
<!-- dialogs -->
<script src="stat/js/recent_notes.js"></script>
<script src="stat/js/add_link.js"></script>
<script src="stat/js/jump_to_note.js"></script>
<script src="stat/js/utils.js"></script>
</body>

View file

@ -1,89 +1,3 @@
function moveBeforeNode(node, beforeNode) {
$.ajax({
url: baseUrl + 'notes/' + node.key + '/moveBefore/' + beforeNode.key,
type: 'PUT',
contentType: "application/json",
success: function () {
node.moveTo(beforeNode, 'before');
}
});
}
function moveAfterNode(node, afterNode) {
$.ajax({
url: baseUrl + 'notes/' + node.key + '/moveAfter/' + afterNode.key,
type: 'PUT',
contentType: "application/json",
success: function () {
node.moveTo(afterNode, 'after');
}
});
}
function moveToNode(node, toNode) {
$.ajax({
url: baseUrl + 'notes/' + node.key + '/moveTo/' + toNode.key,
type: 'PUT',
contentType: "application/json",
success: function () {
node.moveTo(toNode);
toNode.setExpanded(true);
toNode.folder = true;
toNode.renderTitle();
}
});
}
function deleteNode(node) {
if (confirm('Are you sure you want to delete note "' + node.title + '"?')) {
$.ajax({
url: baseUrl + 'notes/' + node.key,
type: 'DELETE',
success: function () {
if (node.getParent() !== null && node.getParent().getChildren().length <= 1) {
node.getParent().folder = false;
node.getParent().renderTitle();
}
globalAllNoteIds = globalAllNoteIds.filter(e => e !== node.key);
// remove from recent notes
globalRecentNotes = globalRecentNotes.filter(note => note !== node.key);
let next = node.getNextSibling();
if (!next) {
next = node.getParent();
}
node.remove();
// activate next element after this one is deleted so we don't lose focus
next.setActive();
}
});
}
}
function moveNodeUp(node) {
if (node.getParent() !== null) {
$.ajax({
url: baseUrl + 'notes/' + node.key + '/moveAfter/' + node.getParent().key,
type: 'PUT',
contentType: "application/json",
success: function () {
if (node.getParent() !== null && node.getParent().getChildren().length <= 1) {
node.getParent().folder = false;
node.getParent().renderTitle();
}
node.moveTo(node.getParent(), 'after');
}
});
}
}
const keybindings = {
"insert": function(node) {
const parentKey = getParentKey(node);

View file

@ -0,0 +1,85 @@
function moveBeforeNode(node, beforeNode) {
$.ajax({
url: baseUrl + 'notes/' + node.key + '/moveBefore/' + beforeNode.key,
type: 'PUT',
contentType: "application/json",
success: function () {
node.moveTo(beforeNode, 'before');
}
});
}
function moveAfterNode(node, afterNode) {
$.ajax({
url: baseUrl + 'notes/' + node.key + '/moveAfter/' + afterNode.key,
type: 'PUT',
contentType: "application/json",
success: function () {
node.moveTo(afterNode, 'after');
}
});
}
function moveToNode(node, toNode) {
$.ajax({
url: baseUrl + 'notes/' + node.key + '/moveTo/' + toNode.key,
type: 'PUT',
contentType: "application/json",
success: function () {
node.moveTo(toNode);
toNode.setExpanded(true);
toNode.folder = true;
toNode.renderTitle();
}
});
}
function deleteNode(node) {
if (confirm('Are you sure you want to delete note "' + node.title + '"?')) {
$.ajax({
url: baseUrl + 'notes/' + node.key,
type: 'DELETE',
success: function () {
if (node.getParent() !== null && node.getParent().getChildren().length <= 1) {
node.getParent().folder = false;
node.getParent().renderTitle();
}
globalAllNoteIds = globalAllNoteIds.filter(e => e !== node.key);
// remove from recent notes
globalRecentNotes = globalRecentNotes.filter(note => note !== node.key);
let next = node.getNextSibling();
if (!next) {
next = node.getParent();
}
node.remove();
// activate next element after this one is deleted so we don't lose focus
next.setActive();
}
});
}
}
function moveNodeUp(node) {
if (node.getParent() !== null) {
$.ajax({
url: baseUrl + 'notes/' + node.key + '/moveAfter/' + node.getParent().key,
type: 'PUT',
contentType: "application/json",
success: function () {
if (node.getParent() !== null && node.getParent().getChildren().length <= 1) {
node.getParent().folder = false;
node.getParent().renderTitle();
}
node.moveTo(node.getParent(), 'after');
}
});
}
}

View file

@ -8,6 +8,12 @@
background-color: #eee;
}
#noteDetailWrapper {
width: 750px;
float: left;
margin-left: 30px;
}
#top-message {
display: none; /* initial state is hidden */
background-color: #e0e0e0;