diff --git a/src/lib/helpers/util.ts b/src/lib/helpers/util.ts new file mode 100644 index 0000000..ef03edf --- /dev/null +++ b/src/lib/helpers/util.ts @@ -0,0 +1,5 @@ +export const pushHistory = (params: string) => { + const currentURL = window.location.href; + const baseURL = currentURL.split('?')[0]; + window.history.pushState(null, '', `${baseURL}${params}`); +} \ No newline at end of file diff --git a/src/lib/loadStorage.ts b/src/lib/loadStorage.ts new file mode 100644 index 0000000..2b74f9b --- /dev/null +++ b/src/lib/loadStorage.ts @@ -0,0 +1,18 @@ +export function loadStorage(key: string) { + switch (key) { + case 'stationJDJ': + return { + common: Number(localStorage.getItem(`${key}Common`)) || 0.5, + uncommon: Number(localStorage.getItem(`${key}Uncommon`)) || 1, + rare: Number(localStorage.getItem(`${key}Rare`)) || 1, + 'ultra-rare': Number(localStorage.getItem(`${key}UltraRare`)) || 1, + epic: Number(localStorage.getItem(`${key}Epic`)) || 1 + }; + case 'stationROCDays': + return Number(localStorage.getItem(key)) || 30; + case 'stationROCTop': + return Number(localStorage.getItem(`${key}`)) || 100; + default: + return localStorage.getItem(key) || ''; + } +} \ No newline at end of file diff --git a/src/routes/tools/+layout.server.ts b/src/routes/tools/+layout.server.ts new file mode 100644 index 0000000..91d4b14 --- /dev/null +++ b/src/routes/tools/+layout.server.ts @@ -0,0 +1,12 @@ +import type { LayoutServerLoad } from './$types'; + +export const load: LayoutServerLoad = async ( { url }) => { + const searchParams = url.searchParams; + const parameters: {[key: string]: string} = {}; + for (const [key, value] of searchParams) { + parameters[key] = value; + } + return { + "parameters": parameters + }; +}; \ No newline at end of file