]> git.lizzy.rs Git - frontend-next.git/blob - src/routes/languages.svelte
feat: api fetch time
[frontend-next.git] / src / routes / languages.svelte
1 <!-- This file is part of api-worker <https://github.com/senpy-club/api-worker>.
2 Copyright (C) 2022-2022 Fuwn <contact@fuwn.me>
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, version 3.
7
8 This program is distributed in the hope that it will be useful, but
9 WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 General Public License for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16 Copyright (C) 2022-2022 Fuwn <contact@fuwn.me>
17 SPDX-License-Identifier: GPL-3.0-only -->
18 <script>
19   import { onMount } from "svelte";
20   import { fetchLanguages } from "$lib/api";
21
22   let languages, fetchTime;
23   let complete = false;
24
25   onMount(async () => {
26     fetchTime = performance.now();
27     languages = await fetchLanguages();
28     fetchTime = performance.now() - fetchTime;
29     complete = true;
30   });
31 </script>
32
33 <svelte:head>
34   <title>languages | senpy-club</title>
35 </svelte:head>
36
37 <div class="content">
38   <h1>Languages</h1>
39
40   {#if !complete}
41     <p>Fetching languages...</p>
42   {:else}
43     <ul>
44       {#each languages as language}
45         <li>
46           {#if language === "C#"}
47             <a href={"/language?language=C%23"}>C#</a>
48           {:else}
49             <a href={"/language?language=" + language}>
50               {language}
51             </a>
52           {/if}
53         </li>
54       {/each}
55     </ul>
56     <small>Fetch time: {fetchTime}ms</small>
57   {/if}
58 </div>