Require submit before results query
Browse files- frontend/app.js +17 -9
- frontend/index.html +2 -2
frontend/app.js
CHANGED
|
@@ -12,6 +12,7 @@ let viewerDrag = null
|
|
| 12 |
let explorerEvents = null
|
| 13 |
let explorerPage = 1
|
| 14 |
let explorerDebounce = null
|
|
|
|
| 15 |
|
| 16 |
|
| 17 |
$$(".tab").forEach(tab => {
|
|
@@ -79,8 +80,10 @@ function route() {
|
|
| 79 |
if (tab === "explorer") {
|
| 80 |
if (parts[1]) {
|
| 81 |
closeExplorerEvents()
|
| 82 |
-
|
|
|
|
| 83 |
} else {
|
|
|
|
| 84 |
loadSearches(parseInt(params.get("page")) || 1)
|
| 85 |
openExplorerEvents()
|
| 86 |
}
|
|
@@ -90,8 +93,8 @@ function route() {
|
|
| 90 |
}
|
| 91 |
|
| 92 |
|
| 93 |
-
function explorerHash(id, page
|
| 94 |
-
return `#/explorer/${encodeURIComponent(id)}?page=${page}
|
| 95 |
}
|
| 96 |
|
| 97 |
|
|
@@ -137,7 +140,10 @@ async function loadSearches(page = 1, silent = false) {
|
|
| 137 |
list.innerHTML = activeHtml + savedHtml + renderSearchPager(data)
|
| 138 |
list.querySelectorAll(".search-item").forEach(el => {
|
| 139 |
if (!el.dataset.id) return
|
| 140 |
-
el.querySelector(".id").addEventListener("click", () => {
|
|
|
|
|
|
|
|
|
|
| 141 |
const rename = el.querySelector(".btn-rename")
|
| 142 |
const del = el.querySelector(".btn-delete")
|
| 143 |
if (rename) rename.addEventListener("click", e => { e.stopPropagation(); renameSearch(el.dataset.id) })
|
|
@@ -219,7 +225,8 @@ function renderExifFilters(id) {
|
|
| 219 |
if (action !== "submit") return
|
| 220 |
const types = filters.filter(el => el.classList.contains("active")).map(el => Number(el.dataset.code))
|
| 221 |
setExifTypes(types)
|
| 222 |
-
|
|
|
|
| 223 |
if (location.hash === hash) openSearch(id, 1, true)
|
| 224 |
else location.hash = hash
|
| 225 |
}
|
|
@@ -233,7 +240,7 @@ async function openSearch(id, page = 1, show = false) {
|
|
| 233 |
list.innerHTML = ""
|
| 234 |
detail.classList.remove("hidden")
|
| 235 |
$("#detail-title").textContent = id
|
| 236 |
-
$("#detail-stats").textContent = "
|
| 237 |
$("#pager").innerHTML = ""
|
| 238 |
$("#results-grid").innerHTML = ""
|
| 239 |
renderExifFilters(id)
|
|
@@ -252,10 +259,11 @@ async function openSearch(id, page = 1, show = false) {
|
|
| 252 |
}
|
| 253 |
}
|
| 254 |
if (!show) {
|
| 255 |
-
$("#detail-stats").textContent = "Submit to show results"
|
| 256 |
return
|
| 257 |
}
|
| 258 |
|
|
|
|
|
|
|
| 259 |
try {
|
| 260 |
const typesParam = exifTypes.length ? exifTypes.join(",") : "none"
|
| 261 |
const resp = await fetch(`/api/results/${encodeURIComponent(id)}?page=${page}&exif_types=${typesParam}`)
|
|
@@ -420,8 +428,8 @@ function renderPager(id, data) {
|
|
| 420 |
pager.innerHTML = `<button class="btn-secondary" id="page-prev" ${data.page <= 1 ? "disabled" : ""}>Prev</button>
|
| 421 |
<span>${start}-${end} of ${data.total} | page ${data.page}/${data.pages}</span>
|
| 422 |
<button class="btn-secondary" id="page-next" ${data.page >= data.pages ? "disabled" : ""}>Next</button>`
|
| 423 |
-
$("#page-prev").onclick = () => { location.hash = explorerHash(id, prev
|
| 424 |
-
$("#page-next").onclick = () => { location.hash = explorerHash(id, next
|
| 425 |
}
|
| 426 |
|
| 427 |
function esc(s) {
|
|
|
|
| 12 |
let explorerEvents = null
|
| 13 |
let explorerPage = 1
|
| 14 |
let explorerDebounce = null
|
| 15 |
+
let submittedSearchId = null
|
| 16 |
|
| 17 |
|
| 18 |
$$(".tab").forEach(tab => {
|
|
|
|
| 80 |
if (tab === "explorer") {
|
| 81 |
if (parts[1]) {
|
| 82 |
closeExplorerEvents()
|
| 83 |
+
const id = decodeURIComponent(parts[1])
|
| 84 |
+
openSearch(id, parseInt(params.get("page")) || 1, submittedSearchId === id)
|
| 85 |
} else {
|
| 86 |
+
submittedSearchId = null
|
| 87 |
loadSearches(parseInt(params.get("page")) || 1)
|
| 88 |
openExplorerEvents()
|
| 89 |
}
|
|
|
|
| 93 |
}
|
| 94 |
|
| 95 |
|
| 96 |
+
function explorerHash(id, page) {
|
| 97 |
+
return `#/explorer/${encodeURIComponent(id)}?page=${page}`
|
| 98 |
}
|
| 99 |
|
| 100 |
|
|
|
|
| 140 |
list.innerHTML = activeHtml + savedHtml + renderSearchPager(data)
|
| 141 |
list.querySelectorAll(".search-item").forEach(el => {
|
| 142 |
if (!el.dataset.id) return
|
| 143 |
+
el.querySelector(".id").addEventListener("click", () => {
|
| 144 |
+
submittedSearchId = null
|
| 145 |
+
location.hash = explorerHash(el.dataset.id, 1)
|
| 146 |
+
})
|
| 147 |
const rename = el.querySelector(".btn-rename")
|
| 148 |
const del = el.querySelector(".btn-delete")
|
| 149 |
if (rename) rename.addEventListener("click", e => { e.stopPropagation(); renameSearch(el.dataset.id) })
|
|
|
|
| 225 |
if (action !== "submit") return
|
| 226 |
const types = filters.filter(el => el.classList.contains("active")).map(el => Number(el.dataset.code))
|
| 227 |
setExifTypes(types)
|
| 228 |
+
submittedSearchId = id
|
| 229 |
+
const hash = explorerHash(id, 1)
|
| 230 |
if (location.hash === hash) openSearch(id, 1, true)
|
| 231 |
else location.hash = hash
|
| 232 |
}
|
|
|
|
| 240 |
list.innerHTML = ""
|
| 241 |
detail.classList.remove("hidden")
|
| 242 |
$("#detail-title").textContent = id
|
| 243 |
+
$("#detail-stats").textContent = ""
|
| 244 |
$("#pager").innerHTML = ""
|
| 245 |
$("#results-grid").innerHTML = ""
|
| 246 |
renderExifFilters(id)
|
|
|
|
| 259 |
}
|
| 260 |
}
|
| 261 |
if (!show) {
|
|
|
|
| 262 |
return
|
| 263 |
}
|
| 264 |
|
| 265 |
+
$("#detail-stats").textContent = "Loading..."
|
| 266 |
+
|
| 267 |
try {
|
| 268 |
const typesParam = exifTypes.length ? exifTypes.join(",") : "none"
|
| 269 |
const resp = await fetch(`/api/results/${encodeURIComponent(id)}?page=${page}&exif_types=${typesParam}`)
|
|
|
|
| 428 |
pager.innerHTML = `<button class="btn-secondary" id="page-prev" ${data.page <= 1 ? "disabled" : ""}>Prev</button>
|
| 429 |
<span>${start}-${end} of ${data.total} | page ${data.page}/${data.pages}</span>
|
| 430 |
<button class="btn-secondary" id="page-next" ${data.page >= data.pages ? "disabled" : ""}>Next</button>`
|
| 431 |
+
$("#page-prev").onclick = () => { location.hash = explorerHash(id, prev) }
|
| 432 |
+
$("#page-next").onclick = () => { location.hash = explorerHash(id, next) }
|
| 433 |
}
|
| 434 |
|
| 435 |
function esc(s) {
|
frontend/index.html
CHANGED
|
@@ -5,7 +5,7 @@
|
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
<link rel="icon" href="data:;base64,=">
|
| 7 |
<title>Pixif2</title>
|
| 8 |
-
<link rel="stylesheet" href="style.css?v=20260703-
|
| 9 |
</head>
|
| 10 |
<body>
|
| 11 |
<div class="topbar">
|
|
@@ -77,6 +77,6 @@
|
|
| 77 |
<img id="viewer-img" alt="">
|
| 78 |
</div>
|
| 79 |
</div>
|
| 80 |
-
<script src="app.js?v=20260703-
|
| 81 |
</body>
|
| 82 |
</html>
|
|
|
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
<link rel="icon" href="data:;base64,=">
|
| 7 |
<title>Pixif2</title>
|
| 8 |
+
<link rel="stylesheet" href="style.css?v=20260703-4">
|
| 9 |
</head>
|
| 10 |
<body>
|
| 11 |
<div class="topbar">
|
|
|
|
| 77 |
<img id="viewer-img" alt="">
|
| 78 |
</div>
|
| 79 |
</div>
|
| 80 |
+
<script src="app.js?v=20260703-4"></script>
|
| 81 |
</body>
|
| 82 |
</html>
|