Superpowered to do lists. No signup required.

update imports

Changed files
+25 -24
src
+1 -20
src/lib/stores.svelte.ts
··· 1 - import { alphabet, generateRandomString } from "oslo/crypto"; 1 + import { generateId } from "./utils"; 2 2 3 3 // Browser + Local Storage 4 4 const browser_exists = (typeof window !== "undefined") && (typeof (document) !== "undefined"); ··· 58 58 ]); 59 59 60 60 export const pinned_list = persisted<string>("pinned_list", local_lists.value![0].id); 61 - 62 - export function generateId() { 63 - return generateRandomString(10, alphabet("a-z", "0-9")); 64 - } 65 - 66 - export function formatSecondsToDuration(seconds: number = 0) { 67 - let hours = Math.floor(seconds / 3600); 68 - let minutes = Math.floor((seconds - (hours * 3600)) / 60); 69 - seconds = seconds - (hours * 3600) - (minutes * 60); 70 - 71 - // string ver. 72 - let hrs, mins, secs; 73 - 74 - if (hours < 10) { hrs = "0" + hours; } else { hrs = hours; } 75 - if (minutes < 10) { mins = "0" + minutes; } else { mins = minutes; } 76 - if (seconds < 10) { secs = "0" + seconds; } else { secs = seconds; } 77 - 78 - return hrs + ':' + mins + ':' + secs ; 79 - }
+20
src/lib/utils.ts
··· 1 + import { alphabet, generateRandomString } from "oslo/crypto"; 2 + 3 + export function generateId() { 4 + return generateRandomString(10, alphabet("a-z", "0-9")); 5 + } 6 + 7 + export function formatSecondsToDuration(seconds: number = 0) { 8 + let hours = Math.floor(seconds / 3600); 9 + let minutes = Math.floor((seconds - (hours * 3600)) / 60); 10 + seconds = seconds - (hours * 3600) - (minutes * 60); 11 + 12 + // string ver. 13 + let hrs, mins, secs; 14 + 15 + if (hours < 10) { hrs = "0" + hours; } else { hrs = hours; } 16 + if (minutes < 10) { mins = "0" + minutes; } else { mins = minutes; } 17 + if (seconds < 10) { secs = "0" + seconds; } else { secs = seconds; } 18 + 19 + return hrs + ':' + mins + ':' + secs ; 20 + }
+4 -4
src/routes/[id]/+page.svelte
··· 1 1 <script lang="ts"> 2 + import { onMount } from "svelte"; 2 3 import { page } from "$app/state"; 3 - import { local_lists, pinned_list, generateId, type List, type Task, formatSecondsToDuration } from "$lib/stores.svelte"; 4 4 import { goto } from "$app/navigation"; 5 5 import toast from "svelte-french-toast"; 6 - import { onMount } from "svelte"; 6 + import { formatSecondsToDuration, generateId } from "$lib/utils"; 7 + import { local_lists, pinned_list, type List, type Task } from "$lib/stores.svelte"; 7 8 8 9 let is_menu_open = $state(false); 9 10 let list : List | undefined = $state(local_lists.value!.find((l) => l.id === page.params.id)); ··· 43 44 task.stopwatchInterval = undefined; 44 45 } 45 46 else { 46 - if (!task.duration) { task.duration = 0; } 47 47 const interval = setInterval(() => { 48 - // @ts-ignore 48 + if (!task.duration) { task.duration = 0; } 49 49 task.duration += 1; 50 50 }, 1000); 51 51 task.stopwatchInterval = interval;