aboutsummaryrefslogtreecommitdiff
path: root/public/gallery.js
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2023-12-23 02:21:55 +0100
committerPřemysl Eric Janouch <p@janouch.name>2023-12-23 02:24:33 +0100
commit5b87208932a8979193bf1ddc9cf99683685526e3 (patch)
tree6a25d46c034d0de694e5b205b2a5293104828ce5 /public/gallery.js
parente0a64f2e1dcf9effdb9e0d6aea0eca7124bafadb (diff)
downloadgallery-5b87208932a8979193bf1ddc9cf99683685526e3.tar.gz
gallery-5b87208932a8979193bf1ddc9cf99683685526e3.tar.xz
gallery-5b87208932a8979193bf1ddc9cf99683685526e3.zip
WIP: Global duplicate search
Diffstat (limited to 'public/gallery.js')
-rw-r--r--public/gallery.js37
1 files changed, 18 insertions, 19 deletions
diff --git a/public/gallery.js b/public/gallery.js
index 19d63bb..ca1e511 100644
--- a/public/gallery.js
+++ b/public/gallery.js
@@ -8,6 +8,8 @@ function call(method, params) {
})
}
+const loading = (window.location.hostname !== 'localhost') ? 'lazy' : undefined
+
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
let BrowseModel = {
@@ -85,18 +87,13 @@ let BrowseView = {
oncreate(vnode) { vnode.dom.focus() },
view(vnode) {
- const loading = undefined
- if (window.location.hostname !== 'localhost')
- loading = 'lazy'
-
return m('.browser[tabindex=0]', {
// Trying to force the oncreate on path changes.
key: BrowseModel.path,
}, BrowseModel.entries.map(e => {
return m(m.route.Link, {href: `/view/${e.sha1}`},
- m('img', {src: `/thumb/${e.sha1}`,
- width: e.thumbW, height: e.thumbH, title: e.name,
- loading}))
+ m('img.thumbnail', {src: `/thumb/${e.sha1}`,
+ width: e.thumbW, height: e.thumbH, title: e.name, loading}))
}))
},
}
@@ -244,8 +241,8 @@ let SimilarThumbnail = {
view(vnode) {
const info = vnode.attrs.info
return m(m.route.Link, {href: `/view/${info.sha1}`},
- m('img', {src: `/thumb/${info.sha1}`,
- width: info.thumbW, height: info.thumbH}))
+ m('img.thumbnail', {src: `/thumb/${info.sha1}`,
+ width: info.thumbW, height: info.thumbH, loading}))
},
}
@@ -324,22 +321,24 @@ let DuplicatesThumbnail = {
const info = vnode.attrs.info
return [
m(m.route.Link, {href: `/similar/${info.sha1}`},
- m('img', {src: `/thumb/${info.sha1}`,
- width: info.thumbW, height: info.thumbH})),
- info.occurences,
+ m('img.thumbnail', {src: `/thumb/${info.sha1}`,
+ width: info.thumbW, height: info.thumbH, loading})),
+ (info.occurences != 1) ? ` ×${info.occurences}` : [],
]
},
}
let DuplicatesList = {
- view(vnode) {
- if (DuplicatesModel.entries.length == 0)
- return "No duplicates"
+ // See BrowseView.
+ oncreate(vnode) { vnode.dom.focus() },
- return m('.duplicates', {}, DuplicatesModel.entries.map(group =>
- m('.row', group.map(entry =>
- m(DuplicatesThumbnail, {info: entry}))),
- ))
+ view(vnode) {
+ let children = (DuplicatesModel.entries.length == 0)
+ ? "No duplicates"
+ : DuplicatesModel.entries.map(group =>
+ m('.row', group.map(entry =>
+ m(DuplicatesThumbnail, {info: entry}))))
+ return m('.duplicates[tabindex=0]', {}, children)
},
}