add multiplier url parameter

This commit is contained in:
Alexander Bocken 2023-12-28 14:20:19 +01:00
parent 69ff12bcdb
commit cd5c210d8a
Signed by: Alexander
GPG Key ID: 1D237BE83F9B05E8

View File

@ -1,8 +1,15 @@
<script>
import { onMount } from 'svelte';
export let data
let multiplier = 1
let custom_mul = "…"
onMount(() => {
// Apply multiplier from URL
const urlParams = new URLSearchParams(window.location.search);
multiplier = urlParams.get('multiplier') || 1;
})
function convertFloatsToFractions(inputString) {
// Split the input string into individual words
const words = inputString.split(' ');
@ -214,7 +221,7 @@ span
{/if}
<div class=ingredients_grid>
{#each list.list as item}
<div class=amount>{@html adjust_amount(item.amount, multiplier)} {item.unit}</div><div class=name>{@html item.name}</div>
<div class=amount>{@html adjust_amount(item.amount, multiplier)} {item.unit}</div><div class=name>{@html item.name.replace("{{multiplier}}", multiplier)}</div>
{/each}
</div>
{/each}