forked from dullage/flatnotes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclasses.js
More file actions
45 lines (38 loc) · 1020 Bytes
/
classes.js
File metadata and controls
45 lines (38 loc) · 1020 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import router from "./router.js";
class Note {
constructor(note) {
this.title = note?.title;
this.lastModified = note?.lastModified;
this.content = note?.content;
}
get lastModifiedAsDate() {
return new Date(this.lastModified * 1000);
}
get lastModifiedAsString() {
return this.lastModifiedAsDate.toLocaleString();
}
}
class SearchResult extends Note {
constructor(searchResult) {
super(searchResult);
this.score = searchResult.score;
this.titleHighlights = searchResult.titleHighlights;
this.contentHighlights = searchResult.contentHighlights;
this.tagMatches = searchResult.tagMatches;
}
get titleHighlightsOrTitle() {
return this.titleHighlights ? this.titleHighlights : this.title;
}
get includesHighlights() {
if (
this.titleHighlights ||
this.contentHighlights ||
(this.tagMatches != null && this.tagMatches.length)
) {
return true;
} else {
return false;
}
}
}
export { Note, SearchResult };