consistent usage of arrow syntax instead of anonymous functions

This commit is contained in:
azivner 2017-10-09 18:53:11 -04:00
parent 49460dfb8a
commit ca87ff9215
15 changed files with 76 additions and 95 deletions

View File

@ -1,4 +1,4 @@
$(document).bind('keydown', 'alt+l', function() { $(document).bind('keydown', 'alt+l', () => {
$("#noteAutocomplete").val(''); $("#noteAutocomplete").val('');
$("#linkTitle").val(''); $("#linkTitle").val('');
@ -19,7 +19,7 @@ $(document).bind('keydown', 'alt+l', function() {
$("#noteAutocomplete").autocomplete({ $("#noteAutocomplete").autocomplete({
source: getAutocompleteItems(globalAllNoteIds), source: getAutocompleteItems(globalAllNoteIds),
minLength: 0, minLength: 0,
change: function () { change: () => {
const val = $("#noteAutocomplete").val(); const val = $("#noteAutocomplete").val();
const noteId = getNodeIdFromLabel(val); const noteId = getNodeIdFromLabel(val);
@ -29,7 +29,7 @@ $(document).bind('keydown', 'alt+l', function() {
}, },
// this is called when user goes through autocomplete list with keyboard // this is called when user goes through autocomplete list with keyboard
// at this point the item isn't selected yet so we use supplied ui.item to see where the cursor is // at this point the item isn't selected yet so we use supplied ui.item to see where the cursor is
focus: function (event, ui) { focus: (event, ui) => {
const noteId = getNodeIdFromLabel(ui.item.value); const noteId = getNodeIdFromLabel(ui.item.value);
setDefaultLinkTitle(noteId); setDefaultLinkTitle(noteId);
@ -37,7 +37,7 @@ $(document).bind('keydown', 'alt+l', function() {
}); });
}); });
$("#insertLinkForm").submit(function() { $("#insertLinkForm").submit(() => {
let val = $("#noteAutocomplete").val(); let val = $("#noteAutocomplete").val();
const noteId = getNodeIdFromLabel(val); const noteId = getNodeIdFromLabel(val);
@ -62,11 +62,11 @@ $("#insertLinkForm").submit(function() {
// when click on link popup, in case of internal link, just go the the referenced note instead of default behavior // when click on link popup, in case of internal link, just go the the referenced note instead of default behavior
// of opening the link in new window/tab // of opening the link in new window/tab
$(document).on('click', 'div.popover-content a', function(e) { $(document).on('click', 'div.popover-content a', e => {
goToInternalNote(e); goToInternalNote(e);
}); });
$(document).on('dblclick', '.note-editable a', function(e) { $(document).on('dblclick', '.note-editable a', e => {
goToInternalNote(e); goToInternalNote(e);
}); });

View File

@ -14,7 +14,7 @@ const contextMenuSetup = {
{title: "Paste after", cmd: "pasteAfter", uiIcon: "ui-icon-clipboard"}, {title: "Paste after", cmd: "pasteAfter", uiIcon: "ui-icon-clipboard"},
{title: "Paste into", cmd: "pasteInto", uiIcon: "ui-icon-clipboard"} {title: "Paste into", cmd: "pasteInto", uiIcon: "ui-icon-clipboard"}
], ],
beforeOpen: function (event, ui) { beforeOpen: (event, ui) => {
const node = $.ui.fancytree.getNode(ui.target); const node = $.ui.fancytree.getNode(ui.target);
// Modify menu entries depending on node status // Modify menu entries depending on node status
globalTree.contextmenu("enableEntry", "pasteAfter", globalClipboardNoteId !== null); globalTree.contextmenu("enableEntry", "pasteAfter", globalClipboardNoteId !== null);
@ -26,8 +26,8 @@ const contextMenuSetup = {
ui.menu.prevKeyboard = node.tree.options.keyboard; ui.menu.prevKeyboard = node.tree.options.keyboard;
node.tree.options.keyboard = false; node.tree.options.keyboard = false;
}, },
close: function (event, ui) {}, close: (event, ui) => {},
select: function (event, ui) { select: (event, ui) => {
const node = $.ui.fancytree.getNode(ui.target); const node = $.ui.fancytree.getNode(ui.target);
if (ui.cmd === "insertNoteHere") { if (ui.cmd === "insertNoteHere") {

View File

@ -3,7 +3,7 @@ function convertNoteToHtml(noteId, failedNotes) {
url: baseApiUrl + 'notes/' + noteId, url: baseApiUrl + 'notes/' + noteId,
type: 'GET', type: 'GET',
async: false, async: false,
success: function (note) { success: note => {
const noteNode = getNodeByKey(noteId); const noteNode = getNodeByKey(noteId);
if (noteNode.data.is_clone) { if (noteNode.data.is_clone) {
@ -23,34 +23,20 @@ function convertNoteToHtml(noteId, failedNotes) {
data: JSON.stringify(note), data: JSON.stringify(note),
contentType: "application/json", contentType: "application/json",
async: false, async: false,
success: function () { success: () => {
console.log("Note " + noteId + " converted.") console.log("Note " + noteId + " converted.")
}, },
error: function () { error: () => {
console.log("Note " + noteId + " failed when writing"); console.log("Note " + noteId + " failed when writing");
failedNotes.push(noteId); failedNotes.push(noteId);
} }
}); });
}, },
error: function () { error: () => {
console.log("Note " + noteId + " failed when reading"); console.log("Note " + noteId + " failed when reading");
failedNotes.push(noteId); failedNotes.push(noteId);
} }
}); });
}
function convertAll2Html() {
const failedNotes = [];
let counter = 1;
for (const noteId of globalAllNoteIds) {
console.log('Converting ' + counter + "/" + globalAllNoteIds.length);
counter++;
convertNoteToHtml(noteId, failedNotes);
}
console.log("Failed notes: ", failedNotes);
} }

View File

@ -9,12 +9,12 @@ const dragAndDropSetup = {
preventRecursiveMoves: true, // Prevent dropping nodes on own descendants preventRecursiveMoves: true, // Prevent dropping nodes on own descendants
preventVoidMoves: true, // Prevent dropping nodes 'before self', etc. preventVoidMoves: true, // Prevent dropping nodes 'before self', etc.
dragStart: function (node, data) { dragStart: (node, data) => {
// This function MUST be defined to enable dragging for the tree. // This function MUST be defined to enable dragging for the tree.
// Return false to cancel dragging of node. // Return false to cancel dragging of node.
return true; return true;
}, },
dragEnter: function (node, data) { dragEnter: (node, data) => {
/* data.otherNode may be null for non-fancytree droppables. /* data.otherNode may be null for non-fancytree droppables.
* Return false to disallow dropping on node. In this case * Return false to disallow dropping on node. In this case
* dragOver and dragLeave are not called. * dragOver and dragLeave are not called.
@ -33,16 +33,13 @@ const dragAndDropSetup = {
// Accept everything: // Accept everything:
return true; return true;
}, },
dragExpand: function (node, data) { dragExpand: (node, data) => {
// return false to prevent auto-expanding data.node on hover // return false to prevent auto-expanding data.node on hover
}, },
dragOver: function (node, data) { dragOver: (node, data) => {},
}, dragLeave: (node, data) => {},
dragLeave: function (node, data) { dragStop: (node, data) => {},
}, dragDrop: (node, data) => {
dragStop: function (node, data) {
},
dragDrop: function (node, data) {
// This function MUST be defined to enable dropping of items on the tree. // This function MUST be defined to enable dropping of items on the tree.
// data.hitMode is 'before', 'after', or 'over'. // data.hitMode is 'before', 'after', or 'over'.

View File

@ -11,7 +11,7 @@ function handleEncryption(requireEncryption, modal, callback) {
$("#encryptionPasswordDialog").dialog({ $("#encryptionPasswordDialog").dialog({
modal: modal, modal: modal,
width: 400, width: 400,
open: function() { open: () => {
if (!modal) { if (!modal) {
// dialog steals focus for itself, which is not what we want for non-modal (viewing) // dialog steals focus for itself, which is not what we want for non-modal (viewing)
getNodeByKey(globalCurrentNote.detail.note_id).setFocus(); getNodeByKey(globalCurrentNote.detail.note_id).setFocus();
@ -54,7 +54,7 @@ function computeScrypt(password, salt, callback) {
const startedDate = new Date(); const startedDate = new Date();
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
scrypt(passwordBuffer, saltBuffer, N, r, p, dkLen, function (error, progress, key) { scrypt(passwordBuffer, saltBuffer, N, r, p, dkLen, (error, progress, key) => {
if (error) { if (error) {
console.log("Error: " + error); console.log("Error: " + error);
@ -72,7 +72,7 @@ function computeScrypt(password, salt, callback) {
}); });
} }
$("#encryptionPasswordForm").submit(function() { $("#encryptionPasswordForm").submit(() => {
const password = $("#encryptionPassword").val(); const password = $("#encryptionPassword").val();
$("#encryptionPassword").val(""); $("#encryptionPassword").val("");
@ -123,7 +123,7 @@ function resetEncryptionSession() {
} }
} }
setInterval(function() { setInterval(() => {
if (globalLastEncryptionOperationDate !== null && new Date().getTime() - globalLastEncryptionOperationDate.getTime() > globalEncryptionSessionTimeout * 1000) { if (globalLastEncryptionOperationDate !== null && new Date().getTime() - globalLastEncryptionOperationDate.getTime() > globalEncryptionSessionTimeout * 1000) {
resetEncryptionSession(); resetEncryptionSession();
} }
@ -341,7 +341,7 @@ function updateNoteSynchronously(noteId, updateCallback, successCallback) {
url: baseApiUrl + 'notes/' + noteId, url: baseApiUrl + 'notes/' + noteId,
type: 'GET', type: 'GET',
async: false, async: false,
success: function (note) { success: note => {
const needSave = updateCallback(note); const needSave = updateCallback(note);
if (!needSave) { if (!needSave) {
@ -358,17 +358,17 @@ function updateNoteSynchronously(noteId, updateCallback, successCallback) {
data: JSON.stringify(note), data: JSON.stringify(note),
contentType: "application/json", contentType: "application/json",
async: false, async: false,
success: function () { success: () => {
if (successCallback) { if (successCallback) {
successCallback(note); successCallback(note);
} }
}, },
error: function () { error: () => {
console.log("Updating " + noteId + " failed."); console.log("Updating " + noteId + " failed.");
} }
}); });
}, },
error: function () { error: () => {
console.log("Reading " + noteId + " failed."); console.log("Reading " + noteId + " failed.");
} }
}); });

View File

@ -2,7 +2,7 @@
jQuery.hotkeys.options.filterInputAcceptingElements = true; jQuery.hotkeys.options.filterInputAcceptingElements = true;
jQuery.hotkeys.options.filterContentEditable = true; jQuery.hotkeys.options.filterContentEditable = true;
$(document).bind('keydown', 'alt+m', function() { $(document).bind('keydown', 'alt+m', () => {
const toggle = $(".hide-toggle"); const toggle = $(".hide-toggle");
const hidden = toggle.css('display') === 'none'; const hidden = toggle.css('display') === 'none';
@ -12,21 +12,21 @@ $(document).bind('keydown', 'alt+m', function() {
}); });
// hide (toggle) everything except for the note content for distraction free writing // hide (toggle) everything except for the note content for distraction free writing
$(document).bind('keydown', 'alt+t', function() { $(document).bind('keydown', 'alt+t', () => {
const date = new Date(); const date = new Date();
const dateString = formatDateTime(date); const dateString = formatDateTime(date);
$('#noteDetail').summernote('insertText', dateString); $('#noteDetail').summernote('insertText', dateString);
}); });
$(window).on('beforeunload', function(){ $(window).on('beforeunload', () => {
// this makes sure that when user e.g. reloads the page or navigates away from the page, the note's content is saved // this makes sure that when user e.g. reloads the page or navigates away from the page, the note's content is saved
// this sends the request asynchronously and doesn't wait for result // this sends the request asynchronously and doesn't wait for result
saveNoteIfChanged(); saveNoteIfChanged();
}); });
// Overrides the default autocomplete filter function to search for matched on atleast 1 word in each of the input term's words // Overrides the default autocomplete filter function to search for matched on atleast 1 word in each of the input term's words
$.ui.autocomplete.filter = function (array, terms) { $.ui.autocomplete.filter = (array, terms) => {
if (!terms) { if (!terms) {
return []; return [];
} }

View File

@ -1,4 +1,4 @@
$(document).bind('keydown', 'alt+j', function() { $(document).bind('keydown', 'alt+j', () => {
$("#jumpToNoteAutocomplete").val(''); $("#jumpToNoteAutocomplete").val('');
$("#jumpToNoteDialog").dialog({ $("#jumpToNoteDialog").dialog({
@ -12,7 +12,7 @@ $(document).bind('keydown', 'alt+j', function() {
}); });
}); });
$("#jumpToNoteForm").submit(function() { $("#jumpToNoteForm").submit(() => {
const val = $("#jumpToNoteAutocomplete").val(); const val = $("#jumpToNoteAutocomplete").val();
const noteId = getNodeIdFromLabel(val); const noteId = getNodeIdFromLabel(val);

View File

@ -41,8 +41,8 @@ function saveNoteIfChanged(callback) {
setInterval(saveNoteIfChanged, 5000); setInterval(saveNoteIfChanged, 5000);
$(document).ready(function() { $(document).ready(() => {
$("#noteTitle").on('input', function() { $("#noteTitle").on('input', () => {
noteChanged(); noteChanged();
}); });
@ -98,7 +98,7 @@ function saveNoteToServer(note, callback) {
type: 'PUT', type: 'PUT',
data: JSON.stringify(note), data: JSON.stringify(note),
contentType: "application/json", contentType: "application/json",
success: function () { success: () => {
isNoteChanged = false; isNoteChanged = false;
message("Saved!"); message("Saved!");
@ -107,7 +107,7 @@ function saveNoteToServer(note, callback) {
callback(); callback();
} }
}, },
error: function () { error: () => {
error("Error saving the note!"); error("Error saving the note!");
} }
}); });
@ -143,7 +143,7 @@ function createNote(node, parentKey, target, encryption) {
encryption: encryption encryption: encryption
}), }),
contentType: "application/json", contentType: "application/json",
success: function(result) { success: result => {
const newNode = { const newNode = {
title: newNoteName, title: newNoteName,
key: result.note_id, key: result.note_id,
@ -192,7 +192,7 @@ function setNoteBackgroundIfEncrypted(note) {
} }
function loadNote(noteId) { function loadNote(noteId) {
$.get(baseApiUrl + 'notes/' + noteId).then(function(note) { $.get(baseApiUrl + 'notes/' + noteId).then(note => {
globalCurrentNote = note; globalCurrentNote = note;
if (newNoteCreated) { if (newNoteCreated) {

View File

@ -17,7 +17,7 @@ function showNoteHistoryDialog(noteId, noteHistoryId) {
$.ajax({ $.ajax({
url: baseApiUrl + 'notes-history/' + noteId, url: baseApiUrl + 'notes-history/' + noteId,
type: 'GET', type: 'GET',
success: function (result) { success: result => {
globalHistoryItems = result; globalHistoryItems = result;
for (const row of result) { for (const row of result) {

View File

@ -8,7 +8,7 @@ function showRecentChanges() {
$.ajax({ $.ajax({
url: baseApiUrl + 'recent-changes/', url: baseApiUrl + 'recent-changes/',
type: 'GET', type: 'GET',
success: function (result) { success: result => {
const groupedByDate = new Map(); const groupedByDate = new Map();
const dayCache = {}; const dayCache = {};
@ -78,7 +78,7 @@ function showRecentChanges() {
$(document).bind('keydown', 'alt+r', showRecentChanges); $(document).bind('keydown', 'alt+r', showRecentChanges);
$(document).on('click', '#recentChangesDialog a', function(e) { $(document).on('click', '#recentChangesDialog a', e => {
goToInternalNote(e, () => { goToInternalNote(e, () => {
$("#recentChangesDialog").dialog('close'); $("#recentChangesDialog").dialog('close');
}); });

View File

@ -1,9 +1,7 @@
let globalRecentNotes = []; let globalRecentNotes = [];
function addRecentNote(noteTreeId, noteContentId) { function addRecentNote(noteTreeId, noteContentId) {
const origDate = new Date(); setTimeout(() => {
setTimeout(function() {
// we include the note into recent list only if the user stayed on the note at least 5 seconds // we include the note into recent list only if the user stayed on the note at least 5 seconds
if (noteTreeId === globalCurrentNote.detail.note_id || noteContentId === globalCurrentNote.detail.note_id) { if (noteTreeId === globalCurrentNote.detail.note_id || noteContentId === globalCurrentNote.detail.note_id) {
// if it's already there, remove the note // if it's already there, remove the note
@ -29,7 +27,7 @@ function showRecentNotes() {
// remove the current note // remove the current note
let recNotes = globalRecentNotes.filter(note => note !== globalCurrentNote.detail.note_id); let recNotes = globalRecentNotes.filter(note => note !== globalCurrentNote.detail.note_id);
$.each(recNotes, function(key, valueNoteId) { $.each(recNotes, (key, valueNoteId) => {
let noteTitle = getFullName(valueNoteId); let noteTitle = getFullName(valueNoteId);
if (!noteTitle) { if (!noteTitle) {
@ -80,7 +78,7 @@ function addLinkBasedOnRecentNotes() {
}); });
} }
$('#recentNotesSelectBox').keydown(function(e) { $('#recentNotesSelectBox').keydown(e => {
const key = e.which; const key = e.which;
if (key === 13)// the enter key code if (key === 13)// the enter key code
@ -94,7 +92,7 @@ $('#recentNotesSelectBox').keydown(function(e) {
e.preventDefault(); e.preventDefault();
}); });
$('#recentNotesSelectBox').dblclick(function(e) { $('#recentNotesSelectBox').dblclick(e => {
setActiveNoteBasedOnRecentNotes(); setActiveNoteBasedOnRecentNotes();
}); });

View File

@ -2,7 +2,7 @@ function displaySettings() {
$.ajax({ $.ajax({
url: baseApiUrl + 'settings', url: baseApiUrl + 'settings',
type: 'GET', type: 'GET',
success: function (result) { success: result => {
$("#encryptionTimeoutInSeconds").val(result['encryption_session_timeout']); $("#encryptionTimeoutInSeconds").val(result['encryption_session_timeout']);
$("#historySnapshotTimeIntervalInSeconds").val(result['history_snapshot_time_interval']); $("#historySnapshotTimeIntervalInSeconds").val(result['history_snapshot_time_interval']);
}, },
@ -39,7 +39,7 @@ $("#changePasswordForm").submit(() => {
'new_password': newPassword1 'new_password': newPassword1
}), }),
contentType: "application/json", contentType: "application/json",
success: function (result) { success: result => {
if (result.success) { if (result.success) {
// encryption password changed so current encryption session is invalid and needs to be cleared // encryption password changed so current encryption session is invalid and needs to be cleared
resetEncryptionSession(); resetEncryptionSession();
@ -71,7 +71,7 @@ $("#encryptionTimeoutForm").submit(() => {
value: encryptionTimeout value: encryptionTimeout
}), }),
contentType: "application/json", contentType: "application/json",
success: function () { success: () => {
alert("Encryption timeout has been changed."); alert("Encryption timeout has been changed.");
globalEncryptionSessionTimeout = encryptionTimeout; globalEncryptionSessionTimeout = encryptionTimeout;
@ -93,7 +93,7 @@ $("#historySnapshotTimeIntervalForm").submit(() => {
value: historySnapshotTimeInterval value: historySnapshotTimeInterval
}), }),
contentType: "application/json", contentType: "application/json",
success: function () { success: () => {
alert("History snapshot time interval has been changed."); alert("History snapshot time interval has been changed.");
}, },
error: () => alert("Error occurred during changing history snapshot time interval.") error: () => alert("Error occurred during changing history snapshot time interval.")

View File

@ -1,40 +1,40 @@
const keybindings = { const keybindings = {
"insert": function(node) { "insert": node => {
const parentKey = getParentKey(node); const parentKey = getParentKey(node);
const encryption = getParentEncryption(node); const encryption = getParentEncryption(node);
createNote(node, parentKey, 'after', encryption); createNote(node, parentKey, 'after', encryption);
}, },
"ctrl+insert": function(node) { "ctrl+insert": node => {
createNote(node, node.key, 'into', node.data.encryption); createNote(node, node.key, 'into', node.data.encryption);
}, },
"del": function(node) { "del": node => {
deleteNode(node); deleteNode(node);
}, },
"shift+up": function(node) { "shift+up": node => {
const beforeNode = node.getPrevSibling(); const beforeNode = node.getPrevSibling();
if (beforeNode !== null) { if (beforeNode !== null) {
moveBeforeNode(node, beforeNode); moveBeforeNode(node, beforeNode);
} }
}, },
"shift+down": function(node) { "shift+down": node => {
let afterNode = node.getNextSibling(); let afterNode = node.getNextSibling();
if (afterNode !== null) { if (afterNode !== null) {
moveAfterNode(node, afterNode); moveAfterNode(node, afterNode);
} }
}, },
"shift+left": function(node) { "shift+left": node => {
moveNodeUp(node); moveNodeUp(node);
}, },
"shift+right": function(node) { "shift+right": node => {
let toNode = node.getPrevSibling(); let toNode = node.getPrevSibling();
if (toNode !== null) { if (toNode !== null) {
moveToNode(node, toNode); moveToNode(node, toNode);
} }
}, },
"return": function(node) { "return": node => {
// doesn't work :-/ // doesn't work :-/
$('#noteDetail').summernote('focus'); $('#noteDetail').summernote('focus');
} }
@ -79,7 +79,7 @@ function setExpandedToServer(note_id, is_expanded) {
url: baseApiUrl + 'notes/' + note_id + '/expanded/' + expanded_num, url: baseApiUrl + 'notes/' + note_id + '/expanded/' + expanded_num,
type: 'PUT', type: 'PUT',
contentType: "application/json", contentType: "application/json",
success: function(result) {} success: result => {}
}); });
} }
@ -92,13 +92,13 @@ setInterval(() => {
$.ajax({ $.ajax({
url: baseApiUrl + 'audit/' + globalFullLoadTime, url: baseApiUrl + 'audit/' + globalFullLoadTime,
type: 'GET', type: 'GET',
success: function (resp) { success: resp => {
if (resp.changed) { if (resp.changed) {
window.location.reload(true); window.location.reload(true);
} }
}, },
statusCode: { statusCode: {
401: function() { 401: () => {
// if the user got logged out then we should display the page // if the user got logged out then we should display the page
// here we do that by reloading which will force the redirect if the user is really logged out // here we do that by reloading which will force the redirect if the user is really logged out
window.location.reload(true); window.location.reload(true);
@ -107,7 +107,7 @@ setInterval(() => {
}); });
}, 10 * 1000); }, 10 * 1000);
$(function(){ $(() => {
$.get(baseApiUrl + 'tree').then(resp => { $.get(baseApiUrl + 'tree').then(resp => {
const notes = resp.notes; const notes = resp.notes;
let startNoteId = resp.start_note_id; let startNoteId = resp.start_note_id;
@ -131,18 +131,18 @@ $(function(){
autoScroll: true, autoScroll: true,
extensions: ["hotkeys", "filter", "dnd"], extensions: ["hotkeys", "filter", "dnd"],
source: notes, source: notes,
activate: function(event, data){ activate: (event, data) => {
const node = data.node.data; const node = data.node.data;
saveNoteIfChanged(() => loadNote(node.note_id)); saveNoteIfChanged(() => loadNote(node.note_id));
}, },
expand: function(event, data) { expand: (event, data) => {
setExpandedToServer(data.node.key, true); setExpandedToServer(data.node.key, true);
}, },
collapse: function(event, data) { collapse: (event, data) => {
setExpandedToServer(data.node.key, false); setExpandedToServer(data.node.key, false);
}, },
init: function(event, data) { init: (event, data) => {
if (startNoteId) { if (startNoteId) {
data.tree.activateKey(startNoteId); data.tree.activateKey(startNoteId);
} }
@ -172,7 +172,7 @@ $(function(){
}); });
function collapseTree() { function collapseTree() {
globalTree.fancytree("getRootNode").visit(function(node){ globalTree.fancytree("getRootNode").visit(node => {
node.setExpanded(false); node.setExpanded(false);
}); });
} }
@ -217,7 +217,7 @@ function resetSearch() {
$("button#btnResetSearch").click(resetSearch); $("button#btnResetSearch").click(resetSearch);
$("input[name=search]").keyup(function (e) { $("input[name=search]").keyup(e => {
const searchString = $(this).val(); const searchString = $(this).val();
if (e && e.which === $.ui.keyCode.ESCAPE || $.trim(searchString) === "") { if (e && e.which === $.ui.keyCode.ESCAPE || $.trim(searchString) === "") {
@ -231,7 +231,7 @@ $("input[name=search]").keyup(function (e) {
// Pass a string to perform case insensitive matching // Pass a string to perform case insensitive matching
const tree = globalTree.fancytree("getTree"); const tree = globalTree.fancytree("getTree");
tree.filterBranches(function(node) { tree.filterBranches(node => {
return resp.includes(node.data.note_id); return resp.includes(node.data.note_id);
}); });
}); });

View File

@ -3,7 +3,7 @@ function moveBeforeNode(node, beforeNode) {
url: baseApiUrl + 'notes/' + node.key + '/moveBefore/' + beforeNode.key, url: baseApiUrl + 'notes/' + node.key + '/moveBefore/' + beforeNode.key,
type: 'PUT', type: 'PUT',
contentType: "application/json", contentType: "application/json",
success: function () { success: () => {
node.moveTo(beforeNode, 'before'); node.moveTo(beforeNode, 'before');
} }
}); });
@ -14,7 +14,7 @@ function moveAfterNode(node, afterNode) {
url: baseApiUrl + 'notes/' + node.key + '/moveAfter/' + afterNode.key, url: baseApiUrl + 'notes/' + node.key + '/moveAfter/' + afterNode.key,
type: 'PUT', type: 'PUT',
contentType: "application/json", contentType: "application/json",
success: function () { success: () => {
node.moveTo(afterNode, 'after'); node.moveTo(afterNode, 'after');
} }
}); });
@ -25,7 +25,7 @@ function moveToNode(node, toNode) {
url: baseApiUrl + 'notes/' + node.key + '/moveTo/' + toNode.key, url: baseApiUrl + 'notes/' + node.key + '/moveTo/' + toNode.key,
type: 'PUT', type: 'PUT',
contentType: "application/json", contentType: "application/json",
success: function () { success: () => {
node.moveTo(toNode); node.moveTo(toNode);
toNode.setExpanded(true); toNode.setExpanded(true);
@ -41,7 +41,7 @@ function deleteNode(node) {
$.ajax({ $.ajax({
url: baseApiUrl + 'notes/' + node.key, url: baseApiUrl + 'notes/' + node.key,
type: 'DELETE', type: 'DELETE',
success: function () { success: () => {
if (node.getParent() !== null && node.getParent().getChildren().length <= 1) { if (node.getParent() !== null && node.getParent().getChildren().length <= 1) {
node.getParent().folder = false; node.getParent().folder = false;
node.getParent().renderTitle(); node.getParent().renderTitle();
@ -72,7 +72,7 @@ function moveNodeUp(node) {
url: baseApiUrl + 'notes/' + node.key + '/moveAfter/' + node.getParent().key, url: baseApiUrl + 'notes/' + node.key + '/moveAfter/' + node.getParent().key,
type: 'PUT', type: 'PUT',
contentType: "application/json", contentType: "application/json",
success: function () { success: () => {
if (node.getParent() !== null && node.getParent().getChildren().length <= 1) { if (node.getParent() !== null && node.getParent().getChildren().length <= 1) {
node.getParent().folder = false; node.getParent().folder = false;
node.getParent().renderTitle(); node.getParent().renderTitle();

View File

@ -46,7 +46,7 @@ function uint8ToBase64(u8Arr) {
} }
function base64ToUint8Array(base64encoded) { function base64ToUint8Array(base64encoded) {
return new Uint8Array(atob(base64encoded).split("").map(function(c) { return c.charCodeAt(0); })); return new Uint8Array(atob(base64encoded).split("").map(c => c.charCodeAt(0)));
} }
function getDateFromTS(timestamp) { function getDateFromTS(timestamp) {