| 
									
										
										
										
											2018-03-27 21:36:01 -04:00
										 |  |  | import noteDetailService from "./note_detail.js"; | 
					
						
							| 
									
										
										
										
											2019-03-30 00:12:32 +01:00
										 |  |  | import searchNotesService from "./search_notes.js"; | 
					
						
							| 
									
										
										
										
											2018-03-27 21:36:01 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | const $searchString = $("#search-string"); | 
					
						
							| 
									
										
										
										
											2018-11-08 10:30:35 +01:00
										 |  |  | const $component = $('#note-detail-search'); | 
					
						
							| 
									
										
										
										
											2019-01-08 23:32:03 +01:00
										 |  |  | const $refreshButton = $('#note-detail-search-refresh-results-button'); | 
					
						
							| 
									
										
										
										
											2019-03-31 21:19:10 +02:00
										 |  |  | const $help = $("#note-detail-search-help"); | 
					
						
							| 
									
										
										
										
											2018-03-27 21:36:01 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-27 21:46:38 -04:00
										 |  |  | function show() { | 
					
						
							| 
									
										
										
										
											2019-03-31 21:19:10 +02:00
										 |  |  |     $help.html(searchNotesService.getHelpText()); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-08 10:30:35 +01:00
										 |  |  |     $component.show(); | 
					
						
							| 
									
										
										
										
											2018-03-27 21:36:01 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     try { | 
					
						
							| 
									
										
										
										
											2019-03-26 22:24:04 +01:00
										 |  |  |         const json = JSON.parse(noteDetailService.getActiveNote().content); | 
					
						
							| 
									
										
										
										
											2018-03-27 21:36:01 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |         $searchString.val(json.searchString); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     catch (e) { | 
					
						
							|  |  |  |         console.log(e); | 
					
						
							|  |  |  |         $searchString.val(''); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     $searchString.on('input', noteDetailService.noteChanged); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-15 21:21:26 +01:00
										 |  |  | function getContent() { | 
					
						
							|  |  |  |     return JSON.stringify({ | 
					
						
							|  |  |  |         searchString: $searchString.val() | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-09 19:54:32 +01:00
										 |  |  | $refreshButton.click(async () => { | 
					
						
							|  |  |  |     await noteDetailService.saveNoteIfChanged(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-30 00:12:32 +01:00
										 |  |  |     await searchNotesService.refreshSearch(); | 
					
						
							| 
									
										
										
										
											2019-01-09 19:54:32 +01:00
										 |  |  | }); | 
					
						
							| 
									
										
										
										
											2019-01-08 23:32:03 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-27 21:36:01 -04:00
										 |  |  | export default { | 
					
						
							|  |  |  |     getContent, | 
					
						
							| 
									
										
										
										
											2018-03-27 21:46:38 -04:00
										 |  |  |     show, | 
					
						
							| 
									
										
										
										
											2018-09-03 16:05:28 +02:00
										 |  |  |     focus: () => null, | 
					
						
							| 
									
										
										
										
											2018-10-31 12:29:01 +01:00
										 |  |  |     onNoteChange: () => null, | 
					
						
							| 
									
										
										
										
											2018-12-24 09:47:00 +01:00
										 |  |  |     cleanup: () => null, | 
					
						
							|  |  |  |     scrollToTop: () => null | 
					
						
							| 
									
										
										
										
											2018-03-27 21:36:01 -04:00
										 |  |  | } |