summaryrefslogtreecommitdiffstats
path: root/index.html
blob: 4e776f58b701f8a59d7ab5662578f942e257b1bb (plain)
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<!DOCTYPE html>
<html>
    <head>
        <title>danrh</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0"> 
        <style>
            body {
                font-family: sans-serif;
                background-color: #fdfded;
                margin: 2em auto;
                max-width: 97vw;
                color: #1a1a1a;
            }
            h1 {
                font-family: Georgia, serif;
                display: flex;
                justify-content: center;
            }
            em {
                display: flex;
                justify-content: center;
            }
            .image-container {
                margin: 2px;
                width: min(480px,95vw);
                height: min(480px,95vw);
                border-radius: 10px;
                overflow: hidden;
            }
            .image-container-inner {
                border-radius: 10px;
                width: 100%;
                position: relative;
                padding-top: 100%;
                background: black;
                overflow: hidden;
            }
            .image-container-inner img {
                position: absolute;
                top: 50%;
                -ms-transform: translate(-50%, -50%);
                transform: translate(-50%, -50%);
                left:50%;
            }
            img {
                max-width: 100%;
                max-height: 100%;
            }
            #root {
                display: flex;
                justify-content: center;
            }
            #imageroot {

            }
            @media only screen and (min-width: 500px) {
                body {
                    width: 500px;
                }
            }
            @media only screen and (min-width: 1000px) {
                body {
                    width: 1000px;
                }
            }
            @media only screen and (min-width: 1500px) {
                body {
                    width: 1500px;
                }
            }
            @media only screen and (min-width: 2000px) {
                body {
                    width: 2000px;
                }
            }
            .image-caption {
                position: relative;
                top: -10%;
                display: flex;
                justify-content: space-between;
                color: #fdfded;
                background: #000a;
                padding: 0 1em;
                font-size: 0.9em;
            }
            .image-caption span {
                padding: 0.4em;
            }
        </style>
    </head>
    <body>
        <h1>Some Photos</h1>
        <em>That I either took or am a subject of.</em>
        <div id="root"></div>
    </body>
<script>
const $ = innerHTML => Object.assign(document.createElement('div'), { innerHTML:innerHTML||'<div></div>' }).firstChild;

Promise.all([
    fetch("images.json").then(r => r.json()),
    fetch("captions.json").then(r => r.json())
])
    .then(([images, captions]) => {
        root.appendChild($(`<div id="imageroot"></div>`));
        images.forEach(({path}) => {
            const caption = captions[path] || '';
            const date = new Date(path.replace(/.*\/(\d{4})(\d{2})(\d{2}).*/,"$1-$2-$3T23:59:59.000Z")).toDateString();
            const imgBox = $(`<div class="image-container" style="float:left;"></div>`);
            const imgBoxOuter = $(`<div class="image-container-inner">`)
            imgBox.appendChild(imgBoxOuter);
            imgBoxOuter.appendChild($(
                `<img loading="lazy" src="${path}">`
            ));
            imgBox.appendChild($(
                `<div class="image-caption">
                <span style="visibility: ${caption ? "visible" : "hidden"};">${caption}</span>
                <span>${date}</span>
            </div>`
            ));
            imageroot.appendChild(imgBox);
        });
    });

</script>
</html>