mirror of
https://github.com/kennethreitz/photos.kennethreitz.org.git
synced 2026-06-21 15:10:56 +00:00
13480d244e
- Analytics code field in SiteConfig (paste any GA/Gauges snippet) - Image detail: EXIF bar first, download in bar, prev/next nav with arrow keys, 'O' for original download, delete button for owner - Word cloud: log-scaled font sizes, shuffled layout - Keyboard grid navigation (arrow keys + Enter) on image/gear grids - Delete redirects to next image instead of dashboard - Only show AI title, hide Flickr filenames - Fix remaining hardcoded "ExifTree" in page titles Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
37 lines
1.5 KiB
HTML
37 lines
1.5 KiB
HTML
<script>
|
|
(function() {
|
|
var cards = Array.from(document.querySelectorAll('.gear-grid > a, .gear-grid .gear-card'));
|
|
if (!cards.length) return;
|
|
var idx = -1;
|
|
|
|
function getCols() {
|
|
var cols = 1;
|
|
var top = cards[0].getBoundingClientRect().top;
|
|
for (var i = 1; i < cards.length; i++) {
|
|
if (Math.abs(cards[i].getBoundingClientRect().top - top) < 5) cols++;
|
|
else break;
|
|
}
|
|
return cols;
|
|
}
|
|
|
|
function focus(i) {
|
|
if (i < 0 || i >= cards.length) return;
|
|
if (idx >= 0) cards[idx].classList.remove('gear-card-focused');
|
|
idx = i;
|
|
cards[idx].classList.add('gear-card-focused');
|
|
cards[idx].scrollIntoView({ block: 'nearest', behavior: 'smooth' });
|
|
}
|
|
|
|
document.addEventListener('keydown', function(e) {
|
|
if (e.target.tagName === 'INPUT' || e.target.tagName === 'TEXTAREA' || e.target.tagName === 'SELECT') return;
|
|
var cols = getCols();
|
|
if (e.key === 'ArrowRight') { e.preventDefault(); focus(idx < 0 ? 0 : idx + 1); }
|
|
else if (e.key === 'ArrowLeft') { e.preventDefault(); focus(idx < 0 ? 0 : idx - 1); }
|
|
else if (e.key === 'ArrowDown') { e.preventDefault(); focus(idx < 0 ? 0 : idx + cols); }
|
|
else if (e.key === 'ArrowUp') { e.preventDefault(); focus(idx < 0 ? 0 : idx - cols); }
|
|
else if (e.key === 'Enter' && idx >= 0) { e.preventDefault(); window.location.href = cards[idx].href; }
|
|
else if (e.key === 'Escape' && idx >= 0) { cards[idx].classList.remove('gear-card-focused'); idx = -1; }
|
|
});
|
|
})();
|
|
</script>
|