-
-
- " <%= query["form-client-name"] ? "readonly" : "" %> type="text" placeholder="Peter Novak" name="form-client-name">
-
-
-
- " <%= query["form-client-address"] ? "readonly" : "" %> type="text" placeholder="Ravna ulica 13 a" name="form-client-address">
-
-
-
- " <%= query["form-client-city"] ? "readonly" : "" %> type="text" placeholder="1000 Ljubljana" name="form-client-city">
-
-
-
- " <%= query["form-amount"] ? "readonly" : "" %> type="number" placeholder="00000001132" name="form-amount">
-
-
-
- " <%= query["form-code"] ? "readonly" : "" %> type="text" placeholder="OTHR" name="form-code">
-
-
-
- " <%= query["form-purpose"] ? "readonly" : "" %> type="text" placeholder="moutain bike first half" name="form-purpose">
-
-
-
- " <%= query["form-iban"] ? "readonly" : "" %> type="text" placeholder="SI56047500000280672" name="form-iban">
-
-
-
- " <%= query["form-reference"] ? "readonly" : "" %> type="text" placeholder="SI121234567890120" name="form-reference">
-
-
-
- " <%= query["form-issuer-name"] ? "readonly" : "" %> type="text" placeholder="Spletne strani na 123" name="form-issuer-name">
-
-
-
- " <%= query["form-issuer-address"] ? "readonly" : "" %> type="text" placeholder="Za deveto smreko 15 k" name="form-issuer-address">
-
-
-
- " <%= query["form-issuer-city"] ? "readonly" : "" %> type="text" placeholder="1000 Ljubljana" name="form-issuer-city">
-
+ <%
+ const items = [
+ { n: "client-name", d: "Client name", p: "Peter Novak", t: "text" },
+ { n: "client-address", d: "Client address", p: "Ravna Ulica 13", t: "text" },
+ { n: "client-city", d: "Client city", p: "1000 Ljubljana", t: "text" },
+ { n: "issuer-name", d: "Issuer name", p: "Spletne strani n'123", t: "text" },
+ { n: "issuer-address", d: "Issuer address", p: "Za deveto smreko 15 k", t: "text" },
+ { n: "issuer-city", d: "Issuer city", p: "1000 Ljubljana", t: "text" },
+ { n: "iban", d: "IBAN", p: "SI56047500000280672", t: "text" },
+ { n: "amount", d: "Amount", p: "00000001050", t: "number" },
+ { n: "code", d: "Code", p: "OTHR", t: "text" },
+ { n: "purpose", d: "Purpose", p: "moutain bike first half", t: "text" },
+ { n: "reference", d: "Reference", p: "SI121234567890120", t: "text" }
+ ]
+ for (i of items) {
+ const str = String(q[i.n])
+ const readonly = (str != "" && !str.includes("*") ? "readonly" : "")
+ const val = str.replace("*", "")
+ %>
+
+
+ type="<%= i.t %>" placeholder="<%= i.p %>" name="<%= i.n %>">
+
+ <% } %>
@@ -113,20 +93,20 @@ function val (name) {
return document.getElementsByName(name)?.[0]?.value || ""
}
function updateQR (e) {
- const querystring = [
- ["client_name", val("form-client-name")],
- ["client_address", val("form-client-address")],
- ["client_city", val("form-client-city")],
- ["amount", val("form-amount")],
- ["purpose_code", val("form-code")],
- ["payment_purpose", val("form-purpose")],
- ["iban", val("form-iban")],
- ["reference", val("form-reference")],
- ["issuer_name", val("form-issuer-name")],
- ["issuer_address", val("form-issuer-address")],
- ["issuer_city", val("form-issuer-city")],
+ const qstring = [
+ ["client_name", val("client-name")],
+ ["client_address", val("client-address")],
+ ["client_city", val("client-city")],
+ ["amount", val("amount")],
+ ["purpose_code", val("code")],
+ ["payment_purpose", val("purpose")],
+ ["iban", val("iban")],
+ ["reference", val("reference")],
+ ["issuer_name", val("issuer-name")],
+ ["issuer_address", val("issuer-address")],
+ ["issuer_city", val("issuer-city")],
].map(v => `${v[0]}=${v[1]}`).join("&")
- qrcode.style.setProperty('background-image', `url("/api/qrcode?${querystring}")`)
+ qrcode.style.setProperty('background-image', `url("/api/qrcode?${qstring}")`)
}
btn.addEventListener("click", updateQR)
diff --git a/src/views/index.ejs b/src/views/index.ejs
index 67fa519..35f9cc3 100644
--- a/src/views/index.ejs
+++ b/src/views/index.ejs
@@ -47,52 +47,52 @@ section div {
Fill in the fields with static information and leave empty the ones that the user has to fill out.