forked from jelveby/bankverify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
99 lines (84 loc) · 2.63 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
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
body {
font-family: 'Helvetica Neue', Arial, sans-serif;
font-weight: 300;
}
h4 {
margin: 4px 0 10px;
}
p {
margin: 3px 0;
}
.account {
background-color: #eee;
border-radius: 4px;
margin-bottom: 10px;
padding: 4px 10px;
width: 400px;
}
[class^="valid"] {
color: #fff;
padding: 2px 3px;
border-radius: 3px;
}
.valid-false {
background-color: #f66;
}
.valid-true {
background-color: #6f6;
}
</style>
<script src="./dist/bankverify.min.js"></script>
<script>
var TemplateEngine = function(html, options) {
var re = /<%([^%>]+)?%>/g, reExp = /(^( )?(if|for|else|switch|case|break|{|}))(.*)?/g, code = 'var r=[];\n', cursor = 0, match;
var add = function(line, js) {
js? (code += line.match(reExp) ? line + '\n' : 'r.push(' + line + ');\n') :
(code += line != '' ? 'r.push("' + line.replace(/"/g, '\\"') + '");\n' : '');
return add;
}
while(match = re.exec(html)) {
add(html.slice(cursor, match.index))(match[1], true);
cursor = match.index + match[0].length;
}
add(html.substr(cursor, html.length - cursor));
code += 'return r.join("");';
return new Function(code.replace(/[\r\t\n]/g, '')).apply(options);
}
var account1 = BankVerify.init('8323-6 988.123.838-4', 'account');
var account2 = BankVerify.init('8381-6', 'account');
var account3 = BankVerify.init('832799030933684', 'account');
var account4 = BankVerify.init('832799030933', 'account');
var accounts = [
account1,
account2,
account3,
account4
];
var shadow = document.createDocumentFragment();
var template =
'<h2>Accounts</h2>' +
'<%for(var index in this.accounts) {%>' +
'<div class="account">' +
'<h4><%this.accounts[index].getAccountNumber()%></h4>' +
'<p>Bank: <%this.accounts[index].bank()%></p>' +
'<p>Clearing number: <%this.accounts[index].clearingNumber()%></p>' +
'<p>Serial number: <%this.accounts[index].serialNumber()%></p>' +
'<p>Normalized: <%this.accounts[index].normalize()%></p>' +
'<p>Valid: <span class="valid-<%this.accounts[index].valid()%>"><%this.accounts[index].valid()%></p>' +
'</div>' +
'<%}%>';
window.addEventListener('load', function () {
document.querySelector('body').innerHTML = TemplateEngine(template, {
accounts: accounts
});
})
</script>
</head>
<body>
</body>
</html>