-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
executable file
·229 lines (218 loc) · 8.1 KB
/
index.html
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="The service verifies the serial number of Euro notes; if the checksum is valid, the note is not counterfeit">
<meta name="keywords" content="euro, notes, banknotes, bank, counterfeit, europa, union, european union, authentication, bce, banknotes authentication, notes authentication, euro authentication, euro notes, euro banknotes, europa series, euro checksum, euro serial number, checksum, serial number">
<meta name="robots" content="all">
<meta name="googlebot" content="noarchive">
<meta name="author" content="Maria Ausilia Napoli Spatafora">
<link rel="stylesheet" type="text/css" href="assets/css/style.css">
<link rel="stylesheet" type="text/css" href="assets/css/media_query.css">
<!--<link rel="icon" href="assets/img/favicon.png">-->
<link rel="apple-touch-icon" sizes="57x57" href="assets/img/favicon/apple-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="assets/img/favicon/apple-icon-60x60.png">
<link rel="apple-touch-icon" sizes="72x72" href="assets/img/favicon/apple-icon-72x72.png">
<link rel="apple-touch-icon" sizes="76x76" href="assets/img/favicon/apple-icon-76x76.png">
<link rel="apple-touch-icon" sizes="114x114" href="assets/img/favicon/apple-icon-114x114.png">
<link rel="apple-touch-icon" sizes="120x120" href="assets/img/favicon/apple-icon-120x120.png">
<link rel="apple-touch-icon" sizes="144x144" href="assets/img/favicon/apple-icon-144x144.png">
<link rel="apple-touch-icon" sizes="152x152" href="assets/img/favicon/apple-icon-152x152.png">
<link rel="apple-touch-icon" sizes="180x180" href="assets/img/favicon/apple-icon-180x180.png">
<link rel="icon" type="image/png" sizes="192x192" href="assets/img/favicon/android-icon-192x192.png">
<link rel="icon" type="image/png" sizes="32x32" href="assets/img/favicon/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="96x96" href="assets/img/favicon/favicon-96x96.png">
<link rel="icon" type="image/png" sizes="16x16" href="assets/img/favicon/favicon-16x16.png">
<link rel="manifest" href="assets/img/favicon/manifest.json">
<meta name="msapplication-TileColor" content="#ffffff">
<meta name="msapplication-TileImage" content="assets/img/favicon/ms-icon-144x144.png">
<meta name="theme-color" content="#ffffff">
<title>€uro Checksum</title>
</head>
<body>
<div>
<h1>€uro Checksum</h1>
<p>€uro Checksum verifies the serial number of your Euro banknotes; if the checksum is valid, the banknotes is not counterfeit (probably).</p>
<p>There is maths behind the serial number and this service checks it. Further information <a href="https://github.com/ausilianapoli/Euro-Checksum/blob/master/README.md">here</a>.</p>
<p id="sn">Insert here your serial number (12 characters):<br><img src="assets/img/triple-arrow-down.png" id="sn" alt="triple arrow down"></p>
<form id="sn_form">
<input id="input" name="serial number" minlength="12" maxlength="12" placeholder="SA2160296285"><br><br>
<input type="button" onclick="checker()" value="Submit" id="submit">
<input type="button" onclick="location.reload()" name="reset" id="reset" value="Reset">
</form>
<p id="result"></p>
<p id="posResult"></p>
<p id="negResult"></p>
</div>
<script>
var input = document.getElementById("input");
input.addEventListener("keypress", function(event){
if(event.keyCode === 13){
event.preventDefault();
document.getElementById("submit").click();
}
})
function checker(){
/*clean paragraphs of positive and negative result*/
document.getElementById("posResult").innerHTML = "";
document.getElementById("negResult").innerHTML = "";
/*constants*/
const LENGTH = 12;
const SERIALNUMBER_REGEX = /^([D-HJ-NPR-Z])([0-9]|[A-Z])([0-9]{10}$)/i
/*extract the input data*/
var x = document.getElementById("sn_form");
var sn = x.elements[0].value;
var text = ""
//console.log(sn.length);
/*check the length*/
if (sn.length != LENGTH){
text += "ERROR: The serial number <bold>MUST</bold> contains 12 characters" + "<br>";
document.getElementById("result").innerHTML = text;
return;
}
else{
text += "The serial number is: " + sn + "<br>";
document.getElementById("result").innerHTML = text;
}
//console.log(x);
//console.log(x.length);
/*check the regular expression of the serial number*/
if(SERIALNUMBER_REGEX.test(sn)){
/*find country code*/
var code = sn[0].toUpperCase();
var bank;
if(code == "P"){
code = 1;
bank = "Netherlands";
}
else if(code == "Y"){
code = 1;
bank = "Greece"
}
else if(code == "G"){
code = 1;
bank = "Cyprus";
}
else if(code == "F"){
code = 2;
bank = "Malta";
}
else if(code == "X"){
code = 2;
bank = "Germany";
}
else if(code == "E"){
code = 3;
bank = "Slovakia"
}
else if(code == "N"){
code = 3;
bank = "Austria";
}
else if(code == "W"){
code = 3;
bank = "Danmark";
}
else if(code == "D"){
code = 4;
bank = "Estonia";
}
else if(code == "M"){
code = 4;
bank = "Portugal";
}
else if(code == "V"){
code = 4;
bank = "Spain";
}
else if(code == "U"){
code = 5;
bank = "France";
}
else if(code == "L"){
code = 5;
bank = "Finland";
}
else if(code == "T"){
code = 6;
bank = "Ireland";
}
else if(code == "K"){
code = 6;
bank = "Sweden";
}
else if(code == "S"){
code = 7;
bank = "Italy";
}
else if(code == "J"){
code = 7;
bank = "United Kingdom";
}
else if(code == "R"){
code = 8;
bank = "Luxembourg";
}
else if(code == "H"){
code = 9;
bank = "Slovenia";
}
else if(code == "Z"){
code = 9;
bank = "Belgium";
}
/*find series banknote*/
var series = sn[1].toUpperCase();
if(series >= 'A' && series <= 'Z'){
text += "The banknote belongs to second (or Europa) series." + "<br>";
series = series.charCodeAt(0);
series = series % 10 + Math.floor(series / 10);
}
else{
text += "The banknote belongs to first series." + "<br>";
series = parseInt(series);
}
//console.log(series);
/*calculate sum and root*/
var sum = series;
//console.log(sum);
var i;
for(i = 2; i<LENGTH; i++) sum += parseInt(sn[i]);
//console.log(sum);
while(sum > 9) sum = sum % 10 + Math.floor(sum / 10);
console.log(sum);
/*verify code*/
if(sum == code){
var posResult = "The serial number of the banknote is valid!" + "<br>" + "The corresponding country is " + bank + "<br>";
document.getElementById("posResult").innerHTML = posResult;
var img = document.createElement("img");
img.src = "assets/img/" + bank + ".svg";
img.alt = "Flag of " + bank;
var src = document.getElementById("posResult");
src.appendChild(img);
}
else{
var negResult = "The serial number of the banknote is not valid!" + "<br>";
document.getElementById("negResult").innerHTML = negResult;
var img = document.createElement("img");
img.src = "assets/img/x.png";
img.alt = "Red 'x' as wrong sign";
var src = document.getElementById("negResult");
src.appendChild(img);
}
}
else{
text += "ERROR: The serial number is not correct."
document.getElementById("result").innerHTML = text;
return;
}
document.getElementById("result").innerHTML = text;
}
</script>
<footer>
<a href="https://github.com/ausilianapoli">Github profile</a> | <a href="https://github.com/ausilianapoli/Euro-Checksum">Github repository</a> | <a href="https://www.linkedin.com/in/maria-ausilia-napoli-spatafora-b529b036/">Linkedin profile</a><br>
<a href="mailto:ausilianapoli@gmail.com?subject=Euro-Checksum">Contact me</a><br>
</footer>
</body>
</html>