aboutsummaryrefslogtreecommitdiff
path: root/src/routes/tools/+page.svelte
blob: f4ffefd91ca753df746cbf154a0bb6617b615440 (plain) (blame)
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
<script lang="ts">
	import ActivityHistory from '$lib/Tools/ActivityHistory.svelte';
	import { todaysCharacterBirthdays } from '$lib/AniList/character';
	import Wrapped from '$lib/Tools/Wrapped.svelte';
	import { browser } from '$app/environment';

	export let data;

	let tool = browser ? Number(new URLSearchParams(window.location.search).get('tool')) || 0 : 0;
</script>

<p>
	<select bind:value={tool}>
		<option value={0}>Tools</option>
		<option value={1}>Today's Character Birthdays</option>
		<option value={2}>Activity History Hole Risks</option>
		<option value={3}>Wrapped (Beta)</option>
	</select>
</p>

{#if tool === 0}
	Select a tool to continue.
{:else if tool === 2}
	<ActivityHistory user={data.user} />
{:else if tool === 3}
	<div id="wrapped"><Wrapped user={data.user} /></div>
{:else if tool === 1}
	<ul>
		{#await todaysCharacterBirthdays()}
			<li>Loading ...</li>
		{:then birthdays}
			{#each birthdays as birthday}
				<li>
					<a href={`https://anilist.co/character/${birthday.id}`} target="_blank"
						>{birthday.name.full}</a
					>
				</li>
			{/each}
		{:catch}
			<li>
				<p>
					Characters could not be loaded. You might have been <a
						href="https://en.wikipedia.org/wiki/Rate_limiting"
						target="_blank">rate limited</a
					>.
				</p>
				<p>
					Try again in a few minutes. If the problem persists, please contact
					<a href="https://anilist.co/user/fuwn" target="_blank">@fuwn</a> on AniList.
				</p>
			</li>
		{/await}
	</ul>
{/if}

<style>
	#wrapped {
		max-width: 60%;
	}
</style>