From fd50a6969cd023d11dfb4ee44a8c5392b3f10abe Mon Sep 17 00:00:00 2001 From: James Ketrenos Date: Sun, 5 Jan 2020 16:51:43 -0800 Subject: [PATCH] Toggle pause on box bar loading Signed-off-by: James Ketrenos --- frontend/face-explorer.html | 22 ++++++++++++++-------- server/routes/photos.js | 6 +++--- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/frontend/face-explorer.html b/frontend/face-explorer.html index 0af1f99..506bf37 100644 --- a/frontend/face-explorer.html +++ b/frontend/face-explorer.html @@ -154,6 +154,8 @@ function makeFaceBoxes() { box.style.width = Math.floor((face.right - face.left) * width) + "%"; box.style.height = Math.floor((face.bottom - face.top) * height) + "%"; box.addEventListener("click", (event) => { + setPause(true); + var bar = document.getElementById("bar"); if (!bar) { bar = document.createElement("div"); @@ -194,6 +196,17 @@ function makeFaceBoxes() { }); } +function setPause(state) { + paused = state; + if (!paused) { + tick(); + } else { + document.getElementById("loading").textContent = "||"; + clearTimeout(scheduled); + scheduled = null; + } +} + function loadPhoto(index) { const photo = photos[index], xml = new XMLHttpRequest(), @@ -319,14 +332,7 @@ document.addEventListener("DOMContentLoaded", function() { document.addEventListener("keydown", function(event) { switch (event.keyCode) { case 32: /* space */ - paused = !paused; - if (!paused) { - tick(); - } else { - document.getElementById("loading").textContent = "||"; - clearTimeout(scheduled); - scheduled = null; - } + setPause(!paused); return; case 37: /* left */ diff --git a/server/routes/photos.js b/server/routes/photos.js index 9641b45..e1d1455 100755 --- a/server/routes/photos.js +++ b/server/routes/photos.js @@ -793,8 +793,7 @@ function getFacesForPhoto(id) { return photoDB.sequelize.query( "SELECT face1Id,face2Id " + "FROM facedistances " + - "WHERE distance<0.5 AND (face1Id=:id OR face2Id=:id) " + - "ORDER BY distance ASC", { + "WHERE distance>0 AND distance<=0.5 AND (face1Id=:id OR face2Id=:id)", { replacements: { id: face.id }, @@ -811,7 +810,8 @@ function getFacesForPhoto(id) { " (fd.face1Id=faces.id AND fd.face2Id=:faceId) " + "OR (fd.face2Id=faces.id AND fd.face1Id=:faceId) " + ") " + - "WHERE faces.id IN (:ids)", { + "WHERE faces.id IN (:ids) " + + "ORDER BY fd.distance ASC", { replacements: { ids: faceIds.map((match) => { return (match.face1Id == face.id) ? match.face2Id : match.face1Id;