-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
212 lines (204 loc) · 5.26 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
<!doctype html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Credit Card</title>
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport"/>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<link href="https://fonts.googleapis.com/css?family=Montserrat&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Source+Code+Pro&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Homemade+Apple&display=swap" rel="stylesheet">
<link rel="stylesheet" href="assets/css/all.min.css" />
<link rel="stylesheet" href="assets/css/normalize.css" />
<link rel="stylesheet" href="assets/css/styles.css" />
</head>
<body>
<div id="app">
<section id="credit-card" :class="{'is-flipped': isFlipped}">
<div class="cc-content">
<div class="front">
<transition name="fade">
<div class="card-icon" v-if="cardIconShow" @click="changeIcon">
<i class="fa-3x fab" :class="ccIcon"></i>
</div>
</transition>
<img src="assets/img/chip.png" id="cc-chip">
<div class="focus-area cc-number" data-rel="card-number">
{{ ccNumber ? ccNumber : 'xxxx xxxx xxxx xxxx' }}
</div>
<div class="flex-it cc-footer">
<span class="focus-area" data-rel="card-name">
<label>
Card Holder
<p>{{ fullName }}</p>
</label>
</span>
<span class="focus-area" data-rel="expiration">
<label>
Expires
</label>
<p v-if="expMonth && expYear">
{{ expMonth }}
<span>/</span>
{{ getExpYear }}
</p>
</span>
</div>
</div>
<div class="back">
<div id="stripe"></div>
<div class="card-icon">
<i class="fa-3x fab" :class="ccIcon"></i>
</div>
<div id="sig-cvv" class="flex-it">
<span id="signature">
{{ fullName }}
</span>
<span id="cvv-area" class="focus-area" data-rel="cvv">
<label>CVV</label>
<div>{{ cvv }}</div>
</span>
</div>
</div>
</div>
</section>
<!-- End of credit card -->
<form id="cc-form" @submit="false">
<div class="form-group">
<label for="card-number">
Card Number
</label>
<input
type="text"
name="card-number"
v-model="ccNumber"
@focus="cardFlip('card-number')"
@keyup="creditCardUpdate">
</div>
<div class="form-group">
<label for="card-number">
Card Holder
</label>
<input
type="text"
name="card-name"
v-model="fullName"
@focus="cardFlip('card-name')">
</div>
<div class="form-group" id="exp-cvv">
<div class="flex-it">
<div>
<label>Exp. Month</label>
<select
name="exp-month"
v-model="expMonth"
@focus="cardFlip('expiration')">
<option value="">Month</option>
<option
:value="month"
v-for="month in 12">
{{ month }}
</option>
</select>
</div>
<div>
<label>Exp. Year</label>
<select
name="exp-year"
@focus="cardFlip('expiration')"
v-model="expYear">
<option value="">Year</option>
<option
:value="(year + minYear)"
v-for="year in 10">
{{ year + minYear }}
</option>
</select>
</div>
</div>
<div>
<label for="cvv">
CVV
</label>
<input
type="text"
v-model="cvv"
name="cvv"
@focus="cardFlip('cvv', true)"
maxlength="3">
</div>
</div>
<div class="form-group">
<button>
Submit
</button>
</div>
</form>
</div>
<script>
var app = new Vue({
el: '#app',
data () {
return {
expMonth: '',
minYear: new Date().getFullYear() - 1,
expYear: '',
ccIcon: 'fa-cc-visa',
ccNumber: '',
fullName: '',
cvv: '',
cardIconShow: true,
isFlipped: false,
};
},
watch: {
ccIcon: function (newIcon) {
this.changeIcon(newIcon);
}
},
computed: {
getExpYear() {
if (!this.expYear) {
return '';
}
return this.expYear.toString().slice(-2);
}
},
methods: {
creditCardUpdate() {
let icon = 'fa-cc-';
switch (true) {
case /^(6011|65)/.test(this.ccNumber):
icon += 'discover';
break;
case /^(51|55)/.test(this.ccNumber):
icon += 'mastercard';
break;
case /^(34|37)/.test(this.ccNumber):
icon += 'amex';
break;
default:
icon += 'visa';
}
this.ccIcon = icon;
},
changeIcon(newIcon) {
this.cardIconShow = false;
setTimeout(() => {
this.ccIcon = newIcon;
this.cardIconShow = true;
}, 750);
},
cardFlip(focusArea, flipped = false) {
this.isFlipped = flipped;
const eles = document.getElementsByClassName('focus-area');
[].forEach.call(eles, function(el) {
el.classList.remove('current-focus');
});
document.querySelector(`[data-rel="${focusArea}"]`).classList.add('current-focus');
}
}
})
</script>
</body>
</html>