-
-
Notifications
You must be signed in to change notification settings - Fork 25
/
index.html
57 lines (55 loc) · 2.25 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Test Card Generator</title>
<link rel="stylesheet" href="./css/card.css"/>
</head>
<base id="base">
<body>
<h1>Test Card Generation Harness</h1>
<div>
<label for="cardType">Select card type</label>
<select id="cardType">
<option value="visa" selected="selected">Visa</option>
<option value="mastercard">Mastercard</option>
<option value="amex">American Express</option>
</select>
<input id="generate" type="button" value="Generate Card">
</div>
<div id="result">
<div id="creditCard">
<div id="logo"></div>
<div id="chip">
<div class="left top"></div>
<div class="right top"></div>
<div class="left middle"></div>
<div class="right middle"></div>
<div class="left bottom"></div>
<div class="right bottom"></div>
</div>
<p id="cardNumber"></p>
<p id="additional">
<span id="expires">Expires end</span><span id="expiryDate"><span id="expiryMonth"></span><span class="separator">/</span><span id="expiryYear"></span></span>
<span id="cvv">CVV</span><span id="cardCVV"></span>
</p>
</div>
</div>
<script type="module">
import {generateCVV, generateExpiryDate, generateFormattedPAN} from './js/generator.js'
function displayCardDetails() {
let cardType = document.getElementById("cardType");
let selectedCardType = cardType.options[cardType.selectedIndex].value;
let expiryDate = generateExpiryDate();
document.getElementById("cardNumber").innerText = generateFormattedPAN(selectedCardType);
document.getElementById("expiryMonth").innerText = expiryDate.month;
document.getElementById("expiryYear").innerText = expiryDate.year;
document.getElementById("cardCVV").innerText = generateCVV(selectedCardType);
document.getElementById("result").setAttribute("style", "display: block;");
document.getElementById("creditCard").className = selectedCardType;
}
document.getElementById("generate").addEventListener("click", displayCardDetails, false);
document.getElementById("base").setAttribute("href", window.location)
</script>
</body>
</html>