-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathphotos.html
61 lines (59 loc) · 2.26 KB
/
photos.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
---
layout: default
title: Photos
---
<div class="photos">
{%- for photo in site.data.photos -%}
{%- assign a = photo.src | split: '20' -%}
{%- assign id = a[1] | split: '.' -%}
{%- assign id = id[0] -%}
<div class="thumb" id="img-{{ id }}">
<label for="{{ forloop.index }}">
<img loading="lazy" class="thumb-image" src="/assets/photos/{{ photo.src }}" alt="{{ photo.caption }}">
<div class="caption">
<span class="photo-date">{{ photo.date }}</span>
<span class="photo-caption">{{ photo.caption }}</span>
</div>
</label>
<input class="modal-state" id="{{ forloop.index }}" type="checkbox">
<div class="modal">
<div id="left-{{- forloop.index -}} " style="left:20px" class="modal-arrow">ᐸ</div>
<div id="right-{{- forloop.index -}}" style="right:20px" class="modal-arrow">ᐳ</div>
<label for="{{ forloop.index }}">
<div class="modal-content">
{% if photo.video %}
<video controls style="justify-content:center;width:70%;object-fit:scale-down;">
<source src="/assets/photos/{{ photo.video }}" type="video/mp4">
Videos not supported
</source>
</video>
{% else %}
<img loading="lazy" class="modal-photo" src="/assets/photos/{{ photo.src }}" alt="{{ photo.caption }}">
{% endif %}
<div>
<span class="photo-date">{{ photo.date }}</span>
<span class="photo-caption">{{ photo.caption }}</span>
</div>
</div>
</label>
</div>
</div>
{%- endfor -%}
</div>
<script>
<!--This script simply enables direct-linking to photos and the back/advance slideshow arrows.-->
const get=document.getElementById.bind(document);
const queryAll=document.querySelectorAll.bind(document);
try{get(new URL(window.location.href).searchParams.get("i")).checked=true;}catch(e){}
queryAll(".modal-arrow").forEach((el)=>{el.onclick=(e)=>{
[dir,idx]=e.target.id.split("-");
try{get((+idx+(dir=="right"?1:-1)).toString()).checked=true; get(idx).checked=false;}catch(e){}
};});
document.addEventListener("keydown", (e) => {
if (event.key === "Escape" || event.key === "Esc") {
queryAll(".modal-state").forEach((el)=>{
el.checked = false;
});
}
});
</script>