Währungen in Kleinbuchstaben und kleine Fixes

This commit is contained in:
2026-05-29 01:17:34 +02:00
parent f1d88eda64
commit 3631674ee3
8 changed files with 17 additions and 22 deletions

View File

@@ -1,7 +1,7 @@
services: services:
web: web:
build: . build: .
image: umrechner:v1.0.2 image: umrechner:v1.0.3
restart: unless-stopped restart: unless-stopped
environment: environment:
- POCKETBASE_URL={$POCKETBASE_URL} - POCKETBASE_URL={$POCKETBASE_URL}

View File

@@ -22,7 +22,7 @@
{{ $pbRates := dict }} {{ $pbRates := dict }}
{{ $latestUpdate := "" }} {{ $latestUpdate := "" }}
{{ range $record := $pbData }} {{ range $record := $pbData }}
{{ $pbRates = merge $pbRates (dict (lower $record.id) $record.rate) }} {{ $pbRates = merge $pbRates (dict $record.id $record.rate) }}
{{ if or (eq $latestUpdate "") (gt $record.updated $latestUpdate) }} {{ if or (eq $latestUpdate "") (gt $record.updated $latestUpdate) }}
{{ $latestUpdate = $record.updated }} {{ $latestUpdate = $record.updated }}
{{ end }} {{ end }}
@@ -39,17 +39,17 @@
{{ if not $pbOk }}{{ continue }}{{ end }} {{ if not $pbOk }}{{ continue }}{{ end }}
{{ $pbCurrencies := slice }} {{ $pbCurrencies := slice }}
{{ range $record := $pbData }} {{ range $record := $pbData }}
{{ $pbCurrencies = $pbCurrencies | append (lower $record.id) }} {{ $pbCurrencies = $pbCurrencies | append $record.id }}
{{ end }} {{ end }}
{{ $availableCurrencies := $pbCurrencies | append "eur" }} {{ $availableCurrencies := $pbCurrencies | append "eur" }}
{{ range $fromCode := $availableCurrencies }} {{ range $fromCode := $availableCurrencies }}
{{ range $toCode := $availableCurrencies }} {{ range $toCode := $availableCurrencies }}
{{ if eq $fromCode $toCode }}{{ continue }}{{ end }} {{ if eq $fromCode $toCode }}{{ continue }}{{ end }}
{{ $fromName := $fromCode | upper }} {{ $fromName := $fromCode }}
{{ with index $units $fromCode }} {{ with index $units $fromCode }}
{{ $fromName = .name }} {{ $fromName = .name }}
{{ end }} {{ end }}
{{ $toName := $toCode | upper }} {{ $toName := $toCode }}
{{ with index $units $toCode }} {{ with index $units $toCode }}
{{ $toName = .name }} {{ $toName = .name }}
{{ end }} {{ end }}
@@ -59,8 +59,8 @@
{{ $description := printf {{ $description := printf
"Konvertieren Sie %s in %s. Einfache und schnelle Umrechnung mit Einheitsumrechner." "Konvertieren Sie %s in %s. Einfache und schnelle Umrechnung mit Einheitsumrechner."
$fromName $toName }} $fromName $toName }}
{{ $fromCurrency := $fromCode | upper }} {{ $fromCurrency := $fromCode }}
{{ $toCurrency := $toCode | upper }} {{ $toCurrency := $toCode }}
{{ $fromRate := 1 }} {{ $fromRate := 1 }}
{{ if ne $fromCode "eur" }} {{ if ne $fromCode "eur" }}
{{ $fromRate = index $pbRates $fromCode }} {{ $fromRate = index $pbRates $fromCode }}

View File

@@ -15,7 +15,8 @@
<link rel="icon" type="image/png" sizes="16x16" href="/icons/favicon-16x16.png"> <link rel="icon" type="image/png" sizes="16x16" href="/icons/favicon-16x16.png">
<link rel="manifest" href="/icons/site.webmanifest"> <link rel="manifest" href="/icons/site.webmanifest">
<link href="/css/main.min.css" rel="stylesheet"> <link href="/css/main.min.css" rel="stylesheet">
{{ block "headscripts" . }}{{ end }} <script defer src="/js/decimal.js-light.min.js"></script>
<script defer src="/js/converter.js"></script>
<script defer src="/js/alpine-ajax-0.12.2.min.js"></script> <script defer src="/js/alpine-ajax-0.12.2.min.js"></script>
<script defer src="/js/alpine-3.14.9.min.js"></script> <script defer src="/js/alpine-3.14.9.min.js"></script>
<meta name="pocketbase-url" content="{{ getenv "POCKETBASE_URL" | default .Site.Params.pocketbase_url }}"> <meta name="pocketbase-url" content="{{ getenv "POCKETBASE_URL" | default .Site.Params.pocketbase_url }}">

View File

@@ -177,7 +177,4 @@
{{ end }} {{ end }}
{{ define "headscripts" }}
<script defer src="/js/decimal.js-light.min.js"></script>
<script defer src="/js/converter.js"></script>
{{ end }}

View File

@@ -9,7 +9,7 @@
{{ with transform.Unmarshal .Content }} {{ with transform.Unmarshal .Content }}
{{ if .items }} {{ if .items }}
{{ range $record := .items }} {{ range $record := .items }}
{{ $pbCurrencies = $pbCurrencies | append (lower $record.id) }} {{ $pbCurrencies = $pbCurrencies | append $record.id }}
{{ end }} {{ end }}
{{ $pbOk = true }} {{ $pbOk = true }}
{{ end }} {{ end }}

View File

@@ -5,8 +5,7 @@
{{ if $pb.ok }} {{ if $pb.ok }}
{{ $filtered := dict }} {{ $filtered := dict }}
{{ range $slug, $data := $units }} {{ range $slug, $data := $units }}
{{ $slugLower := lower $slug }} {{ if or (eq $slug "eur") (in $pb.currencies $slug) }}
{{ if or (eq $slugLower "eur") (in $pb.currencies $slugLower) }}
{{ $filtered = merge $filtered (dict $slug $data) }} {{ $filtered = merge $filtered (dict $slug $data) }}
{{ end }} {{ end }}
{{ end }} {{ end }}

View File

@@ -89,13 +89,11 @@ function createConverter(engine, config) {
if (!normalized || isNaN(normalized)) { if (!normalized || isNaN(normalized)) {
return; return;
} }
const fromCode = (config.fromCurrency || '') const fromCode = config.fromCurrency || '';
.toUpperCase(); const toCode = config.toCurrency || '';
const toCode = (config.toCurrency || '') const fromRate = fromCode === 'eur'
.toUpperCase();
const fromRate = fromCode === 'EUR'
? 1 : this.rates[fromCode]; ? 1 : this.rates[fromCode];
const toRate = toCode === 'EUR' const toRate = toCode === 'eur'
? 1 : this.rates[toCode]; ? 1 : this.rates[toCode];
if (!fromRate || !toRate) { if (!fromRate || !toRate) {
return; return;

View File

@@ -23,7 +23,7 @@ function runImport() {
let match; let match;
while ((match = CURRENCY_RATE_REGEX.exec(xml)) !== null) { while ((match = CURRENCY_RATE_REGEX.exec(xml)) !== null) {
rates.push({ rates.push({
currency: match[1], currency: match[1].toLowerCase(),
rate: parseFloat(match[2]), rate: parseFloat(match[2]),
}); });
} }