-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
220 lines (193 loc) · 6.23 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Referral Link Generator + QR Code</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/qrcodejs/1.0.0/qrcode.min.js"></script>
<style>
:root {
--primary-color: #4a90e2;
--secondary-color: #f5f5f5;
--text-color: #333;
--shadow-color: rgba(0, 0, 0, 0.1);
--success-color: #28a745;
}
body {
font-family: 'Arial', sans-serif;
line-height: 1.6;
color: var(--text-color);
background-color: var(--secondary-color);
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
}
.container {
background-color: #ffffff;
padding: 2rem;
border-radius: 8px;
box-shadow: 0 4px 6px var(--shadow-color);
max-width: 400px;
width: 100%;
}
h2 {
color: var(--primary-color);
margin-bottom: 1.5rem;
text-align: center;
}
form {
display: flex;
flex-direction: column;
}
label {
margin-bottom: 0.5rem;
font-weight: bold;
}
input[type="text"] {
padding: 0.5rem;
margin-bottom: 1rem;
border: 1px solid #ddd;
border-radius: 4px;
font-size: 1rem;
}
button {
background-color: var(--primary-color);
color: white;
border: none;
padding: 0.75rem;
border-radius: 4px;
cursor: pointer;
font-size: 1rem;
transition: all 0.3s ease;
position: relative;
overflow: hidden;
}
button:hover {
background-color: #3a80d2;
transform: translateY(-2px);
box-shadow: 0 4px 6px var(--shadow-color);
}
button:active {
transform: translateY(0);
box-shadow: none;
}
button::after {
content: '';
position: absolute;
top: 50%;
left: 50%;
width: 5px;
height: 5px;
background: rgba(255, 255, 255, 0.5);
opacity: 0;
border-radius: 100%;
transform: scale(1, 1) translate(-50%);
transform-origin: 50% 50%;
}
@keyframes ripple {
0% {
transform: scale(0, 0);
opacity: 1;
}
20% {
transform: scale(25, 25);
opacity: 1;
}
100% {
opacity: 0;
transform: scale(40, 40);
}
}
button.animate::after {
animation: ripple 0.6s ease-out;
}
#successMessage {
display: none;
color: var(--success-color);
margin-top: 1rem;
text-align: center;
font-weight: bold;
}
#qrCodeContainer {
display: flex;
justify-content: center;
margin-top: 1rem;
}
@media (max-width: 480px) {
.container {
padding: 1.5rem;
}
}
footer {
margin-top: 2rem;
text-align: center;
font-size: 0.9rem;
color: #666;
}
footer p {
margin: 0;
}
</style>
</head>
<body>
<div class="container">
<h2>Referral Link Generator</h2>
<form id="referralForm">
<label for="name">Name:</label>
<input type="text" id="name" required>
<button type="button" onclick="generateCopyAndQR()">Generate, Copy, and Create QR</button>
</form>
<p id="successMessage"></p>
<div id="qrCodeContainer"></div>
<footer>
<p>Developed with ❤ by <a href="https://github.com/vauzher" target="_blank" class="text-blue-500">Vauzher</a>
</footer>
</div>
<script>
function generateCopyAndQR() {
var button = document.querySelector('button');
button.classList.add('animate');
var name = document.getElementById("name").value.trim();
if (name === "") {
alert("Please enter a name.");
return;
}
var formattedName = encodeURIComponent(name);
//CHANGE THIS LINK TO YOUR WEBSITE'S LINK
var generatedLink = "https://yourawesomewebsite.com/?ref=" + formattedName;
// Copy to clipboard
navigator.clipboard.writeText(generatedLink).then(function() {
// Generate QR Code
var qrCodeContainer = document.getElementById("qrCodeContainer");
qrCodeContainer.innerHTML = ''; // Clear previous QR code
new QRCode(qrCodeContainer, {
text: generatedLink,
width: 128,
height: 128
});
// Show success message
var successMessage = document.getElementById("successMessage");
successMessage.textContent = "Link generated, copied to clipboard, and QR code created!";
successMessage.style.display = "block";
setTimeout(function() {
successMessage.style.display = "none";
}, 5000);
// Remove the animation class after the animation is complete
setTimeout(function() {
button.classList.remove('animate');
}, 600);
}, function(err) {
console.error('Could not copy text: ', err);
alert('Failed to copy the link. Please try again.');
// Remove the animation class if there's an error
setTimeout(function() {
button.classList.remove('animate');
}, 600);
});
}
</script>
</body>
</html>