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