mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 02:16:05 +01:00 
			
		
		
		
	removed all onclick handlers from index template
This commit is contained in:
		| @@ -1,6 +1,7 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
|  |  | ||||||
| const attributesDialog = (function() { | const attributesDialog = (function() { | ||||||
|  |     const $showDialogButton = $(".show-attributes-button"); | ||||||
|     const $dialog = $("#attributes-dialog"); |     const $dialog = $("#attributes-dialog"); | ||||||
|     const $saveAttributesButton = $("#save-attributes-button"); |     const $saveAttributesButton = $("#save-attributes-button"); | ||||||
|     const $attributesBody = $('#attributes-table tbody'); |     const $attributesBody = $('#attributes-table tbody'); | ||||||
| @@ -218,6 +219,8 @@ const attributesDialog = (function() { | |||||||
|         $(this).autocomplete("search", $(this).val()); |         $(this).autocomplete("search", $(this).val()); | ||||||
|     }); |     }); | ||||||
|  |  | ||||||
|  |     $showDialogButton.click(showDialog); | ||||||
|  |  | ||||||
|     return { |     return { | ||||||
|         showDialog |         showDialog | ||||||
|     }; |     }; | ||||||
|   | |||||||
| @@ -1,6 +1,7 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
|  |  | ||||||
| const jumpToNote = (function() { | const jumpToNote = (function() { | ||||||
|  |     const $showDialogButton = $("#jump-to-note-button"); | ||||||
|     const $dialog = $("#jump-to-note-dialog"); |     const $dialog = $("#jump-to-note-dialog"); | ||||||
|     const $autoComplete = $("#jump-to-note-autocomplete"); |     const $autoComplete = $("#jump-to-note-autocomplete"); | ||||||
|     const $form = $("#jump-to-note-form"); |     const $form = $("#jump-to-note-form"); | ||||||
| @@ -50,6 +51,8 @@ const jumpToNote = (function() { | |||||||
|         return false; |         return false; | ||||||
|     }); |     }); | ||||||
|  |  | ||||||
|  |     $showDialogButton.click(showDialog); | ||||||
|  |  | ||||||
|     return { |     return { | ||||||
|         showDialog |         showDialog | ||||||
|     }; |     }; | ||||||
|   | |||||||
| @@ -1,6 +1,7 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
|  |  | ||||||
| const noteHistory = (function() { | const noteHistory = (function() { | ||||||
|  |     const $showDialogButton = $("#show-history-button"); | ||||||
|     const $dialog = $("#note-history-dialog"); |     const $dialog = $("#note-history-dialog"); | ||||||
|     const $list = $("#note-history-list"); |     const $list = $("#note-history-list"); | ||||||
|     const $content = $("#note-history-content"); |     const $content = $("#note-history-content"); | ||||||
| @@ -72,6 +73,8 @@ const noteHistory = (function() { | |||||||
|         return false; |         return false; | ||||||
|     }); |     }); | ||||||
|  |  | ||||||
|  |     $showDialogButton.click(showCurrentNoteHistory); | ||||||
|  |  | ||||||
|     return { |     return { | ||||||
|         showCurrentNoteHistory |         showCurrentNoteHistory | ||||||
|     }; |     }; | ||||||
|   | |||||||
| @@ -1,6 +1,7 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
|  |  | ||||||
| const noteSource = (function() { | const noteSource = (function() { | ||||||
|  |     const $showDialogButton = $("#show-source-button"); | ||||||
|     const $dialog = $("#note-source-dialog"); |     const $dialog = $("#note-source-dialog"); | ||||||
|     const $noteSource = $("#note-source"); |     const $noteSource = $("#note-source"); | ||||||
|  |  | ||||||
| @@ -51,6 +52,8 @@ const noteSource = (function() { | |||||||
|         e.preventDefault(); |         e.preventDefault(); | ||||||
|     }); |     }); | ||||||
|  |  | ||||||
|  |     $showDialogButton.click(showDialog); | ||||||
|  |  | ||||||
|     return { |     return { | ||||||
|         showDialog |         showDialog | ||||||
|     }; |     }; | ||||||
|   | |||||||
| @@ -1,6 +1,7 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
|  |  | ||||||
| const recentChanges = (function() { | const recentChanges = (function() { | ||||||
|  |     const $showDialogButton = $("#recent-changes-button"); | ||||||
|     const $dialog = $("#recent-changes-dialog"); |     const $dialog = $("#recent-changes-dialog"); | ||||||
|  |  | ||||||
|     async function showDialog() { |     async function showDialog() { | ||||||
| @@ -83,6 +84,8 @@ const recentChanges = (function() { | |||||||
|  |  | ||||||
|     $(document).bind('keydown', 'alt+r', showDialog); |     $(document).bind('keydown', 'alt+r', showDialog); | ||||||
|  |  | ||||||
|  |     $showDialogButton.click(showDialog); | ||||||
|  |  | ||||||
|     return { |     return { | ||||||
|         showDialog |         showDialog | ||||||
|     }; |     }; | ||||||
|   | |||||||
| @@ -1,6 +1,7 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
|  |  | ||||||
| const recentNotes = (function() { | const recentNotes = (function() { | ||||||
|  |     const $showDialogButton = $("#recent-notes-button"); | ||||||
|     const $dialog = $("#recent-notes-dialog"); |     const $dialog = $("#recent-notes-dialog"); | ||||||
|     const $searchInput = $('#recent-notes-search-input'); |     const $searchInput = $('#recent-notes-search-input'); | ||||||
|  |  | ||||||
| @@ -94,6 +95,8 @@ const recentNotes = (function() { | |||||||
|         e.preventDefault(); |         e.preventDefault(); | ||||||
|     }); |     }); | ||||||
|  |  | ||||||
|  |     $showDialogButton.click(showDialog); | ||||||
|  |  | ||||||
|     return { |     return { | ||||||
|         showDialog, |         showDialog, | ||||||
|         addRecentNote, |         addRecentNote, | ||||||
|   | |||||||
| @@ -1,6 +1,7 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
|  |  | ||||||
| const settings = (function() { | const settings = (function() { | ||||||
|  |     const $showDialogButton = $("#settings-button"); | ||||||
|     const $dialog = $("#settings-dialog"); |     const $dialog = $("#settings-dialog"); | ||||||
|     const $tabs = $("#settings-tabs"); |     const $tabs = $("#settings-tabs"); | ||||||
|  |  | ||||||
| @@ -38,6 +39,8 @@ const settings = (function() { | |||||||
|         showMessage("Settings change have been saved."); |         showMessage("Settings change have been saved."); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     $showDialogButton.click(showDialog); | ||||||
|  |  | ||||||
|     return { |     return { | ||||||
|         showDialog, |         showDialog, | ||||||
|         saveSettings, |         saveSettings, | ||||||
|   | |||||||
| @@ -229,6 +229,8 @@ function uploadAttachment() { | |||||||
|     $("#attachment-upload").trigger('click'); |     $("#attachment-upload").trigger('click'); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | $("#upload-attachment-button").click(uploadAttachment); | ||||||
|  |  | ||||||
| $("#attachment-upload").change(async function() { | $("#attachment-upload").change(async function() { | ||||||
|     const formData = new FormData(); |     const formData = new FormData(); | ||||||
|     formData.append('upload', this.files[0]); |     formData.append('upload', this.files[0]); | ||||||
|   | |||||||
| @@ -22,6 +22,8 @@ const noteEditor = (function() { | |||||||
|     const $attachmentOpen = $("#attachment-open"); |     const $attachmentOpen = $("#attachment-open"); | ||||||
|     const $searchString = $("#search-string"); |     const $searchString = $("#search-string"); | ||||||
|  |  | ||||||
|  |     const $executeScriptButton = $("#execute-script-button"); | ||||||
|  |  | ||||||
|     let editor = null; |     let editor = null; | ||||||
|     let codeEditor = null; |     let codeEditor = null; | ||||||
|  |  | ||||||
| @@ -373,6 +375,8 @@ const noteEditor = (function() { | |||||||
|  |  | ||||||
|     $(document).bind('keydown', "ctrl+return", executeCurrentNote); |     $(document).bind('keydown', "ctrl+return", executeCurrentNote); | ||||||
|  |  | ||||||
|  |     $executeScriptButton.click(executeCurrentNote()); | ||||||
|  |  | ||||||
|     setInterval(saveNoteIfChanged, 5000); |     setInterval(saveNoteIfChanged, 5000); | ||||||
|  |  | ||||||
|     return { |     return { | ||||||
|   | |||||||
| @@ -4,6 +4,9 @@ const noteTree = (function() { | |||||||
|     const $tree = $("#tree"); |     const $tree = $("#tree"); | ||||||
|     const $parentList = $("#parent-list"); |     const $parentList = $("#parent-list"); | ||||||
|     const $parentListList = $("#parent-list-inner"); |     const $parentListList = $("#parent-list-inner"); | ||||||
|  |     const $createTopLevelNoteButton = $("#create-top-level-note-button"); | ||||||
|  |     const $collapseTreeButton = $("#collapse-tree-button"); | ||||||
|  |     const $scrollToCurrentNoteButton = $("#scroll-to-current-note-button"); | ||||||
|  |  | ||||||
|     let instanceName = null; // should have better place |     let instanceName = null; // should have better place | ||||||
|  |  | ||||||
| @@ -945,6 +948,10 @@ const noteTree = (function() { | |||||||
|         }); |         }); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     $createTopLevelNoteButton.click(createNewTopLevelNote); | ||||||
|  |     $collapseTreeButton.click(collapseTree); | ||||||
|  |     $scrollToCurrentNoteButton.click(scrollToCurrentNote); | ||||||
|  |  | ||||||
|     return { |     return { | ||||||
|         reload, |         reload, | ||||||
|         collapseTree, |         collapseTree, | ||||||
|   | |||||||
| @@ -5,6 +5,8 @@ const protected_session = (function() { | |||||||
|     const $passwordForm = $("#protected-session-password-form"); |     const $passwordForm = $("#protected-session-password-form"); | ||||||
|     const $password = $("#protected-session-password"); |     const $password = $("#protected-session-password"); | ||||||
|     const $noteDetailWrapper = $("#note-detail-wrapper"); |     const $noteDetailWrapper = $("#note-detail-wrapper"); | ||||||
|  |     const $protectButton = $("#protect-button"); | ||||||
|  |     const $unprotectButton = $("#unprotect-button"); | ||||||
|  |  | ||||||
|     let protectedSessionDeferred = null; |     let protectedSessionDeferred = null; | ||||||
|     let lastProtectedSessionOperationDate = null; |     let lastProtectedSessionOperationDate = null; | ||||||
| @@ -169,6 +171,9 @@ const protected_session = (function() { | |||||||
|         } |         } | ||||||
|     }, 5000); |     }, 5000); | ||||||
|  |  | ||||||
|  |     $protectButton.click(protectNoteAndSendToServer); | ||||||
|  |     $unprotectButton.click(unprotectNoteAndSendToServer); | ||||||
|  |  | ||||||
|     return { |     return { | ||||||
|         setProtectedSessionTimeout, |         setProtectedSessionTimeout, | ||||||
|         ensureProtectedSession, |         ensureProtectedSession, | ||||||
|   | |||||||
| @@ -7,6 +7,7 @@ const searchTree = (function() { | |||||||
|     const $doSearchButton = $("#do-search-button"); |     const $doSearchButton = $("#do-search-button"); | ||||||
|     const $saveSearchButton = $("#save-search-button"); |     const $saveSearchButton = $("#save-search-button"); | ||||||
|     const $searchBox = $("#search-box"); |     const $searchBox = $("#search-box"); | ||||||
|  |     const $toggleSearchButton = $("#toggle-search-button"); | ||||||
|  |  | ||||||
|     $resetSearchButton.click(resetSearch); |     $resetSearchButton.click(resetSearch); | ||||||
|  |  | ||||||
| @@ -74,6 +75,8 @@ const searchTree = (function() { | |||||||
|         e.preventDefault(); |         e.preventDefault(); | ||||||
|     }); |     }); | ||||||
|  |  | ||||||
|  |     $toggleSearchButton.click(toggleSearch); | ||||||
|  |  | ||||||
|     return { |     return { | ||||||
|         toggleSearch |         toggleSearch | ||||||
|     }; |     }; | ||||||
|   | |||||||
| @@ -15,6 +15,8 @@ async function syncNow() { | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | $("#sync-now-button").click(syncNow); | ||||||
|  |  | ||||||
| async function forceNoteSync(noteId) { | async function forceNoteSync(noteId) { | ||||||
|     const result = await server.post('sync/force-note-sync/' + noteId); |     const result = await server.post('sync/force-note-sync/' + noteId); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -14,22 +14,22 @@ | |||||||
|         </div> |         </div> | ||||||
|  |  | ||||||
|         <div style="flex-grow: 100;"> |         <div style="flex-grow: 100;"> | ||||||
|           <button class="btn btn-xs" onclick="jumpToNote.showDialog();" title="CTRL+J">Jump to note</button> |           <button class="btn btn-xs" id="jump-to-note-button" title="CTRL+J">Jump to note</button> | ||||||
|           <button class="btn btn-xs" onclick="recentNotes.showDialog();" title="CTRL+E">Recent notes</button> |           <button class="btn btn-xs" id="recent-notes-button" title="CTRL+E">Recent notes</button> | ||||||
|           <button class="btn btn-xs" onclick="recentChanges.showDialog();">Recent changes</button> |           <button class="btn btn-xs" id="recent-changes-button">Recent changes</button> | ||||||
|         </div> |         </div> | ||||||
|  |  | ||||||
|         <div id="plugin-buttons"> |         <div id="plugin-buttons"> | ||||||
|         </div> |         </div> | ||||||
|  |  | ||||||
|         <div> |         <div> | ||||||
|           <button class="btn btn-xs" onclick="syncNow();" title="Number of outstanding changes to be pushed to server"> |           <button class="btn btn-xs" id="sync-now-button" title="Number of outstanding changes to be pushed to server"> | ||||||
|             <span class="ui-icon ui-icon-refresh"></span> |             <span class="ui-icon ui-icon-refresh"></span> | ||||||
|  |  | ||||||
|             Sync now (<span id="changes-to-push-count">0</span>) |             Sync now (<span id="changes-to-push-count">0</span>) | ||||||
|           </button> |           </button> | ||||||
|  |  | ||||||
|           <button class="btn btn-xs" onclick="settings.showDialog();"> |           <button class="btn btn-xs" id="settings-button"> | ||||||
|             <span class="ui-icon ui-icon-gear"></span> Settings</button> |             <span class="ui-icon ui-icon-gear"></span> Settings</button> | ||||||
|  |  | ||||||
|           <form action="logout" id="logout-button" method="POST" style="display: inline;"> |           <form action="logout" id="logout-button" method="POST" style="display: inline;"> | ||||||
| @@ -40,16 +40,16 @@ | |||||||
|  |  | ||||||
|       <div class="hide-toggle" style="grid-area: tree-actions;"> |       <div class="hide-toggle" style="grid-area: tree-actions;"> | ||||||
|         <div style="display: flex; justify-content: space-around; padding: 10px 0 10px 0; margin: 0 20px 0 20px; border: 1px solid #ccc;"> |         <div style="display: flex; justify-content: space-around; padding: 10px 0 10px 0; margin: 0 20px 0 20px; border: 1px solid #ccc;"> | ||||||
|           <a onclick="noteTree.createNewTopLevelNote()" title="Create new top level note" class="icon-action" |           <a id="create-top-level-note-button" title="Create new top level note" class="icon-action" | ||||||
|              style="background: url('images/icons/file-plus.png')"></a> |              style="background: url('images/icons/file-plus.png')"></a> | ||||||
|  |  | ||||||
|           <a onclick="noteTree.collapseTree()" title="Collapse note tree" class="icon-action" |           <a id="collapse-tree-button" title="Collapse note tree" class="icon-action" | ||||||
|              style="background: url('images/icons/list.png')"></a> |              style="background: url('images/icons/list.png')"></a> | ||||||
|  |  | ||||||
|           <a onclick="noteTree.scrollToCurrentNote()" title="Scroll to current note. Shortcut CTRL+." class="icon-action" |           <a id="scroll-to-current-note-button" title="Scroll to current note. Shortcut CTRL+." class="icon-action" | ||||||
|              style="background: url('images/icons/crosshair.png')"></a> |              style="background: url('images/icons/crosshair.png')"></a> | ||||||
|  |  | ||||||
|           <a onclick="searchTree.toggleSearch()" title="Search in notes" class="icon-action" |           <a id="toggle-search-button" title="Search in notes" class="icon-action" | ||||||
|              style="background: url('images/icons/search.png')"></a> |              style="background: url('images/icons/search.png')"></a> | ||||||
|         </div> |         </div> | ||||||
|  |  | ||||||
| @@ -80,14 +80,12 @@ | |||||||
|  |  | ||||||
|       <div class="hide-toggle" style="grid-area: title;"> |       <div class="hide-toggle" style="grid-area: title;"> | ||||||
|         <div style="display: flex; align-items: center;"> |         <div style="display: flex; align-items: center;"> | ||||||
|           <a onclick="protected_session.protectNoteAndSendToServer()" |           <a title="Protect the note so that password will be required to view the note" | ||||||
|              title="Protect the note so that password will be required to view the note" |  | ||||||
|              class="icon-action" |              class="icon-action" | ||||||
|              id="protect-button" |              id="protect-button" | ||||||
|              style="display: none; background: url('images/icons/lock.png')"></a> |              style="display: none; background: url('images/icons/lock.png')"></a> | ||||||
|  |  | ||||||
|           <a onclick="protected_session.unprotectNoteAndSendToServer()" |           <a title="Unprotect note so that password will not be required to access this note in the future" | ||||||
|              title="Unprotect note so that password will not be required to access this note in the future" |  | ||||||
|              class="icon-action" |              class="icon-action" | ||||||
|              id="unprotect-button" |              id="unprotect-button" | ||||||
|              style="display: none; background: url('images/icons/unlock.png')"></a> |              style="display: none; background: url('images/icons/unlock.png')"></a> | ||||||
| @@ -100,8 +98,7 @@ | |||||||
|  |  | ||||||
|           <button class="btn btn-sm" |           <button class="btn btn-sm" | ||||||
|                   style="display: none; margin-right: 10px" |                   style="display: none; margin-right: 10px" | ||||||
|                   id="execute-script-button" |                   id="execute-script-button">Execute <kbd>Ctrl+Enter</kbd></button> | ||||||
|                   onclick="noteEditor.executeCurrentNote()">Execute <kbd>Ctrl+Enter</kbd></button> |  | ||||||
|  |  | ||||||
|           <div class="dropdown" id="note-type" data-bind="visible: type() != 'search'"> |           <div class="dropdown" id="note-type" data-bind="visible: type() != 'search'"> | ||||||
|             <button data-bind="disable: isDisabled()" id="dLabel" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="btn btn-sm"> |             <button data-bind="disable: isDisabled()" id="dLabel" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="btn btn-sm"> | ||||||
| @@ -126,10 +123,10 @@ | |||||||
|               <span class="caret"></span> |               <span class="caret"></span> | ||||||
|             </button> |             </button> | ||||||
|             <ul class="dropdown-menu dropdown-menu-right" aria-labelledby="dLabel"> |             <ul class="dropdown-menu dropdown-menu-right" aria-labelledby="dLabel"> | ||||||
|               <li><a onclick="noteHistory.showCurrentNoteHistory();"><kbd>Alt+H</kbd> History</a></li> |               <li><a id="show-history-button"><kbd>Alt+H</kbd> History</a></li> | ||||||
|               <li><a onclick="attributesDialog.showDialog();"><kbd>Alt+A</kbd> Attributes</a></li> |               <li><a class="show-attributes-button"><kbd>Alt+A</kbd> Attributes</a></li> | ||||||
|               <li><a onclick="noteSource.showDialog();"><kbd>Ctrl+U</kbd> HTML source</a></li> |               <li><a id="show-source-button"><kbd>Ctrl+U</kbd> HTML source</a></li> | ||||||
|               <li><a onclick="uploadAttachment();">Upload attachment</a></li> |               <li><a id="upload-attachment-button">Upload attachment</a></li> | ||||||
|             </ul> |             </ul> | ||||||
|           </div> |           </div> | ||||||
|         </div> |         </div> | ||||||
| @@ -208,7 +205,7 @@ | |||||||
|       </div> |       </div> | ||||||
|  |  | ||||||
|       <div id="attribute-list"> |       <div id="attribute-list"> | ||||||
|         <button class="btn btn-sm" onclick="attributesDialog.showDialog();">Attributes:</button> |         <button class="btn btn-sm show-attributes-button">Attributes:</button> | ||||||
|  |  | ||||||
|         <span id="attribute-list-inner"></span> |         <span id="attribute-list-inner"></span> | ||||||
|       </div> |       </div> | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user