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
126
127
128
129
130
131
132
133
134
135
136
137
138
|
<!-- This file is part of api-worker <https://github.com/senpy-club/api-worker>.
Copyright (C) 2022-2022 Fuwn <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, version 3.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Copyright (C) 2022-2022 Fuwn <[email protected]>
SPDX-License-Identifier: GPL-3.0-only -->
<script>
import { onMount } from "svelte";
import { fetchImages } from "$lib/api";
import { page } from "$app/stores";
const errorImages = [
"https://www.pngarts.com/files/8/Confused-Anime-Transparent-Image.png",
"https://cdn130.picsart.com/246838980018212.png?r1024x1024",
"https://toppng.com/public/uploads/thumbnail/confused-anime-png-anime-question-png-gif-11563638774nccphyut3x.png",
"https://linuxreviews.org/images/8/8d/Blond-anime-girl-with-red-questionmark.png",
"https://external-preview.redd.it/VNfYgsb6Pqn4xlEBpYl11534fIpOfN1XeMe7NrzgmQs.png?width=282&auto=webp&s=3247341e1cb8a6d6f63b7b3d63809e52ca0558fd",
"https://i.ya-webdesign.com/images/confused-anime-png-5.png",
"https://www.pngarts.com/files/8/Confused-Anime-PNG-Picture.png",
"https://64.media.tumblr.com/20fb900f57db568393387211c9c4760c/tumblr_olanyyuuQZ1tbejoso2_400.png",
"https://stickershop.line-scdn.net/stickershop/v1/product/7982958/LINEStorePC/main.png;compress=true",
"https://emoji.gg/assets/emoji/8573_Shikiconfused.png",
"https://i.imgur.com/TOgxESH.jpg",
];
let images;
let complete = false;
$: language = $page.url.searchParams.get("language");
$: languageEncoded = $page.url.searchParams
.get("language")
.replaceAll("#", "%23");
$: imageQuery = $page.url.searchParams.get("image");
$: image = imageQuery
? imageQuery < images
? images[imageQuery]
: null
: null;
onMount(async () => {
images = await fetchImages(language);
complete = true;
if (imageQuery) {
// If the `imageQuery` is a string
if (Number.isNaN(Number(imageQuery))) {
image = images.filter((i) => i.includes(imageQuery));
// Make sure that if there are no exact matches to the `imageQuery`;
// show error page
if (image[0] !== imageQuery) {
image[0] = undefined;
}
if (!image[0]) {
image =
"https://www.pngarts.com/files/8/Confused-Anime-Transparent-Image.png";
image = errorImages[Math.floor(Math.random() * errorImages.length)];
}
} else {
image = images[imageQuery];
}
}
});
</script>
<svelte:head>
<title>{language} | The Senpy Club</title>
</svelte:head>
<div class="content">
<h1>
<a href={`/language?language=${languageEncoded}`}>{language}</a>
</h1>
{#if !complete}
<p>Fetching girls ...</p>
{:else if images.length === 0}
<p>No images were found for this language.</p>
{:else if image}
{#if errorImages.includes(image)}
<div class="highlight-image">
<p>
<i>This image could not be found.</i>
</p>
<a href={image}>
<img src={image} alt="A confused anime girl" />
</a>
</div>
{:else if image}
<div class="highlighted-image">
<a href={image} target="_blank">
<img src={image} alt="An anime girl holding a programming book" />
</a>
</div>
{/if}
{:else}
<ul class="image-rack">
{#each images as image}
<li id="image-rack-item">
<a
href={`/language?language=${languageEncoded}&image=${images.indexOf(
image
)}`}
>
<img src={image} alt="An anime girl holding a programming book" />
</a>
</li>
{/each}
</ul>
{/if}
</div>
<style>
.highlighted-image img {
height: 75vh;
transition: 0.25s;
}
.highlighted-image img:hover {
height: 72.5vh;
opacity: 0.75;
}
.highlighted-image a:hover {
border-bottom: none;
}
</style>
|