FaxMe commited on
Commit
d2be290
·
verified ·
1 Parent(s): 3846f10

add a reset button so users can click a reset if they make a mistake - Initial Deployment

Browse files
Files changed (2) hide show
  1. README.md +7 -5
  2. index.html +321 -19
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: Qr Code Generator
3
- emoji: 🦀
4
- colorFrom: pink
5
- colorTo: purple
6
  sdk: static
7
  pinned: false
 
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: qr-code-generator
3
+ emoji: 🐳
4
+ colorFrom: gray
5
+ colorTo: red
6
  sdk: static
7
  pinned: false
8
+ tags:
9
+ - deepsite
10
  ---
11
 
12
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
index.html CHANGED
@@ -1,19 +1,321 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>QRify - URL to QR Code Converter</title>
7
+ <script src="https://cdn.tailwindcss.com"></script>
8
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
9
+ <script src="https://cdn.jsdelivr.net/npm/qrcode-generator@1.4.4/qrcode.min.js"></script>
10
+ <style>
11
+ .gradient-bg {
12
+ background: linear-gradient(135deg, #6e8efb, #a777e3);
13
+ }
14
+ .qr-code-container {
15
+ transition: all 0.3s ease;
16
+ }
17
+ .qr-code-container:hover {
18
+ transform: translateY(-5px);
19
+ box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
20
+ }
21
+ .input-field:focus {
22
+ box-shadow: 0 0 0 3px rgba(167, 119, 227, 0.5);
23
+ }
24
+ .download-btn {
25
+ transition: all 0.2s ease;
26
+ }
27
+ .download-btn:hover {
28
+ transform: scale(1.05);
29
+ }
30
+ @keyframes pulse {
31
+ 0%, 100% {
32
+ opacity: 1;
33
+ }
34
+ 50% {
35
+ opacity: 0.5;
36
+ }
37
+ }
38
+ .animate-pulse {
39
+ animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
40
+ }
41
+ </style>
42
+ </head>
43
+ <body class="min-h-screen gradient-bg text-gray-100">
44
+ <div class="container mx-auto px-4 py-12">
45
+ <!-- Header -->
46
+ <header class="text-center mb-12">
47
+ <h1 class="text-4xl md:text-5xl font-bold mb-4">
48
+ <i class="fas fa-qrcode mr-3"></i>QRify
49
+ </h1>
50
+ <p class="text-xl md:text-2xl opacity-90">Convert any URL into a shareable QR code</p>
51
+ </header>
52
+
53
+ <!-- Main Content -->
54
+ <main class="max-w-3xl mx-auto">
55
+ <!-- Input Section -->
56
+ <div class="bg-white bg-opacity-10 backdrop-filter backdrop-blur-lg rounded-xl p-6 mb-8 shadow-xl">
57
+ <div class="flex flex-col md:flex-row gap-4">
58
+ <input
59
+ type="url"
60
+ id="urlInput"
61
+ placeholder="Enter your URL (e.g., https://example.com)"
62
+ class="input-field flex-grow px-4 py-3 rounded-lg bg-white bg-opacity-20 border border-white border-opacity-30 focus:outline-none focus:border-purple-300 placeholder-white placeholder-opacity-70"
63
+ >
64
+ <button
65
+ id="generateBtn"
66
+ class="px-6 py-3 bg-purple-600 hover:bg-purple-700 rounded-lg font-semibold transition-colors flex items-center justify-center"
67
+ >
68
+ <i class="fas fa-bolt mr-2"></i> Generate
69
+ </button>
70
+ <button
71
+ id="resetBtn"
72
+ class="px-6 py-3 bg-white bg-opacity-20 hover:bg-opacity-30 rounded-lg font-semibold transition-colors flex items-center justify-center"
73
+ >
74
+ <i class="fas fa-undo mr-2"></i> Reset
75
+ </button>
76
+ </div>
77
+ <div id="errorMessage" class="mt-2 text-red-300 text-sm hidden"></div>
78
+ </div>
79
+
80
+ <!-- QR Code Display Section -->
81
+ <div id="qrSection" class="hidden">
82
+ <div class="bg-white bg-opacity-10 backdrop-filter backdrop-blur-lg rounded-xl p-8 shadow-xl">
83
+ <h2 class="text-2xl font-semibold mb-6 text-center">Your QR Code is Ready!</h2>
84
+
85
+ <div class="flex flex-col lg:flex-row items-center gap-8">
86
+ <!-- QR Code Container -->
87
+ <div class="qr-code-container bg-white p-4 rounded-lg flex-1 max-w-xs mx-auto">
88
+ <div id="qrCode" class="w-full h-full"></div>
89
+ </div>
90
+
91
+ <!-- Details and Actions -->
92
+ <div class="flex-1">
93
+ <div class="mb-6">
94
+ <h3 class="text-lg font-medium mb-2">Destination URL:</h3>
95
+ <p id="destinationUrl" class="break-all bg-white bg-opacity-10 px-3 py-2 rounded"></p>
96
+ </div>
97
+
98
+ <div class="flex flex-wrap gap-3">
99
+ <button id="downloadBtn" class="download-btn px-5 py-2 bg-white text-purple-700 rounded-lg font-medium flex items-center">
100
+ <i class="fas fa-download mr-2"></i> Download
101
+ </button>
102
+ <button id="shareBtn" class="download-btn px-5 py-2 bg-purple-600 hover:bg-purple-700 rounded-lg font-medium flex items-center">
103
+ <i class="fas fa-share-alt mr-2"></i> Share
104
+ </button>
105
+ <button id="copyBtn" class="download-btn px-5 py-2 bg-white bg-opacity-20 hover:bg-opacity-30 rounded-lg font-medium flex items-center">
106
+ <i class="fas fa-copy mr-2"></i> Copy Link
107
+ </button>
108
+ </div>
109
+ </div>
110
+ </div>
111
+ </div>
112
+ </div>
113
+
114
+ <!-- Loading State -->
115
+ <div id="loadingSection" class="hidden text-center py-12">
116
+ <div class="animate-pulse flex flex-col items-center">
117
+ <div class="w-16 h-16 bg-white bg-opacity-20 rounded-full mb-4"></div>
118
+ <div class="h-4 bg-white bg-opacity-20 rounded w-1/3 mb-2"></div>
119
+ <div class="h-4 bg-white bg-opacity-20 rounded w-1/2"></div>
120
+ </div>
121
+ </div>
122
+ </main>
123
+
124
+ <!-- Features Section -->
125
+ <section class="max-w-6xl mx-auto mt-16">
126
+ <h2 class="text-2xl md:text-3xl font-bold text-center mb-8">Why Use QRify?</h2>
127
+
128
+ <div class="grid grid-cols-1 md:grid-cols-3 gap-6">
129
+ <div class="bg-white bg-opacity-10 backdrop-filter backdrop-blur-lg rounded-xl p-6">
130
+ <div class="text-purple-300 mb-4 text-3xl">
131
+ <i class="fas fa-bolt"></i>
132
+ </div>
133
+ <h3 class="text-xl font-semibold mb-2">Instant Generation</h3>
134
+ <p class="opacity-90">Create QR codes in seconds with our lightning-fast generator.</p>
135
+ </div>
136
+
137
+ <div class="bg-white bg-opacity-10 backdrop-filter backdrop-blur-lg rounded-xl p-6">
138
+ <div class="text-purple-300 mb-4 text-3xl">
139
+ <i class="fas fa-share-alt"></i>
140
+ </div>
141
+ <h3 class="text-xl font-semibold mb-2">Easy Sharing</h3>
142
+ <p class="opacity-90">Share your QR codes effortlessly with friends, colleagues, or customers.</p>
143
+ </div>
144
+
145
+ <div class="bg-white bg-opacity-10 backdrop-filter backdrop-blur-lg rounded-xl p-6">
146
+ <div class="text-purple-300 mb-4 text-3xl">
147
+ <i class="fas fa-mobile-alt"></i>
148
+ </div>
149
+ <h3 class="text-xl font-semibold mb-2">Mobile Friendly</h3>
150
+ <p class="opacity-90">Works perfectly on all devices, from smartphones to desktops.</p>
151
+ </div>
152
+ </div>
153
+ </section>
154
+
155
+ <!-- Footer -->
156
+ <footer class="mt-16 text-center text-white text-opacity-70 text-sm">
157
+ <p>Made with <i class="fas fa-heart text-red-400"></i> by QRify Team</p>
158
+ <p class="mt-1">© 2023 QRify - All rights reserved</p>
159
+ </footer>
160
+ </div>
161
+
162
+ <script>
163
+ document.addEventListener('DOMContentLoaded', function() {
164
+ const urlInput = document.getElementById('urlInput');
165
+ const generateBtn = document.getElementById('generateBtn');
166
+ const resetBtn = document.getElementById('resetBtn');
167
+ const qrSection = document.getElementById('qrSection');
168
+ const loadingSection = document.getElementById('loadingSection');
169
+ const errorMessage = document.getElementById('errorMessage');
170
+ const destinationUrl = document.getElementById('destinationUrl');
171
+ const downloadBtn = document.getElementById('downloadBtn');
172
+ const shareBtn = document.getElementById('shareBtn');
173
+ const copyBtn = document.getElementById('copyBtn');
174
+ const qrCodeContainer = document.getElementById('qrCode');
175
+
176
+ let currentQRCode = null;
177
+ let currentUrl = '';
178
+
179
+ // Generate QR Code
180
+ generateBtn.addEventListener('click', generateQRCode);
181
+ urlInput.addEventListener('keypress', function(e) {
182
+ if (e.key === 'Enter') {
183
+ generateQRCode();
184
+ }
185
+ });
186
+
187
+ function generateQRCode() {
188
+ const url = urlInput.value.trim();
189
+
190
+ // Validate URL
191
+ if (!url) {
192
+ showError('Please enter a URL');
193
+ return;
194
+ }
195
+
196
+ try {
197
+ // Add https:// if not present
198
+ let formattedUrl = url;
199
+ if (!url.startsWith('http://') && !url.startsWith('https://')) {
200
+ formattedUrl = 'https://' + url;
201
+ }
202
+
203
+ new URL(formattedUrl); // This will throw if invalid
204
+
205
+ // Show loading
206
+ loadingSection.classList.remove('hidden');
207
+ qrSection.classList.add('hidden');
208
+ errorMessage.classList.add('hidden');
209
+
210
+ // Simulate loading (for demo purposes)
211
+ setTimeout(() => {
212
+ createQRCode(formattedUrl);
213
+ loadingSection.classList.add('hidden');
214
+ qrSection.classList.remove('hidden');
215
+ }, 800);
216
+
217
+ } catch (e) {
218
+ showError('Please enter a valid URL');
219
+ }
220
+ }
221
+
222
+ function createQRCode(url) {
223
+ currentUrl = url;
224
+ destinationUrl.textContent = url;
225
+
226
+ // Clear previous QR code
227
+ qrCodeContainer.innerHTML = '';
228
+
229
+ // Generate new QR code
230
+ const qr = qrcode(0, 'L');
231
+ qr.addData(url);
232
+ qr.make();
233
+
234
+ // Create QR code image
235
+ const qrImg = qr.createImgTag(4, 0);
236
+ qrCodeContainer.innerHTML = qrImg;
237
+
238
+ currentQRCode = qr;
239
+ }
240
+
241
+ function showError(message) {
242
+ errorMessage.textContent = message;
243
+ errorMessage.classList.remove('hidden');
244
+ }
245
+
246
+ // Download QR Code
247
+ downloadBtn.addEventListener('click', function() {
248
+ if (!currentQRCode) return;
249
+
250
+ const canvas = document.createElement('canvas');
251
+ const ctx = canvas.getContext('2d');
252
+ const size = currentQRCode.getModuleCount() * 4;
253
+
254
+ canvas.width = size;
255
+ canvas.height = size;
256
+
257
+ // Create QR code pixels
258
+ for (let row = 0; row < currentQRCode.getModuleCount(); row++) {
259
+ for (let col = 0; col < currentQRCode.getModuleCount(); col++) {
260
+ ctx.fillStyle = currentQRCode.isDark(row, col) ? '#000000' : '#ffffff';
261
+ ctx.fillRect(col * 4, row * 4, 4, 4);
262
+ }
263
+ }
264
+
265
+ // Convert to image and download
266
+ canvas.toBlob(function(blob) {
267
+ const link = document.createElement('a');
268
+ link.download = `qrify-${new Date().getTime()}.png`;
269
+ link.href = URL.createObjectURL(blob);
270
+ link.click();
271
+ }, 'image/png');
272
+ });
273
+
274
+ // Share QR Code
275
+ shareBtn.addEventListener('click', function() {
276
+ if (!currentQRCode || !navigator.share) {
277
+ // Fallback for browsers that don't support Web Share API
278
+ alert('Web Share API not supported in your browser. Please download the QR code instead.');
279
+ return;
280
+ }
281
+
282
+ navigator.share({
283
+ title: 'Check out this QR code',
284
+ text: `Scan this QR code to visit ${currentUrl}`,
285
+ url: currentUrl
286
+ }).catch(err => {
287
+ console.log('Error sharing:', err);
288
+ });
289
+ });
290
+
291
+ // Copy URL to clipboard
292
+ copyBtn.addEventListener('click', function() {
293
+ if (!currentUrl) return;
294
+
295
+ navigator.clipboard.writeText(currentUrl).then(() => {
296
+ // Show copied feedback
297
+ const originalText = copyBtn.innerHTML;
298
+ copyBtn.innerHTML = '<i class="fas fa-check mr-2"></i> Copied!';
299
+
300
+ setTimeout(() => {
301
+ copyBtn.innerHTML = originalText;
302
+ }, 2000);
303
+ }).catch(err => {
304
+ console.error('Could not copy text: ', err);
305
+ });
306
+ });
307
+
308
+ // Reset functionality
309
+ resetBtn.addEventListener('click', function() {
310
+ urlInput.value = '';
311
+ qrSection.classList.add('hidden');
312
+ errorMessage.classList.add('hidden');
313
+ urlInput.focus();
314
+ });
315
+
316
+ // Focus input on page load
317
+ urlInput.focus();
318
+ });
319
+ </script>
320
+ <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=FaxMe/qr-code-generator" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
321
+ </html>