mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-04 05:28:59 +01:00 
			
		
		
		
	consistent usage of arrow syntax instead of anonymous functions
This commit is contained in:
		
							parent
							
								
									49460dfb8a
								
							
						
					
					
						commit
						ca87ff9215
					
				@ -1,4 +1,4 @@
 | 
			
		||||
$(document).bind('keydown', 'alt+l', function() {
 | 
			
		||||
$(document).bind('keydown', 'alt+l', () => {
 | 
			
		||||
    $("#noteAutocomplete").val('');
 | 
			
		||||
    $("#linkTitle").val('');
 | 
			
		||||
 | 
			
		||||
@ -19,7 +19,7 @@ $(document).bind('keydown', 'alt+l', function() {
 | 
			
		||||
    $("#noteAutocomplete").autocomplete({
 | 
			
		||||
        source: getAutocompleteItems(globalAllNoteIds),
 | 
			
		||||
        minLength: 0,
 | 
			
		||||
        change: function () {
 | 
			
		||||
        change: () => {
 | 
			
		||||
            const val = $("#noteAutocomplete").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
 | 
			
		||||
        // 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);
 | 
			
		||||
 | 
			
		||||
            setDefaultLinkTitle(noteId);
 | 
			
		||||
@ -37,7 +37,7 @@ $(document).bind('keydown', 'alt+l', function() {
 | 
			
		||||
    });
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
$("#insertLinkForm").submit(function() {
 | 
			
		||||
$("#insertLinkForm").submit(() => {
 | 
			
		||||
    let val = $("#noteAutocomplete").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
 | 
			
		||||
// 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);
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
$(document).on('dblclick', '.note-editable a', function(e) {
 | 
			
		||||
$(document).on('dblclick', '.note-editable a', e => {
 | 
			
		||||
    goToInternalNote(e);
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -14,7 +14,7 @@ const contextMenuSetup = {
 | 
			
		||||
        {title: "Paste after", cmd: "pasteAfter", 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);
 | 
			
		||||
        // Modify menu entries depending on node status
 | 
			
		||||
        globalTree.contextmenu("enableEntry", "pasteAfter", globalClipboardNoteId !== null);
 | 
			
		||||
@ -26,8 +26,8 @@ const contextMenuSetup = {
 | 
			
		||||
        ui.menu.prevKeyboard = node.tree.options.keyboard;
 | 
			
		||||
        node.tree.options.keyboard = false;
 | 
			
		||||
    },
 | 
			
		||||
    close: function (event, ui) {},
 | 
			
		||||
    select: function (event, ui) {
 | 
			
		||||
    close: (event, ui) => {},
 | 
			
		||||
    select: (event, ui) => {
 | 
			
		||||
        const node = $.ui.fancytree.getNode(ui.target);
 | 
			
		||||
 | 
			
		||||
        if (ui.cmd === "insertNoteHere") {
 | 
			
		||||
 | 
			
		||||
@ -3,7 +3,7 @@ function convertNoteToHtml(noteId, failedNotes) {
 | 
			
		||||
        url: baseApiUrl + 'notes/' + noteId,
 | 
			
		||||
        type: 'GET',
 | 
			
		||||
        async: false,
 | 
			
		||||
        success: function (note) {
 | 
			
		||||
        success: note => {
 | 
			
		||||
            const noteNode = getNodeByKey(noteId);
 | 
			
		||||
 | 
			
		||||
            if (noteNode.data.is_clone) {
 | 
			
		||||
@ -23,34 +23,20 @@ function convertNoteToHtml(noteId, failedNotes) {
 | 
			
		||||
                data: JSON.stringify(note),
 | 
			
		||||
                contentType: "application/json",
 | 
			
		||||
                async: false,
 | 
			
		||||
                success: function () {
 | 
			
		||||
                success: () => {
 | 
			
		||||
                    console.log("Note " + noteId + " converted.")
 | 
			
		||||
                },
 | 
			
		||||
                error: function () {
 | 
			
		||||
                error: () => {
 | 
			
		||||
                    console.log("Note " + noteId + " failed when writing");
 | 
			
		||||
 | 
			
		||||
                    failedNotes.push(noteId);
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
        },
 | 
			
		||||
        error: function () {
 | 
			
		||||
        error: () => {
 | 
			
		||||
            console.log("Note " + noteId + " failed when reading");
 | 
			
		||||
 | 
			
		||||
            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);
 | 
			
		||||
}
 | 
			
		||||
@ -9,12 +9,12 @@ const dragAndDropSetup = {
 | 
			
		||||
    preventRecursiveMoves: true, // Prevent dropping nodes on own descendants
 | 
			
		||||
    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.
 | 
			
		||||
        // Return false to cancel dragging of node.
 | 
			
		||||
        return true;
 | 
			
		||||
    },
 | 
			
		||||
    dragEnter: function (node, data) {
 | 
			
		||||
    dragEnter: (node, data) => {
 | 
			
		||||
        /* data.otherNode may be null for non-fancytree droppables.
 | 
			
		||||
        * Return false to disallow dropping on node. In this case
 | 
			
		||||
        * dragOver and dragLeave are not called.
 | 
			
		||||
@ -33,16 +33,13 @@ const dragAndDropSetup = {
 | 
			
		||||
        // Accept everything:
 | 
			
		||||
        return true;
 | 
			
		||||
    },
 | 
			
		||||
    dragExpand: function (node, data) {
 | 
			
		||||
    dragExpand: (node, data) => {
 | 
			
		||||
        // return false to prevent auto-expanding data.node on hover
 | 
			
		||||
    },
 | 
			
		||||
    dragOver: function (node, data) {
 | 
			
		||||
    },
 | 
			
		||||
    dragLeave: function (node, data) {
 | 
			
		||||
    },
 | 
			
		||||
    dragStop: function (node, data) {
 | 
			
		||||
    },
 | 
			
		||||
    dragDrop: function (node, data) {
 | 
			
		||||
    dragOver: (node, data) => {},
 | 
			
		||||
    dragLeave: (node, data) => {},
 | 
			
		||||
    dragStop: (node, data) => {},
 | 
			
		||||
    dragDrop: (node, data) => {
 | 
			
		||||
        // This function MUST be defined to enable dropping of items on the tree.
 | 
			
		||||
        // data.hitMode is 'before', 'after', or 'over'.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -11,7 +11,7 @@ function handleEncryption(requireEncryption, modal, callback) {
 | 
			
		||||
        $("#encryptionPasswordDialog").dialog({
 | 
			
		||||
            modal: modal,
 | 
			
		||||
            width: 400,
 | 
			
		||||
            open: function() {
 | 
			
		||||
            open: () => {
 | 
			
		||||
                if (!modal) {
 | 
			
		||||
                    // dialog steals focus for itself, which is not what we want for non-modal (viewing)
 | 
			
		||||
                    getNodeByKey(globalCurrentNote.detail.note_id).setFocus();
 | 
			
		||||
@ -54,7 +54,7 @@ function computeScrypt(password, salt, callback) {
 | 
			
		||||
    const startedDate = new Date();
 | 
			
		||||
 | 
			
		||||
    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) {
 | 
			
		||||
                console.log("Error: " + error);
 | 
			
		||||
 | 
			
		||||
@ -72,7 +72,7 @@ function computeScrypt(password, salt, callback) {
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
$("#encryptionPasswordForm").submit(function() {
 | 
			
		||||
$("#encryptionPasswordForm").submit(() => {
 | 
			
		||||
    const password = $("#encryptionPassword").val();
 | 
			
		||||
    $("#encryptionPassword").val("");
 | 
			
		||||
 | 
			
		||||
@ -123,7 +123,7 @@ function resetEncryptionSession() {
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
setInterval(function() {
 | 
			
		||||
setInterval(() => {
 | 
			
		||||
    if (globalLastEncryptionOperationDate !== null && new Date().getTime() - globalLastEncryptionOperationDate.getTime() > globalEncryptionSessionTimeout * 1000) {
 | 
			
		||||
        resetEncryptionSession();
 | 
			
		||||
    }
 | 
			
		||||
@ -341,7 +341,7 @@ function updateNoteSynchronously(noteId, updateCallback, successCallback) {
 | 
			
		||||
        url: baseApiUrl + 'notes/' + noteId,
 | 
			
		||||
        type: 'GET',
 | 
			
		||||
        async: false,
 | 
			
		||||
        success: function (note) {
 | 
			
		||||
        success: note => {
 | 
			
		||||
            const needSave = updateCallback(note);
 | 
			
		||||
 | 
			
		||||
            if (!needSave) {
 | 
			
		||||
@ -358,17 +358,17 @@ function updateNoteSynchronously(noteId, updateCallback, successCallback) {
 | 
			
		||||
                data: JSON.stringify(note),
 | 
			
		||||
                contentType: "application/json",
 | 
			
		||||
                async: false,
 | 
			
		||||
                success: function () {
 | 
			
		||||
                success: () => {
 | 
			
		||||
                    if (successCallback) {
 | 
			
		||||
                        successCallback(note);
 | 
			
		||||
                    }
 | 
			
		||||
                },
 | 
			
		||||
                error: function () {
 | 
			
		||||
                error: () => {
 | 
			
		||||
                    console.log("Updating " + noteId + " failed.");
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
        },
 | 
			
		||||
        error: function () {
 | 
			
		||||
        error: () => {
 | 
			
		||||
            console.log("Reading " + noteId + " failed.");
 | 
			
		||||
        }
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
@ -2,7 +2,7 @@
 | 
			
		||||
jQuery.hotkeys.options.filterInputAcceptingElements = true;
 | 
			
		||||
jQuery.hotkeys.options.filterContentEditable = true;
 | 
			
		||||
 | 
			
		||||
$(document).bind('keydown', 'alt+m', function() {
 | 
			
		||||
$(document).bind('keydown', 'alt+m', () => {
 | 
			
		||||
    const toggle = $(".hide-toggle");
 | 
			
		||||
    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
 | 
			
		||||
$(document).bind('keydown', 'alt+t', function() {
 | 
			
		||||
$(document).bind('keydown', 'alt+t', () => {
 | 
			
		||||
    const date = new Date();
 | 
			
		||||
    const dateString = formatDateTime(date);
 | 
			
		||||
 | 
			
		||||
    $('#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 sends the request asynchronously and doesn't wait for result
 | 
			
		||||
    saveNoteIfChanged();
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
// 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) {
 | 
			
		||||
        return [];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -1,4 +1,4 @@
 | 
			
		||||
$(document).bind('keydown', 'alt+j', function() {
 | 
			
		||||
$(document).bind('keydown', 'alt+j', () => {
 | 
			
		||||
    $("#jumpToNoteAutocomplete").val('');
 | 
			
		||||
 | 
			
		||||
    $("#jumpToNoteDialog").dialog({
 | 
			
		||||
@ -12,7 +12,7 @@ $(document).bind('keydown', 'alt+j', function() {
 | 
			
		||||
    });
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
$("#jumpToNoteForm").submit(function() {
 | 
			
		||||
$("#jumpToNoteForm").submit(() => {
 | 
			
		||||
    const val = $("#jumpToNoteAutocomplete").val();
 | 
			
		||||
    const noteId = getNodeIdFromLabel(val);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -41,8 +41,8 @@ function saveNoteIfChanged(callback) {
 | 
			
		||||
 | 
			
		||||
setInterval(saveNoteIfChanged, 5000);
 | 
			
		||||
 | 
			
		||||
$(document).ready(function() {
 | 
			
		||||
    $("#noteTitle").on('input', function() {
 | 
			
		||||
$(document).ready(() => {
 | 
			
		||||
    $("#noteTitle").on('input', () => {
 | 
			
		||||
        noteChanged();
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
@ -98,7 +98,7 @@ function saveNoteToServer(note, callback) {
 | 
			
		||||
        type: 'PUT',
 | 
			
		||||
        data: JSON.stringify(note),
 | 
			
		||||
        contentType: "application/json",
 | 
			
		||||
        success: function () {
 | 
			
		||||
        success: () => {
 | 
			
		||||
            isNoteChanged = false;
 | 
			
		||||
 | 
			
		||||
            message("Saved!");
 | 
			
		||||
@ -107,7 +107,7 @@ function saveNoteToServer(note, callback) {
 | 
			
		||||
                callback();
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
        error: function () {
 | 
			
		||||
        error: () => {
 | 
			
		||||
            error("Error saving the note!");
 | 
			
		||||
        }
 | 
			
		||||
    });
 | 
			
		||||
@ -143,7 +143,7 @@ function createNote(node, parentKey, target, encryption) {
 | 
			
		||||
            encryption: encryption
 | 
			
		||||
        }),
 | 
			
		||||
        contentType: "application/json",
 | 
			
		||||
        success: function(result) {
 | 
			
		||||
        success: result => {
 | 
			
		||||
            const newNode = {
 | 
			
		||||
                title: newNoteName,
 | 
			
		||||
                key: result.note_id,
 | 
			
		||||
@ -192,7 +192,7 @@ function setNoteBackgroundIfEncrypted(note) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function loadNote(noteId) {
 | 
			
		||||
    $.get(baseApiUrl + 'notes/' + noteId).then(function(note) {
 | 
			
		||||
    $.get(baseApiUrl + 'notes/' + noteId).then(note => {
 | 
			
		||||
        globalCurrentNote = note;
 | 
			
		||||
 | 
			
		||||
        if (newNoteCreated) {
 | 
			
		||||
 | 
			
		||||
@ -17,7 +17,7 @@ function showNoteHistoryDialog(noteId, noteHistoryId) {
 | 
			
		||||
    $.ajax({
 | 
			
		||||
        url: baseApiUrl + 'notes-history/' + noteId,
 | 
			
		||||
        type: 'GET',
 | 
			
		||||
        success: function (result) {
 | 
			
		||||
        success: result => {
 | 
			
		||||
            globalHistoryItems = result;
 | 
			
		||||
 | 
			
		||||
            for (const row of result) {
 | 
			
		||||
 | 
			
		||||
@ -8,7 +8,7 @@ function showRecentChanges() {
 | 
			
		||||
    $.ajax({
 | 
			
		||||
        url: baseApiUrl + 'recent-changes/',
 | 
			
		||||
        type: 'GET',
 | 
			
		||||
        success: function (result) {
 | 
			
		||||
        success: result => {
 | 
			
		||||
            const groupedByDate = new Map();
 | 
			
		||||
            const dayCache = {};
 | 
			
		||||
 | 
			
		||||
@ -78,7 +78,7 @@ function showRecentChanges() {
 | 
			
		||||
 | 
			
		||||
$(document).bind('keydown', 'alt+r', showRecentChanges);
 | 
			
		||||
 | 
			
		||||
$(document).on('click', '#recentChangesDialog a', function(e) {
 | 
			
		||||
$(document).on('click', '#recentChangesDialog a', e => {
 | 
			
		||||
    goToInternalNote(e, () => {
 | 
			
		||||
        $("#recentChangesDialog").dialog('close');
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
@ -1,9 +1,7 @@
 | 
			
		||||
let globalRecentNotes = [];
 | 
			
		||||
 | 
			
		||||
function addRecentNote(noteTreeId, noteContentId) {
 | 
			
		||||
    const origDate = new Date();
 | 
			
		||||
 | 
			
		||||
    setTimeout(function() {
 | 
			
		||||
    setTimeout(() => {
 | 
			
		||||
        // 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 it's already there, remove the note
 | 
			
		||||
@ -29,7 +27,7 @@ function showRecentNotes() {
 | 
			
		||||
    // remove the current note
 | 
			
		||||
    let recNotes = globalRecentNotes.filter(note => note !== globalCurrentNote.detail.note_id);
 | 
			
		||||
 | 
			
		||||
    $.each(recNotes, function(key, valueNoteId) {
 | 
			
		||||
    $.each(recNotes, (key, valueNoteId) => {
 | 
			
		||||
        let noteTitle = getFullName(valueNoteId);
 | 
			
		||||
 | 
			
		||||
        if (!noteTitle) {
 | 
			
		||||
@ -80,7 +78,7 @@ function addLinkBasedOnRecentNotes() {
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
$('#recentNotesSelectBox').keydown(function(e) {
 | 
			
		||||
$('#recentNotesSelectBox').keydown(e => {
 | 
			
		||||
    const key = e.which;
 | 
			
		||||
 | 
			
		||||
    if (key === 13)// the enter key code
 | 
			
		||||
@ -94,7 +92,7 @@ $('#recentNotesSelectBox').keydown(function(e) {
 | 
			
		||||
    e.preventDefault();
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
$('#recentNotesSelectBox').dblclick(function(e) {
 | 
			
		||||
$('#recentNotesSelectBox').dblclick(e => {
 | 
			
		||||
    setActiveNoteBasedOnRecentNotes();
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -2,7 +2,7 @@ function displaySettings() {
 | 
			
		||||
    $.ajax({
 | 
			
		||||
        url: baseApiUrl + 'settings',
 | 
			
		||||
        type: 'GET',
 | 
			
		||||
        success: function (result) {
 | 
			
		||||
        success: result => {
 | 
			
		||||
            $("#encryptionTimeoutInSeconds").val(result['encryption_session_timeout']);
 | 
			
		||||
            $("#historySnapshotTimeIntervalInSeconds").val(result['history_snapshot_time_interval']);
 | 
			
		||||
        },
 | 
			
		||||
@ -39,7 +39,7 @@ $("#changePasswordForm").submit(() => {
 | 
			
		||||
            'new_password': newPassword1
 | 
			
		||||
        }),
 | 
			
		||||
        contentType: "application/json",
 | 
			
		||||
        success: function (result) {
 | 
			
		||||
        success: result => {
 | 
			
		||||
            if (result.success) {
 | 
			
		||||
                // encryption password changed so current encryption session is invalid and needs to be cleared
 | 
			
		||||
                resetEncryptionSession();
 | 
			
		||||
@ -71,7 +71,7 @@ $("#encryptionTimeoutForm").submit(() => {
 | 
			
		||||
            value: encryptionTimeout
 | 
			
		||||
        }),
 | 
			
		||||
        contentType: "application/json",
 | 
			
		||||
        success: function () {
 | 
			
		||||
        success: () => {
 | 
			
		||||
            alert("Encryption timeout has been changed.");
 | 
			
		||||
 | 
			
		||||
            globalEncryptionSessionTimeout = encryptionTimeout;
 | 
			
		||||
@ -93,7 +93,7 @@ $("#historySnapshotTimeIntervalForm").submit(() => {
 | 
			
		||||
            value: historySnapshotTimeInterval
 | 
			
		||||
        }),
 | 
			
		||||
        contentType: "application/json",
 | 
			
		||||
        success: function () {
 | 
			
		||||
        success: () => {
 | 
			
		||||
            alert("History snapshot time interval has been changed.");
 | 
			
		||||
         },
 | 
			
		||||
        error: () => alert("Error occurred during changing history snapshot time interval.")
 | 
			
		||||
 | 
			
		||||
@ -1,40 +1,40 @@
 | 
			
		||||
const keybindings = {
 | 
			
		||||
    "insert": function(node) {
 | 
			
		||||
    "insert": node => {
 | 
			
		||||
        const parentKey = getParentKey(node);
 | 
			
		||||
        const encryption = getParentEncryption(node);
 | 
			
		||||
 | 
			
		||||
        createNote(node, parentKey, 'after', encryption);
 | 
			
		||||
    },
 | 
			
		||||
    "ctrl+insert": function(node) {
 | 
			
		||||
    "ctrl+insert": node => {
 | 
			
		||||
        createNote(node, node.key, 'into', node.data.encryption);
 | 
			
		||||
    },
 | 
			
		||||
    "del": function(node) {
 | 
			
		||||
    "del": node => {
 | 
			
		||||
        deleteNode(node);
 | 
			
		||||
    },
 | 
			
		||||
    "shift+up": function(node) {
 | 
			
		||||
    "shift+up": node => {
 | 
			
		||||
        const beforeNode = node.getPrevSibling();
 | 
			
		||||
 | 
			
		||||
        if (beforeNode !== null) {
 | 
			
		||||
            moveBeforeNode(node, beforeNode);
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    "shift+down": function(node) {
 | 
			
		||||
    "shift+down": node => {
 | 
			
		||||
        let afterNode = node.getNextSibling();
 | 
			
		||||
        if (afterNode !== null) {
 | 
			
		||||
            moveAfterNode(node, afterNode);
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    "shift+left": function(node) {
 | 
			
		||||
    "shift+left": node => {
 | 
			
		||||
        moveNodeUp(node);
 | 
			
		||||
    },
 | 
			
		||||
    "shift+right": function(node) {
 | 
			
		||||
    "shift+right": node => {
 | 
			
		||||
        let toNode = node.getPrevSibling();
 | 
			
		||||
 | 
			
		||||
        if (toNode !== null) {
 | 
			
		||||
            moveToNode(node, toNode);
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    "return": function(node) {
 | 
			
		||||
    "return": node => {
 | 
			
		||||
        // doesn't work :-/
 | 
			
		||||
        $('#noteDetail').summernote('focus');
 | 
			
		||||
    }
 | 
			
		||||
@ -79,7 +79,7 @@ function setExpandedToServer(note_id, is_expanded) {
 | 
			
		||||
        url: baseApiUrl + 'notes/' + note_id + '/expanded/' + expanded_num,
 | 
			
		||||
        type: 'PUT',
 | 
			
		||||
        contentType: "application/json",
 | 
			
		||||
        success: function(result) {}
 | 
			
		||||
        success: result => {}
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -92,13 +92,13 @@ setInterval(() => {
 | 
			
		||||
    $.ajax({
 | 
			
		||||
        url: baseApiUrl + 'audit/' + globalFullLoadTime,
 | 
			
		||||
        type: 'GET',
 | 
			
		||||
        success: function (resp) {
 | 
			
		||||
        success: resp => {
 | 
			
		||||
            if (resp.changed) {
 | 
			
		||||
                window.location.reload(true);
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
        statusCode: {
 | 
			
		||||
            401: function() {
 | 
			
		||||
            401: () => {
 | 
			
		||||
                // 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
 | 
			
		||||
                window.location.reload(true);
 | 
			
		||||
@ -107,7 +107,7 @@ setInterval(() => {
 | 
			
		||||
    });
 | 
			
		||||
}, 10 * 1000);
 | 
			
		||||
 | 
			
		||||
$(function(){
 | 
			
		||||
$(() => {
 | 
			
		||||
    $.get(baseApiUrl + 'tree').then(resp => {
 | 
			
		||||
        const notes = resp.notes;
 | 
			
		||||
        let startNoteId = resp.start_note_id;
 | 
			
		||||
@ -131,18 +131,18 @@ $(function(){
 | 
			
		||||
            autoScroll: true,
 | 
			
		||||
            extensions: ["hotkeys", "filter", "dnd"],
 | 
			
		||||
            source: notes,
 | 
			
		||||
            activate: function(event, data){
 | 
			
		||||
            activate: (event, data) => {
 | 
			
		||||
                const node = data.node.data;
 | 
			
		||||
 | 
			
		||||
                saveNoteIfChanged(() => loadNote(node.note_id));
 | 
			
		||||
            },
 | 
			
		||||
            expand: function(event, data) {
 | 
			
		||||
            expand: (event, data) => {
 | 
			
		||||
                setExpandedToServer(data.node.key, true);
 | 
			
		||||
            },
 | 
			
		||||
            collapse: function(event, data) {
 | 
			
		||||
            collapse: (event, data) => {
 | 
			
		||||
                setExpandedToServer(data.node.key, false);
 | 
			
		||||
            },
 | 
			
		||||
            init: function(event, data) {
 | 
			
		||||
            init: (event, data) => {
 | 
			
		||||
                if (startNoteId) {
 | 
			
		||||
                    data.tree.activateKey(startNoteId);
 | 
			
		||||
                }
 | 
			
		||||
@ -172,7 +172,7 @@ $(function(){
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
function collapseTree() {
 | 
			
		||||
    globalTree.fancytree("getRootNode").visit(function(node){
 | 
			
		||||
    globalTree.fancytree("getRootNode").visit(node => {
 | 
			
		||||
        node.setExpanded(false);
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
@ -217,7 +217,7 @@ function resetSearch() {
 | 
			
		||||
 | 
			
		||||
$("button#btnResetSearch").click(resetSearch);
 | 
			
		||||
 | 
			
		||||
$("input[name=search]").keyup(function (e) {
 | 
			
		||||
$("input[name=search]").keyup(e => {
 | 
			
		||||
    const searchString = $(this).val();
 | 
			
		||||
 | 
			
		||||
    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
 | 
			
		||||
            const tree = globalTree.fancytree("getTree");
 | 
			
		||||
            tree.filterBranches(function(node) {
 | 
			
		||||
            tree.filterBranches(node => {
 | 
			
		||||
                return resp.includes(node.data.note_id);
 | 
			
		||||
            });
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
@ -3,7 +3,7 @@ function moveBeforeNode(node, beforeNode) {
 | 
			
		||||
        url: baseApiUrl + 'notes/' + node.key + '/moveBefore/' + beforeNode.key,
 | 
			
		||||
        type: 'PUT',
 | 
			
		||||
        contentType: "application/json",
 | 
			
		||||
        success: function () {
 | 
			
		||||
        success: () => {
 | 
			
		||||
            node.moveTo(beforeNode, 'before');
 | 
			
		||||
        }
 | 
			
		||||
    });
 | 
			
		||||
@ -14,7 +14,7 @@ function moveAfterNode(node, afterNode) {
 | 
			
		||||
        url: baseApiUrl + 'notes/' + node.key + '/moveAfter/' + afterNode.key,
 | 
			
		||||
        type: 'PUT',
 | 
			
		||||
        contentType: "application/json",
 | 
			
		||||
        success: function () {
 | 
			
		||||
        success: () => {
 | 
			
		||||
            node.moveTo(afterNode, 'after');
 | 
			
		||||
        }
 | 
			
		||||
    });
 | 
			
		||||
@ -25,7 +25,7 @@ function moveToNode(node, toNode) {
 | 
			
		||||
        url: baseApiUrl + 'notes/' + node.key + '/moveTo/' + toNode.key,
 | 
			
		||||
        type: 'PUT',
 | 
			
		||||
        contentType: "application/json",
 | 
			
		||||
        success: function () {
 | 
			
		||||
        success: () => {
 | 
			
		||||
            node.moveTo(toNode);
 | 
			
		||||
 | 
			
		||||
            toNode.setExpanded(true);
 | 
			
		||||
@ -41,7 +41,7 @@ function deleteNode(node) {
 | 
			
		||||
        $.ajax({
 | 
			
		||||
            url: baseApiUrl + 'notes/' + node.key,
 | 
			
		||||
            type: 'DELETE',
 | 
			
		||||
            success: function () {
 | 
			
		||||
            success: () => {
 | 
			
		||||
                if (node.getParent() !== null && node.getParent().getChildren().length <= 1) {
 | 
			
		||||
                    node.getParent().folder = false;
 | 
			
		||||
                    node.getParent().renderTitle();
 | 
			
		||||
@ -72,7 +72,7 @@ function moveNodeUp(node) {
 | 
			
		||||
            url: baseApiUrl + 'notes/' + node.key + '/moveAfter/' + node.getParent().key,
 | 
			
		||||
            type: 'PUT',
 | 
			
		||||
            contentType: "application/json",
 | 
			
		||||
            success: function () {
 | 
			
		||||
            success: () => {
 | 
			
		||||
                if (node.getParent() !== null && node.getParent().getChildren().length <= 1) {
 | 
			
		||||
                    node.getParent().folder = false;
 | 
			
		||||
                    node.getParent().renderTitle();
 | 
			
		||||
 | 
			
		||||
@ -46,7 +46,7 @@ function uint8ToBase64(u8Arr) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
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) {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user