diff --git a/src/lib/Counter.svelte b/src/lib/Counter.svelte deleted file mode 100644 index 8953ed2..0000000 --- a/src/lib/Counter.svelte +++ /dev/null @@ -1,103 +0,0 @@ - - -
- - -
-
- - {Math.floor($displayed_count)} -
-
- - -
- - diff --git a/src/lib/bundle.json b/src/lib/bundle.json deleted file mode 120000 index 9d29b61..0000000 --- a/src/lib/bundle.json +++ /dev/null @@ -1 +0,0 @@ -../../../utxo/dist/22/bundle.json \ No newline at end of file diff --git a/src/lib/form.js b/src/lib/form.js deleted file mode 100644 index 157d951..0000000 --- a/src/lib/form.js +++ /dev/null @@ -1,55 +0,0 @@ -import { invalidate } from '$app/navigation'; - -// this action (https://svelte.dev/tutorial/actions) allows us to -// progressively enhance a
that already works without JS -export function enhance(form, { pending, error, result } = {}) { - let current_token; - - async function handle_submit(e) { - const token = (current_token = {}); - - e.preventDefault(); - - const data = new FormData(form); - - if (pending) pending({ data, form }); - - try { - const response = await fetch(form.action, { - method: form.method, - headers: { - accept: 'application/json' - }, - body: data - }); - - if (token !== current_token) return; - - if (response.ok) { - if (result) result({ data, form, response }); - - const url = new URL(form.action); - url.search = url.hash = ''; - invalidate(url.href); - } else if (error) { - error({ data, form, error: null, response }); - } else { - console.error(await response.text()); - } - } catch (e) { - if (error) { - error({ data, form, error: e, response: null }); - } else { - throw e; - } - } - } - - form.addEventListener('submit', handle_submit); - - return { - destroy() { - form.removeEventListener('submit', handle_submit); - } - }; -} diff --git a/src/routes/about.svelte b/src/routes/about.svelte deleted file mode 100644 index 569d3e1..0000000 --- a/src/routes/about.svelte +++ /dev/null @@ -1,50 +0,0 @@ - - - - About - - -
-

About this app

- -

- This is a SvelteKit app. You can make your own by typing the - following into your command line and following the prompts: -

- - -
npm init svelte@next
- -

- The page you're looking at is purely static HTML, with no client-side interactivity needed. - Because of that, we don't need to load any JavaScript. Try viewing the page's source, or opening - the devtools network panel and reloading. -

- -

- The TODOs page illustrates SvelteKit's data loading and form handling. Try using - it with JavaScript disabled! -

-
- - diff --git a/src/routes/todos/_api.js b/src/routes/todos/_api.js deleted file mode 100644 index 5682be8..0000000 --- a/src/routes/todos/_api.js +++ /dev/null @@ -1,22 +0,0 @@ -/* - This module is used by the /todos endpoint to - make calls to api.svelte.dev, which stores todos - for each user. The leading underscore indicates that this is - a private module, _not_ an endpoint — visiting /todos/_api - will net you a 404 response. - - (The data on the todo app will expire periodically; no - guarantees are made. Don't use it to organise your life.) -*/ - -const base = 'https://api.svelte.dev'; - -export function api(method, resource, data) { - return fetch(`${base}/${resource}`, { - method, - headers: { - 'content-type': 'application/json' - }, - body: data && JSON.stringify(data) - }); -} diff --git a/src/routes/todos/index.js b/src/routes/todos/index.js deleted file mode 100644 index 92edf96..0000000 --- a/src/routes/todos/index.js +++ /dev/null @@ -1,66 +0,0 @@ -import { api } from './_api'; - -export const get = async ({ locals }) => { - // locals.userid comes from src/hooks.js - const response = await api('get', `todos/${locals.userid}`); - - if (response.status === 404) { - // user hasn't created a todo list. - // start with an empty array - return { - body: { - todos: [] - } - }; - } - - if (response.status === 200) { - return { - body: { - todos: await response.json() - } - }; - } - - return { - status: response.status - }; -}; - -export const post = async ({ request, locals }) => { - const form = await request.formData(); - - await api('post', `todos/${locals.userid}`, { - text: form.get('text') - }); - - return {}; -}; - -// If the user has JavaScript disabled, the URL will change to -// include the method override unless we redirect back to /todos -const redirect = { - status: 303, - headers: { - location: '/todos' - } -}; - -export const patch = async ({ request, locals }) => { - const form = await request.formData(); - - await api('patch', `todos/${locals.userid}/${form.get('uid')}`, { - text: form.has('text') ? form.get('text') : undefined, - done: form.has('done') ? !!form.get('done') : undefined - }); - - return redirect; -}; - -export const del = async ({ request, locals }) => { - const form = await request.formData(); - - await api('delete', `todos/${locals.userid}/${form.get('uid')}`); - - return redirect; -}; diff --git a/src/routes/todos/index.svelte b/src/routes/todos/index.svelte deleted file mode 100644 index d4d81ed..0000000 --- a/src/routes/todos/index.svelte +++ /dev/null @@ -1,178 +0,0 @@ - - - - Todos - - -
-

Todos

- - { - form.reset(); - } - }} - > - - - - {#each todos as todo (todo.uid)} -
-
{ - todo.done = !!data.get('done'); - } - }} - > - - -
- {/each} -
- -