| 
									
										
										
										
											2018-03-25 19:49:33 -04:00
										 |  |  | import addLinkDialog from '../dialogs/add_link.js'; | 
					
						
							|  |  |  | import jumpToNoteDialog from '../dialogs/jump_to_note.js'; | 
					
						
							| 
									
										
										
										
											2018-03-25 13:02:39 -04:00
										 |  |  | import labelsDialog from '../dialogs/labels.js'; | 
					
						
							| 
									
										
										
										
											2018-03-25 20:52:38 -04:00
										 |  |  | import noteRevisionsDialog from '../dialogs/note_revisions.js'; | 
					
						
							| 
									
										
										
										
											2018-03-25 19:49:33 -04:00
										 |  |  | import noteSourceDialog from '../dialogs/note_source.js'; | 
					
						
							|  |  |  | import recentChangesDialog from '../dialogs/recent_changes.js'; | 
					
						
							|  |  |  | import recentNotesDialog from '../dialogs/recent_notes.js'; | 
					
						
							|  |  |  | import settingsDialog from '../dialogs/settings.js'; | 
					
						
							|  |  |  | import sqlConsoleDialog from '../dialogs/sql_console.js'; | 
					
						
							| 
									
										
										
										
											2018-03-24 11:18:46 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-25 11:09:17 -04:00
										 |  |  | import cloning from './cloning.js'; | 
					
						
							|  |  |  | import contextMenu from './context_menu.js'; | 
					
						
							|  |  |  | import dragAndDropSetup from './drag_and_drop.js'; | 
					
						
							|  |  |  | import exportService from './export.js'; | 
					
						
							|  |  |  | import link from './link.js'; | 
					
						
							| 
									
										
										
										
											2018-03-27 00:22:02 -04:00
										 |  |  | import messagingService from './messaging.js'; | 
					
						
							| 
									
										
										
										
											2018-03-25 20:18:08 -04:00
										 |  |  | import noteDetailService from './note_detail.js'; | 
					
						
							| 
									
										
										
										
											2018-03-25 11:09:17 -04:00
										 |  |  | import noteType from './note_type.js'; | 
					
						
							|  |  |  | import protected_session from './protected_session.js'; | 
					
						
							| 
									
										
										
										
											2018-03-25 19:49:33 -04:00
										 |  |  | import searchTreeService from './search_tree.js'; | 
					
						
							| 
									
										
										
										
											2018-03-25 11:09:17 -04:00
										 |  |  | import ScriptApi from './script_api.js'; | 
					
						
							|  |  |  | import ScriptContext from './script_context.js'; | 
					
						
							|  |  |  | import sync from './sync.js'; | 
					
						
							| 
									
										
										
										
											2018-03-25 19:49:33 -04:00
										 |  |  | import treeService from './tree.js'; | 
					
						
							| 
									
										
										
										
											2018-03-25 11:09:17 -04:00
										 |  |  | import treeChanges from './tree_changes.js'; | 
					
						
							|  |  |  | import treeUtils from './tree_utils.js'; | 
					
						
							|  |  |  | import utils from './utils.js'; | 
					
						
							| 
									
										
										
										
											2018-03-25 20:18:08 -04:00
										 |  |  | import server from './server.js'; | 
					
						
							| 
									
										
										
										
											2018-03-26 22:29:14 -04:00
										 |  |  | import entrypoints from './entrypoints.js'; | 
					
						
							|  |  |  | import tooltip from './tooltip.js'; | 
					
						
							|  |  |  | import bundle from "./bundle.js"; | 
					
						
							|  |  |  | import treeCache from "./tree_cache.js"; | 
					
						
							| 
									
										
										
										
											2018-03-24 11:18:46 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-25 20:18:08 -04:00
										 |  |  | // required for CKEditor image upload plugin
 | 
					
						
							|  |  |  | window.glob.getCurrentNode = treeService.getCurrentNode; | 
					
						
							|  |  |  | window.glob.getHeaders = server.getHeaders; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // required for ESLint plugin
 | 
					
						
							|  |  |  | window.glob.getCurrentNote = noteDetailService.getCurrentNote; | 
					
						
							|  |  |  | window.glob.requireLibrary = utils.requireLibrary; | 
					
						
							|  |  |  | window.glob.ESLINT = utils.ESLINT; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-26 22:29:14 -04:00
										 |  |  | window.onerror = function (msg, url, lineNo, columnNo, error) { | 
					
						
							|  |  |  |     const string = msg.toLowerCase(); | 
					
						
							| 
									
										
										
										
											2018-03-25 19:49:33 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-26 22:29:14 -04:00
										 |  |  |     let message = "Uncaught error: "; | 
					
						
							| 
									
										
										
										
											2018-03-25 19:49:33 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-26 22:29:14 -04:00
										 |  |  |     if (string.indexOf("script error") > -1){ | 
					
						
							|  |  |  |         message += 'No details available'; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else { | 
					
						
							|  |  |  |         message += [ | 
					
						
							|  |  |  |             'Message: ' + msg, | 
					
						
							|  |  |  |             'URL: ' + url, | 
					
						
							|  |  |  |             'Line: ' + lineNo, | 
					
						
							|  |  |  |             'Column: ' + columnNo, | 
					
						
							|  |  |  |             'Error object: ' + JSON.stringify(error) | 
					
						
							|  |  |  |         ].join(' - '); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-03-25 19:49:33 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-26 22:29:14 -04:00
										 |  |  |     messagingService.logError(message); | 
					
						
							| 
									
										
										
										
											2018-03-25 19:49:33 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-26 22:29:14 -04:00
										 |  |  |     return false; | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2018-03-25 19:49:33 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-26 22:29:14 -04:00
										 |  |  | $("#logout-button").toggle(!utils.isElectron()); | 
					
						
							| 
									
										
										
										
											2018-03-25 19:49:33 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-26 22:29:14 -04:00
										 |  |  | if (utils.isElectron()) { | 
					
						
							|  |  |  |     require('electron').ipcRenderer.on('create-day-sub-note', async function(event, parentNoteId) { | 
					
						
							|  |  |  |         // this might occur when day note had to be created
 | 
					
						
							|  |  |  |         if (!await treeCache.getNote(parentNoteId)) { | 
					
						
							|  |  |  |             await treeService.reload(); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2018-03-25 19:49:33 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-26 22:29:14 -04:00
										 |  |  |         await treeService.activateNode(parentNoteId); | 
					
						
							| 
									
										
										
										
											2018-03-24 11:18:46 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-26 22:29:14 -04:00
										 |  |  |         setTimeout(() => { | 
					
						
							|  |  |  |             const node = treeService.getCurrentNode(); | 
					
						
							| 
									
										
										
										
											2018-03-24 11:18:46 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-26 22:29:14 -04:00
										 |  |  |             treeService.createNote(node, node.data.noteId, 'into', node.data.isProtected); | 
					
						
							|  |  |  |         }, 500); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2018-03-25 22:37:02 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-26 22:29:14 -04:00
										 |  |  | treeService.showTree(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | entrypoints.registerEntrypoints(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | tooltip.setupTooltip(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | $(document).ready(bundle.executeStartupBundles); |