ketr.photos/clusters-pre
James Ketrenos 5e55a845ca Sort and limit clusters output while debugging
Signed-off-by: James Ketrenos <james_git@ketrenos.com>
2020-01-11 16:35:21 -08:00

58 lines
1.6 KiB
Plaintext

<html>
<script>'<base href="BASEPATH">';</script>
<script>
document.addEventListener("DOMContentLoaded", (event) => {
var div = document.createElement("div");
div.textContent = "There are " + clusters.length + " clusters.";
document.body.appendChild(div);
clusters.sort((a, b) => { return b.length - a.length });
clusters.forEach((cluster, clusterIndex) => {
var div = document.createElement("div");
div.textContent = "Cluster " + (clusterIndex + 1) + " has " + cluster.length + " neighbors.";
document.body.appendChild(div);
if (clusterIndex < 20) cluster.forEach((tuple, index) => {
if (index > 15) {
return;
}
var div = document.createElement("div");
div.classList.add("face");
let faceId = tuple[0],
photoId = tuple[1];
div.setAttribute("photo-id", photoId);
div.style.backgroundImage = "url(face-data/" + (faceId % 100) + "/" + faceId + "-original.png)";
div.addEventListener("click", (event) => {
let photoId = parseInt(event.currentTarget.getAttribute("photo-id"));
if (photoId) {
window.open("face-explorer.html?" + photoId, "photo-" + photoId);
} else {
alert("No photo id mapped to face.");
}
});
document.body.appendChild(div);
});
});
});
</script>
<style>
body {
margin: 0;
padding: 0;
}
.face {
width: 128px;
height: 128px;
background-size: contain;
background-position: center center;
display: inline-block;
border: 1px solid black;
margin: 0.5em;
cursor: pointer;
}
.face:hover {
box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.5);
}
</style>