summaryrefslogtreecommitdiff
path: root/public
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2023-12-25 02:44:30 +0100
committerPřemysl Eric Janouch <p@janouch.name>2023-12-25 03:14:47 +0100
commitbc037315470431ac1f1ba2c7365ca634895e113f (patch)
tree5a61f6a574634155604bf7b7ce0d72121d8d9dab /public
parent6788a8fbe6af9418374b633e92d6307056701e70 (diff)
downloadgallery-bc037315470431ac1f1ba2c7365ca634895e113f.tar.gz
gallery-bc037315470431ac1f1ba2c7365ca634895e113f.tar.xz
gallery-bc037315470431ac1f1ba2c7365ca634895e113f.zip
Shuffle code
Diffstat (limited to 'public')
-rw-r--r--public/gallery.js230
1 files changed, 115 insertions, 115 deletions
diff --git a/public/gallery.js b/public/gallery.js
index 4933064..52a92ab 100644
--- a/public/gallery.js
+++ b/public/gallery.js
@@ -253,6 +253,120 @@ let Tags = {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+let DuplicatesModel = {
+ entries: [],
+
+ async reload() {
+ this.entries = await call('duplicates', {})
+ },
+}
+
+let DuplicatesThumbnail = {
+ view(vnode) {
+ const info = vnode.attrs.info
+ return [
+ m(m.route.Link, {href: `/similar/${info.sha1}`},
+ m(Thumbnail, {info})),
+ (info.occurences != 1) ? ` ×${info.occurences}` : [],
+ ]
+ },
+}
+
+let DuplicatesList = {
+ // See BrowseView.
+ oncreate(vnode) { vnode.dom.focus() },
+
+ 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)
+ },
+}
+
+let Duplicates = {
+ oninit(vnode) {
+ DuplicatesModel.reload()
+ },
+
+ view(vnode) {
+ return m('.container', {}, [
+ m(Header),
+ m('.body', {}, m(DuplicatesList)),
+ ])
+ },
+}
+
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+let OrphansModel = {
+ entries: [],
+
+ async reload() {
+ this.entries = await call('orphans', {})
+ },
+}
+
+let OrphansReplacement = {
+ view(vnode) {
+ const info = vnode.attrs.info
+ if (!info)
+ return []
+
+ return [
+ ` → `,
+ m(m.route.Link, {href: `/view/${info.sha1}`},
+ m(Thumbnail, {info})),
+ `${info.tags} tags`,
+ ]
+ },
+}
+
+let OrphansRow = {
+ view(vnode) {
+ const info = vnode.attrs.info
+ return m('.row', [
+ // It might not load, but still allow tag viewing.
+ m(m.route.Link, {href: `/view/${info.sha1}`},
+ m(Thumbnail, {info})),
+ `${info.tags} tags`,
+ m(OrphansReplacement, {info: info.replacement}),
+ ])
+ },
+}
+
+let OrphansList = {
+ // See BrowseView.
+ oncreate(vnode) { vnode.dom.focus() },
+
+ view(vnode) {
+ let children = (OrphansModel.entries.length == 0)
+ ? "No orphans"
+ : OrphansModel.entries.map(info => [
+ m("h2", info.lastPath),
+ m(OrphansRow, {info}),
+ ])
+ return m('.orphans[tabindex=0]', {}, children)
+ },
+}
+
+let Orphans = {
+ oninit(vnode) {
+ OrphansModel.reload()
+ },
+
+ view(vnode) {
+ return m('.container', {}, [
+ m(Header),
+ m('.body', {}, m(OrphansList)),
+ ])
+ },
+}
+
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
let ViewModel = {
sha1: undefined,
width: 0,
@@ -427,120 +541,6 @@ let Similar = {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-let DuplicatesModel = {
- entries: [],
-
- async reload() {
- this.entries = await call('duplicates', {})
- },
-}
-
-let DuplicatesThumbnail = {
- view(vnode) {
- const info = vnode.attrs.info
- return [
- m(m.route.Link, {href: `/similar/${info.sha1}`},
- m(Thumbnail, {info})),
- (info.occurences != 1) ? ` ×${info.occurences}` : [],
- ]
- },
-}
-
-let DuplicatesList = {
- // See BrowseView.
- oncreate(vnode) { vnode.dom.focus() },
-
- 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)
- },
-}
-
-let Duplicates = {
- oninit(vnode) {
- DuplicatesModel.reload()
- },
-
- view(vnode) {
- return m('.container', {}, [
- m(Header),
- m('.body', {}, m(DuplicatesList)),
- ])
- },
-}
-
-// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-let OrphansModel = {
- entries: [],
-
- async reload() {
- this.entries = await call('orphans', {})
- },
-}
-
-let OrphansReplacement = {
- view(vnode) {
- const info = vnode.attrs.info
- if (!info)
- return []
-
- return [
- ` → `,
- m(m.route.Link, {href: `/view/${info.sha1}`},
- m(Thumbnail, {info})),
- `${info.tags} tags`,
- ]
- },
-}
-
-let OrphansRow = {
- view(vnode) {
- const info = vnode.attrs.info
- return m('.row', [
- // It might not load, but still allow tag viewing.
- m(m.route.Link, {href: `/view/${info.sha1}`},
- m(Thumbnail, {info})),
- `${info.tags} tags`,
- m(OrphansReplacement, {info: info.replacement}),
- ])
- },
-}
-
-let OrphansList = {
- // See BrowseView.
- oncreate(vnode) { vnode.dom.focus() },
-
- view(vnode) {
- let children = (OrphansModel.entries.length == 0)
- ? "No orphans"
- : OrphansModel.entries.map(info => [
- m("h2", info.lastPath),
- m(OrphansRow, {info}),
- ])
- return m('.orphans[tabindex=0]', {}, children)
- },
-}
-
-let Orphans = {
- oninit(vnode) {
- OrphansModel.reload()
- },
-
- view(vnode) {
- return m('.container', {}, [
- m(Header),
- m('.body', {}, m(OrphansList)),
- ])
- },
-}
-
-// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
window.addEventListener('load', () => {
m.route(document.body, "/browse/", {
// The path doesn't need to be escaped, perhaps change that (":key...").
@@ -554,6 +554,6 @@ window.addEventListener('load', () => {
"/view/:key": View,
"/similar/:key": Similar,
- "/search/:space/:tag": undefined,
+ "/search/:key": undefined,
})
})