aboutsummaryrefslogtreecommitdiff
path: root/frontend/hitler-clicker/src/routes/main/+page.svelte
blob: dc7842cc61c51dbeb51ea3622de7d56a1e363847 (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
61
62
63
64
<script>
	// @ts-nocheck

	/* hitler-clicer
	 * main page
	 * © 2025 hitler.rip <git@hitler.rip>
	 * licensed under AGPLv3-or-later; see licenses/code.md for more information
	 */

	import { onMount } from 'svelte';

	let token = $state("");

	onMount(() => {

		if (document.cookie) {

			token = document.cookie.slice(6);
			console.log(token);

		} else {

			console.log("no token provided. anonymous play is not supported yet!")

		}

	});

</script>

<main class="
	flex flex-col items-center justify-center my-10 mx-15 text-center
">

	<h1 class="text-6xl font-bold my-5">Hitler Clicker!</h1>

	{#if token}

	{#await fetch("http://localhost:8000/info.php", {
		method: "POST",
		headers: {
			"Accept": "application/json",
			"Content-Type": "application/json",
		},
		body: JSON.stringify({
			"token": token
		})
	}).then((response) => response.json())}
		<p>...</p>
	{:then response}

		<p>{response.name} {response.team} {response.clicks}</p>

	{:catch error}
		<pre>{error.message}</pre>
	{/await}

	{:else}

		<p>anonymous play not supported yet. please return to the landing page and log in from there.</p>

	{/if}

</main>