forked from rsalzer/simple-qrbill
-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
65 lines (58 loc) · 2.67 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// var chartURL = "https://chart.googleapis.com/chart?"+
// "cht=qr&choe=UTF-8&chld=M|0&chs=400x400"+
// "&chl="+
// "SPC%0A0200%0A1%0A"+
// "CH0983019ROBERTSALZER"+//IBAN
// "%0AS%0A"+
// "Robert%20Salzer"+ //Name
// "%0A"+"Bahnhofstrasse"+ //Strasse
// "%0A"+"1"+ //Nummer
// "%0A"+"8032"+ //PLZ
// "%0A"+"Zürich"+ //ORT
// "%0A"+"CH"+ //Land
// "%0A%0A%0A%0A%0A%0A%0A%0A"+
// "5.00"+ //Betrag
// "%0A"+"CHF"+ //Währung
// "%0A%0A%0A%0A%0A%0A%0A%0ANON%0A%0A"+
// "Spende%20an%20Robert%20Salzer"+ //Beschreibung
// "%0AEPD%0A";
//chartURL = "https://chart.googleapis.com/chart?cht=qr&choe=UTF-8&chld=M|0&chs=400x400&chl=SPC%0A0200%0A1%0ACH0983019ROBERTSALZER%0AS%0ARobert%20Salzer%0A%0A%0A8032%0AZürich%0ACH%0A%0A%0A%0A%0A%0A%0A%0A5.00%0ACHF%0A%0A%0A%0A%0A%0A%0A%0ANON%0A%0ASpende%20an%20Robert%20Salzer%0AEPD%0A";
function createQRCode() {
var iban = document.getElementById("iban").value;
var name = document.getElementById("name").value;
var street = document.getElementById("street").value;
var housenumber = document.getElementById("housenumber").value;
var plz = document.getElementById("plz").value;
var place = document.getElementById("place").value;
var amount = document.getElementById("amount").value;
var reason = document.getElementById("reason").value;
var content =
"SPC"+
"%0A"+"0200"+
"%0A"+"1"+
"%0A"+encodeURIComponent(iban.replace(/\s+/g, ''))+ //IBAN
"%0A"+"S"+ //S
"%0A"+encodeURIComponent(name)+ //Name
"%0A"+encodeURIComponent(street)+ //Strasse
"%0A"+encodeURIComponent(housenumber)+ //Nummer
"%0A"+encodeURIComponent(plz)+ //PLZ
"%0A"+encodeURIComponent(place)+ //ORT
"%0A"+"CH"+ //Land
"%0A%0A%0A%0A%0A%0A%0A"+ //Leerzeilen
"%0A"+encodeURIComponent(Number(amount).toFixed(2))+ //Betrag
"%0A"+"CHF"+ //Währung
"%0A%0A%0A%0A%0A%0A%0A"+ //Leerzeilen
"%0ANON"+ //NON
"%0A"+ //Leeerzeile
"%0A"+encodeURIComponent(reason)+ //Beschreibung
"%0AEPD%0A"; //EPD
var chartURL = "https://chart.googleapis.com/chart?"+
"cht=qr&choe=UTF-8&chld=M|0&chs=400x400"+
"&chl="+content;
var img = document.getElementById("qr");
img.src = chartURL;
var directURL = "qrbill://"+content;
var a = document.getElementById("qrbill");
a.href = directURL;
}
createQRCode();